From owner-freebsd-hackers Wed Jan 16 10: 0:37 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id 605F037B41A for ; Wed, 16 Jan 2002 10:00:20 -0800 (PST) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020116180019.JKWJ3578.rwcrmhc52.attbi.com@InterJet.elischer.org>; Wed, 16 Jan 2002 18:00:19 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id JAA87216; Wed, 16 Jan 2002 09:45:10 -0800 (PST) Date: Wed, 16 Jan 2002 09:45:09 -0800 (PST) From: Julian Elischer To: Greg Black Cc: Foldi Tamas , freebsd-hackers@freebsd.org Subject: Re: interesting open() issue In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 He's talking about the different 'group' setting.. I think. it's different because SYSV (linux is based on the semantics of sysV) and BSD have a differnt semantic on this and always have.. BSD makes the file get the same group as the directory. Linux gives it the primary group of the creator. Linux can act the same as BSD if the SGID bit is set on the directory (I think). There may also be a mount option but I'm not sure if that was ever implelemnted. On Wed, 16 Jan 2002, Greg Black wrote: > Foldi Tamas wrote: > > | Hello hackers, > > Don't send this sort of newbie programmer question to the > hackers list (or to any of the FreeBSD lists). > > | I tried the following program on Tru64, FreeBSD and linux: > | > | #include > | #include > | #include > | #include > | main() { > | int fd; > | fd = open ( "/tmp/foobar", (O_RDWR | O_CREAT), 0020); > | perror("open"); > | close(fd); > | } > | > | The program ran successfully, but the created file was different. > | On Linux: > | -----w---- 1 crow crow 0 Jan 16 10:32 /tmp/foobar > | > | On Tru64/FreeBSD: > | ---------- 1 crow users 0 Jan 16 10:30 /tmp/foobar > | > | I'm not sure what the result supposed to be. Any ideas ? > > If you want the exact same results on each system and if you > want the file to have the mode you set, you need to put two > additional system calls *before* the open(2) call: > > unlink("/tmp/foobar"); > umask(0); > > If the file exists, the mode in the open() won't affect it and > it will retain whatever it already had, so you need to ensure > that it's not there first. If your umask setting masks the > group write bit, it won't be set unless you first clear the > umask setting. > > Now go and read about Unix programming. > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message