Mailinglist Archive: opensuse (626 mails)

< Previous Next >
Re: [opensuse] 'mv' a read-only directory doesn't work...why not?
Am 09.11.18 um 17:23 schrieb Linda Walsh:
So why is moving 'dir1' from 'a' to 'b' disallowed?  Shouldn't
the move only look at the rw permissions on 'a' and 'b'?

You created a simple example. In the real world, there might be files
and folders of other users (root?) in there.

If a directory can't be "written", then you can't modify the files
inside (add, remove or modify them).

rmdir works because you modify "." (the current folder) which isn't
write protected. rm a/file1 shouldn't work.

As per the man page, the mv fails because you don't have write
permission to update the ".." entry in the directory you try to move.
You need to be able to replace ./dir1/.. with the new parent folder but
you can't.

*EACCES *Write permission is denied for the directory containing
/oldpath/ or /newpath/, or, search permission is denied for one of
the directories in the path prefix of /oldpath/ or /newpath/, or
/oldpath/ is a directory and does not allow write permission
(needed to update the /../ entry). (See also
path_resolution(7)
<http://man7.org/linux/man-pages/man7/path_resolution.7.html>.)


To "emphasize the point":  1) I can do a 'cp -a a/dir1 b/' which
works.  Since they are
  on the same device, even hardlinks will be duplicated.
2) I can then follow-up with 'rmdir a/dir1', which also
  works (no warning like when removing a file):
 > rm a/file1
 rm: remove write-protected regular empty file 'a/file1'?

I.e. the exact same actions 'mv' would do if I was copying
between devices.

Err no. The actions have the same result but use different operations.
To get to the backside of a house, I can go left and right (and even
over the roof). Same result, different ways.

Regards,

--
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://blog.pdark.de/


--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References