Bug 163014 - incorrect working directory after removing USB flash disk without umounting it
Summary: incorrect working directory after removing USB flash disk without umounting it
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 3
Hardware: i386
OS: Linux
medium
low
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-07-12 09:26 UTC by Vlado Potisk
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2005-07-12 22:06:41 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Vlado Potisk 2005-07-12 09:26:28 UTC
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.

Comment 1 Dave Jones 2005-07-12 22:06:41 UTC
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.



Comment 2 Vlado Potisk 2005-07-13 11:58:50 UTC
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 !



Note You need to log in before you can comment on or make changes to this bug.