fail to rm directory

Ask a Question related to Linux / Unix Administration, Design and Development.

  1. #1

    Default fail to rm directory

    Hi,

    I have an empty directory can not be removed. Is there any way to diagnose
    the problem? I can use fsck to recover. But I want to pin down the cause.
    The problem itself is hard to reproduce.

    # ls
    testdir1
    # rm -rf testdir1
    rm: Unable to remove directory testdir1: File exists
    # cd testdir1
    # ls -al
    total 4
    drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..

    thanks
    Ming


    Luo, Ming [CAR:5K36:EXCH] Guest

  2. Similar Questions and Discussions

    1. Active Directory Search fails ("The directory service is unavailab
      Hi all, I'm having one of those nerve wrecking errors, when trying to perform a simple search in an Active Directory. The objective of the code...
    2. Server cannot access application directory ... The directory does not exist or is not accessible because of security settings
      If you are using Windows XP in a Workgroup, rather than a Domain, then by default "Simple Filesharing" is turned on, and you won't see a security...
    3. Server cannot access application directory... The directory does not exist or is not accessible because of security settings.
      Hi, I have this issue with the error below. Let me explain my goal and my server environement: Goal: To have 3 separate web servers reading...
    4. rsync exclude file - directory name without directory contents
      When using rsync to maintain incremental backups significant space can be saved on the backup server by excluding directories that have non-critical...
    5. wher is the Qt directory and KDE directory in Mandrake Linux 9.1?
      I am currently want to compile kdevelop 3.0 alpha version, but it says I need to export QTDIR and KDEDIR, but I don`t know where they are. I am...
  3. #2

    Default Re: fail to rm directory

    In article <cbfba0$29t$1@zcars0v6.ca.nortel.com>, Luo, Ming
    [CAR:5K36:EXCH] wrote:
    >I have an empty directory can not be removed. Is there any way to diagnose
    >the problem? I can use fsck to recover. But I want to pin down the cause.
    >The problem itself is hard to reproduce.
    >
    ># ls
    >testdir1
    ># rm -rf testdir1
    >rm: Unable to remove directory testdir1: File exists
    ># cd testdir1
    ># ls -al
    >total 4
    >drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    >drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    You got 50% extra free on your link count.

    --
    Elvis Notargiacomo master AT barefaced DOT cheek
    [url]http://www.notatla.org.uk/goen/[/url]
    all mail refused Guest

  4. #3

    Default Re: fail to rm directory

    Hi Ming,
    this is probably du to a filesystme inconsistency. Do a umount and fsck on
    the filesystem.
    /Sebastian [url]www.tomac.se[/url]


    "Luo, Ming [CAR:5K36:EXCH]" <luoz@americasm01.nt.com> wrote in message
    news:cbfba0$29t$1@zcars0v6.ca.nortel.com...
    > Hi,
    >
    > I have an empty directory can not be removed. Is there any way to
    diagnose
    > the problem? I can use fsck to recover. But I want to pin down the cause.
    > The problem itself is hard to reproduce.
    >
    > # ls
    > testdir1
    > # rm -rf testdir1
    > rm: Unable to remove directory testdir1: File exists
    > # cd testdir1
    > # ls -al
    > total 4
    > drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    > drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    >
    > thanks
    > Ming
    >
    >

    Sebastian Tomac Guest

  5. #4

    Default Re: fail to rm directory


    "Luo, Ming [CAR:5K36:EXCH]" <luoz@americasm01.nt.com> wrote in message
    news:cbfba0$29t$1@zcars0v6.ca.nortel.com...
    > Hi,
    >
    > I have an empty directory can not be removed. Is there any way to
    diagnose
    > the problem? I can use fsck to recover. But I want to pin down the
    cause.
    > The problem itself is hard to reproduce.
    >
    > # ls
    > testdir1
    > # rm -rf testdir1
    > rm: Unable to remove directory testdir1: File exists
    > # cd testdir1
    > # ls -al
    > total 4
    > drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    > drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    >
    > thanks
    > Ming
    >
    >
    That link count of 3, especially for the "." entry is very suspicious.
    I think it ought to be 2. If you can umount the file system and
    run "fsck -y" against its partition, you might find that some reference
    count has become corrupted, though I don't know how such a thing
    could happen.

    You might try this, before running fsck:
    cd <parent-of-testdir1>
    /bin/tar cvf /tmp/testdir1.tar testdir # look for any errors here!
    /bin/tar xvf /tmp/testdir1.tar # should force overwrite
    /bin/ls -al testdir1 # check if the reference count has changed

    Good luck!


    Dennis Glover Guest

  6. #5

    Default Re: fail to rm directory

    In comp.unix.solaris Luo, Ming [CAR:5K36:EXCH] <luoz@americasm01.nt.com> wrote:
    > Hi,
    > I have an empty directory can not be removed. Is there any way to diagnose
    > the problem? I can use fsck to recover. But I want to pin down the cause.
    > The problem itself is hard to reproduce.
    > # ls
    > testdir1
    > # rm -rf testdir1
    > rm: Unable to remove directory testdir1: File exists
    > # cd testdir1
    > # ls -al
    > total 4
    > drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    > drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    Ouch. Your directory has 3 links. Normal for an empty directory is
    2 (one from the . in the directory, and one from 'testdir1' in the
    parent directory).

    Somehow you have a 3rd link. Either a subdirectory was removed
    inconsistently (did the machine crash?) or an extra link was made.

    Grab the inode of the directory and do a
    find <filesystem> -inum <inode> -print

    If the directory shows up twice, then a hard link to the directory was
    somehow made.

    If 'fsck' cleans it up, I'd assume a crash caused a corruption. 'fsck'
    might not clean it up, either. You might have to clear the inode with
    clri and then fsck the filesytem to clean up.

    --
    Darren Dunham [email]ddunham@taos.com[/email]
    Senior Technical Consultant TAOS [url]http://www.taos.com/[/url]
    Got some Dr Pepper? San Francisco, CA bay area
    < This line left intentionally blank to confuse you. >
    Darren Dunham Guest

  7. #6

    Default Re: fail to rm directory

    Luo, Ming wrote:
    > I have an empty directory can not be removed. Is there any way to diagnose
    > the problem? I can use fsck to recover. But I want to pin down the cause.
    > The problem itself is hard to reproduce.
    >
    > # ls
    > testdir1
    > # rm -rf testdir1
    > rm: Unable to remove directory testdir1: File exists
    > # cd testdir1
    > # ls -al
    > total 4
    > drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    > drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    Is this directory mounted somewhere by NFS?

    There exists following possible scenario:

    - You export the filesystem containing testdir1 by NFS.
    - You mount it on another host.
    - You create subdirectories or files within testdir.
    - You have processes on the system that mounted this filesystem
    by NFS that open these files and/or chdir to the subdirectories
    within testdir1.
    - Now, if you ``rm -fr testdir1'', files and/or directories
    named ``.nfs<something>'' will be created within ``testdir1''
    to keep them alive for the processes on the other system.

    This causes ``rm -fr testdir1'' to fail with the error message
    above and this may also cause ``.'' to have a link count greater
    than 2 (in case of subdirectories).

    To check if this is your problem, just wait some time after the
    ``rm -fr testdir1'' and check whether ``.nfs<something>'' files
    or directories reappear.

    Andreas.

    --
    Dr. Andreas F. Borchert, SAI, Universitaet Ulm | Habe Mut, dich deines
    Helmholtzstrasse 18, E02, Tel +49 731 50-23572 | eigenen Verstandes zu
    [url]http://www.mathematik.uni-ulm.de/sai/borchert/[/url] | bedienen! -- I. Kant
    Andreas Borchert Guest

  8. #7

    Default Re: fail to rm directory

    On Fri, 25 Jun 2004 00:38:30 +0200, Andreas Borchert wrote:
    > Luo, Ming wrote:
    >> I have an empty directory can not be removed. Is there any way to diagnose
    >> the problem? I can use fsck to recover. But I want to pin down the cause.
    >> The problem itself is hard to reproduce.
    >>
    >> # ls
    >> testdir1
    >> # rm -rf testdir1
    >> rm: Unable to remove directory testdir1: File exists
    >> # cd testdir1
    >> # ls -al
    >> total 4
    >> drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    >> drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    >
    > Is this directory mounted somewhere by NFS?
    >
    > There exists following possible scenario:
    >
    > - You export the filesystem containing testdir1 by NFS.
    > - You mount it on another host.
    > - You create subdirectories or files within testdir.
    > - You have processes on the system that mounted this filesystem
    > by NFS that open these files and/or chdir to the subdirectories
    > within testdir1.
    > - Now, if you ``rm -fr testdir1'', files and/or directories
    > named ``.nfs<something>'' will be created within ``testdir1''
    > to keep them alive for the processes on the other system.
    I didn't know that... but shouldn't "ls -al" show all files, including
    hidden files, such as .nfs<something>?

    Ah, (dim light gimmers?) maybe this depends on which machine (NFS server,
    or (one of) NFS client) one is working? I had assumed (ref. Benny Hill)...
    > This causes ``rm -fr testdir1'' to fail with the error message
    > above and this may also cause ``.'' to have a link count greater
    > than 2 (in case of subdirectories).
    >
    > To check if this is your problem, just wait some time after the
    > ``rm -fr testdir1'' and check whether ``.nfs<something>'' files
    > or directories reappear.
    >
    > Andreas.
    --
    Juhan Leemet
    Logicognosis, Inc.

    Juhan Leemet Guest

  9. #8

    Default Re: fail to rm directory

    Juhan Leemet wrote:
    > On Fri, 25 Jun 2004 00:38:30 +0200, Andreas Borchert wrote:
    >> - Now, if you ``rm -fr testdir1'', files and/or directories
    >> named ``.nfs<something>'' will be created within ``testdir1''
    >> to keep them alive for the processes on the other system.
    >
    > I didn't know that... but shouldn't "ls -al" show all files, including
    > hidden files, such as .nfs<something>?
    Yes. However, it takes some time until these ``.nfs<something>''
    entries reappear. And, if you are invoking ``ls -al'' on an NFS
    client, it might take even longer.
    > Ah, (dim light gimmers?) maybe this depends on which machine (NFS server,
    > or (one of) NFS client) one is working?
    Indeed!

    Andreas.

    --
    Dr. Andreas F. Borchert, SAI, Universitaet Ulm | Habe Mut, dich deines
    Helmholtzstrasse 18, E02, Tel +49 731 50-23572 | eigenen Verstandes zu
    [url]http://www.mathematik.uni-ulm.de/sai/borchert/[/url] | bedienen! -- I. Kant
    Andreas Borchert Guest

  10. #9

    Default Re: fail to rm directory

    In comp.unix.admin Luo, Ming [CAR:5K36:EXCH] <luoz@americasm01.nt.com> wrote:
    > Hi,
    > I have an empty directory can not be removed. Is there any way to diagnose
    > the problem? I can use fsck to recover. But I want to pin down the cause.
    > The problem itself is hard to reproduce.
    > # ls
    > testdir1
    > # rm -rf testdir1
    > rm: Unable to remove directory testdir1: File exists
    > # cd testdir1
    > # ls -al
    > total 4
    > drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    > drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    What OS ?


    It looks like an additional hardlink to the directory.

    Do ls -i to find out inode number and see what the other link goes to.

    > thanks
    > Ming


    --
    Peter Håkanson
    IPSec Sverige ( At Gothenburg Riverside )
    Sorry about my e-mail address, but i'm trying to keep spam out,
    remove "icke-reklam" if you feel for mailing me. Thanx.
    phn@icke-reklam.ipsec.nu Guest

  11. #10

    Default Re: fail to rm directory

    In article <GNHCc.77011$kw3.66192@newssvr29.news.prodigy.com> ,
    Darren Dunham <ddunham@redwood.taos.com> wrote:
    >> I have an empty directory can not be removed. Is there any way to diagnose
    >> the problem? I can use fsck to recover. But I want to pin down the cause.
    >> The problem itself is hard to reproduce.
    >
    >> # ls
    >> testdir1
    >> # rm -rf testdir1
    >> rm: Unable to remove directory testdir1: File exists
    >> # cd testdir1
    >> # ls -al
    >> total 4
    >> drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    >> drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    >
    >Ouch. Your directory has 3 links. Normal for an empty directory is
    >2 (one from the . in the directory, and one from 'testdir1' in the
    >parent directory).
    For UFS, you are correct.

    For POSIX in general, you are not correct. An empty directory on a POSIX
    compliant system may have a link count of 1 and the link count does not
    need to change if you create subdirectories.

    This is why e.g. GNU find by default behaves POSIXly incorrect as it makes
    assumptions on the link count of directories.

    --
    EMail:joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
    [email]js@cs.tu-berlin.de[/email] (uni) If you don't have iso-8859-1
    [email]schilling@fokus.fraunhofer.de[/email] (work) chars I am J"org Schilling
    URL: [url]http://www.fokus.fraunhofer.de/usr/schilling[/url] [url]ftp://ftp.berlios.de/pub/schily[/url]
    Joerg Schilling Guest

  12. #11

    Default Re: fail to rm directory

    Darren Dunham wrote:
    > Luo, Ming wrote:
    >
    > > I have an empty directory can not be removed.
    > > # ls
    > > testdir1
    > > # rm -rf testdir1
    > > rm: Unable to remove directory testdir1: File exists
    > > # cd testdir1
    > > # ls -al
    > > total 4
    > > drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    > > drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    >
    > Ouch. Your directory has 3 links. Normal for an empty directory is
    > 2 (one from the . in the directory, and one from 'testdir1' in the
    > parent directory).
    >
    > Somehow you have a 3rd link. Either a subdirectory was removed
    > inconsistently (did the machine crash?) or an extra link was made.
    This is why many versions of Unix supply an "ln" command that
    checks if the hard link it is making is to a directory and
    refuses. Some versions have even refued root.
    > Grab the inode of the directory and do a
    > find <filesystem> -inum <inode> -print
    >
    > If the directory shows up twice, then a hard link to the directory was
    > somehow made.
    Then delete one of the two hard links with "unlink" and use
    "rm -r" on the other.
    > If 'fsck' cleans it up, I'd assume a crash caused a corruption. 'fsck'
    > might not clean it up, either. You might have to clear the inode with
    > clri and then fsck the filesytem to clean up.
    Before I saw the hard link count of 3, I figured it could be a
    mount point. It would not be able to delete a mount point because
    mount points aren't subject to unlink. To acheive the count of 3
    it would take mounting a filesystem over a directory that already
    has a subdir, but I think it would still show as a link count of
    2. Every once in a while I'll encounter asymetry problems where
    the directory that receives the mount point has significantly
    different ownerships and permissions than the root of the mounted
    filesystem, but that tends to make permission-denied not file-exists
    errors.
    Doug Freyburger Guest

  13. #12

    Default Re: fail to rm directory

    In comp.unix.admin Joerg Schilling <js@cs.tu-berlin.de> wrote:
    > In article <GNHCc.77011$kw3.66192@newssvr29.news.prodigy.com> ,
    > Darren Dunham <ddunham@redwood.taos.com> wrote:
    >>> I have an empty directory can not be removed. Is there any way to diagnose
    >>> the problem? I can use fsck to recover. But I want to pin down the cause.
    >>> The problem itself is hard to reproduce.
    >>
    >>> # ls
    >>> testdir1
    >>> # rm -rf testdir1
    >>> rm: Unable to remove directory testdir1: File exists
    >>> # cd testdir1
    >>> # ls -al
    >>> total 4
    >>> drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    >>> drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    >>
    >>Ouch. Your directory has 3 links. Normal for an empty directory is
    >>2 (one from the . in the directory, and one from 'testdir1' in the
    >>parent directory).
    > For UFS, you are correct.
    > For POSIX in general, you are not correct. An empty directory on a POSIX
    > compliant system may have a link count of 1 and the link count does not
    > need to change if you create subdirectories.
    I assume that the writer's system does not use POSIX-FS. In fact noone does.

    > This is why e.g. GNU find by default behaves POSIXly incorrect as it makes
    > assumptions on the link count of directories.
    Sometimes RMS aggrres with me.


    --
    Peter Håkanson
    IPSec Sverige ( At Gothenburg Riverside )
    Sorry about my e-mail address, but i'm trying to keep spam out,
    remove "icke-reklam" if you feel for mailing me. Thanx.
    phn@icke-reklam.ipsec.nu Guest

  14. #13

    Default Re: fail to rm directory

    [email]phn@icke-reklam.ipsec.nu[/email] writes:
    >I assume that the writer's system does not use POSIX-FS. In fact noone does.
    "hsfs" on Solaris does not have traditional link count semantics
    for directories and GNU find fails on it.


    Casper
    --
    Expressed in this posting are my opinions. They are in no way related
    to opinions held by my employer, Sun Microsystems.
    Statements on Sun products included here are not gospel and may
    be fiction rather than truth.
    Casper H.S. Dik Guest

  15. #14

    Default Re: fail to rm directory

    In article <cbh589$pjb$1@news.cs.tu-berlin.de>,
    [email]js@cs.tu-berlin.de[/email] (Joerg Schilling) writes:
    > In article <GNHCc.77011$kw3.66192@newssvr29.news.prodigy.com> ,
    > Darren Dunham <ddunham@redwood.taos.com> wrote:
    >
    >>> I have an empty directory can not be removed. Is there any way to diagnose
    >>> the problem? I can use fsck to recover. But I want to pin down the cause.
    >>> The problem itself is hard to reproduce.
    >>
    >>> # ls
    >>> testdir1
    >>> # rm -rf testdir1
    >>> rm: Unable to remove directory testdir1: File exists
    >>> # cd testdir1
    >>> # ls -al
    >>> total 4
    >>> drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    >>> drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    >>
    >>Ouch. Your directory has 3 links. Normal for an empty directory is
    >>2 (one from the . in the directory, and one from 'testdir1' in the
    >>parent directory).
    >
    > For UFS, you are correct.
    >
    > For POSIX in general, you are not correct. An empty directory on a POSIX
    > compliant system may have a link count of 1 and the link count does not
    > need to change if you create subdirectories.
    >
    > This is why e.g. GNU find by default behaves POSIXly incorrect as it makes
    > assumptions on the link count of directories.
    >
    One can give it the peculiar "-noleaf" option to prevent that assumption.

    Since one can get the source, one could also modify it to prevent that
    assumption by default; I haven't checked, but there might even be a
    configuration option to that effect.


    --
    mailto:rlhamil@smart.net [url]http://www.smart.net/~rlhamil[/url]
    Richard L. Hamilton Guest

  16. #15

    Default Re: fail to rm directory

    In article <ixkzn6o743t.fsf@dev.null>, Tim wrote:
    >It screws up in ClearCase's MVFS filesystem as well. It fails to
    >descend into this dir's subdirectories. Note that the link count
    >doesn't match the number of directories shown by ls -l:
    >
    >$ ls -d .
    >drwxrwxr-x 5 tbutler users 4313 Nov 10 2003 .
    >$ ls -l | grep ^d | wc -l
    > 12
    >
    >(I hadn't chased down the cause of this until this thread reminded
    >me of it. Using the suggested option "-noleaf" does cause it to
    >descend into all subdirs.)
    Do you also have directories hardlinked to their grandparents ?
    I've never been able to tell whether this is the fault of Clearcase
    or the people in my company who configured it.

    This caused me to write a find-like replacement that remembers
    pairs of (st_dev,st_ino) and won't revisit them.

    --
    Elvis Notargiacomo master AT barefaced DOT cheek
    [url]http://www.notatla.org.uk/goen/[/url]
    all mail refused Guest

  17. #16

    Default Re: fail to rm directory

    Since you included comp.unix.solaris, I'll presume this is a Solaris
    system. Most UNIX and UNIX-like operating systems do allow superuser
    (root) to create multiple hard links to directories. This is generally
    restricted to superuser and is generally not recommended, due to the
    problems it can cause.

    If you don't have a corrupted filesystem (many would view multiple hard
    links to a directory as a type of corruption), it would seem you have
    multiple hard links to the directory. You might start by doing
    something like:
    # ls -ldi testdir1
    # find mount_point_of_filesystem -xdev -inum inum_of_testdir1 -print

    Take a close look at the man pages for link and unlink.

    Generally speaking, one should never unlink a non-empty directory.
    If, however, a directory contains an ancestor directory, one would
    typically need to use unlink to remove the ancestor from the descendant.

    A rough example of that type of scenario might be something like this:
    # mkdir loop
    # link loop loop/loop
    Correction would typically require:
    # unlink loop/loop

    In your case it seems likely the extra hard link is somewhere else,
    e.g.:
    # mkdir testdir1
    # link testdir1 testdir2
    In that case,
    # unlink testdir2
    would typically remove the extra hard link, dropping the link count on
    testdir1, such that testdir1 could then be removed via normal means.

    Random note: I noticed that LINUX appears to disallow even superuser
    from creating multiple hard links to directories (at least via link)
    even on other UNIX filesystem types which clearly support such, and are
    also supported under LINUX.

    And here's example test (with some comments) under Solaris:

    # uname -rs
    SunOS 5.9
    # mkdir /tmp/foo && cd /tmp/foo
    # mkdir testdir1 && ls -lid testdir1
    468350682 drwxr-xr-x 2 root root 69 Jul 17 14:00 testdir1
    # link testdir1 testdir2
    # ls -lid * */. */.. | sort
    468350630 drwxr-xr-x 3 root root 151 Jul 17 14:00 testdir1/..
    468350630 drwxr-xr-x 3 root root 151 Jul 17 14:00 testdir2/..
    468350682 drwxr-xr-x 3 root root 69 Jul 17 14:00 testdir1
    468350682 drwxr-xr-x 3 root root 69 Jul 17 14:00 testdir1/.
    468350682 drwxr-xr-x 3 root root 69 Jul 17 14:00 testdir2
    468350682 drwxr-xr-x 3 root root 69 Jul 17 14:00 testdir2/.
    # rm -rf *
    rm: Unable to remove directory testdir1: File exists
    rm: Unable to remove directory testdir2: File exists
    # rmdir *
    rmdir: directory "testdir1": Directory not empty
    rmdir: directory "testdir2": Directory not empty
    # unlink testdir2
    # rmdir testdir1
    # mkdir d && link d d/d
    # rm -rf d
    Segmentation Fault - core dumped
    # rm d/core
    # unlink d/d
    unlink: Invalid argument
    .... I wasn't expecting that to fail like that
    # truss unlink d/d
    ....
    unlink("d/d") Err#22_EINVAL
    ....
    # unlink d
    .... but that removes the directory ... not sure if it left the
    filesystem clean though (most notably did it decrement the link count on
    the directory to zero, or did it create an unreferenced directory?)
    # mkdir -p a/c
    # link a a/c/a
    # unlink a/c/a
    # rmdir a/c a

    "Luo, Ming [CAR:5K36:EXCH]" <luoz@americasm01.nt.com> wrote in message news:<cbfba0$29t$1@zcars0v6.ca.nortel.com>...
    > I have an empty directory can not be removed. Is there any way to diagnose
    > the problem? I can use fsck to recover. But I want to pin down the cause.
    > The problem itself is hard to reproduce.
    > # ls
    > testdir1
    > # rm -rf testdir1
    > rm: Unable to remove directory testdir1: File exists
    > # cd testdir1
    > # ls -al
    > total 4
    > drwxr-xr-x 3 root other 512 Jun 23 14:45 .
    > drwxr-xr-x 3 mycomp mycomp 512 Jun 23 14:18 ..
    Michael Paoli Guest

  18. #17

    Default Re: fail to rm directory

    Michael Paoli wrote:
    [...]
    > # unlink d
    > ... but that removes the directory ... not sure if it left the
    > filesystem clean though (most notably did it decrement the link count on
    > the directory to zero, or did it create an unreferenced directory?)
    calling unlink(2) on a directory will not decrement the link count
    of the unlinked directories parent directory. You will be unable
    to remove the parent directory afterwards using rmdir(1) or rm(1) -rf,
    untill fsck(1M) does clear things up.

    Thus calling unlink(2) on a directory is not recommended.

    While this may look like a bug in the first place, it is the consequence
    of the unlink(2) behavior defined by various standards we have to comply with.

    ---
    frankB
    Frank Batschulat Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139