[comp.unix.wizards] Bad directory problem - Any answers?

mike%cs1.wsu.edu@RELAY.CS.NET (Mike Kibler) (06/23/87)

I have been away from the net for a while, so I do not
know if this problem has already been solved.

SYSTEM:  VAX 11/750 running 4.3 BSD
PROBLEM: A directory called bin was created with a '..' but not '.'. 
         Instead a directory file called 'old' which appears
         to really be '.' is located in the bin directory.

	 A file system check of course reveals that the directory
	 is missing '.', but I have not been able to fix it using
	 fsck.

	 I tried an unlink ( fool!). Of course fsck just stuck it
	 under lost+found.

	 Rmdir cannot remove it because it finds 'old' located
	 in the directory.

	 Don't even think about doing a rm -r old. A little 
	 recursive loop results.

	 Any way to get rid of this bad dir without remaking the
	 file system??

	 
Please mail replys to my CSNET address. Thanks,

 ---- Mike  ( Those who can,  do. Those who can't simulate! )

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Michael K. Kibler        CSNET:  mike%cs1.wsu.edu@RELAY.CS.NET
 Computer Science Dept.   UUCP:   ..!ucbvax!ucdavis!egg-id!ui3!wsucshp!wsu!mike
 Washington State Univ.   BITNET: kibler@wsuvm1.BITNET
 Pullman, WA. 99164-1210  PHONE:  509-335-2723 or 509-335-6636

franco@MIKEY.BBN.COM (Frank A. Lonigro) (06/25/87)

Mike:
        Just so I understand what your problem is I have
the following examples:

% pwd
/usr
% ls -lasg bin
total 15
   1 drwxr-xr-x 16 franco   system       1024 Jun 25 09:30 ..
  14 drwxr-xr-x  1 franco   system       1024 Dec  2  1986 old
% cd bin/old
% pwd
/usr/bin      <----  I'm confused about this, you mentioned that
                old seems to be dot.  If this is so, then have you
                tried this simple 'C' program?

main()
{
   /* change the name of old to be dot */
   rename("/usr/bin/old", "/usr/bin/.");
}

		If that doesn't work you can try re-linking dot
		back into bin like so:

main()
{
   /* reconnect dot */
   link("/usr/bin", "/usr/bin/.");
}

		Of course if the rename doesn't work then you are stuck
		with dot and old being the same.  Maybe at this point
		you can clear the inode of old with the 'clri' command
		since dot and old should have different inodes.  An
		fsck should take care of the rest.

Good luck!!!  If I happen to think of something else for you to try
I will let you know.....

franco%mikey.bbn.com@relay.cs.net
UUCP:  through Harvard.

rgoguen@MIKEY.BBN.COM (06/29/87)

Mike
	Write a 1 line C program relinking PATH -> PATH/. using the link(2) call
You must be super user. Then remove the directory.

Bob Goguen