# mount_msdosfs bug?



## Brandybuck (Mar 7, 2009)

I can't mount vfat/msdos USB drivers in KDE4. But I can mount ufs drives. After HOURS of trying to figure this out (which users should never have to do) I discover that the -L option to mount_msdosfs does not work. When I try to mount by hand I get the following:


```
$ mount_msdosfs -u 1001 -L C /dev/da0s1 mnt
mount_msdosfs:  C: No such file or directory
```

This is the exact same debug message I get out of HAL when I try to mount the drive in KDE using the Device Notifier.  I don't use the -u or -L options by hand, but that's what KDE tells HAL to use, which I didn't find out until debugging HAL. Here is the HAL debug output:


```
mount_point    = ''                                                             
mount_fstype   = 'vfat'                                                         
mount_options  = '-u=1001       -L=C    '                                       
trying dir /media/disk                                                          
given_options[0] = '-u=1001'                                                    
given_options[1] = '-L=C'                                                       
allowed_options[0] = 'ro'                                                       
allowed_options[1] = 'noexec'                                                   
allowed_options[2] = 'noatime'                                                  
allowed_options[3] = 'longnames'                                                
allowed_options[4] = 'shortnames'
allowed_options[5] = 'nowin95'
allowed_options[6] = '-u='
allowed_options[7] = '-g='
allowed_options[8] = '-m='
allowed_options[9] = '-M='
allowed_options[10] = '-L='
allowed_options[11] = '-D='
allowed_options[12] = 'large'
using action org.freedesktop.hal.storage.mount-removable for uid 1001, system_bus_connection :1.32
23:09:32.678 [I] device.c:1894: Removing locks from ':1.68'
passed privilege
2757: XYA creating /media/.hal-mtab~
2757: XYA closing /media/.hal-mtab~
/sbin/mount error 19968, stdout='', stderr='mount_msdosfs: C: No such file or directory
'
pid 2757: rc=1 signaled=0: /usr/local/libexec/hal-storage-mount
23:09:32.686 [I] device.c:1894: Removing locks from ':1.67'
23:09:32.686 [I] hald_dbus.c:4042: No more methods in queue
23:09:32.686 [I] hald_dbus.c:4105: failed with 'org.freedesktop.Hal.Device.Volume.UnknownFailure' 'mount_msdosfs: C: No such file or directory '
```

I am using FreeBSD 7.1-STABLE. Did something change with the mount_msdosfs command? Unfortunately, mount options for HAL are hardcoded into KDE, making this a very annoying bug.

Help, fixes, workarounds wanted! Many thanks in advance!


----------



## Mel_Flynn (Mar 7, 2009)

Either set a valid locale in your environment (export LANG=en_US.ISO8859-1), or delete -L from valid mount options in /usr/local/share/hal/fdi/policy/10osvendor.fdi.


----------



## Djn (Mar 7, 2009)

Why isn't C a valid locale?


----------



## Mel_Flynn (Mar 7, 2009)

It is. I should've said 'proper'. It's a bug in mount_msdosfs, I suppose. It expects locales to be in the proper 'lang.encoding' format:

```
if (setlocale(LC_CTYPE, optarg) == NULL)
                                err(EX_CONFIG, "%s", optarg);
                        [B]csp = strchr(optarg,'.');[/B]
                        if (!csp)
                                err(EX_CONFIG, "%s", optarg);
```


----------



## Brandybuck (Mar 7, 2009)

Mel_Flynn said:
			
		

> Either set a valid locale in your environment (export LANG=en_US.ISO8859-1), or delete -L from valid mount options in /usr/local/share/hal/fdi/policy/10osvendor.fdi.



I have that for my LANG. But I also have LC_ALL explicitly set in login.conf so that another app will run without complaining. That's the problem with the right way of doing things, there are so many of them to choose from! 

Except now I get this:

$ mount_msdosfs -u 1001 -L en_US.ISO8859-1 /dev/da0s1 mnt
mount_msdosfs: cannot find or load "msdosfs_iconv" kernel module
mount_msdosfs: msdosfs_iconv: Operation not permitted
$ sudo kldload msdosfs_iconv
$ mount_msdosfs -u 1001 -L en_US.ISO8859-1 /dev/da0s1 mnt
mount_msdosfs: msdosfs_iconv: Operation not permitted

I'll just edit the fdi file, it sounds like the path of least resistance.


----------



## Mel_Flynn (Mar 7, 2009)

If the last command works under sudo, you need sysctl vfs.usermount=1. With hald running as root, things should work now though.

Maybe you can write a wrapper around that other program that sets LC_ALL in env before starting?


----------



## Djn (Mar 8, 2009)

Mel_Flynn said:
			
		

> It is. I should've said 'proper'. It's a bug in mount_msdosfs, I suppose. It expects locales to be in the proper 'lang.encoding' format:
> 
> ```
> if (setlocale(LC_CTYPE, optarg) == NULL)
> ...



Oh, right. That's slightly inconvenient.
(Though not something that bites me - I have it set to no_NO.iso8859-15 anyway.)


----------

