Date: Sun, 17 Mar 2013 21:01:21 +0100 From: Jilles Tjoelker <jilles@stack.nl> To: Pawel Jakub Dawidek <pjd@FreeBSD.org> Cc: freebsd-arch@FreeBSD.org Subject: Re: chflags(2)'s flags argument. Message-ID: <20130317200121.GC65525@stack.nl> In-Reply-To: <20130317003559.GA1364@garage.freebsd.pl> References: <20130317003559.GA1364@garage.freebsd.pl>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Mar 17, 2013 at 01:35:59AM +0100, Pawel Jakub Dawidek wrote: > Currently this is a bit messy: chflags(2) and fchflags(2) take 'flags' > argument of type unsigned long and lchflags(2) takes the same argument > of type int. At least this is what you can see in manual page and in > prototypes of those functions in sys/stat.h. > However all of those syscalls are defined in syscalls.master to take the > 'flags' argument of type int and this is what they use in kernel. > I'd like to proposed the following patch: > http://people.freebsd.org/~pjd/patches/chflags_int.patch > It changes type of the 'flags' argument from unsigned long to int where > possible. > I believe this change won't break ABI, as the syscalls (apart from the > prototypes) already expect int and I hope in doesn't break API in any > really visible and destructive way. If you think otherwise, let me know. I wonder if we want to keep all those ugly casts between the various types for file flags. They are unnecessary and might get stale. For example, if (fchflags(to_fd, (u_long)sbp->st_flags)) (or changed to (int)). The cast may have been necessary in the bad old days without prototypes. > Note that the patch doesn't touch the strtofflags(3) function, as I > believe it would break ABI and it doesn't touch the fflagstostr(3) > function to stay consistent with strtofflags(3). That's int and unsigned long. That's not the complete collection. The st_flags member of struct stat is of type fflags_t which is a typedef for uint32_t. It is sad what a mess this is :( > PS. Manual page text provided by jilles. The manual page text is, in fact, in the chflagsat(2) patch. -- Jilles Tjoelker
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130317200121.GC65525>