mvdir: where is it, how can I get it?

Michael Gersten cc1 at valhalla.cs.ucla.edu
Thu Sep 22 12:13:07 AEST 1988


In article <15911 at shemp.CS.UCLA.EDU> I was talking about mvdir not on the 3b1,
and proposed the following little program in a protected directory:
>>
>>main(argc,argv) char **argv;
>>{
>>	link (argv[1], argv[2]);
>>	unlink (argv[1]);
>>}
>>
>>, add some checks, and make it 6777, owned by root, in a directory only

Now, I got a few comments, about other references to the directory, ., .. of
children, etc. So, I decided to figure them out. If you spot any errors, please
let me know.

First: mymvdir dir1 dir2 (renaming in the current directory)
mymvdir will link the two, then unlink the first. This will result in an
extra link count for the inode initially, then a normal link count. The id
inode has not changed, so dir1/*/.. (now dir2/*/..) has the correct inode number.

Second: mymvdir dir1 dir2/dir1 (putting into a sub directory)
Once again, the inode in use will be the same. Therefore, any ..'s, .'s, or
others will still have the correct inode number.

Third: mymvdir dir1 dir1/dir2
This will cause problems. After dir1 is unlinked, there will be no file for that
inode/directory that can be referenced. 

Fourth: current directories.
As I understand it, a process's current directory is just the inode number
of the directory, and the disk sectors are read in from the buffer pool as
needed. Since the inodes are still the same, and directory writes (since the
names have been changed) go into the buffer pool immediately, this should not
be a problem.

Bottom line: I have spent 3 days poking at this, and can find no problem other
than security, or if the user makes a mistake. So, can anyone tell me why I
should not make this availible for myself?

			Michael
Still looking for a real "mvdir", "at", and "atrun", as well as a good mv that
mv's dir on its own.



More information about the Comp.sys.att mailing list