Solved

POSIX 1003.1 Compliance and lstat() functionality

Posted on 1997-10-30
2
294 Views
Last Modified: 2013-12-26
In order to better understand what is meant by POSIX compliance, I would like to pose the following question/scenario. I am using a version of UNIX that is stated to be POSIX 1003.1 compliant and I would like to compile and run a C program in POSIX mode that utilizes the lstat() function. The POSIX 1003.1 standard does not include Berkeley-style symbolic file links. Symbolic links were not included in the standard until POSIX 1003.1b. Therefore, the lstat() function is not part of the POSIX standard that my system conforms to. What should happen or be expected to happen when I try to compile this program specifying POSIX compliance.

a) A fatal error should occur during compile/link time.
b) The program should compile/link with warnings.
c) The program should compile/link without warnings.

If the program does compile, what should happen when the lstat() function is performed during execution of the program.

a) The program should generate a run-time error.
b) The lstat() function should work properly as defined by the ANSI C or K&R standard.
c) Since the lstat() function is not part of this POSIX standard, it can behave any way it chooses which includes giving totally erroneous results.

Since POSIX is an evolving standard, does it attempt to define expected results from functions that are not yet part of the standard but part of the systems C programming environment?. I would be interested in any responses or comments to this question. As a note, my system returns erroneous results when the lstat() function is performed, improperly mapped stat structure elements, which I have been informed is totally acceptable performance.

0
Comment
Question by:condon
2 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 80 total points
ID: 1295469
At compile time:
--> a) A fatal error should occur during compile/link time.

because your POSIX compliant include files do not have an lstat().

Of cource, if you use non-POSIX compliant includes beside the
POSIX onse, the compiler could not report this as an error.
I think it depends on the compiler if it detects at least a
warning.


After compiling you have to link. If you allow non-POSIX libs
here, your program will run without problems (probably).


POSIX standard does not prevent you using none-POSIX functions.
0
 

Author Comment

by:condon
ID: 1295470
This scenario has been tested on three versions of UNIX. Sun, UNISYS SVR4 and UnixWare. The Sun does not warn during compile and link and the executable performs correctly. The other UNIX versions both compile without warnings despite setting the compiler for standard comformance, but give invalid results at run-time. The SVR4 system and UnixWare do not appear to have a set of POSIX header files as opposed to non-POSIX. The variances between the two modes is accomplished via #if/#else macro constructs in the one set of header files. Also, on these systems there are no POSIX libraries per say. It appears that the functions operate in either POSIX or non-POSIX modes determined at run-time possibly by some global flag. Also, there is a function called _lxstat() in the stat.h file that uses one aditional parameter which appears to be a mode value indicator. If I call this low level function with a value of 1, it works properly in POSIX mode but if I use a value of 2, it gives the same improper results as I see when calling lstat() in POSIX mode. I assume lstat() calls _lxstat() and passes an incorrect mode value when running in POSIX mode.

Thanks for your answer and if you have any additional input please forward it to me.

Regards,
Joe Condon

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now