Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved]halevt crashes when I unplug my USB key.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1400
Location: Adelaide/Australia

PostPosted: Tue Feb 02, 2010 5:47 am    Post subject: [Solved]halevt crashes when I unplug my USB key. Reply with quote

Any ideas/suggestions?

Root is a member of 'plugdev' group.
If halevt is running when I plug my key in, it will mount the device.
Curiously, when it crashes, no core is created.
I have ulimit set (at least in the current session, I have updated /etc/security/limits.conf but have not restarted since then)
Code:
# ulimit -c
10000
core pattern is set.
Code:

# cat /proc/sys/kernel/core_pattern
/tmp/cores/%e-%s-%u-%g-%p.core
the /tmp/cores directory exists and is world writable.

Installed versions of relevant software is...
Code:

sys-apps/halevt   Installed versions:  0.1.4-r2(15:31:49 01/12/10)(nls -rpath)
sys-apps/dbus     Installed versions:  1.2.3-r1(10:38:01 01/08/10)(X -debug -doc -selinux)
sys-apps/hal      Installed versions:  0.5.13-r2(11:31:49 01/08/10)(X crypt kernel_linux -acpi -apm -consolekit -debug -dell -disk-partition -doc -kernel_FreeBSD -laptop -policykit -selinux)

_________________
...Lyall


Last edited by lyallp on Thu Feb 18, 2010 5:01 am; edited 1 time in total
Back to top
View user's profile Send private message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1400
Location: Adelaide/Australia

PostPosted: Thu Feb 18, 2010 5:01 am    Post subject: Reply with quote

Hmm... Ditched my customised xml config (which used to work fine) for the bog standard one and crashes went away.

I know I modified it before because my USB key was formatted NTFS and the default behavior did not automatically mount NTFS drives.

Oh well, my usb key is now FAT32 (only cos I am having trouble convincing it to format as NTFS), but it works now so I will leave it at that.
_________________
...Lyall
Back to top
View user's profile Send private message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1400
Location: Adelaide/Australia

PostPosted: Thu Feb 18, 2010 10:26 pm    Post subject: Reply with quote

Ok, I decided I didn't like the default behaviour of halevt.
I plug my USB key in, it auto mounts, but it automounted owned/group as root.
I could read it but not write to it.
I could pumount it.
This has an added bonus of actually being able to mount NTFS keys.

So, here is my new halevt config file.
This mounts the key as group 'plugdev' - which I am a member of, so I can write to the key.
All other behavior is the same.

Note that I use an entity for the mount command, it seems silly to have a complex command repeated when it can be in one place.
Other than the MOUNT_COMMAND entity and the OnInit and Insertion entries, everything else is identical.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE halevt:Configuration [

<!-- this entity corresponds with mountable devices, which have
 volume.policy.should_mount true or don't have
 volume.policy.should_mount false and are block devices hotpluggable or
 removable.
-->
<!ENTITY MOUNTABLE "hal.block.device &amp; hal.block.is_volume = true &amp; (hal.volume.policy.should_mount = true | ((! hal.volume.policy.should_mount = false) &amp; (hal.block.storage_device.hal.storage.policy.should_mount = true | ((! hal.block.storage_device.hal.storage.policy.should_mount = false)  &amp; (hal.block.storage_device.hal.storage.hotpluggable = true | hal.block.storage_device.hal.storage.removable = true)))))">
<!ENTITY MOUNT_COMMAND "pmount --umask 002 --dmask 002 --read-write --noatime --type $hal.volume.fstype$ $hal.block.device$ '$hal.volume.label$'">
]>
<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">

<!--
Remember to use &amp; and &quot; for & and " in xml attributes.

In a match attribute, hal.* is special since it matches any device.
In a match attribute property it is possible to refer to other
device properties. For example
hal.block.storage_device.hal.storage.policy.should_mount
refers to the storage.policy.should_mount property of the block.storage_device
device associated with a given device.

In an exec attribute, $hal.udi$ is special since it is replaced by
the device udi. $hal.some.property$ is replaced by the value
of the property some.property.
!-->

<!--
Removable devices support
!-->

<!--
This rule matches removable devices which have volume.policy.should_mount true
or don't have volume.policy.should_mount false.
Upon insertion, they are mounted and recorded by halevt-mount.
-m 002 sets the umask of mount to 002 when pmount is used system-wide
to mount the device. This allows regular users to read the device.
!-->
<halevt:Device match="&MOUNTABLE;">
   <halevt:Insertion exec="&MOUNT_COMMAND;"/>
   <halevt:Insertion exec="halevt-mount -s"/>
   <!-- <halevt:Insertion exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> -->
</halevt:Device>

