GNOME Bugzilla – Bug 333370
udev causes mountpointdetection to fail
Last modified: 2009-12-04 03:51:44 UTC
Please describe the problem: When using a udev rule to set up the symlink for my external USB HD, gparted will segfault if the drive is mounted when I start gparted. If the drive is not mounted gparted will start normally. Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Yes Other information: If I manually mount this drive,as root mount /dev/sda1 -t vfat /mnt/usbhd, gparted-0.2.2 will run normally.
could you post the udev rule pls?
sorry forget it, I found your other thread with all the details.
i think i'll solve this for now by also parsing /etc/mtab. Later on we could look into this different /proc/mounts. As soon as i find some time i'll supply a tarball for Mark to test.
mark, could you please test this tarball and report your findings? http://gparted.sourceforge.net/gparted-0.2.2.tar.gz
Here's another piece of the puzzle. I define my usb rule the other way around so the new device is /dev/usb_key and the symlink is /dev/sda1 -> /dev/usb_key ( Cant remember why but there was reason , maybe gparted didnot like it! ) /etc/udev/rules.d/10-udev.rules : KERNEL=="sd*[0-9]*", ACTION=="add", SYSFS{model}=="USB Flash Disk*" ,SYMLINK+="%k", NAME="usb_key the slight syntax change is due to udev-070 , so dont get confused by that. now gparted can format this setup and correctly reports free size etc but it cannot umount it, tho' the error is pretty vague so I dont know why not. HTH
Now I just tried your new tarball with my setup : bash-3.1#ls -ail /dev/sda* 18384 brw-rw---- 1 root disk 8, 0 2006-03-06 00:05 /dev/sda 18427 lrwxrwxrwx 1 root root 7 2006-03-06 00:05 /dev/sda1 -> usb_key bash-3.1#mount /dev/sda1 bash-3.1#mount ... /dev/usb_key on /mnt/usb type vfat (rw,noexec,nosuid,nodev,shortname=winnt) bash-3.1#gparted /dev/sda I get the same --- display as noted above and umount works but info gives and exclamation icon and cant find the mountpoint. now if I mount it by the true block device's name: bash-3.1#gparted /dev/usb_key gparted now shows a non-existant /dev/usb_key1 that it seems to have made up on its own. Still no size data and an exclamation icon. Now if I revert to Mark's kind of udev rule where /dev/usb_key is the symlink, gparted invents /dev/sda1p1 !! bash-3.1#gparted /dev/sda gets stuck in a spin and I have to cntl_C . bash-3.1#gparted /dev/sda1 runs but shows sda1p1 and cant do much with it. NO size data , exclm etc. At the same time cli df -h does give correct output. I'll post this then try a reboot.
Created attachment 60725 [details] Latest gparted test
udev rule: BUS="scsi", SYSFS{vendor}="IBM-DTLA", KERNEL="sd*", NAME="%k", SYMLINK="usbhd%n" The device(s) /dev/sda and /dev/sda1 are created by udev: mmyoung@darkstar:~$ ls -l /dev/sda* brw-rw---- 1 root disk 8, 0 2006-03-05 17:22 /dev/sda brw-rw---- 1 root disk 8, 1 2006-03-05 17:22 /dev/sda1 My udev rule creates the two symlinks: mmyoung@darkstar:~$ ls -l /dev/usbhd* lrwxrwxrwx 1 root root 3 2006-03-05 17:22 /dev/usbhd -> sda lrwxrwxrwx 1 root root 4 2006-03-05 17:22 /dev/usbhd1 -> sda1 I compiled and installed the latest 0.2.2 tarball supplied and gparted works, with my udev rule in place AND it displays the correct drive information. I have attached a screenshot. Notice that the USB_HD icon is on my desktop signifing that the filesystem is indeed mounted. mmyoung@darkstar:~$ mount /dev/sda1 on /mnt/usbhd type vfat (rw,nosuid,nodev) Thanks! Later, Mark Young
OK , reboot and using Marks style of rule now works OK if I give it the real device name and not the symlink as argument (no arg is fine too). maybe you try to find yourself a usb flash device to play with since it seems to reproduce the same behaviour. you can create similar conditions on gentoo. I'm using udev-070 on 2.6.11-nitro2 without hal and dbus so it does not seem like there's any tricky distro specific oddities going on here. it may be easier than debugging your efforts by proxy.
Just found that rebooting with my original set of rules is OK if the device is not mounted. otherwise with it mounted , calling gparted with the true /dev/usb_key causes nonsense, letting gparted without arg. it uses /dev/sda1 which is a symlink and it gives the --- output. have not looked at your code on this but it seems like a workaround for a specific case rather than a more generalised fix.
hmm, i'm happy it did work for Mark. FYI, i solved mark's problem by parsing /etc/mtab as well as /proc/mounts. Because his /etc/mtab was intact and correct this solved his problem. @gnutter: Your problem seems to be different from Mark's, but you have the advantage to know more about gparted's internals. Are you sure device and partition detection are OK and only the mountpointdetection fails? Also, do you have /etc/mtab in place? You have to realize i have no experience with udevrules at all. The reason for this is simple: i don't have any usbdevices :/ (poor student here ;) ) I'd appreciate it if you could formulate WHAT exactly the problem is and supply the contents of /proc/partitions /etc/fstab /proc/mounts /etc/mtab (you know, the usual :) ) Maybe you could also propose a solution/patch for this?
>>You have to realize i have no experience with udevrules at all. >>The reason for this is simple: i don't have any usbdevices >> (poor student here ) Oh come on, small usb sticks are more common a floppy disks these days! No-one's suggesting you buy a hard drive. I had a look at your code , it's basically an extention of what I did for unmounted mountpoints. But I dont understand the working or the iterators too well. It sure produced some odd results. from /proc/mounts: /dev/usb_key /mnt/usb vfat rw,nodiratime,nosuid,nodev,noexec,fmask=0022,dmask=0022,codepage=cp850,iocharset=iso8859-15,shortname=winnt 0 0 from mtab: /dev/usb_key /mnt/usb vfat rw,noexec,nosuid,nodev,shortname=winnt 0 0 bash-3.1#ls -ail /dev/sda* 611419 brw-rw---- 1 root disk 8, 0 2006-03-06 11:05 /dev/sda 611468 lrwxrwxrwx 1 root root 7 2006-03-06 11:05 /dev/sda1 -> usb_key In this setup gparted info says cant find mount points and gives ---
yep, i guess this is because gparted tries to work with '/dev/sda1' while '/dev/usb_key' is used in the relevant files. does gparted show /dev/sda1 or /dev/usb_key in its interface?
btw, the 'iteratorstuff' sorts the mountpoints and removes duplicates. that's all.
hmm, I've changed the udev rules to something more consistant. Now I have: bash-3.1#ls -ail /dev/sda* 13868 lrwxrwxrwx 1 root root 7 2006-03-06 12:44 /dev/sda -> usb_key 13921 lrwxrwxrwx 1 root root 8 2006-03-06 12:44 /dev/sda1 -> usb_key1 gparted still has basically the same issues. even tho' these devices are the real devices it still seems to prefere dealing with /dev/sda* which are symlinks. the main display shows sda but the info page gives "path" as /dev/sda1 "real path" correctly , /dev/usb_key1 proc/mounts and mtab both now deal with the new device names so it seems to be where you are detecting the partitions that things go wrong. Could this be a bug in what libparted is returning? Otherwise maybe you should be using the "real path" all the time anyway. It sure seems to cause probs when the two are not the same.
Ah-ha! /proc/partitions ... 22 9 4104576 hdc9 22 10 11679224 hdc10 22 11 8001 hdc11 8 0 256000 sda 8 1 255728 sda1 seems this is the root cause of the problem. despite the udev rules this is still showing sda* I dont know whether that is correct or not but maybe like I said for gparted to be more robust you should be using "real path" when the two are not the same. I'll try posting on gentoo about this.
this is getting interesting :) till now every setup i've seen had the same entries in /proc/partitions and /proc/mounts, /etc/mtab. i guess the best thing to do is to match the mountpoints agains the 'real path' and the 'short path' (i already have both in Partition). That way it should work (hopefully) I guess it is correct behaviour, /proc/partitions using 'real devices' and /etc/fstab and /etc/mtab using the symlinks (as defined in the udev rule). However it would be good to check it out. Maybe you can post the url to the bug/forumpost you've made? thanks
no replies to my post yet , if I get something helpful I'll link you. I suspect this may be normal. /proc/partitions maybe lower level than udev/devfs . Indeed it does not output /dev/* just the kernel name which may be invariant, so I'll have to rethink my udev if it causes problems. hwvr, it's only when you start looking at unusual setups that you start to see if you've made assumption and the bugs come out. So I think either way the outcome will be useful to you. I've always has these anarchistic tendancies but it invariably leads to a fuller understanding of how things work. If I get anything relevant I'll keep you posted.
Hi guys, sorry for the delay, i've been busy working on other stuff mostly. I've changed the way gparted stores paths to devices/partitions and as a side-effect i hope this issue will also be gone. I'd appreciate it if you could get the latest CVS and give it a try. If access to CVS is going to be a problem i can provide a tarball.
with the following devices I still have pretty much the same issues: bash-3.1#ls -ail /dev/sda* 245995 brw-rw---- 1 root disk 8, 0 2006-03-16 19:50 /dev/sda 246046 lrwxrwxrwx 1 root root 7 2006-03-16 19:50 /dev/sda1 -> usb_key gparted /dev/usb_key comes up with a non-existant /dev/usb_key1 with the excl. mark icon. gparted /dev/sda looks correct, mounts OK but says it cant umount the partition afterwards.
> gparted /dev/sda looks correct, mounts OK but says it cant umount the partition > afterwards. since unmounting is done by calling 'umount' it should give some reason (maybe the device is busy?). Please post it here. so the issue with the unknown mountpoint is gone when you start gparted like 'gparted /dev/sda' ? And what happens if you just start 'gparted' ?
>(In reply to comment #19) > I'd appreciate it if you could get the latest CVS and give it a try. If access > to CVS is going to be a problem i can provide a tarball. A tarball would be nice. It's easier for me to package. Thanks, Mark Young
without arguements is read /dev/sda cant umount /dev/sda1 with this msg. The partition could not be unmounted from the following mountpoints: /mnt/usb Most likely other partitions are also mounted on these mountpoints. You are advised to unmount them manually.
hey.. that's weird. That error only shows up when this particular mountpoint (/mnt/usb) is used by more partitions. Any idea if that might be that case? If not, then we're looking at a glitch.. It just occurs to me this could be caused by a difference between /etc/mtab and /proc/mounts. If the partition is known as /dev/sda1 AND as /dev/usb_key1 it could screw this (rather simple) algorithm. Anything interesting in /etc/mtab and /proc/mounts?
> A tarball would be nice. It's easier for me to package. You'll get one asap, right now i can't get shell access on the SF servers.
as promised http://gparted.sourceforge.net/gparted-cvs20060317.tar.bz2
>>That error only shows up when this particular >>mountpoint (/mnt/usb) is used by more partitions NO, that's the point , it was not dual mounted, it is incorrectly guessing the cause of the error. If I manually mount the device before starting gparted /dev/sda it gets detected OK. gparted and umount it correctly and remount it . but that is where it goes a bit wrong. I see this in mtab: /dev/usb_key /mnt/usb vfat rw 0 0 and this in /proc/mounts: /dev/sda1 /mnt/usb vfat rw,nodiratime,fmask=0022,dmask=0022,codepage=cp850,iocharset=iso8859-15 0 0 Then it can no longer umount as stated before. One thing more I noticed is htat in both cases the info dlg shows two enties for path: /dev/sda1 AND /dev/usb_key. In either case the fictive /dev/usb_key1 does not seem to be in either proc or mtab.
>NO, that's the point , it was not dual mounted, it is incorrectly guessing the >cause of the error. yeah, thats why i said: 'If not, then we're looking at a glitch..' ... I think it's best to try to reproduce the problem on my own box. Did you do anything special or should editing the udev-rules be sufficient?
No I just added the simple udev rule as indicated above. AFAICR I did not even need to restart udev .
Thank you Mark M. Young and gnutter@catking.net for reporting this problem. There have been many advancements since GParted 0.2.2. The latest release is GParted 0.4.8. Would you be able to try out the latest GParted release with this problem, and report back here if the problem still exists or not?
Ping.... Also setting this bug to NEEDINFO.
I thought this was fixed a *long* time ago.
Thank you Mark for the response. As such I am closing this bug. If this bug recurs for anyone, then please feel free to either re-open this bug, or else create a new bug and provide further details.