Subject: Request For Comments!! POSIX atomic mv
To: None <netbsd-users@netbsd.org>
From: George Georgalis <george@galis.org>
List: netbsd-users
Date: 12/12/2007 21:17:56
Recently I submitted a support request to Apple
regarding a behavior in Leopard, which did not exist
in prior Apple versions, and I'm confused how the
issue presents itself in NetBSD.
mkdir setup-XXX
chmod 555 setup-XXX
mv setup-XXX final
That's basically it. Would like to create a tmp
directory into which some project is setup. At which
point write permissions are removed and in one step
the directory is moved to its final location to
become available.
That worked on Darwin prior to Leopard, and it works
in some cases in NetBSD 3.1_STABLE
geo@run:/home/geo/tmp mkdir setup-XXX
geo@run:/home/geo/tmp chmod 555 setup-XXX/
geo@run:/home/geo/tmp mv setup-XXX/ final
geo@run:/home/geo/tmp cd ../
geo@run:/home/geo mkdir setup-XXX
geo@run:/home/geo chmod 555 setup-XXX/
geo@run:/home/geo mv setup-XXX/ final
geo@run:/home/geo mkdir setup-XXX
geo@run:/home/geo chmod 555 setup-XXX/
geo@run:/home/geo mv setup-XXX/ tmp/final2
mv: rename setup-XXX/ to tmp/final2: Permission denied
geo@run:/home/geo ls -ld ./ setup* final* tmp/ tmp/final*
drwx-----x 52 geo geo 6656 Dec 12 20:48 ./
dr-xr-xr-x 2 geo geo 512 Dec 12 20:47 final
dr-xr-xr-x 2 geo geo 512 Dec 12 20:48 setup-XXX
drwxr-xr-x 12 geo geo 2048 Dec 12 20:46 tmp/
dr-xr-xr-x 2 geo geo 512 Dec 12 20:46 tmp/final
geo@run:/home/geo uname -a
NetBSD run 3.1_STABLE NetBSD 3.1_STABLE (NORUN) #1: Tue Oct 23 11:41:28 EDT 2007 root@run:/usr/obj/sys/arch/i386/compile/NORUN i386
geo@run:/home/geo ls -ld /home
lrwxr-xr-x 1 root wheel 8 Feb 12 2006 /home -> usr/home
geo@run:/home/geo mount | grep usr
/dev/wd0e on /usr type ffs (nodev, soft dependencies, local)
Of course root doesn't have the move problem, but
I'd like not to require root to atomically create
final. The downside of using the install program to
set the mode is portions of final will be in place
before the entire final is created.
Apple has responded to my support request saying
write access is needed to move a directory, per
POSIX.
Not having access to POSIX, I have to wonder if that
is interpreted correctly. And if so, how does one
atomically create a readonly populated directory?
(without root)
How is the netbsd behavior explained that I can
rename the mode 555 dir in my home, but not if I'm
moving it to my mode 755 tmp at the same time?
// George
--
George Georgalis, information system scientist <IXOYE><