Date: Wed, 10 Apr 2002 04:13:23 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: Bogdan TARU <bgd@icomag.de> Cc: "Rogier R. Mulhuijzen" <drwilco@drwilco.net>, freebsd-hackers@FreeBSD.ORG Subject: Re: 'rm' incompatibility with Posix.2 Message-ID: <3CB41E53.E3BBD76A@mindspring.com> References: <20020410103608.F79910-100000@fw.cgn.icom>
next in thread | previous in thread | raw e-mail | index | archive | help
Bogdan TARU wrote: > I didn't say the behaviour contradicts Posix.2. I just said that Posix.2 > specifies removal of the trailing slashes when doing directory operation. Path component operations are a mixed bag. They can occur partially in user space, or they can occur in the kernel. When you refer to a specific object by Name, you are referring to the object. So if we create a sitaution: cd /tmp mkdir tmp cd tmp rimmer# cd /tmp mkdir p ln -s p q and examine what we have, we see: ls -ldi p q p/ q/ 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:03 p 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:03 p/ 43223 lrwxr-xr-x 1 root wheel 1 Apr 10 04:03 q -> p 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:03 q/ Let's try your operation: rm -rf q/ ls -ldi p q p/ q/ ls: p: No such file or directory ls: p/: No such file or directory ls: q/: No such file or directory 43223 lrwxr-xr-x 1 root wheel 1 Apr 10 04:03 q -> p Let's undo this: mkdir p ls -ldi p q p/ q/ 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:04 p 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:04 p/ 43223 lrwxr-xr-x 1 root wheel 1 Apr 10 04:03 q -> p 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:04 q/ And try without teh trailing "/": rm q ls -ldi p q p/ q/ ls: q: No such file or directory ls: q/: No such file or directory 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:04 p 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:04 p/ > Which, for example, freebsd 'rm' does not, which leads to a strange > behaviour. As I stated, I have tryied this on more than one other OS > (OpenBSD 2.9, 3.0, Linux, HP UX 10.20, Solaris 2.7, 2.8), and all yelded > the same result (different from the FreeBSD). Try the "ls -ldi" example I gave, as well. If POSIX states the trailing slash should be removed (please provide references), then it will make listing the contents of a directory pointed to by a symbolic link impossible, without an explicit reference, e.g.: ln -s p q ls -lai p q q/ 43223 lrwxr-xr-x 1 root wheel 1 Apr 10 04:09 q -> p p: total 5 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:04 . 43089 drwxrwxrwt 5 root wheel 4096 Apr 10 04:09 .. q/: total 5 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:04 . 43089 drwxrwxrwt 5 root wheel 4096 Apr 10 04:09 .. 43089 drwxrwxrwt 5 root wheel 4096 Apr 10 04:09 .. rimmer# ... though it *does* look like the "total" calculation is broken. 8-). > Also, I quote from the FreeBSD man page of 'rm': > > "The rm utility removes symbolic links, not the files referenced by > the links." Only when you give them the symbolic link as the argument. If you add the trailing "/" to "q", you are saying "the directory q or the directory pointed to by the symbolic link q". Consider the case of trying to list "the contents of the directory pointed to by the symbolic link q". You can do this, but it's a bit awkward: ls -lai q/. total 5 170 drwxr-xr-x 2 root wheel 512 Apr 10 04:04 . 43089 drwxrwxrwt 5 root wheel 4096 Apr 10 04:09 .. But... the same can not be done on a remove: rm -rf q/. rm: "." and ".." may not be removed It seems to me that making your change means that ls is also broken, and that making the change to ls is wrong. It also seems to me that making the change universally breaks the operation on the target of a symbolic link. I don't see how you can reconcile the operation of "ls" with your proposed operation for "rm". -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CB41E53.E3BBD76A>