You are not logged in.

#1 2009-06-10 19:57:43

EVRAMP
Member
From: Czech Republic
Registered: 2008-10-03
Posts: 173
Website

Removable devices with UTF-8

Hi is there a way how to make HAL mount removable devices with iocharset=utf8 option?
I tried this file:

cat /etc/hal/fdi/policy/uf8.pdi

<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
 <device>
   <match key="block.is_volume" bool="true">
     <match key="@block.storage_device:storage.hotpluggable" bool="true">
       <merge key="volume.policy.mount_option.iocharset" type="string">utf8</merge>
     </match>
     <match key="@block.storage_device:storage.removable" bool="true">
       <merge key="volume.policy.mount_option.iocharset" type="string">utf8</merge>
     </match>
   </match>
 </device>

But no success.

Offline

#2 2009-06-10 20:06:07

EVRAMP
Member
From: Czech Republic
Registered: 2008-10-03
Posts: 173
Website

Re: Removable devices with UTF-8

And I also have this to add noatime option for removable devices:

cat /etc/hal/fdi/policy/20-noatime.fdi

<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
 <device>
   <match key="block.is_volume" bool="true">
     <match key="@block.storage_device:storage.hotpluggable" bool="true">
       <merge key="volume.policy.mount_option.noatime" type="bool">true</merge>
     </match>
     <match key="@block.storage_device:storage.removable" bool="true">
       <merge key="volume.policy.mount_option.noatime" type="bool">true</merge>
     </match>
   </match>
 </device>

But mount shows:

/dev/sdc1 on /media/disk type vfat (rw,nosuid,nodev,uhelper=hal,shortname=lower,uid=1001)

Last edited by EVRAMP (2009-06-10 20:06:56)

Offline

#3 2009-06-16 08:38:54

Tristero
Member
From: Germany
Registered: 2008-01-16
Posts: 33

Re: Removable devices with UTF-8

Same here. File /etc/hal/fdi/policy/30-wellknown-devices.fdi matches a vfat usb-stick by its UUID, assigns to it a name and tries to mount it with the exec-option:

   <device>
       <match key="volume.uuid" string="4743-555F">
            <merge key="volume.label" type="string">kingston1</merge>
            <merge key="volume.policy.mount_option.exec" type="bool">true</merge>
       </match>
   </device>

The "exec" option is ignored when the actual mount operation takes place.

mount -l (excerpt):

/dev/sdb1 on /media/kingston1 type vfat (rw,nosuid,nodev,noatime,uhelper=hal,shortname=winnt,iocharset=utf8,uid=1000)

The content of file 30-wellknown-devices.fdi is definitely respected, since lshal says about the device:

  (...)
  volume.mount.valid_options = {'ro', 'sync', 'dirsync', 'noatime', 'nodiratime', 'noexec', 'quiet', 'remount', 'exec', 'utf8', 'shortname=', 'codepage=', 'iocharset=', 'umask=', 'dmask=', 'fmask=', 'uid=', 'flush'} (string list)
  volume.mount_point = '/media/kingston1'  (string)
  volume.num_blocks = 1953760  (0x1dcfe0)  (uint64)
  volume.partition.media_size = 1000341504  (0x3ba00000)  (uint64)
  volume.partition.number = 1  (0x1)  (int)
  volume.partition.start = 16384  (0x4000)  (uint64)
  volume.policy.mount_option.exec = true  (bool)
  volume.policy.mount_option.noatime = true  (bool)
  volume.policy.mount_option.sync = true  (bool)
  volume.size = 1000325120  (0x3b9fc000)  (uint64)
  volume.unmount.valid_options = {'lazy'} (string list)
  volume.uuid = '4743-555F'  (string)
  (...)

So HAL knows the option, accepts the option for the device in question, mounts the device to the specified mountpoint but ignores the mount option.

The HAL specification did not help me. http://people.freedesktop.org/~david/ha … -spec.html

I also would like to understand what happens here (not) and why. Can somebody elaborate on that?

Last edited by Tristero (2009-06-16 08:40:58)


You might very well think that, I couldn't possibly comment.

Offline

#4 2009-06-16 13:14:33

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: Removable devices with UTF-8

I made some researches on the web about 'how to use mount options with hal', and here are the rare interesting infos I found :
from http://lists.freedesktop.org/archives/h … 08872.html

...
HAL does not those policy options anymore. It expects mount options from user
backend that actually initiates mounting.
...

and
from http://lists.freedesktop.org/archives/h … 11733.html

There are is no volume.policy.mount_option.* since ages if you take a look at
the HAL spec. The tool you use (KDE/GNOME/ivman ...) has to handle all the
mount options.

