linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Steigerwald <Martin@lichtvoll.de>
To: kreijack@inwind.it
Cc: linux-btrfs@vger.kernel.org, Tsutomu Itoh <t-itoh@jp.fujitsu.com>,
	Eric Sandeen <sandeen@redhat.com>,
	chris.mason@fusionio.com,
	Stefan Behrens <sbehrens@giantdisaster.de>,
	David Sterba <dsterba@suse.cz>
Subject: Re: [PATCH, RFC] btrfs-progs: require mkfs -f force option to overwrite filesystem or partition table
Date: Tue, 26 Feb 2013 22:16:55 +0100	[thread overview]
Message-ID: <201302262216.56187.Martin@lichtvoll.de> (raw)
In-Reply-To: <512D092F.5040003@gmail.com>

Am Dienstag, 26. Februar 2013 schrieb Goffredo Baroncelli:
> > And I teach not to in my trainings as well.
> >
> > 
> >
> > Everyone who uses rm -rf by default even just for deleting a single
> > file does  it as long as he or she deleted his / her home directory or
> > something.
> 
> Unfortunately the "rm -rf" is a different case. Removing a directory is
> a common case. We should not be forced to use the -f for common case. A
> '-f' flag should be used only in "uncommon" case (like *re*format a disk
> or a test-suite)...
> 
> However I think that '-f' is good for mkfs.btrfs.

I don´t get you on this one:

artin@merkaba:~/Zeit> export LANG=C
martin@merkaba:~/Zeit> mkdir test
martin@merkaba:~/Zeit> rm test
rm: cannot remove 'test': Is a directory
martin@merkaba:~/Zeit#1> rm -f test
rm: cannot remove 'test': Is a directory
martin@merkaba:~/Zeit#1> rm -r test
martin@merkaba:~/Zeit> mkdir test
martin@merkaba:~/Zeit> rmdir test
martin@merkaba:~/Zeit>

So you do not need -f to remove a directory, but either rm -r or rmdir (if 
its empty).

I think that special casing deleting empty directories with rmdir command 
doesn´t make much sense. The most important distinction there IMHO is to 
recurse or not to recurse. Thus I would let rm also delete empty directories 
and remove rmdir altogether or alias it to rm (without -r!). Thats how it 
was done on AmigaOS delete command. Delete would delete files and empty 
dirs, and recurse only if ALL option was given.

rm -f doesn´t work anyway if parent directory has write permission removed:

martin@merkaba:~/Zeit> mkdir -p test/test
martin@merkaba:~/Zeit> chmod a-w test
martin@merkaba:~/Zeit> cd test
martin@merkaba:~/Zeit> rm -r test
rm: descend into write-protected directory 'test'? y
rm: cannot remove 'test/test': Permission denied
martin@merkaba:~/Zeit> rm -rf test
rm: cannot remove 'test/test': Permission denied

       -f, --force
              ignore nonexistent files and arguments, never prompt



Only in the case the directory itself is write-protected rm -f makes the 
prompt go away:

martin@merkaba:~/Zeit> mkdir test
martin@merkaba:~/Zeit> chmod a-w test
martin@merkaba:~/Zeit> rm -r test
rm: remove write-protected directory 'test'? y
martin@merkaba:~/Zeit> mkdir -m a-w test
martin@merkaba:~/Zeit> ls -ld test
dr-xr-xr-x 1 martin martin 0 Feb 26 22:12 test
martin@merkaba:~/Zeit> rm -rf test

But on skipping write protection -f is justified I think.

But more so since this is a empty directory and the parent directory has 
write protection, rmdir will remove it without -f (which it doesn´t support 
anyway):

martin@merkaba:~/Zeit> mkdir -m a-w test
martin@merkaba:~/Zeit> rmdir test
martin@merkaba:~/Zeit> 

Thanks,
-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

  reply	other threads:[~2013-02-26 21:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 18:30 [PATCH, RFC] btrfs-progs: require mkfs -f force option to overwrite filesystem or partition table Eric Sandeen
2013-02-14 20:23 ` Chris Mason
2013-02-14 21:20   ` Eric Sandeen
2013-02-20 15:37 ` Stefan Behrens
2013-02-25 23:39   ` Tsutomu Itoh
2013-02-26  0:07     ` Eric Sandeen
2013-02-26  3:55       ` Tsutomu Itoh
2013-02-26  4:06         ` Eric Sandeen
2013-02-26  4:25           ` Tsutomu Itoh
2013-02-26  7:05             ` Dave Chinner
2013-02-26  8:53               ` Tsutomu Itoh
2013-02-28 16:30               ` mpbtr
2013-02-26 10:37         ` Martin Steigerwald
2013-02-26 19:12           ` Goffredo Baroncelli
2013-02-26 21:16             ` Martin Steigerwald [this message]
2013-02-26 12:43     ` David Sterba
2013-02-26 20:23   ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201302262216.56187.Martin@lichtvoll.de \
    --to=martin@lichtvoll.de \
    --cc=chris.mason@fusionio.com \
    --cc=dsterba@suse.cz \
    --cc=kreijack@inwind.it \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=sbehrens@giantdisaster.de \
    --cc=t-itoh@jp.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).