gcardwel@polaris.acs.uci.edu (Guy Cardwell) (06/28/90)
I have created a mess. Playing the curious Unix hacker, I created a directory, and then created a hard link to that directory using ln -f. Now I have a problem. I can not seem to get rid of either of the directories. I am running SunOS 4.0.3. I have tried to delete the directories with the following as root: rm -r dir1 rmdir dir1 unlink dir1 The man page for unlink implies that unlink is almost a sure kill... it even warns that you should be careful about this, as all of the files in the directory would be lost... it does not however get rid of the directories. This link count on both of the directories is 3. (. .. other directory) Nothing seems to be convinced that the directories are empty.. Short of dump/restore, I dont know what to do. Any ideas?? Guy
gaynor@busboys.rutgers.edu (Silver) (06/29/90)
> I created ... a hard link to that directory using ln -f. I can not seem to > get rid of either of the directories ... as root using rm, rmdir, or unlink. I did the same thing a couple of years ago, took the same approach, and failed as well. unlink is SUPPOSED to handle this. However, I wound up having to interactively fsck the system. I did not chase down the problem further, so I can't tell you why unlink didn't work. Regards, [Ag] gaynor@topaz.rutgers.edu
omerzu@quando.quantum.de (Thomas Omerzu) (06/29/90)
Suppose it's a bug in unlink. It seems really as if the only way would be a `clri' on the inode of "dir1" and "dir2", followed by a `fsck', which will remove the directories. Not very nice, but working. -- *-----------------------------------------------------------------------------* Thomas Omerzu UUCP: ...!unido!quando!omerzu / omerzu@quando.uucp Quantum GmbH, Bitnet: UNIDO!quando!omerzu / omerzu%quando@UNIDO(.bitnet) Dortmund, Germany Internet: omerzu@quando.quantum.de
guy@auspex.auspex.com (Guy Harris) (06/30/90)
>Suppose it's a bug in unlink. It is. SunOS, for some unknown reason, disallows (at the system call level, not at the file system level!) *all* attempts to unlink directories, even by the super-user. >It seems really as if the only way would be a `clri' on the >inode of "dir1" and "dir2", They share the same inode; one "clri" is sufficient. >followed by a `fsck', which will remove the directories. ...and shove everything that was in them into "lost+found", with cryptic names. Unless the directory in question was empty, I'd first make another directory at the same level as the link you wanted to keep, move everything (don't forget files, other than the obvious "." and "..", with names beginning with "."!) into the new directory, then do the unmount/clri/fsck. (Don't forget the unmount.)
marka@dmssyd.syd.dms.CSIRO.AU (Mark Andrews) (07/02/90)
In article <3575@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: |>Suppose it's a bug in unlink. |It is. SunOS, for some unknown reason, disallows (at the system call |level, not at the file system level!) *all* attempts to unlink |directories, even by the super-user. |>It seems really as if the only way would be a `clri' on the |>inode of "dir1" and "dir2", |They share the same inode; one "clri" is sufficient. |>followed by a `fsck', which will remove the directories. |...and shove everything that was in them into "lost+found", with cryptic |names. |Unless the directory in question was empty, I'd first make another |directory at the same level as the link you wanted to keep, move |everything (don't forget files, other than the obvious "." and "..", |with names beginning with "."!) into the new directory, then do the |unmount/clri/fsck. (Don't forget the unmount.) Fsck can actually pick this condition up (well it did it once). If you move all links to the directory to a new directory, umount and run fsck it should pick up the problem. "IS AN EXTRANEOUS HARD LINK TO DIRECTORY" from strings of fsck. Mark.
gcardwel@polaris.acs.uci.edu (Guy Cardwell) (07/02/90)
My thanks to everyone who responded via e-mail and postings about how to unlink directories created with ln -f. The general concensus seems (and it worked for me..) was to clri and then fsck... a real bummer if you want the machine serving a hundred other workstations on campus... oh well... just blame the NFS SERVER NOT RESPONDING on the LAN people. I will probably be sending hate mail to some friends of mine at Sun. Thanks for help ( and stop sending mail ! ) Guy