[lsb-discuss] stat(), lstat() and fstat()

Craig.Scott at csiro.au Craig.Scott at csiro.au
Wed Jan 26 01:20:10 PST 2011


Sorry about the flood to your inbox. ;)

The LSB headers *do* define stat(), lstat() and fstat() in sys/stat.h, but I think incorrectly:

    extern int fstat(int __fd, struct stat *__buf);
    extern int fstat64(int __fd, struct stat64 *__buf);
    extern int lstat(const char *__file, struct stat *__buf);
    extern int lstat64(const char *__file, struct stat64 *__buf);
    extern int mknod(const char *__path, mode_t __mode, dev_t __dev);
    extern int stat(const char *__file, struct stat *__buf);
    extern int stat64(const char *__file, struct stat64 *__buf);

They are not binary-level functions according to the LSB spec, so they should be macros that forward to __xstat() and friends?

________________________________________
From: Scott, Craig (CMIS, Clayton)
Sent: Wednesday, 26 January 2011 8:10 PM
To: LSB mailing list
Subject: RE: stat(), lstat() and fstat()

And LSB navigator doesn't even know about fstatat(), but does at least know about stat(), lstat() and fstat() - strange that the binary functions these forward to are in the LSB, but navigator claims that the macros stat(), lstat() and fstat() are not and never have been....

________________________________________
From: Scott, Craig (CMIS, Clayton)
Sent: Wednesday, 26 January 2011 8:08 PM
To: LSB mailing list
Subject: RE: stat(), lstat() and fstat()

Actually, the same situation exists for fstatat() as well:

http://refspecs.linux-foundation.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---fxstatat-1.html

Since there appears to be a family of these functions (there are also ...64 versions for large file support), so not sure how many others there will be as well.

________________________________________
From: Scott, Craig (CMIS, Clayton)
Sent: Wednesday, 26 January 2011 8:03 PM
To: LSB mailing list
Subject: stat(), lstat() and fstat()

I suspect these three function macros are missing from the LSB headers, but details are a bit hard to find. Here's a link to the relevant LSB page:

http://refspecs.linux-foundation.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---xstat.html

In particular, the last line says:

"stat(), lstat(), and fstat() are not in the binary standard; they are only in the source standard."

These three function macros should result in calls to the functions __xstat(), __lxstat() and __fxstat() respectively, all of which do have extern prototypes in the sys/stat.h headers for the LSB 4.1 packages (I'm using the ones that appeared in the LSB yum repo as of 21st Jan). It would seem to be an oversight not to provide the three stat(), lstat() and fstat() macros since without them, code would need to call  __stat() and friends which looks like it's not how these were meant to be used in source code. Or am I misunderstanding the way these are intended to be called?

For motivation, this is likely to appear as a problem in fixing an issue in the libarchive project, which is an upstream component of CMake.


--
Dr Craig Scott
Computational Software Engineering Team Leader, CSIRO (CMIS)
Melbourne, Australia


More information about the lsb-discuss mailing list