Date: Sat, 5 Apr 2014 22:47:48 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: Konstantin Belousov <kostikbel@gmail.com> Cc: standards@freebsd.org, freebsd-gnats-submit@FreeBSD.org, Christian Neukirchen <chneukirchen@gmail.com> Subject: Re: standards/188173: O_NOFOLLOW visibility not POSIX 2008 conforming Message-ID: <20140405204748.GA20798@stack.nl> In-Reply-To: <20140405201607.GL21331@kib.kiev.ua> References: <201404011531.s31FVVNR008903@cgiserv.freebsd.org> <20140405201607.GL21331@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Apr 05, 2014 at 11:16:07PM +0300, Konstantin Belousov wrote: > On Tue, Apr 01, 2014 at 03:31:31PM +0000, Christian Neukirchen wrote: > > >Fix: > > Adjust the condition in /usr/include/sys/fcntl.h to use _POSIX_C_SOURCE >= 200809 > > > > #if __BSD_VISIBLE > > #define O_NOFOLLOW 0x0100 /* don't follow symlinks */ > > #endif > > > Thank you for noting this. Still, I want to formally request your > confirmation that the following patch works for you. I only have 1003.1, > 2013 access right now. > diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h > index 3461f8b..2691449 100644 > --- a/sys/sys/fcntl.h > +++ b/sys/sys/fcntl.h > @@ -96,7 +96,7 @@ typedef __pid_t pid_t; > #define O_FSYNC 0x0080 /* synchronous writes */ > #endif > #define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */ > -#if __BSD_VISIBLE > +#if __POSIX_VISIBLE >= 200809 > #define O_NOFOLLOW 0x0100 /* don't follow symlinks */ > #endif > #define O_CREAT 0x0200 /* create if nonexistent */ This looks good, but I went ahead and made the other new POSIX.1-2008 things visible as well and removed redundant __BSD_VISIBLE condition parts: Index: sys/sys/fcntl.h =================================================================== --- sys/sys/fcntl.h (revision 263842) +++ sys/sys/fcntl.h (working copy) @@ -96,7 +96,7 @@ typedef __pid_t pid_t; #define O_FSYNC 0x0080 /* synchronous writes */ #endif #define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */ -#if __BSD_VISIBLE +#if __POSIX_VISIBLE >= 200809 #define O_NOFOLLOW 0x0100 /* don't follow symlinks */ #endif #define O_CREAT 0x0200 /* create if nonexistent */ @@ -115,7 +115,7 @@ typedef __pid_t pid_t; #endif /* Defined by POSIX Extended API Set Part 2 */ -#if __BSD_VISIBLE +#if __POSIX_VISIBLE >= 200809 #define O_DIRECTORY 0x00020000 /* Fail if not directory */ #define O_EXEC 0x00040000 /* Open for execute only */ #endif @@ -184,7 +184,7 @@ typedef __pid_t pid_t; #endif /* Defined by POSIX Extended API Set Part 2 */ -#if __BSD_VISIBLE +#if __POSIX_VISIBLE >= 200809 /* * Magic value that specify the use of the current working directory * to determine the target of relative file paths in the openat() and @@ -211,7 +211,7 @@ typedef __pid_t pid_t; #define F_SETFD 2 /* set file descriptor flags */ #define F_GETFL 3 /* get file status flags */ #define F_SETFL 4 /* set file status flags */ -#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 +#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ #endif @@ -229,7 +229,7 @@ typedef __pid_t pid_t; #define F_READAHEAD 15 /* read ahead */ #define F_RDAHEAD 16 /* Darwin compatible read ahead */ #endif -#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +#if __POSIX_VISIBLE >= 200809 #define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */ #endif #if __BSD_VISIBLE @@ -310,10 +310,10 @@ int fcntl(int, int, ...); #if __BSD_VISIBLE int flock(int, int); #endif -#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +#if __POSIX_VISIBLE >= 200809 int openat(int, const char *, int, ...); #endif -#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 +#if __POSIX_VISIBLE >= 200112 int posix_fadvise(int, off_t, off_t, int); int posix_fallocate(int, off_t, off_t); #endif For testing, I compiled (using -std=c99) and ran the following: #define _POSIX_C_SOURCE 200809 #include <fcntl.h> int main(int argc, char **argv) { if (argc != 2) return 2; int fd = open(argv[1], O_RDONLY | O_NOFOLLOW); if (fd == -1) return 1; return 0; } and likewise with #define _XOPEN_SOURCE 700 instead of #define _POSIX_C_SOURCE 200809. -- Jilles Tjoelker
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140405204748.GA20798>