Solved

POSIX 1003.1 Compliance and lstat() functionality

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 58
maxBlock challenge 30 142
pre4 challenge 19 104
Fibonacci challenge 11 133
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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