Date: Wed, 10 Jul 1996 09:03:05 +1000 From: Bruce Evans <bde@zeta.org.au> To: bde@zeta.org.au, zach@blizzard.gaffaneys.com Cc: freebsd-bugs@freefall.freebsd.org Subject: Re: bin/1375: Extraneous warning from mv(1) Message-ID: <199607092303.JAA09150@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>> This is probably a bug in mv.1. mv should and does try harder than >> cp to preserve attributes. >But why should I, as a user, care.. as long as the setuid/setgid bits Some users might care. E.g., if the file is supposed to have a particular gid so that everyone in the group can access it, then mv'ing it across file systems will break group accessibility even if you put it back. Try this: touch /tmp/z # gid is same as /tmp (bin) mv /tmp/z ~ # gid gets clobbered to your gid mv ~/z /tmp # gid is still yours, not bin mv cannot know if the user cares, so it shouldn't silently drop attributes. I now think it should refuse to the move if it can't preserve all the attributes. It can simply unlink the target and avoid unlinking the source if there is a problem. The problem is much more complicated for moving entire trees. Is mv supposed to successfully move the entire tree before unlinking anything in the original tree and then check that all unlinks would succeed before unlinking anything? I think it should. Otherwise an error leaves both the source and target trees in a mess. Try this: mkdir /tmp/z mkdir /tmp/z/a touch /tmp/z/b /tmp/z/c /tmp/z/a/d /tmp/z/a/e su chown root /tmp/z/a /tmp/z/c /tmp/z/a/e exit mv /tmp/z ~ This gives suitable error messages for not being able to move /tmp/z/a or its contents. It silently moves /tmp/z/c and loses its uid. The target tree ends up with all the files from the source tree (everything is readable so there is no problem copying it) and everything possible got removed from the original tree because the `cp -pRP' step succeeded although it didn't preserve one uid. Messes like this are easy to create using cp -pRP and rm -rf explicitly :-). mv across file systems is of negative worth unless it does a better job of makeing the move atomic. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199607092303.JAA09150>