FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Development

 
 
LinkBack Thread Tools
 
Old 09-10-2011, 07:58 PM
Jim Meyering
 
Default rm --no-traverse-mount-points [ stop rm at same-dev bind mounts

Thomas Moschny wrote:
> having a rm command accidentally removing 3/4 of my system yesterday,
> I am starting to wonder whether it is possible to have rm reliably
> stop at bind mounts. I know there is a --one-file-system option, but
> it is not working when the bind mount points to the same device:
>
> % cd /tmp
> % mkdir -p a/b c/d ; touch c/d/file ; mount --bind c a/b
> % find a
> a
> a/b
> a/b/d
> a/b/d/file
> % rm -rf --one-file-system a
> rm: cannot remove `a/b': Device or resource busy
> % find a
> a
> a/b
>
> `file' has been removed. Imho the name of the --one-file-system option
> is misleading as it only compares st_dev fields.

Thanks for the example, but I don't see how that option name is
misleading. A "file system" is the thing you create with "mkfs".
Even though normally there is only one mount point per file system,
the fact that with bind mounts there can be many doesn't change
the name of the thing occupying the underlying device: a file system.

I think you want a new option, say --no-traverse-mount-points.

> Besides filing a
> bug/enhancement ticket for coreutils, does someone know a reliable way
> to stop rm in such cases?

It would tell rm -r not to cross any mount point. Rm would have to be
able to read at start-up the set of all mount points, or maybe only
the mount points for a given device the first time a new device is
encountered. Then, it could easily and efficiently test whether each
directory processed is in that set.

I've Cc'd bug-coreutils, so this message will create a ticket in the
issue tracker: http://debbugs.gnu.org/coreutils.
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
 
Old 09-11-2011, 12:25 PM
Thomas Moschny
 
Default rm --no-traverse-mount-points [ stop rm at same-dev bind mounts

2011/9/10 Jim Meyering <jim@meyering.net>:
> Thanks for the example, but I don't see how that option name is
> misleading. *A "file system" is the thing you create with "mkfs".
> Even though normally there is only one mount point per file system,
> the fact that with bind mounts there can be many doesn't change
> the name of the thing occupying the underlying device: a file system.
>
> I think you want a new option, say --no-traverse-mount-points.

The term "file system" can of course have different meaning to
different people - you could also argue it means "file system type",
with unexpected results for the interpretation of "--one-file-system".
Anyway, that is nitpicking on my side; obviously it was clear what I
meant: An option to make rm walk the tree, ignoring (=not following)
mount points. Thanks for opening the ticket.

As a side note: I am not sure whether that also means it should remove
stuff normally hidden by such a mountpoint?

As long as such a "--no-traverse-mount-points" option is not available
yet for rm, I am still looking for suggestions on how to achieve the
same effect in a shell script.

--
Thomas Moschny <thomas.moschny@gmail.com>
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
 

Thread Tools




All times are GMT. The time now is 04:34 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org