From owner-freebsd-hackers Thu Aug 29 0:35:51 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 238E437B400 for ; Thu, 29 Aug 2002 00:35:48 -0700 (PDT) Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id CEDF143E65 for ; Thu, 29 Aug 2002 00:35:46 -0700 (PDT) (envelope-from keramida@ceid.upatras.gr) Received: from hades.hell.gr (patr530-a090.otenet.gr [212.205.215.90]) by mailsrv.otenet.gr (8.12.4/8.12.4) with ESMTP id g7T7Zc6e022262 for ; Thu, 29 Aug 2002 10:35:43 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.5/8.12.5) with ESMTP id g7T7ZaNK035275 for ; Thu, 29 Aug 2002 10:35:36 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.5/8.12.5/Submit) id g7T7ZXN6035274 for hackers@freebsd.org; Thu, 29 Aug 2002 10:35:33 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 29 Aug 2002 10:35:31 +0300 From: Giorgos Keramidas To: hackers@freebsd.org Subject: chown() vs. setfown() prototype in vfs_syscalls.c Message-ID: <20020829073530.GB33894@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-PGP-Fingerprint: C1EB 0653 DB8B A557 3829 00F9 D60F 941A 3186 03B6 X-Phone: +30-944-116520 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hello, A friend asked me why he was getting warnings about conversion of unsigned to signed, when calling chown() with: chown("/dev/null", -1, -1); The manpage of chown has a prototype of: int chown(const char *path, uid_t owner, gid_t group); But the manpage mentions that (uid_d)-1 is the right value for a chown operation that wants to leave the user part of the owner:group set unchanged. After a bit of research he found that the definition of uid_t was (unsigned int) and that's why -1 was giving him warnings. But the fun doesn't stop there... The implementation of chown in vfs_syscalls.c uses `int' as the type of the two uid_t/gid_t arguments in the *uap argument, and then calls setfown() which accepts uid_t and gid_t !!! Then setfown() copies the values in a `struct vattr' at the va_uid and va_gid members, which are also uid_t and gid_t. The only place where the uid & gid arguments of chown() are int and not uid_t and gid_t is in the prototype of the system call itself. Is this really necessary? Is there a reason behind it? -- FreeBSD: The Power to Serve -- http://www.FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message