POSIX 1003.1 Compliance and lstat() functionality

Posted on 1997-10-30
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.

Question by:condon
LVL 51

Accepted Solution

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

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.

Author Comment

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.

Joe Condon


Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 61
java ^ examples 8 65
firstChar challenge 13 115
Remove Password Protection from pdf (with password) using an command line executable 5 50
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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