I checked the most recent Hal specifications, and there doesn't exist any volume.policy.mount_option.
I understand that to mean Hal is only used to declare valid mount options, but not to set them.
Setting them doesn't generate errors, but they are ignored because the values are not transmitted, only the name of the valid options to the upper application which actually does the mounting.
Personally I use KDE, and there doesn't exist yet system settings choices to declare mount options (Maybe it's possible in other environments).
So to get different options from the default ones, I concluded that we have to use pmount manually (see 'man pmount' for the possible pmount options) or writing the options in a line in the /etc/fstab file.
I have already found that, if a line exist in /etc/fstab, KDE will use it to mount a removable device instead of the default options, see last post of http://bbs.archlinux.org/viewtopic.php?id=53316.

Last edited by berbae (2009-06-16 13:21:22)

Offline

#5 2009-06-17 00:08:24

Tristero
Member
From: Germany
Registered: 2008-01-16
Posts: 33

Re: Removable devices with UTF-8

Thanks, berbae, for pointing this out. Meanwhile I found this:

http://wiki.archlinux.org/index.php/Using_udev_to_map_multiple_entries_to_a_device

which was very helpful.

For mounting "known" devices with special options, I wrote udev rules which seem to work fine.


You might very well think that, I couldn't possibly comment.

Offline

#6 2009-06-18 13:39:05

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: Removable devices with UTF-8

As a problem may have several solutions, I propose another method to mount removable medias with chosen mount options and at a chosen mount point.
The advantage of that method, I think, is that only one file is used and easily edited, and nothing else has to be modified in the system (no .fdi files are touched).
Here is the batch file which I named mountusb :

#!/bin/bash
# Script mountusb by Bernard Baeyens (berbae) 2009-06-18
# to mount plugged in removable medias, using hal and pmount
# without knowing the device name
# without modifying the /etc/fstab file
# without needing to create a fixed directory under /media

# The device name attributed by udev is transmitted to hal and can be accessed
# with the utility hal-get-property.
# So with this method it doesn't need to be a fixed name.

# The user must maintain the three lists below, for the removable medias he uses.

# List of the variable part of the hal udi for the removable medias
UDI=(0000_0002 DA8E_98E0 68E8_9D1A)
# List of the corresponding desired pmount options
OPTIONS=("--sync --noatime" "--sync --noatime" "--sync --noatime")
# List of the corresponding label used to mount the device under /media
# pmount will create the /media/<label> directory itself
LABEL=(sony stick1 stick2)

NB=${#UDI[*]}
for (( I=0;I<$NB;I+=1 )); do
    DEVICE=$(hal-get-property --udi=/org/freedesktop/Hal/devices/volume_uuid_${UDI[$I]} --key=block.device 2>/dev/null)
    MOUNTED=$(hal-get-property --udi=/org/freedesktop/Hal/devices/volume_uuid_${UDI[$I]} --key=volume.is_mounted 2>/dev/null)
    if [ a$DEVICE != a ] && [ -b $DEVICE ] && [ a$MOUNTED != a ] && [ $MOUNTED == false ]; then
        echo "Executing command : pmount ${OPTIONS[$I]} $DEVICE ${LABEL[$I]}"
        if pmount ${OPTIONS[$I]} $DEVICE ${LABEL[$I]}; then
            echo "To unmount the device use : pumount /media/${LABEL[$I]}"
        fi
    fi
done
# To unmount before plugging out the media : pumount /media/<label>
# The command will remove the /media/<label> directory after the unmounting

The values in the file correspond to a Sony walkman and two memory sticks of mine.
The UDI values can be determined by plugging in the removable media and consulting the output of the lshal command.
I hope that this batch could be useful to someone.

Edit : Added a test to execute pmount command only if the volume is not already mounted.

Last edited by berbae (2009-06-20 09:25:06)

Offline

#7 2009-10-07 13:53:26

xian_hu
Member
Registered: 2009-10-07
Posts: 1

Re: Removable devices with UTF-8

GNOME does not use HAL options either. However, you can change easily the default options for filesystems in the GNOME configuration tool(s).

Personally I prefer gconf-editor. The settins are under /system/storage/default_options/<fstype>
I changed here the fmask/dmask of ntfs-3g, and also enabled utf8 for VFAT smile

Last edited by xian_hu (2009-10-07 13:54:41)

Offline

#8 2009-10-07 21:39:47

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: Removable devices with UTF-8

In Gnome it is possible but it was not in KDE, at least untill 4.3.1 release.
I don't know for the new 4.3.2 release because I now use Openbox as window manager.
I use now halevt from AUR for automounting with alltray notification.
The mount options can be set in a xml conf file in ~/.halevt folder :

<halevt:Device match="...">
   <halevt:Insertion exec="halevt-mount -u $hal.udi$ -o sync -o noatime -o nodiratime -o noexec && alltray -stask -st halevt_umount_from_tray-kdialog.sh '"$hal.block.device$"' '"$hal.volume.label$"'"/>
</halevt:Device>

"..." is replaced by a logical expression to determine which device is plugged in.
The <halevt:Insertion exec="..."/> is wrapped in the quote tags but it is one line in the xml conf file.

Offline

Board footer

Powered by FluxBB