[svlug] Removing current working directory

Dagmar d'Surreal dagmar at dsurreal.org
Tue Jan 8 00:21:01 PST 2002


On Mon, 7 Jan 2002, S wrote:

>  As far as I know, one cannot delete the present working
>  directory.  I observed the following strange behaviour: (rh7.1)
>
(snippage)
>  [root at localhost testdir]# rmdir ../testdir/
>  [root at localhost testdir]#
> [root at localhost testdir]# man rmdir
>  shell-init: could not get current directory: getcwd: cannot access parent
>  directories: No such file or directory
(snippage)
>  chdir: could not get current directory: getcwd: cannot access parent
>  directories: No such file or directory
>  RMDIR(1)                       FSF                       RMDIR(1)
>  ..
>  ..
>  q
> [root at localhost testdir]# cd
> [root at localhost root]# man rmdir
>  --doesnt crib here --
>
>  Any comments?

It looks like you deleted the cwd just fine to me, else you wouldn't be
seeing those error messages.  Keep in mind that a bash prompt is *not* the
same thing as your actual current working directory.

Just one note... those inodes don't actually get freed until all the files
inside are no longer in use.  This can be used to cause some serious
trouble.  :)  You can merrily make a binary that allocates a configuration
file and keeps it open with read-write access, and then deletes itself,
the configuration file, and the directory it was in from the disk... and
it will still run just fine and continue to be able to write to it's
config/scratch file.  (ohmygosh!)

Just don't expect disk useage tools to be very pleased with you if you do
this "trick".





More information about the svlug mailing list