From owner-freebsd-arch@FreeBSD.ORG Sun Mar 17 20:01:22 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C105F730; Sun, 17 Mar 2013 20:01:22 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 89925FBE; Sun, 17 Mar 2013 20:01:22 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id DD0923592E5; Sun, 17 Mar 2013 21:01:21 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id B360F2848C; Sun, 17 Mar 2013 21:01:21 +0100 (CET) Date: Sun, 17 Mar 2013 21:01:21 +0100 From: Jilles Tjoelker To: Pawel Jakub Dawidek Subject: Re: chflags(2)'s flags argument. Message-ID: <20130317200121.GC65525@stack.nl> References: <20130317003559.GA1364@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130317003559.GA1364@garage.freebsd.pl> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-arch@FreeBSD.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Mar 2013 20:01:22 -0000 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