hal/hald debug-hald.sh, NONE, 1.1 device_info.c, 1.20,
1.21 run-hald.sh, 1.3, 1.4 util.c, 1.2, 1.3 util.h, 1.2, 1.3
David Zeuthen
david at freedesktop.org
Thu Feb 10 09:03:59 PST 2005
Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv28549/hald
Modified Files:
device_info.c run-hald.sh util.c util.h
Added Files:
debug-hald.sh
Log Message:
2005-02-10 David Zeuthen <davidz at redhat.com>
* volume_id/fat.c (volume_id_probe_vfat): Must have been a typo by Kay,
changed from VOLUME_ID_DISKLABEL to VOLUME_ID_FILESYSTEM.
* tools/fstab-sync.c (remove_udi): Remember to init the DBusError since
some operations may fail.
(main): Look at $HALD_ACTION for add, remove instead of first
positional parameter $1.
* hald/linux2/probing/probe-volume.c: New file
* hald/linux2/probing/probe-storage.c: New file
* hald/linux2/probing/linux_dvd_rw_utils.[ch]: New files (imported
from hal-0.4.x)
* hald/linux2/probing/Makefile.am: Add rules for hald-probe-storage
and hald-probe-volume
* hald/linux2/addons/addon-storage.c: New file
* hald/linux2/addons/Makefile.am: Add rules for hald-addon-storage
* hald/linux2/osspec.c (sigio_handler): New function
(sigio_iochn_data): New function
(osspec_init): Set up signal handler for SIGIO and the neccesary
pipes to handle it safely. Set up directory watcher for /etc and
invoke blockdev_mtab_changed whenever that happens
* hald/linux2/hotplug.c (hotplug_rescan_device): Call blockdev_*
if appropriate
* hald/linux2/blockdev.h: Add some new prototype for interacting
with hotplug.c (much like what physdev.h and classdev.h)
exported. Also add the prototype for a new function
blockdev_mtab_changed.
* hald/linux2/blockdev.c: Actually put some code here (the previous
code was just boiler plate).
* hald/util.h (struct HalHelperData_s): Add boolean already_issued_
callback
* hald/util.c (hal_util_get_string_from_file): Truncate whitespace
from string read
(hal_util_terminate_helper): Don't remove the child watcher source,
but set a flag that we already did the callback and helper_child_exited
will reap the child (including removing sources). This helps reap the
zombies I've been seeing.
(helper_child_timeout): -do-
(helper_child_exited): Only do callback if we haven't already done
so.
* hald/debug-hald.sh: Another nice script for running gdb on hald;
just run this script and invoke the run command from the gdb console.
* hald/run-hald.sh: Also export ../tools so we can get fstab-sync
going. Set HAL_FDI_SOURCE
* hald/device_info.c (di_search_and_merge): Respect the env
var HAL_FDI_SOURCE which is useful for development as hald will
read you local .fdi files
* fdi/90defaultpolicy/storage-policy.fdi: Temporarily add
fstab-sync add/rem callouts (mental note: move to other file
soon); also add the media detection addon
* fdi/90defaultpolicy/power-mgmt-policy.fdi: New file
* fdi/90defaultpolicy/Makefile.am (fdi90defaultpolicydir): Add
power-mgmt-policy.fdi
--- NEW FILE: debug-hald.sh ---
#!/bin/sh
export PATH=linux2:linux2/probing:linux2/addons:.:../tools:$PATH
export HAL_FDI_SOURCE=../fdi
gdb run --args ./hald --daemon=no --verbose=yes --retain-privileges
Index: device_info.c
===================================================================
RCS file: /cvs/hal/hal/hald/device_info.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- device_info.c 3 Feb 2005 22:09:47 -0000 1.20
+++ device_info.c 10 Feb 2005 17:03:57 -0000 1.21
@@ -1399,7 +1399,6 @@
return found_fdi_file;
}
-
/** Search the device info file repository for a .fdi file to merge
* more information into the device object.
*
@@ -1409,8 +1408,21 @@
dbus_bool_t
di_search_and_merge (HalDevice *d)
{
+ static gboolean have_checked_hal_fdi_source = FALSE;
+ static char *hal_fdi_source = NULL;
+ char *source;
- return scan_fdi_files (PACKAGE_DATA_DIR "/hal/fdi", d);
+ if (!have_checked_hal_fdi_source) {
+ hal_fdi_source = getenv ("HAL_FDI_SOURCE");
+ have_checked_hal_fdi_source = TRUE;
+ }
+
+ if (hal_fdi_source != NULL)
+ source = hal_fdi_source;
+ else
+ source = PACKAGE_DATA_DIR "/hal/fdi";
+
+ return scan_fdi_files (source, d);
}
/** @} */
Index: run-hald.sh
===================================================================
RCS file: /cvs/hal/hal/hald/run-hald.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- run-hald.sh 8 Feb 2005 21:37:47 -0000 1.3
+++ run-hald.sh 10 Feb 2005 17:03:57 -0000 1.4
@@ -1,5 +1,6 @@
#!/bin/sh
-export PATH=linux2:linux2/probing:linux2/addons:.:$PATH
+export PATH=linux2:linux2/probing:linux2/addons:.:../tools:$PATH
+export HAL_FDI_SOURCE=../fdi
./hald --daemon=no --verbose=yes --retain-privileges
Index: util.c
===================================================================
RCS file: /cvs/hal/hal/hald/util.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- util.c 8 Feb 2005 22:36:58 -0000 1.2
+++ util.c 10 Feb 2005 17:03:57 -0000 1.3
@@ -340,6 +340,7 @@
gchar path[HAL_PATH_MAX];
gchar *result;
gsize len;
+ guint i;
f = NULL;
result = NULL;
@@ -356,11 +357,18 @@
HAL_ERROR (("Cannot read from '%s'", path));
goto out;
}
-
+
len = strlen (buf);
if (len>0)
buf[len-1] = '\0';
+ /* Clear remaining whitespace */
+ for (i = len-2; i >= 0; --i) {
+ if (!g_ascii_isspace (buf[i]))
+ break;
+ buf[i] = '\0';
+ }
+
result = buf;
out:
@@ -418,14 +426,16 @@
kill (ed->pid, SIGTERM);
/* TODO: yikes; what about removing the zombie? */
- if (ed->timeout_watch_id != (guint) -1)
+ if (ed->timeout_watch_id != (guint) -1) {
g_source_remove (ed->timeout_watch_id);
- g_source_remove (ed->child_watch_id);
- g_spawn_close_pid (ed->pid);
+ ed->timeout_watch_id = -1;
+ }
+
+ ed->already_issued_callback = TRUE;
ed->cb (ed->d, TRUE, -1, ed->data1, ed->data2, ed);
- g_free (ed);
+ /* ed will be cleaned up when helper_child_exited reaps the child */
return;
}
@@ -438,14 +448,13 @@
/* kill kenny! kill it!! */
kill (ed->pid, SIGTERM);
- /* TODO: yikes; what about removing the zombie? */
- g_source_remove (ed->child_watch_id);
- g_spawn_close_pid (ed->pid);
+ ed->timeout_watch_id = -1;
+ ed->already_issued_callback = TRUE;
ed->cb (ed->d, TRUE, -1, ed->data1, ed->data2, ed);
- g_free (ed);
+ /* ed will be cleaned up when helper_child_exited reaps the child */
return FALSE;
}
@@ -454,14 +463,15 @@
{
HalHelperData *ed = (HalHelperData *) data;
- HAL_INFO (("child exited for pid %d", ed->pid));
+ HAL_INFO (("child exited for pid %d", pid));
if (ed->timeout_watch_id != (guint) -1)
g_source_remove (ed->timeout_watch_id);
g_spawn_close_pid (ed->pid);
- ed->cb (ed->d, FALSE, WEXITSTATUS (status), ed->data1, ed->data2, ed);
-
+ if (!ed->already_issued_callback)
+ ed->cb (ed->d, FALSE, WEXITSTATUS (status), ed->data1, ed->data2, ed);
+
g_free (ed);
}
Index: util.h
===================================================================
RCS file: /cvs/hal/hal/hald/util.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- util.h 8 Feb 2005 22:36:58 -0000 1.2
+++ util.h 10 Feb 2005 17:03:57 -0000 1.3
@@ -91,6 +91,8 @@
gpointer data1;
gpointer data2;
HalDevice *d;
+
+ gboolean already_issued_callback;
};
HalHelperData *hal_util_helper_invoke (const gchar *command_line, gchar **extra_env, HalDevice *d,
More information about the hal-commit
mailing list