Roland Mas, 2006-04-23 11:54:37 +0200 :

> When I think about it, I end up concluding that this file (or
> directory or whatever it is) doesn't belong there.  Even if I wanted
> to let HAL mount and unmount stuff, there's no guarantee that the
> filesystem containing the mountpoints is writable.  Such state
> information should therefore be stored somewhere else, like
> /var/run, which seems more appropriate and should fix both problems.

And here's a patch implementing that suggestion.  It works for me,
since it allows autofs to expire mountpoints again, and it seems not
to prevent Gnome from mounting and unmounting USB keys automagically.
I haven't tested that second part very thouroughly though, since it's
not in my regular usage patterns.  Feel free to rewrite if needed :-)

Roland.
-- 
Roland Mas

It would be hard to be deader without special training.
  -- in Theatre of Cruelty (Terry Pratchett)
diff -ruN hal-0.5.7/debian/changelog hal-0.5.7+lolando/debian/changelog
--- hal-0.5.7/debian/changelog  2006-04-23 15:13:03.000000000 +0200
+++ hal-0.5.7+lolando/debian/changelog  2006-04-23 15:16:18.000000000 +0200
@@ -1,3 +1,11 @@
+hal (0.5.7-1+lolando) unstable; urgency=low
+
+  * debian/patches/07_state_files_location.patch
+    + Added.  Change location of .created-by-hal files.
+  * Fixed hal.dirs and hal.init.dbus accordingly.
+
+ -- Roland Mas <[EMAIL PROTECTED]>  Sun, 23 Apr 2006 15:16:18 +0200
+
 hal (0.5.7-1) unstable; urgency=low
 
   * New upstream release
diff -ruN hal-0.5.7/debian/hal.dirs hal-0.5.7+lolando/debian/hal.dirs
--- hal-0.5.7/debian/hal.dirs   2006-04-23 15:13:03.000000000 +0200
+++ hal-0.5.7+lolando/debian/hal.dirs   2006-04-23 13:36:50.000000000 +0200
@@ -1,2 +1,3 @@
 /var/run/hal
+/var/run/hal/storage-states
 /etc/hal/fdi
diff -ruN hal-0.5.7/debian/hal.init.dbus hal-0.5.7+lolando/debian/hal.init.dbus
--- hal-0.5.7/debian/hal.init.dbus      2006-04-23 15:13:03.000000000 +0200
+++ hal-0.5.7+lolando/debian/hal.init.dbus      2006-04-23 13:38:09.000000000 
+0200
@@ -12,6 +12,7 @@
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/sbin/hald
 PIDDIR=/var/run/hal
+STATE_DIR=/var/run/hal/storage-states
 PIDFILE=$PIDDIR/hald.pid
 NAME=hald
 DAEMONUSER=hal
@@ -33,6 +34,10 @@
     mkdir -p $PIDDIR
     chown $DAEMONUSER:$DAEMONUSER $PIDDIR
   fi
+  if [ ! -d $STATE_DIR ]; then
+    mkdir -p $STATE_DIR
+    chown $DAEMONUSER:$DAEMONUSER $STATE_DIR
+  fi
        log_daemon_msg "Starting $DESC" "$NAME"
        start-stop-daemon --start --pidfile $PIDFILE \
                --exec $DAEMON -- $DAEMON_OPTS
