From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.0.4-1.3.1 Firefox/1.0.4 Description of problem: Removing a USB flash disk without unmounting it first is a user error, but the kernel seems to have some recovery procedure for this case, but it changes the working directory in a wrong way. Version-Release number of selected component (if applicable): kernel-2.6.11-1.35_FC3 How reproducible: Always Steps to Reproduce: 1. plug in the USB flash disk 2. mount /media/usbdisk 3. cd /media/usbdisk/some/directory 4. unplug the USB flash disk (this is not normal, but can happen by mistake) 5. pwd Actual Results: pwd shows that the current working directory is /some/directory, but such directory does not exist and never existed before. Expected Results: I'm not sure, but in my opinion the CWD should stay unchanged, i.e. /media/usbdisk/some/directory and all access to it should result in an I/O error. If the kernel is permitted to change the cwd of a process, then /media as a new CWD makes more sense - it is an existing parent directory of the original working directory. Additional info: Getting the same results with a memory card and a USB card reader.
This is expected behaviour. Trying to do anything like reading/writing files in that dir will fail, but as you have a current reference count on the dir, it's still a valid part of the tree until you cd out of it.
The situation is little bit different, but worse when the directory structure on the flash disk are similar to the root disk, here is an example: # mount /media/usbdisk1 # cd /media/usbdisk1/bin -- unplug the usb disk hardware now -- # pwd /media/usbdisk1/bin # sh # pwd /bin # ls . | wc 77 77 419 # ls /bin | wc 96 96 593 The new shell says its working directory is /bin with 77 entries (on the flash disk) but it also recognizes another /bin with 96 entries (on the root hard disk). Two directories with the same name ! Be sure to always correctly unmount external disks, otherwise strange things might happen !