<!--
When a device get a mount point, it is passed to halevt-mount which can
record it. The property that changes is volume.is_mounted, and the action is
executed when the value of volume.is_mounted becomes true.
!-->
<halevt:Device match="hal.block.device &amp; hal.block.is_volume = true &amp; hal.volume.mount_point">
   <halevt:Property name="hal.volume.is_mounted">
      <halevt:Action value="true" exec="halevt-mount -s"/>
   </halevt:Property>
</halevt:Device>

<!--
When a device is unmounted, it is recorded by halevt-mount.
!-->
<halevt:Device match="hal.block.device &amp; hal.block.is_volume = true">
    <halevt:Property name="hal.volume.is_mounted">
        <halevt:Action value="false" exec="halevt-mount -s"/>
    </halevt:Property>
</halevt:Device>

<!--
When a device is removed, it is recorded by halevt-mount.
Note that at that point the device is already out of hal, so we use
* which matches any device in the match attribute, and only pass the
udi to the command.
!-->
<halevt:Device match="hal.*">
     <halevt:Removal exec="halevt-umount -u $hal.udi$; halevt-umount -s"/>
</halevt:Device>


<!--
Example of a use of OnInit. At startup all the devices are matched and the exec
comand is run for those that match. Here we match all the removable devices
that aren't already mounted and mount and register them.
!-->

<halevt:Device match="&MOUNTABLE;">
   <halevt:OnInit exec="&MOUNT_COMMAND;"/>
   <halevt:OnInit exec="halevt-mount -s"/>
   <!-- <halevt:OnInit exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> -->
</halevt:Device>

<!--
Example of a use of Condition. When a device matches and the condition has become
true for that device, the corresponding exec command is launched.

<halevt:Device match="hal.info.udi = /org/freedesktop/Hal/devices/acpi_PWRF">
    <halevt:Condition name="ButtonPressed" exec="/usr/bin/sudo /sbin/shutdown"/>
</halevt:Device>

!-->

<!--
Example of a use of OnInit. At startup all the devices are matched and the exec
comand is run for those that match.

<halevt:Device match="hal.info.category = battery">
    <halevt:OnInit exec="hvbattery -u $hal.udi$ -l $hal.battery.charge_level.percentage$ -s $hal.battery.rechargeable.is_discharging"/>
</halevt:Device>
!-->


</halevt:Configuration>

_________________
...Lyall
Back to top
View user's profile Send private message
Hwoarang
Retired Dev
Retired Dev


Joined: 24 Feb 2007
Posts: 701
Location: Leeds, UK

PostPosted: Sun Aug 15, 2010 12:19 am    Post subject: Reply with quote

Can you please explain me your changes since I do have a similar issue?
Back to top
View user's profile Send private message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1400
Location: Adelaide/Australia

PostPosted: Sun Aug 15, 2010 12:36 am    Post subject: Reply with quote

Here is my current halevt.xml
An addition is that some USB keys don't have a volume label, so would not automount.
I have made it so if the initial mount fails (using an empty volume label), it attempts to mount using the UUID (see the Insertion element)
The key is the umask and dmask options of pmount.
Please note that there is probably a lot of garbage in here, but it works for me.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE halevt:Configuration [

<!-- this entity corresponds with mountable devices, which have
 volume.policy.should_mount true or don't have
 volume.policy.should_mount false and are block devices hotpluggable or
 removable.
-->
<!ENTITY MOUNTABLE "hal.block.device &amp; hal.block.is_volume = true &amp; (hal.volume.policy.should_mount = true | ((! hal.volume.policy.should_mount = false) &amp; (hal.block.storage_device.hal.storage.policy.should_mount = true | ((! hal.block.storage_device.hal.storage.policy.should_mount = false)  &amp; (hal.block.storage_device.hal.storage.hotpluggable = true | hal.block.storage_device.hal.storage.removable = true)))))">
<!ENTITY MOUNT_COMMAND "pmount --umask 002 --dmask 002 --read-write --noatime --type $hal.volume.fstype$ $hal.block.device$ '$hal.volume.label$'">
<!ENTITY MOUNT_COMMAND_BY_UUID "pmount --umask 002 --dmask 002 --read-write --noatime --type $hal.volume.fstype$ $hal.block.device$ '$hal.volume.uuid$'">
]>
<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">

<!--
Remember to use &amp; and &quot; for & and " in xml attributes.

In a match attribute, hal.* is special since it matches any device.
In a match attribute property it is possible to refer to other
device properties. For example
hal.block.storage_device.hal.storage.policy.should_mount
refers to the storage.policy.should_mount property of the block.storage_device
device associated with a given device.

In an exec attribute, $hal.udi$ is special since it is replaced by
the device udi. $hal.some.property$ is replaced by the value
of the property some.property.
!-->

<!--
Removable devices support
!-->

