allow rename to "--bind"-mounted filesystem
Hi,
i just came over this patch, and wondered why is it missing in both 2.4 and 2.5 (the code in do_rename is identical in both kernels).
Are such renames really not allowed, or was it just fixed differently?
-alex
----- Forwarded message from Eric Lammerts <[email protected]> -----
Date: Sun, 19 Jan 2003 00:34:59 +0100
Subject: [PATCH] allow rename to "--bind"-mounted filesystem
From: Eric Lammerts <[email protected]>
To: [email protected]
Message-ID: <[email protected]>
X-Mailing-List: [email protected]
Hi,
I just discovered that rename(2) does not allow you to rename a file within the same filesystem if there is a "--bind" in the way. For example:
# mkdir mydir
# mount --bind . mydir
# touch myfile
# strace -erename perl -e 'rename "myfile", "mydir/myfile2"'
rename("myfile", "mydir/myfile2") = -1 EXDEV (Invalid cross-device link)IMHO it should be possible to do a rename in this situation.
I propose to remove the check in do_rename() altogether. It shouldn't be necessary, since there's also a check for a cross-device rename in vfs_rename_dir() and vfs_rename_other().
Patch below has been tested.
Eric
fs/namei.c renamed from fs/namei.c.orig +0 -4
@@ -1860,10 +1860,6 @@if (error) goto exit1; - error = -EXDEV ; -if (oldnd.mnt != newnd.mnt) - goto exit2; - old_dir = oldnd.dentry; error = -EBUSY ;if (oldnd.last_type !=LAST_NORM )
Quoted 6 lines · Alex Riesen
Hi,
i just came over this patch, and wondered why is it missing in both 2.4 and 2.5 (the code indo_renameis identical in both kernels).Are such renames really not allowed, or was it just fixed differently?
Such remames are _deliberately_ not allowed.
[email protected], Tue, May 06, 2003 16:30:26 +0200:
Quoted 10 lines · Alex Riesen
Quoted 6 lines
Hi,
i just came over this patch, and wondered why is it missing in both 2.4 and 2.5 (the code indo_renameis identical in both kernels).Are such renames really not allowed, or was it just fixed differently?
Such remames are _deliberately_ not allowed.
because that would be against semantics of a mounted filesystem? (which, in turn, would break something)
Quoted 7 lines · Alex Riesen
[email protected], Tue, May 06, 2003 16:30:26 +0200:
Quoted 6 lines · Alex Riesen
Quoted 5 lines
Hi,
i just came over this patch, and wondered why is it missing in both 2.4 and 2.5 (the code indo_renameis identical in both kernels).
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Are such renames really not allowed, or was it just fixed differently?
Such remames are _deliberately_ not allowed.
because that would be against semantics of a mounted filesystem? (which, in turn, would break something)
Binding a subtree creates a sandbox of sorts. You can bind a bunch of subtrees of the same fs into namespace and have normal protection against rename and link between them.
[email protected], Tue, May 06, 2003 17:02:19 +0200:
Quoted 10 lines · Alex Riesen
Quoted 9 lines
[email protected], Tue, May 06, 2003 16:30:26 +0200:
Quoted 8 lines · Alex Riesen
Quoted 6 lines
i just came over this patch, and wondered why is it missing in both 2.4 and 2.5 (the code in
do_renameis identical in both kernels).Are such renames really not allowed, or was it just fixed differently?
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Such remames are _deliberately_ not allowed.
because that would be against semantics of a mounted filesystem? (which, in turn, would break something)
Binding a subtree creates a sandbox of sorts. You can bind a bunch of subtrees of the same fs into namespace and have normal protection against rename and link between them.
sounds useful, even though i can't think of real example of such a use :)
Thank you, that clarifies the behaviour, at least to me.
Quoted 7 lines · Alex Riesen
[email protected], Tue, May 06, 2003 17:02:19 +0200:
Quoted 3 lines
Binding a subtree creates a sandbox of sorts. You can bind a bunch of subtrees of the same fs into namespace and have normal protection against rename and link between them.
sounds useful, even though i can't think of real example of such a use :)
chroot? As Al said, you create a sandbox this way. Saved me more than once from stupid mistakes.
Carl-Daniel