tags 305765 +patch
thanks
Hi Eduard,
On Fri, Apr 22, 2005 at 03:13:33AM +0200, Eduard Bloch wrote:
> when I try to umount a partition mounted by the same user before, the
> operation fails and I get a segmentation fault. On partitions mounted by
> root, there is a proper message:
>
> $ umount /mnt/c
> umount: only root can unmount /dev/hda1 from /mnt/c
> $ umount /mnt/d
> Segmentation fault
> $ mount
> ...
> /dev/hda1 /mnt/c vfat
> rw,nodiratime,nosuid,nodev,noexec,fmask=0000,dmask=0000,codepage=cp437,iocharset=utf8,utf8
> 0 0
> /dev/sda1 /mnt/d vfat
> rw,nodiratime,nosuid,nodev,noexec,uid=1000,gid=1000,fmask=0000,dmask=0000,codepage=cp437,iocharset=utf8,utf8
> 0 0
> $ cat /etc/fstab
> ...
> /dev/hda1 /mnt/c vfat auto,user,umask=000,utf8 0
> 0
> UUID="41EB-F193" /mnt/d vfat auto,user,umask=000,utf8
> 0 0
>
> This looks odd, I cannot see the reasons for a) not allowing the umount and b)
> the segmentation fault.
For b), there are a couple of different issues at play.
The segfault happens in has_uuid(), when mount_get_devname_by_uuid()
returns NULL and umount then tries dereferencing that. Attached patch
has_uuid_segv.diff should address that.
Next thing, has_uuid() passes the device as argument to ..by_uuid().
That obviously fails, since there is no UUID of "/dev/sda1" :-) Attached
patch has_uuid_uuid.diff changes it to really pass the uuid as expected.
Still doesn't work? The uuid passed to has_uuid() includes the double
quotes around the uuid if configured like in your fstab. If you remove
those quotes, umount should now happily umount the correct device.
cheers,
Max
--- mount/fstab.c~ 2005-04-22 14:21:16.730370176 +0200
+++ mount/fstab.c 2005-04-22 14:21:57.685144104 +0200
@@ -294,9 +294,12 @@
static int
has_uuid(const char *device, const char *uuid){
const char *devuuid;
- int ret;
+ int ret = 0;
devuuid = mount_get_devname_by_uuid(device);
+ if (!devuuid)
+ return ret;
+
ret = !strcmp(uuid, devuuid);
/* free(devuuid); */
return ret;
--- mount/fstab.c~ 2005-04-22 14:31:51.975301216 +0200
+++ mount/fstab.c 2005-04-22 14:32:12.104241152 +0200
@@ -293,14 +293,14 @@
static int
has_uuid(const char *device, const char *uuid){
- const char *devuuid;
+ const char *devname;
int ret = 0;
- devuuid = mount_get_devname_by_uuid(device);
- if (!devuuid)
+ devname = mount_get_devname_by_uuid(uuid);
+ if (!devname)
return ret;
- ret = !strcmp(uuid, devuuid);
+ ret = !strcmp(device, devname);
/* free(devuuid); */
return ret;
}