<!--
This rule matches removable devices which have volume.policy.should_mount true
or don't have volume.policy.should_mount false.
Upon insertion, they are mounted and recorded by halevt-mount.
-m 002 sets the umask of mount to 002 when pmount is used system-wide
to mount the device. This allows regular users to read the device.
!-->
<halevt:Device match="&MOUNTABLE;">
   <!-- <halevt:Insertion exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> -->
   <halevt:Insertion exec="/bin/bash -c &quot;&MOUNT_COMMAND; || &MOUNT_COMMAND_BY_UUID;&quot;"/>
   <!-- <halevt:Insertion exec="halevt-mount -u $hal.udi$ -d /dev/disk/by-uuid/$hal.volume.uuid$ -m 002"/> -->
</halevt:Device>
<!-- if didn't mount using uuid, try mounting by label -->
<!--
<halevt:Device match="&MOUNTABLE; &amp; ! hal.volume.is_mounted;">
   <halevt:Insertion exec="halevt-mount /mnt/$hal.volume.label$"/>
</halevt:Device>
-->
<!--
When a device get a mount point, it is passed to halevt-mount which can
record it. The property that changes is volume.is_mounted, and the action is
executed when the value of volume.is_mounted becomes true.
!-->
<halevt:Device match="hal.block.device &amp; hal.block.is_volume = true &amp; hal.volume.mount_point">
   <halevt:Property name="hal.volume.is_mounted">
      <halevt:Action value="true" exec="halevt-mount -s"/>
   </halevt:Property>
</halevt:Device>

<!--
When a device is unmounted, it is recorded by halevt-mount.
!-->
<halevt:Device match="hal.block.device &amp; hal.block.is_volume = true">
    <halevt:Property name="hal.volume.is_mounted">
        <halevt:Action value="false" exec="halevt-mount -s"/>
    </halevt:Property>
</halevt:Device>

<!--
When a device is removed, it is recorded by halevt-mount.
Note that at that point the device is already out of hal, so we use
* which matches any device in the match attribute, and only pass the
udi to the command.
!-->
<halevt:Device match="hal.*">
     <halevt:Removal exec="halevt-umount -u $hal.udi$ -d /dev/disk/by-uuid/$hal.volume.uuid$; halevt-umount -s"/>
     <!-- <halevt:Removal exec="halevt-umount -u $hal.udi$; halevt-umount -s"/> -->
</halevt:Device>


<!--
Example of a use of OnInit. At startup all the devices are matched and the exec
comand is run for those that match. Here we match all the removable devices
that aren't already mounted and mount and register them.
!-->

<halevt:Device match="&MOUNTABLE;">
   <halevt:OnInit exec="&MOUNT_COMMAND;"/>
   <!-- <halevt:OnInit exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> -->
</halevt:Device>
<!-- if didn't mount using uuid, try mounting by label -->
<!--
<halevt:Device match="&MOUNTABLE; &amp; ! hal.volume.is_mounted;">
   <halevt:OnInit exec="halevt-mount /mnt/$hal.volume.label$"/>
</halevt:Device>
-->

<!--
Example of a use of Condition. When a device matches and the condition has become
true for that device, the corresponding exec command is launched.
-->
<halevt:Device match="hal.info.udi = /org/freedesktop/Hal/devices/acpi_PWRF">
    <halevt:Condition name="ButtonPressed" exec="/usr/bin/sudo /sbin/shutdown"/>
</halevt:Device>


<!--
Example of a use of Condition with detail value attribute. This condition
differentiates between three different hotkeys for a ButtonPressed event
and performs the appropriate action for each.
-->
<halevt:Device match="hal.input.originating_device.hal.info.linux.driver = atkbd">
    <halevt:Condition name="ButtonPressed" value="mute"        exec="amixer -q set Master toggle"/>
    <halevt:Condition name="ButtonPressed" value="volume-down" exec="amixer -q set Master 1-"/>
    <halevt:Condition name="ButtonPressed" value="volume-up"   exec="amixer -q set Master 1+"/>
</halevt:Device>


<!--
Example of a use of OnInit. At startup all the devices are matched and the exec
comand is run for those that match.

<halevt:Device match="hal.info.category = battery">
    <halevt:OnInit exec="hvbattery -u $hal.udi$ -l $hal.battery.charge_level.percentage$ -s $hal.battery.rechargeable.is_discharging"/>
</halevt:Device>
!-->


</halevt:Configuration>

_________________
...Lyall
Back to top
View user's profile Send private message
Hwoarang
Retired Dev
Retired Dev


Joined: 24 Feb 2007
Posts: 701
Location: Leeds, UK

PostPosted: Mon Aug 16, 2010 1:44 pm    Post subject: Reply with quote

Well thanks but again I am not quite sure which parameter is responsible mount with r/w permissions for my user

I guess this is the correct parameter to user

Code:
  <halevt:OnInit exec="halevt-mount -s"/>
   <!-- <halevt:OnInit exec="halevt-mount -u $hal.udi$ -o sync -m 002"/> -->


Replacing -u $hal.udi$ -o sync -m 002 with -s seems to works for me
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum