coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: rm --preserve-root=all to protect mount points


From: Pádraig Brady
Subject: RFC: rm --preserve-root=all to protect mount points
Date: Sun, 10 Jun 2018 23:14:14 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

I was asked off list to consider adding an option to rm
that could be enabled with an alias, and would protect
mount points specified on the command line.

I think this is useful functionality as rm will ultimately
fail to remove the mount point itself, but only after
processing the whole file system.

It's unusual to remove a whole file system as it's
generally more efficient to recreate and remount them,
and in the particular case I was told about, it was
a pretty effective DoS to the system to process
and unlink the whole tree.

Rather than add a new option, I thought it cleaner
to extend the existing --preserve-root option to support
--preserve-root=all, as that can be interpreted to
preserve the root of all specified file systems.

Attached is the proposed implementation,
to which I'll add tests and docs after comments.

An example run on my system is:

  $ rm -r --preserve-root=all /dev/shm
  rm: skipping '/dev/shm', since it's a mount point
  rm: and --preserve-root=all is in effect

cheers,
Pádraig

Attachment: rm-preserve-mount-points.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]