diff -ruN hal-0.5.7/debian/patches/07_state_files_location.patch 
hal-0.5.7+lolando/debian/patches/07_state_files_location.patch
--- hal-0.5.7/debian/patches/07_state_files_location.patch      1970-01-01 
01:00:00.000000000 +0100
+++ hal-0.5.7+lolando/debian/patches/07_state_files_location.patch      
2006-04-23 13:34:34.000000000 +0200
@@ -0,0 +1,188 @@
+diff -Nur hal-0.5.7-old/hald/linux2/blockdev.c hal-0.5.7/hald/linux2/blockdev.c
+--- hal-0.5.7-old/hald/linux2/blockdev.c       2006-02-24 05:29:06.000000000 
+0100
++++ hal-0.5.7/hald/linux2/blockdev.c   2006-04-23 12:38:39.000000000 +0200
+@@ -251,7 +251,7 @@
+               device_property_atomic_update_end ();
+               HAL_INFO (("set %s to unmounted", hal_device_get_udi (dev)));
+ 
+-              mount_point_hal_file = g_strdup_printf ("%s/.created-by-hal", 
mount_point);
++              mount_point_hal_file = g_strdup_printf 
("%s/%s/.created-by-hal", STATE_DIR, mount_point);
+               if (g_file_test (mount_point_hal_file, G_FILE_TEST_EXISTS)) {
+                       char *cleanup_stdin;
+                       char *extra_env[2];
+diff -Nur hal-0.5.7-old/hald/linux2/blockdev.h hal-0.5.7/hald/linux2/blockdev.h
+--- hal-0.5.7-old/hald/linux2/blockdev.h       2005-12-08 20:03:02.000000000 
+0100
++++ hal-0.5.7/hald/linux2/blockdev.h   2006-04-23 12:38:39.000000000 +0200
+@@ -28,6 +28,8 @@
+ 
+ #include <glib.h>
+ 
++#define STATE_DIR "/var/run/hal/storage-states"
++
+ void hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const char 
*device_file, gboolean is_partition, HalDevice *parent, void *end_token);
+ 
+ void hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, gboolean 
is_partition, void *end_token);
+diff -Nur hal-0.5.7-old/tools/hal-luks-remove hal-0.5.7/tools/hal-luks-remove
+--- hal-0.5.7-old/tools/hal-luks-remove        2006-02-13 08:29:44.000000000 
+0100
++++ hal-0.5.7/tools/hal-luks-remove    2006-04-23 12:38:39.000000000 +0200
+@@ -6,6 +6,8 @@
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License version 2.
+ 
++STATE_DIR="/var/run/hal/storage-states"
++
+ if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ] || [ 
"$HAL_PROP_VOLUME_UUID" == "" ] ; then
+         echo "Missing or empty environment variable(s)." >&2
+         echo "This script should be started by hald." >&2
+@@ -22,9 +24,9 @@
+     if [ ! x${#MOUNT_POINT} = x0 ]; then
+       /bin/umount -l "$MOUNT_POINT"
+         # remove directory only if HAL has created it
+-      if [ -e "$MOUNT_POINT/.created-by-hal" ]; then
+-          rm -f "$MOUNT_POINT/.created-by-hal"
+-          rmdir --ignore-fail-on-non-empty "$MOUNT_POINT"
++      if [ -e "$STATE_DIR/$MOUNT_POINT/.created-by-hal" ]; then
++          rm -f "$STATE_DIR/$MOUNT_POINT/.created-by-hal"
++          rmdir --ignore-fail-on-non-empty "$MOUNT_POINT" 
"$STATE_DIR/$MOUNT_POINT"
+       fi
+       
+     fi
+diff -Nur hal-0.5.7-old/tools/hal-system-storage-cleanup-mountpoint 
hal-0.5.7/tools/hal-system-storage-cleanup-mountpoint
+--- hal-0.5.7-old/tools/hal-system-storage-cleanup-mountpoint  2006-02-12 
23:38:45.000000000 +0100
++++ hal-0.5.7/tools/hal-system-storage-cleanup-mountpoint      2006-04-23 
12:38:39.000000000 +0200
+@@ -5,15 +5,17 @@
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License version 2.
+ 
++STATE_DIR="/var/run/hal/storage-states"
++
+ if [ "$HALD_CLEANUP" = "" ]; then
+     echo Specify directory to clean up with the environment variable 
HALD_CLEANUP
+     exit 1
+ fi
+ 
+ # check if we created it
+-if [ ! -e "$HALD_CLEANUP/.created-by-hal" ]; then
++if [ ! -e "$STATE_DIR/$HALD_CLEANUP/.created-by-hal" ]; then
+     exit 1
+ fi
+ 
+-rm -f "$HALD_CLEANUP/.created-by-hal"
+-rmdir --ignore-fail-on-non-empty "$HALD_CLEANUP"
++rm -f "$STATE_DIR/$HALD_CLEANUP/.created-by-hal"
++rmdir --ignore-fail-on-non-empty "$HALD_CLEANUP" "$STATE_DIR/$HALD_CLEANUP"
+diff -Nur hal-0.5.7-old/tools/hal-system-storage-cleanup-mountpoints 
hal-0.5.7/tools/hal-system-storage-cleanup-mountpoints
+--- hal-0.5.7-old/tools/hal-system-storage-cleanup-mountpoints 2006-02-13 
03:39:22.000000000 +0100
++++ hal-0.5.7/tools/hal-system-storage-cleanup-mountpoints     2006-04-23 
12:38:39.000000000 +0200
+@@ -7,6 +7,7 @@
+ # it under the terms of the GNU General Public License version 2.
+ 
+ MOUNT_ROOT="/media"
++STATE_DIR="/var/run/hal/storage-states"
+ 
+ for DIR in $MOUNT_ROOT/*; do
+ 
+@@ -14,7 +15,7 @@
+     DIRMOD=${DIR//[[:space:]]/040}
+ 
+     # check if we created it
+-    if [ -e "$DIR/.created-by-hal" ]; then
++    if [ -e "$STATE_DIR/$DIR/.created-by-hal" ]; then
+       BUSY=0
+       while read dev dir type options; do
+           if [ "$dir" = "$DIRMOD" ]; then
+@@ -23,8 +24,8 @@
+           fi
+       done < /proc/mounts
+       if [ "$BUSY" != "1" ]; then
+-          rm -f "$DIR/.created-by-hal"
+-          rmdir --ignore-fail-on-non-empty "$DIR"
++          rm -f "$STATE_DIR/$DIR/.created-by-hal"
++          rmdir --ignore-fail-on-non-empty "$DIR" "$STATE_DIR/$DIR"
+       fi
+     fi
+ done
+diff -Nur hal-0.5.7-old/tools/hal-system-storage-eject 
hal-0.5.7/tools/hal-system-storage-eject
+--- hal-0.5.7-old/tools/hal-system-storage-eject       2006-02-22 
07:26:00.000000000 +0100
++++ hal-0.5.7/tools/hal-system-storage-eject   2006-04-23 12:38:39.000000000 
+0200
+@@ -5,7 +5,9 @@
+ #
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License version 2.
+-#
++
++STATE_DIR="/var/run/hal/storage-states"
++
+ # Check for environment variables
+ if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ] ; then
+     echo "Missing or empty environment variable(s)." >&2
+@@ -47,9 +49,9 @@
+ 
+ if [ "$HAL_PROP_INFO_HAL_MOUNT_CREATED_MOUNT_POINT" != "" ]; then
+     # remove directory only if HAL has created it
+-    if [ -e $HAL_PROP_INFO_HAL_MOUNT_CREATED_MOUNT_POINT/.created-by-hal ]; 
then
+-      rm -f $HAL_PROP_INFO_HAL_MOUNT_CREATED_MOUNT_POINT/.created-by-hal
+-      rmdir --ignore-fail-on-non-empty 
"$HAL_PROP_INFO_HAL_MOUNT_CREATED_MOUNT_POINT"
++    if [ -e 
$STATE_DIR/$HAL_PROP_INFO_HAL_MOUNT_CREATED_MOUNT_POINT/.created-by-hal ]; then
++      rm -f 
$STATE_DIR/$HAL_PROP_INFO_HAL_MOUNT_CREATED_MOUNT_POINT/.created-by-hal
++      rmdir --ignore-fail-on-non-empty 
"$HAL_PROP_INFO_HAL_MOUNT_CREATED_MOUNT_POINT" 
"$STATE_DIR/$HAL_PROP_INFO_HAL_MOUNT_CREATED_MOUNT_POINT"
+     fi
+ fi
+ 
+diff -Nur hal-0.5.7-old/tools/hal-system-storage-mount 
hal-0.5.7/tools/hal-system-storage-mount
+--- hal-0.5.7-old/tools/hal-system-storage-mount       2006-02-14 
19:49:55.000000000 +0100
++++ hal-0.5.7/tools/hal-system-storage-mount   2006-04-23 12:38:39.000000000 
+0200
+@@ -7,6 +7,7 @@
+ # it under the terms of the GNU General Public License version 2.
+ 
+ MOUNT_ROOT="/media"
++STATE_DIR="/var/run/hal/storage-states"
+ 
+ # Check for environment variables
+ if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ]; then
+@@ -182,7 +183,8 @@
+ if [ ! -e "$MOUNT_ROOT/$MOUNTPOINT" ]; then
+     MOUNTPOINT_CREATED=1
+     mkdir "$MOUNT_ROOT/$MOUNTPOINT"
+-    touch "$MOUNT_ROOT/$MOUNTPOINT/.created-by-hal"
++    mkdir -p "$STATE_DIR/$MOUNT_ROOT/$MOUNTPOINT"
++    touch "$STATE_DIR/$MOUNT_ROOT/$MOUNTPOINT/.created-by-hal"
+ fi
+ 
+ if [ ! -e "$MOUNT_ROOT/$MOUNTPOINT" ]; then
+@@ -210,8 +212,8 @@
+           echo "Failed to mount device." >&2
+     esac
+     if [ -n "$MOUNTPOINT_CREATED" ]; then
+-      rm -f "$MOUNT_ROOT/$MOUNTPOINT/.created-by-hal"
+-      rmdir "$MOUNT_ROOT/$MOUNTPOINT"
++      rm -f "$STATE_DIR/$MOUNT_ROOT/$MOUNTPOINT/.created-by-hal"
++      rmdir "$MOUNT_ROOT/$MOUNTPOINT" "$STATE_DIR/$MOUNT_ROOT/$MOUNTPOINT"
+     fi
+     exit 1
+ fi
+diff -Nur hal-0.5.7-old/tools/hal-system-storage-unmount 
hal-0.5.7/tools/hal-system-storage-unmount
+--- hal-0.5.7-old/tools/hal-system-storage-unmount     2006-02-20 
03:18:59.000000000 +0100
++++ hal-0.5.7/tools/hal-system-storage-unmount 2006-04-23 12:38:39.000000000 
+0200
+@@ -6,6 +6,8 @@
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License version 2.
+ 
++STATE_DIR="/var/run/hal/storage-states"
++
+ # Check for environment variables
+ if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ] ; then
+     echo "Missing or empty environment variable(s)." >&2
+@@ -103,9 +105,9 @@
+ fi
+ 
+ # remove directory only if HAL has created it
+-if [ -e "$MOUNT_POINT/.created-by-hal" ]; then
+-  rm -f "$MOUNT_POINT/.created-by-hal"
+-  rmdir --ignore-fail-on-non-empty "$MOUNT_POINT"
++if [ -e "$STATE_DIR/$MOUNT_POINT/.created-by-hal" ]; then
++  rm -f "$STATE_DIR/$MOUNT_POINT/.created-by-hal"
++  rmdir --ignore-fail-on-non-empty "$MOUNT_POINT" "$STATE_DIR/$MOUNT_POINT"
+ fi
+ 
+ hal-set-property --udi $UDI --key info.hal_mount.created_mount_point --remove 
> /dev/null 2>&1

Reply via email to