struct flock with fcntl and _FILE_OFFSET_BITS=64 is broken
Andreas Jaeger
aj@suse.de
Mon May 8 10:31:00 GMT 2000
struct flock is defined with different sizes if you compile with
-D_FILE_OFFSET_BITS=64. The following example will break in this case
since the kernel expects a struct with a different size:
struct flock fl;
fcntl (fd, F_GETLK, &fl);
What can we do? I see two alternatives:
A) Use in <bits/fcntl.h>:
#ifndef __USE_FILE_OFFSET64
#define F_GETLK 5 /* Get record locking info. */
#define F_SETLK 6 /* Set record locking info (non-blocking). */
#define F_SETLKW 7 /* Set record locking info (blocking). */
#else
#define F_GETLK F_GETLK64 /* Get record locking info. */
#define F_SETLK F_SETLK64 /* Set record locking info (non-blocking). */
#define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
#endif
B) The other alternative is to add fcntl64 and handle it the usual
way:
# ifndef __USE_FILE_OFFSET64
extern int fcntl (...
# else
# ifdef __REDIRECT
extern int __REDIRECT (fcntl, ..., fcntl64);
# else
# define fcntl fcntl64
# endif
# endif
What do you think? Which alternative is better - or does it work
already without problems?
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
More information about the Libc-hacker
mailing list