Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Nov 2006 18:22:39 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Joerg Pernfuss <elessar@bsdforen.de>, <freebsd-hackers@freebsd.org>
Subject:   Re: [patch] rm can have undesired side-effects
Message-ID:  <200611050222.kA52Mdm0011497@apollo.backplane.com>
References:  <20061029222847.GA68272@marvin.astase.com> <20061030003628.42bc5f8d@loki.starkstrom.lan> <00f201c6fbb6$0c6bd150$b3db87d4@multiplay.co.uk> <20061030024358.39a12359@loki.starkstrom.lan> 

next in thread | previous in thread | raw e-mail | index | archive | help
::...
::Although I am a big defender of "the user should know what he does",
::the "right thing to do"[TM] would probably be to sync the behaviour
::of FreeBSD's rm(1) to OpenBSD and lobby NetBSD and DragonFlyBSD to do
::the same :)
::
::	Joerg
:
:    I agree.  I will make this change in DragonFly right now, in fact.
:    The -P option really needs to be consistent across environments
:    and my take on the original design was so users could alias rm to
:    rm -P in their .cshrc files.  Clearly it cannot destroy the contents
:    of the file in the presence of hard links when used in that context.
:
:					-Matt

    Followup note here.  OpenBSD's /bin/rm source is doing something
    unexpected... it isn't unlink()ing the file if it has > 1 hardlinks
    and -P is used.  That is its current behavior.

    pkgbox# /usr/obj/archive/OpenBSD-current/src/bin/rm/rm -P /tmp/x
    pkgbox# echo "x" > /tmp/x
    pkgbox# ln /tmp/x /tmp/y
    pkgbox# /usr/obj/archive/OpenBSD-current/src/bin/rm/rm -P /tmp/x
    rm: /tmp/x (inode 36): not overwritten due to multiple links
    pkgbox# ls -la /tmp/x /tmp/y
    -rw-r--r--  2 root  wheel  2 Nov  4 18:19 /tmp/x
    -rw-r--r--  2 root  wheel  2 Nov  4 18:19 /tmp/y
    pkgbox# 

    I'm not sure I agree with this.  It makes -P unusable as a .cshrc alias.
    I would have expected it to still unlink the file.

    In anycase, for now I am going to sync DragonFly's rm with OpenBSD anyhow,
    even though I'm scratching my head a bit.  This may be just as broken
    as before, just in a different (and safer) way.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611050222.kA52Mdm0011497>