diff options
author | David Zeuthen <davidz@redhat.com> | 2006-08-19 13:49:32 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2006-08-19 13:49:32 -0400 |
commit | d9bcef8e186626c8270d848f585e64c363cf6796 (patch) | |
tree | 848e957e84bbc278c6aee332f78363a6d921a3f3 | |
parent | ca064f6f313f7afd134e67e0fa7ac2fc5e25dd64 (diff) | |
parent | 27050b659a63c9ffe79f997a2d562a56821e49c3 (diff) |
Merge branch 'master' of ssh://david@git.freedesktop.org/git/hal
69 files changed, 435 insertions, 457 deletions
diff --git a/doc/conf/match-USB-camera.fdi b/doc/conf/match-USB-camera.fdi index dac0cce9..a3f65081 100644 --- a/doc/conf/match-USB-camera.fdi +++ b/doc/conf/match-USB-camera.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <!-- Example: This device information file matches a Sony digital still camera by matching on the USB vendor and product identifers. --> diff --git a/doc/conf/match-USB-mp3-player.fdi b/doc/conf/match-USB-mp3-player.fdi index 88afef98..5797d73f 100644 --- a/doc/conf/match-USB-mp3-player.fdi +++ b/doc/conf/match-USB-mp3-player.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <!-- Example: This device information file matches an USB Mass Storage based MP3 player by the matching on the USB vendor and product identifiers. --> diff --git a/doc/conf/match-cardreader.fdi b/doc/conf/match-cardreader.fdi index 6b88ebff..9ae7b2e8 100644 --- a/doc/conf/match-cardreader.fdi +++ b/doc/conf/match-cardreader.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <!-- Example: This device information file matches a memory card reader with multiple storage ports that can be active at the same time. --> diff --git a/doc/conf/storage-non-fixed.fdi b/doc/conf/storage-non-fixed.fdi index 2e7bc899..5c312f75 100644 --- a/doc/conf/storage-non-fixed.fdi +++ b/doc/conf/storage-non-fixed.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <!-- This .fdi files makes sure no fixed storage device gets tagged as mountable except if it's a floppy or optical drive --> diff --git a/doc/conf/storage-policy-examples.fdi b/doc/conf/storage-policy-examples.fdi index 1f220e6f..cbf482cf 100644 --- a/doc/conf/storage-policy-examples.fdi +++ b/doc/conf/storage-policy-examples.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> diff --git a/doc/conf/storage-skip-all.fdi b/doc/conf/storage-skip-all.fdi index 5037f5b3..f8b3300e 100644 --- a/doc/conf/storage-skip-all.fdi +++ b/doc/conf/storage-skip-all.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <!-- This .fdi files will tag all storage devices as non mountable --> <deviceinfo version="0.2"> diff --git a/doc/spec/hal-spec-examples.xml b/doc/spec/hal-spec-examples.xml index 7f0e58d0..4849fba5 100644 --- a/doc/spec/hal-spec-examples.xml +++ b/doc/spec/hal-spec-examples.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- CVSID: $Id$ --> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <chapter id="examples"> diff --git a/doc/spec/hal-spec-fdi-files.xml b/doc/spec/hal-spec-fdi-files.xml index f0fc23d7..ba4f1af1 100644 --- a/doc/spec/hal-spec-fdi-files.xml +++ b/doc/spec/hal-spec-fdi-files.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- CVSID: $Id$ --> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <chapter id="spec-device-info"> diff --git a/doc/spec/hal-spec-introduction.xml b/doc/spec/hal-spec-introduction.xml index cce02585..c8f514c3 100644 --- a/doc/spec/hal-spec-introduction.xml +++ b/doc/spec/hal-spec-introduction.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- CVSID: $Id$ --> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <chapter id="introduction"> diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml index 12c68e51..7c1eddda 100644 --- a/doc/spec/hal-spec-properties.xml +++ b/doc/spec/hal-spec-properties.xml @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- CVSID: $Id$ --> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <chapter id="device-properties"> @@ -963,6 +962,74 @@ <entry>Yes</entry> <entry>SCSI Logical Unit Number</entry> </row> + <row> + <entry> + <literal>scsi.type</literal> (string) + </entry> + <entry>Example: disk</entry> + <entry>Yes</entry> + <entry>SCSI device type</entry> + </row> + <row> + <entry></entry> + <entry>cdrom</entry> + <entry></entry> + <entry>This is a SCSI cdrom device.</entry> + </row> + <row> + <entry></entry> + <entry>comm</entry> + <entry></entry> + <entry>This is a SCSI communication device.</entry> + </row> + <row> + <entry></entry> + <entry>disk</entry> + <entry></entry> + <entry>This is a SCSI disk device.</entry> + </row> + <row> + <entry></entry> + <entry>medium_changer</entry> + <entry></entry> + <entry>This is a SCSI media changer (e.g. for CD/Tape).</entry> + </row> + <row> + <entry></entry> + <entry>printer</entry> + <entry></entry> + <entry>This is a SCSI printer.</entry> + </row> + <row> + <entry></entry> + <entry>processor</entry> + <entry></entry> + <entry>This is a SCSI processor device.</entry> + </row> + <row> + <entry></entry> + <entry>raid</entry> + <entry></entry> + <entry>This is a SCSI raid device.</entry> + </row> + <row> + <entry></entry> + <entry>scanner</entry> + <entry></entry> + <entry>This is a SCSI scanner.</entry> + </row> + <row> + <entry></entry> + <entry>tape</entry> + <entry></entry> + <entry>This is a SCSI tape device.</entry> + </row> + <row> + <entry></entry> + <entry>unknown</entry> + <entry></entry> + <entry>The type of this SCSI device is unknwon.</entry> + </row> </tbody> </tgroup> </informaltable> diff --git a/doc/spec/hal-spec.xml.in b/doc/spec/hal-spec.xml.in index 3dcf602f..822cc95c 100644 --- a/doc/spec/hal-spec.xml.in +++ b/doc/spec/hal-spec.xml.in @@ -1,5 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- CVSID: $Id$ --> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <book id="index"> diff --git a/fdi/fdi.dtd b/fdi/fdi.dtd index bb3e3e18..360d9177 100644 --- a/fdi/fdi.dtd +++ b/fdi/fdi.dtd @@ -1,5 +1,4 @@ <!-- Document Type for FreeDesktop.org Device Information Files --> -<!-- CVSID: $Id$ --> <!-- <deviceinfo> is the top-level element of an fdi file. --> <!ELEMENT deviceinfo (device*) > diff --git a/fdi/information/10freedesktop/10-camera-ptp.fdi b/fdi/information/10freedesktop/10-camera-ptp.fdi index 81e27567..98797252 100644 --- a/fdi/information/10freedesktop/10-camera-ptp.fdi +++ b/fdi/information/10freedesktop/10-camera-ptp.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> <device> diff --git a/fdi/information/10freedesktop/10-cd-dvd-burner.fdi b/fdi/information/10freedesktop/10-cd-dvd-burner.fdi index 4b09741c..0cb920f3 100644 --- a/fdi/information/10freedesktop/10-cd-dvd-burner.fdi +++ b/fdi/information/10freedesktop/10-cd-dvd-burner.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> diff --git a/fdi/information/10freedesktop/10-usb-music-players.fdi b/fdi/information/10freedesktop/10-usb-music-players.fdi index 633a7c06..129c352e 100644 --- a/fdi/information/10freedesktop/10-usb-music-players.fdi +++ b/fdi/information/10freedesktop/10-usb-music-players.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> <device> diff --git a/fdi/information/10freedesktop/10-usb-pda.fdi b/fdi/information/10freedesktop/10-usb-pda.fdi index 677ec18b..1133f5e3 100644 --- a/fdi/information/10freedesktop/10-usb-pda.fdi +++ b/fdi/information/10freedesktop/10-usb-pda.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> diff --git a/fdi/information/10freedesktop/10-usb-zip-drives.fdi b/fdi/information/10freedesktop/10-usb-zip-drives.fdi index c532b3f4..bf2f64c8 100644 --- a/fdi/information/10freedesktop/10-usb-zip-drives.fdi +++ b/fdi/information/10freedesktop/10-usb-zip-drives.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> <device> diff --git a/fdi/information/10freedesktop/10-wireless-mice.fdi b/fdi/information/10freedesktop/10-wireless-mice.fdi index 6fff1735..4a7f3ed5 100644 --- a/fdi/information/10freedesktop/10-wireless-mice.fdi +++ b/fdi/information/10freedesktop/10-wireless-mice.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> <device> <match key="info.bus" string="usb_device"> diff --git a/fdi/policy/10osvendor/10-keyboard-policy.fdi b/fdi/policy/10osvendor/10-keyboard-policy.fdi index fd5a2ecc..4bae7c6d 100644 --- a/fdi/policy/10osvendor/10-keyboard-policy.fdi +++ b/fdi/policy/10osvendor/10-keyboard-policy.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> diff --git a/fdi/policy/10osvendor/10-laptop-panel-mgmt-policy.fdi b/fdi/policy/10osvendor/10-laptop-panel-mgmt-policy.fdi index 5030bae2..f59fbdd0 100644 --- a/fdi/policy/10osvendor/10-laptop-panel-mgmt-policy.fdi +++ b/fdi/policy/10osvendor/10-laptop-panel-mgmt-policy.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> diff --git a/fdi/policy/10osvendor/10-power-mgmt-policy.fdi b/fdi/policy/10osvendor/10-power-mgmt-policy.fdi index 3c292fdb..2c2705ab 100644 --- a/fdi/policy/10osvendor/10-power-mgmt-policy.fdi +++ b/fdi/policy/10osvendor/10-power-mgmt-policy.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> diff --git a/fdi/policy/10osvendor/10-toshiba-buttons.fdi b/fdi/policy/10osvendor/10-toshiba-buttons.fdi index 9ea60353..b2e83d7e 100644 --- a/fdi/policy/10osvendor/10-toshiba-buttons.fdi +++ b/fdi/policy/10osvendor/10-toshiba-buttons.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> diff --git a/fdi/policy/10osvendor/15-storage-luks.fdi b/fdi/policy/10osvendor/15-storage-luks.fdi index b6e91d66..2746446c 100644 --- a/fdi/policy/10osvendor/15-storage-luks.fdi +++ b/fdi/policy/10osvendor/15-storage-luks.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> <device> diff --git a/fdi/policy/10osvendor/20-storage-methods.fdi b/fdi/policy/10osvendor/20-storage-methods.fdi index 0983ecef..f67c7b05 100644 --- a/fdi/policy/10osvendor/20-storage-methods.fdi +++ b/fdi/policy/10osvendor/20-storage-methods.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> <device> diff --git a/fdi/preprobe/10osvendor/10-ide-drives.fdi b/fdi/preprobe/10osvendor/10-ide-drives.fdi index 7cb74ee6..61fa1ff8 100644 --- a/fdi/preprobe/10osvendor/10-ide-drives.fdi +++ b/fdi/preprobe/10osvendor/10-ide-drives.fdi @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <deviceinfo version="0.2"> diff --git a/hald-runner/runner.c b/hald-runner/runner.c index a2d1a210..73012338 100644 --- a/hald-runner/runner.c +++ b/hald-runner/runner.c @@ -163,6 +163,7 @@ run_exited(GPid pid, gint status, gpointer data) if (rd->stderr_v >= 0) { /* Need to read stderr */ error = get_string_array_from_fd(rd->stderr_v); + close(rd->stderr_v); rd->stderr_v = -1; } if (rd->msg != NULL) diff --git a/hald/device_info.c b/hald/device_info.c index 17751d39..478c94a1 100644 --- a/hald/device_info.c +++ b/hald/device_info.c @@ -1453,8 +1453,12 @@ out: -static int +static int +#ifdef __GLIBC__ my_alphasort(const void *a, const void *b) +#else +my_alphasort(const struct dirent **a, const struct dirent **b) +#endif { return -alphasort (a, b); } diff --git a/hald/device_store.c b/hald/device_store.c index 96ca58f1..d11cf6ed 100644 --- a/hald/device_store.c +++ b/hald/device_store.c @@ -203,10 +203,10 @@ hal_device_store_remove (HalDeviceStore *store, HalDevice *device) store->devices = g_slist_remove (store->devices, device); g_signal_handlers_disconnect_by_func (device, - emit_device_property_changed, + (gpointer)emit_device_property_changed, store); g_signal_handlers_disconnect_by_func (device, - emit_device_capability_added, + (gpointer)emit_device_capability_added, store); g_signal_emit (store, signals[STORE_CHANGED], 0, device, FALSE); diff --git a/hald/linux2/acpi.c b/hald/linux2/acpi.c index 0ce181d5..9f190b74 100644 --- a/hald/linux2/acpi.c +++ b/hald/linux2/acpi.c @@ -28,14 +28,13 @@ #include <string.h> #include "../device_info.h" -#include "../logger.h" #include "../hald_dbus.h" +#include "../logger.h" #include "../util.h" #include "osspec_linux.h" #include "acpi.h" -#include "hotplug.h" enum { ACPI_TYPE_BATTERY, diff --git a/hald/linux2/addons/addon-acpi-buttons-toshiba.c b/hald/linux2/addons/addon-acpi-buttons-toshiba.c index b1002805..908cf4ec 100644 --- a/hald/linux2/addons/addon-acpi-buttons-toshiba.c +++ b/hald/linux2/addons/addon-acpi-buttons-toshiba.c @@ -29,11 +29,12 @@ # include <config.h> #endif +#include <linux/input.h> #include <stdio.h> -#include <unistd.h> #include <stdlib.h> #include <string.h> -#include <linux/input.h> +#include <unistd.h> + #include <glib/gmain.h> #include "libhal/libhal.h" diff --git a/hald/linux2/addons/addon-acpi.c b/hald/linux2/addons/addon-acpi.c index 9025e530..220d71d7 100644 --- a/hald/linux2/addons/addon-acpi.c +++ b/hald/linux2/addons/addon-acpi.c @@ -26,16 +26,14 @@ # include <config.h> #endif +#include <errno.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> -#include <errno.h> #include <string.h> -#include <sys/types.h> -#include <sys/stat.h> #include <sys/socket.h> +#include <sys/types.h> #include <sys/un.h> -#include <fcntl.h> +#include <unistd.h> #include "libhal/libhal.h" diff --git a/hald/linux2/addons/addon-hid-ups.c b/hald/linux2/addons/addon-hid-ups.c index ffc4c65b..4a47db22 100644 --- a/hald/linux2/addons/addon-hid-ups.c +++ b/hald/linux2/addons/addon-hid-ups.c @@ -34,19 +34,17 @@ # include <config.h> #endif +/* asm/types.h required for __s32 in linux/hiddev.h */ +#include <asm/types.h> #include <errno.h> -#include <string.h> -#include <stdlib.h> +#include <fcntl.h> +#include <linux/hiddev.h> +#include <stdint.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sys/ioctl.h> -#include <stdint.h> -#include <sys/stat.h> -#include <stdint.h> -#include <fcntl.h> #include <unistd.h> -/* asm/types.h required for __s32 in linux/hiddev.h */ -#include <asm/types.h> -#include <linux/hiddev.h> #include "libhal/libhal.h" diff --git a/hald/linux2/addons/addon-keyboard.c b/hald/linux2/addons/addon-keyboard.c index 8d235274..29afcb0e 100644 --- a/hald/linux2/addons/addon-keyboard.c +++ b/hald/linux2/addons/addon-keyboard.c @@ -30,13 +30,8 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <errno.h> #include <string.h> #include <sys/types.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <fcntl.h> #include <linux/input.h> #include "libhal/libhal.h" diff --git a/hald/linux2/addons/addon-macbookpro-backlight.c b/hald/linux2/addons/addon-macbookpro-backlight.c index 974de012..c97211bb 100644 --- a/hald/linux2/addons/addon-macbookpro-backlight.c +++ b/hald/linux2/addons/addon-macbookpro-backlight.c @@ -25,21 +25,19 @@ **************************************************************************/ #include <config.h> +#include <fcntl.h> #include <stdio.h> - -#include <glib/gmain.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - -#include <sys/io.h> #include <stdlib.h> #include <string.h> +#include <sys/io.h> #include <sys/mman.h> #include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> #include <pci/pci.h> +#include <unistd.h> + +#include <glib/gmain.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> #include "libhal/libhal.h" #include "../probing/shared.h" diff --git a/hald/linux2/addons/addon-pmu.c b/hald/linux2/addons/addon-pmu.c index 278e5864..2cbacce6 100644 --- a/hald/linux2/addons/addon-pmu.c +++ b/hald/linux2/addons/addon-pmu.c @@ -25,18 +25,15 @@ # include <config.h> #endif -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> #include <errno.h> -#include <string.h> -#include <stdint.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/un.h> #include <fcntl.h> #include <linux/adb.h> #include <linux/pmu.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> #include "libhal/libhal.h" diff --git a/hald/linux2/addons/addon-storage.c b/hald/linux2/addons/addon-storage.c index e725cba7..83f44285 100644 --- a/hald/linux2/addons/addon-storage.c +++ b/hald/linux2/addons/addon-storage.c @@ -28,21 +28,17 @@ #endif #include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/ioctl.h> -#include <stdint.h> -#include <sys/stat.h> -#include <stdint.h> -#include <sys/wait.h> #include <fcntl.h> -#include <unistd.h> -#include <linux/kdev_t.h> #include <linux/cdrom.h> #include <linux/fs.h> #include <mntent.h> #include <scsi/sg.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> +#include <unistd.h> #include "libhal/libhal.h" diff --git a/hald/linux2/apm.c b/hald/linux2/apm.c index d0254fb4..fc417ae3 100644 --- a/hald/linux2/apm.c +++ b/hald/linux2/apm.c @@ -26,21 +26,21 @@ #include <string.h> +#include "../hald_dbus.h" #include "../device_info.h" #include "../logger.h" -#include "../hald_dbus.h" #include "../util.h" #include "osspec_linux.h" #include "apm.h" -#include "hotplug.h" enum { APM_TYPE_BATTERY, APM_TYPE_AC_ADAPTER }; +int interval_poll_round = 0; typedef struct APMDevHandler_s { @@ -202,11 +202,25 @@ battery_refresh (HalDevice *d, APMDevHandler *handler) remaining_time = i.battery_time * 60; } - /* set the time on discharge, and remove property on charging because unknown on APM */ - if (remaining_time > 0) - hal_device_property_set_int (d, "battery.remaining_time", remaining_time); - else + /* set the time to discharge, or remove key for charging */ + if (remaining_time > 0) { + /* switched from charging to discharging, set key */ + if (!is_charging && is_discharging && !hal_device_has_property(d,"battery.remaining_time")) { + hal_device_property_set_int (d, "battery.remaining_time", remaining_time); + interval_poll_round = 0; + } + /* after 30 seconds (15*APM_POLL_INTERVAL) set key */ + else if (interval_poll_round == 15) { + hal_device_property_set_int (d, "battery.remaining_time", remaining_time); + interval_poll_round = 0; + } + /* else: only increment counter and set no key to avoid needless events/changes + because APM produce with each read a new value for remaining time */ + else + interval_poll_round++; + } else { hal_device_property_remove (d, "battery.remaining_time"); + } /* set the correct charge states */ hal_device_property_set_bool (d, "battery.rechargeable.is_charging", is_charging); diff --git a/hald/linux2/blockdev.c b/hald/linux2/blockdev.c index d232115d..e40dd932 100644 --- a/hald/linux2/blockdev.c +++ b/hald/linux2/blockdev.c @@ -26,49 +26,33 @@ # include <config.h> #endif -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <mntent.h> -#include <errno.h> -#include <stdint.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/utsname.h> -#include <unistd.h> #include <ctype.h> -#include <unistd.h> -#include <linux/kdev_t.h> - #include <limits.h> -#include <errno.h> +#include <linux/kdev_t.h> +#include <mntent.h> #include <stdint.h> +#include <stdlib.h> +#include <string.h> #include <sys/stat.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <fcntl.h> #include <syslog.h> +#include <unistd.h> -#include <glib.h> #include <dbus/dbus.h> #include <dbus/dbus-glib.h> -#include "../osspec.h" -#include "../logger.h" -#include "../hald.h" #include "../device_info.h" +#include "../hald.h" #include "../hald_dbus.h" -#include "../util.h" #include "../hald_runner.h" - -#include "osspec_linux.h" +#include "../logger.h" +#include "../osspec.h" +#include "../util.h" #include "coldplug.h" +#include "hotplug.h" #include "hotplug_helper.h" +#include "osspec_linux.h" -#include "hotplug.h" #include "blockdev.h" /*--------------------------------------------------------------------------------------------------------------*/ @@ -172,117 +156,6 @@ cleanup_mountpoint_cb (HalDevice *d, guint32 exit_type, g_free (mount_point); } -static gboolean -is_mounted_by_hald (const char *mount_point) -{ - int i; - FILE *hal_mtab; - int hal_mtab_len; - int num_read; - char *hal_mtab_buf; - char **lines; - gboolean found; - int lock_mtab_fd; - - hal_mtab = NULL; - hal_mtab_buf = NULL; - found = FALSE; - - /* take the lock on /media/.hal-mtab-lock so we don't race with the Mount() and Unmount() methods */ - - /* do not attempt to create the file; tools/hal-storage-shared.c will create it and - * set the correct ownership so this unprivileged process (running as haldaemon) can - * lock it too - */ - lock_mtab_fd = open ("/media/.hal-mtab-lock", 0); - if (lock_mtab_fd < 0) { - HAL_INFO (("Cannot open /media/.hal-mtab for locking")); - goto out; - } - -tryagain: - if (flock (lock_mtab_fd, LOCK_EX) != 0) { - if (errno == EINTR) - goto tryagain; - HAL_ERROR (("Cannot obtain lock on /media/.hal-mtab")); - goto out; - } - - /*HAL_DEBUG (("examining /media/.hal-mtab for %s", mount_point));*/ - - hal_mtab = fopen ("/media/.hal-mtab", "r"); - if (hal_mtab == NULL) { - HAL_ERROR (("Cannot open /media/.hal-mtab")); - goto out; - } - if (fseek (hal_mtab, 0L, SEEK_END) != 0) { - HAL_ERROR (("Cannot seek to end of /media/.hal-mtab")); - goto out; - } - hal_mtab_len = ftell (hal_mtab); - if (hal_mtab_len < 0) { - HAL_ERROR (("Cannot determine size of /media/.hal-mtab")); - goto out; - } - rewind (hal_mtab); - - hal_mtab_buf = g_new0 (char, hal_mtab_len + 1); - num_read = fread (hal_mtab_buf, 1, hal_mtab_len, hal_mtab); - if (num_read != hal_mtab_len) { - HAL_ERROR (("Cannot read from /media/.hal-mtab")); - goto out; - } - fclose (hal_mtab); - hal_mtab = NULL; - - /*HAL_DEBUG (("hal_mtab = '%s'\n", hal_mtab_buf));*/ - - lines = g_strsplit (hal_mtab_buf, "\n", 0); - g_free (hal_mtab_buf); - hal_mtab_buf = NULL; - - /* find the entry we're going to unmount */ - for (i = 0; lines[i] != NULL && !found; i++) { - char **line_elements; - - /*HAL_DEBUG ((" line = '%s'", lines[i]));*/ - - if ((lines[i])[0] == '#') - continue; - - line_elements = g_strsplit (lines[i], "\t", 6); - if (g_strv_length (line_elements) == 6) { -/* - HAL_DEBUG ((" devfile = '%s'", line_elements[0])); - HAL_DEBUG ((" uid = '%s'", line_elements[1])); - HAL_DEBUG ((" session id = '%s'", line_elements[2])); - HAL_DEBUG ((" fs = '%s'", line_elements[3])); - HAL_DEBUG ((" options = '%s'", line_elements[4])); - HAL_DEBUG ((" mount_point = '%s'", line_elements[5])); - HAL_DEBUG ((" (comparing against '%s')", mount_point)); -*/ - - if (strcmp (line_elements[5], mount_point) == 0) { - found = TRUE; - /*HAL_INFO (("device at '%s' is indeed mounted by HAL's Mount()", mount_point));*/ - } - - } - - g_strfreev (line_elements); - } - -out: - if (lock_mtab_fd >= 0) - close (lock_mtab_fd); - if (hal_mtab != NULL) - fclose (hal_mtab); - if (hal_mtab_buf != NULL) - g_free (hal_mtab_buf); - - return found; -} - void blockdev_refresh_mount_state (HalDevice *d) { @@ -409,7 +282,7 @@ blockdev_refresh_mount_state (HalDevice *d) } /* look up in /media/.hal-mtab to see if we mounted this one */ - if (mount_point != NULL && strlen (mount_point) > 0 && is_mounted_by_hald (mount_point)) { + if (mount_point != NULL && strlen (mount_point) > 0 && hal_util_is_mounted_by_hald (mount_point)) { char *cleanup_stdin; char *extra_env[2]; @@ -1319,7 +1192,7 @@ force_unmount (HalDevice *d, void *end_token) mount_point = hal_device_property_get_string (d, "volume.mount_point"); /* look up in /media/.hal-mtab to see if we mounted this one */ - if (mount_point != NULL && strlen (mount_point) > 0 && is_mounted_by_hald (mount_point)) { + if (mount_point != NULL && strlen (mount_point) > 0 && hal_util_is_mounted_by_hald (mount_point)) { char *unmount_stdin; char *extra_env[2]; diff --git a/hald/linux2/classdev.c b/hald/linux2/classdev.c index 6a896bfa..3e3a6679 100644 --- a/hald/linux2/classdev.c +++ b/hald/linux2/classdev.c @@ -29,50 +29,30 @@ # include <config.h> #endif -#include <stdio.h> +#include <ctype.h> +#include <limits.h> +#include <linux/types.h> +#include <net/if_arp.h> /* for ARPHRD_... */ #include <stdlib.h> -#include <stdarg.h> #include <string.h> -#include <mntent.h> -#include <errno.h> #include <stdint.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/utsname.h> -#include <unistd.h> -#include <ctype.h> #include <unistd.h> -#include <limits.h> -#include <errno.h> -#include <stdint.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <net/if_arp.h> /* for ARPHRD_... */ -#include <sys/socket.h> -#include <linux/types.h> -#include <net/if.h> - -#include <glib.h> #include <dbus/dbus.h> #include <dbus/dbus-glib.h> -#include "../osspec.h" -#include "../logger.h" -#include "../hald.h" #include "../device_info.h" #include "../device_store.h" -#include "../util.h" +#include "../hald.h" #include "../hald_runner.h" - -#include "osspec_linux.h" +#include "../logger.h" +#include "../osspec.h" +#include "../util.h" #include "coldplug.h" #include "hotplug_helper.h" +#include "osspec_linux.h" -#include "hotplug.h" #include "classdev.h" /*--------------------------------------------------------------------------------------------------------------*/ diff --git a/hald/linux2/coldplug.c b/hald/linux2/coldplug.c index df757857..e47a90f5 100644 --- a/hald/linux2/coldplug.c +++ b/hald/linux2/coldplug.c @@ -27,28 +27,25 @@ # include <config.h> #endif +#include <stdint.h> #include <stdio.h> #include <string.h> -#include <mntent.h> -#include <errno.h> -#include <stdint.h> #include <sys/stat.h> #include <unistd.h> -#include <glib.h> #include <dbus/dbus.h> #include <dbus/dbus-glib.h> -#include "../osspec.h" -#include "../logger.h" -#include "../hald.h" #include "../device_info.h" +#include "../hald.h" +#include "../logger.h" +#include "../osspec.h" #include "../util.h" #include "osspec_linux.h" +#include "hotplug.h" #include "coldplug.h" -#include "hotplug.h" #define DMPREFIX "dm-" diff --git a/hald/linux2/hotplug.c b/hald/linux2/hotplug.c index 50d7ffa4..4eac8b9e 100644 --- a/hald/linux2/hotplug.c +++ b/hald/linux2/hotplug.c @@ -28,36 +28,28 @@ #endif #include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <mntent.h> -#include <errno.h> #include <stdint.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/utsname.h> +#include <string.h> #include <unistd.h> -#include <glib.h> #include <dbus/dbus.h> #include <dbus/dbus-glib.h> -#include "../osspec.h" -#include "../logger.h" -#include "../hald.h" #include "../device_info.h" +#include "../hald.h" +#include "../logger.h" +#include "../osspec.h" -#include "osspec_linux.h" - -#include "hotplug.h" -#include "physdev.h" -#include "classdev.h" -#include "blockdev.h" #include "acpi.h" #include "apm.h" +#include "blockdev.h" +#include "classdev.h" +#include "osspec_linux.h" +#include "physdev.h" #include "pmu.h" +#include "hotplug.h" + /** Queue of ordered hotplug events */ GQueue *hotplug_event_queue; diff --git a/hald/linux2/ids.c b/hald/linux2/ids.c index cf7638e6..35dcec2a 100644 --- a/hald/linux2/ids.c +++ b/hald/linux2/ids.c @@ -28,18 +28,10 @@ #endif #include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <mntent.h> -#include <errno.h> #include <stdint.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/utsname.h> +#include <string.h> #include <unistd.h> -#include <glib.h> #include <dbus/dbus.h> #include <dbus/dbus-glib.h> diff --git a/hald/linux2/osspec.c b/hald/linux2/osspec.c index 395043b2..9571d250 100644 --- a/hald/linux2/osspec.c +++ b/hald/linux2/osspec.c @@ -32,52 +32,37 @@ #define _GNU_SOURCE 1 #include <ctype.h> -#include <stdio.h> +#include <errno.h> +#include <limits.h> +#include <linux/types.h> +#include <net/if_arp.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> -#include <getopt.h> -#include <assert.h> -#include <unistd.h> -#include <stdarg.h> -#include <limits.h> -#include <errno.h> -#include <mntent.h> -#include <signal.h> +#include <sys/stat.h> #include <sys/un.h> #include <sys/utsname.h> #include <unistd.h> -#include <stdint.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <net/if_arp.h> -#include <sys/socket.h> -#include <linux/types.h> -#include <sys/ioctl.h> -#include <net/if.h> -#include <sys/ioctl.h> -#include <net/if.h> -#include <glib.h> #include <dbus/dbus.h> #include <dbus/dbus-glib.h> -#include "../osspec.h" -#include "../logger.h" +#include "../device_info.h" #include "../hald.h" #include "../hald_dbus.h" #include "../hald_runner.h" -#include "../device_info.h" +#include "../logger.h" +#include "../osspec.h" #include "../util.h" -#include "hotplug.h" -#include "coldplug.h" -#include "ids.h" #include "acpi.h" #include "apm.h" -#include "pmu.h" #include "blockdev.h" +#include "coldplug.h" +#include "hotplug.h" +#include "ids.h" +#include "pmu.h" + #include "osspec_linux.h" static char *hal_sysfs_path; diff --git a/hald/linux2/physdev.c b/hald/linux2/physdev.c index 4679a9f8..c2ae795b 100644 --- a/hald/linux2/physdev.c +++ b/hald/linux2/physdev.c @@ -27,37 +27,27 @@ # include <config.h> #endif -#include <stdio.h> #include <string.h> -#include <mntent.h> -#include <errno.h> #include <stdint.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/utsname.h> #include <unistd.h> -#include <glib.h> #include <dbus/dbus.h> #include <dbus/dbus-glib.h> -#include "../osspec.h" -#include "../logger.h" -#include "../hald.h" #include "../device_info.h" +#include "../hald.h" +#include "../logger.h" +#include "../osspec.h" #include "../util.h" #include "coldplug.h" -#include "hotplug_helper.h" - #include "hotplug.h" -#include "physdev.h" - +#include "hotplug_helper.h" #include "ids.h" - #include "osspec_linux.h" +#include "physdev.h" + /*--------------------------------------------------------------------------------------------------------------*/ static HalDevice * @@ -684,25 +674,40 @@ scsi_add (const gchar *sysfs_path, HalDevice *parent) hal_util_get_int_from_file (sysfs_path, "type", &type, 0); HAL_INFO (("%s/type -> %d (-> scsi.type)", sysfs_path, type)); switch (type) { - case 0: - /* Disk */ - case 14: - /* TYPE_RBC (Reduced Block Commands) - * Simple Direct Access Device, set it to disk - * (some Firewire Disks use it) - */ + case 0: /* TYPE_DISK (disk) */ + case 7: /* TYPE_MOD (Magneto-optical disk) */ + case 14: /* TYPE_RBC (Reduced Block Commands) + * Simple Direct Access Device, set it to disk + * (some Firewire Disks use it) + */ hal_device_property_set_string (d, "scsi.type", "disk"); break; - case 1: - /* Tape */ + case 1: /* TYPE_TAPE (Tape) */ hal_device_property_set_string (d, "scsi.type", "tape"); break; - case 4: - /* WORM */ - case 5: - /* CD-ROM */ + case 2: + /* TYPE_PRINTER (Tape) */ + hal_device_property_set_string (d, "scsi.type", "printer"); + break; + case 3: /* TYPE_PROCESSOR */ + hal_device_property_set_string (d, "scsi.type", "processor"); + break; + case 4: /* TYPE_WORM */ + case 5: /* TYPE_ROM (CD-ROM) */ hal_device_property_set_string (d, "scsi.type", "cdrom"); break; + case 6: /* TYPE_SCANNER */ + hal_device_property_set_string (d, "scsi.type", "scanner"); + break; + case 8: /* TYPE_MEDIUM_CHANGER */ + hal_device_property_set_string (d, "scsi.type", "medium_changer"); + break; + case 9: /* TYPE_COMM */ + hal_device_property_set_string (d, "scsi.type", "comm"); + break; + case 12: /* TYPE_RAID */ + hal_device_property_set_string (d, "scsi.type", "raid"); + break; default: hal_device_property_set_string (d, "scsi.type", "unknown"); } diff --git a/hald/linux2/pmu.c b/hald/linux2/pmu.c index 9f554acd..901e48eb 100644 --- a/hald/linux2/pmu.c +++ b/hald/linux2/pmu.c @@ -31,14 +31,14 @@ #include <unistd.h> #include "../device_info.h" -#include "../logger.h" #include "../hald_dbus.h" +#include "../logger.h" #include "../util.h" +#include "hotplug.h" #include "osspec_linux.h" #include "pmu.h" -#include "hotplug.h" enum { PMU_TYPE_BATTERY, diff --git a/hald/linux2/probing/probe-hiddev.c b/hald/linux2/probing/probe-hiddev.c index 9e8839b8..fbc1861a 100644 --- a/hald/linux2/probing/probe-hiddev.c +++ b/hald/linux2/probing/probe-hiddev.c @@ -27,19 +27,15 @@ # include <config.h> #endif -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/ioctl.h> -#include <stdint.h> -#include <sys/stat.h> -#include <stdint.h> -#include <fcntl.h> -#include <unistd.h> /* asm/types.h required for __s32 in linux/hiddev.h */ #include <asm/types.h> +#include <fcntl.h> #include <linux/hiddev.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <unistd.h> #include "libhal/libhal.h" diff --git a/hald/linux2/probing/probe-input.c b/hald/linux2/probing/probe-input.c index 9e8191c6..0c921ac3 100644 --- a/hald/linux2/probing/probe-input.c +++ b/hald/linux2/probing/probe-input.c @@ -27,17 +27,15 @@ # include <config.h> #endif +#include <errno.h> +#include <fcntl.h> +#include <linux/input.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <errno.h> -#include <stdint.h> -#include <sys/stat.h> -#include <fcntl.h> #include <unistd.h> -#include <linux/input.h> - #include "libhal/libhal.h" #include "shared.h" diff --git a/hald/linux2/probing/probe-pc-floppy.c b/hald/linux2/probing/probe-pc-floppy.c index 35b5567f..0a48c846 100644 --- a/hald/linux2/probing/probe-pc-floppy.c +++ b/hald/linux2/probing/probe-pc-floppy.c @@ -27,20 +27,15 @@ # include <config.h> #endif -#include <errno.h> -#include <string.h> -#include <stdlib.h> +#include <fcntl.h> +#include <linux/fd.h> +#include <linux/kdev_t.h> +#include <stdint.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sys/ioctl.h> -#include <stdint.h> -#include <sys/stat.h> -#include <stdint.h> -#include <fcntl.h> #include <unistd.h> -#include <linux/kdev_t.h> -#include <linux/cdrom.h> -#include <linux/fs.h> -#include <linux/fd.h> #include "libhal/libhal.h" diff --git a/hald/linux2/probing/probe-printer.c b/hald/linux2/probing/probe-printer.c index d97dfe78..0da9c603 100644 --- a/hald/linux2/probing/probe-printer.c +++ b/hald/linux2/probing/probe-printer.c @@ -25,15 +25,12 @@ # include <config.h> #endif -#include <errno.h> -#include <string.h> -#include <stdlib.h> +#include <fcntl.h> +#include <stdint.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sys/ioctl.h> -#include <stdint.h> -#include <sys/stat.h> -#include <stdint.h> -#include <fcntl.h> #include <unistd.h> #include <glib.h> diff --git a/hald/linux2/probing/probe-serial.c b/hald/linux2/probing/probe-serial.c index e0e617e3..3f53ef2c 100644 --- a/hald/linux2/probing/probe-serial.c +++ b/hald/linux2/probing/probe-serial.c @@ -28,17 +28,14 @@ # include <config.h> #endif -#include <errno.h> -#include <string.h> -#include <stdlib.h> +#include <fcntl.h> +#include <linux/serial.h> +#include <stdint.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sys/ioctl.h> -#include <stdint.h> -#include <sys/stat.h> -#include <stdint.h> -#include <fcntl.h> #include <unistd.h> -#include <linux/serial.h> #include "libhal/libhal.h" diff --git a/hald/linux2/probing/probe-smbios.c b/hald/linux2/probing/probe-smbios.c index d44f09e7..6e20a684 100644 --- a/hald/linux2/probing/probe-smbios.c +++ b/hald/linux2/probing/probe-smbios.c @@ -28,14 +28,12 @@ # include <config.h> #endif +#include <ctype.h> +#include <fcntl.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <stdint.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> #include <string.h> -#include <ctype.h> #include "libhal/libhal.h" #include "shared.h" diff --git a/hald/linux2/probing/probe-storage.c b/hald/linux2/probing/probe-storage.c index 75f0b8b0..9bfbbb0a 100644 --- a/hald/linux2/probing/probe-storage.c +++ b/hald/linux2/probing/probe-storage.c @@ -28,21 +28,18 @@ # include <config.h> #endif +#include <ctype.h> #include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/ioctl.h> -#include <stdint.h> -#include <sys/stat.h> -#include <stdint.h> #include <fcntl.h> -#include <unistd.h> -#include <ctype.h> #include <linux/kdev_t.h> #include <linux/cdrom.h> #include <linux/fs.h> #include <mntent.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> #include <glib.h> #include <libvolume_id.h> diff --git a/hald/linux2/probing/probe-volume.c b/hald/linux2/probing/probe-volume.c index b484b61b..b70bd55f 100644 --- a/hald/linux2/probing/probe-volume.c +++ b/hald/linux2/probing/probe-volume.c @@ -28,22 +28,17 @@ # include <config.h> #endif +#include <ctype.h> #include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/ioctl.h> -#include <stdint.h> -#include <sys/stat.h> -#include <stdint.h> #include <fcntl.h> -#include <unistd.h> -#include <ctype.h> -#include <linux/kdev_t.h> #include <linux/cdrom.h> #include <linux/fs.h> -#include <time.h> -#include <sys/time.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> +#include <unistd.h> #include <glib.h> #include <libvolume_id.h> diff --git a/hald/logger.c b/hald/logger.c index 2dc1cc46..f3a5cde6 100644 --- a/hald/logger.c +++ b/hald/logger.c @@ -33,7 +33,7 @@ #include <stdarg.h> #include <time.h> #include <sys/time.h> -#include <sys/syslog.h> +#include <syslog.h> #include "logger.h" diff --git a/hald/util.c b/hald/util.c index 786b2691..8f3233be 100644 --- a/hald/util.c +++ b/hald/util.c @@ -36,8 +36,10 @@ #include <stdint.h> #include <sys/stat.h> #include <unistd.h> +#include <fcntl.h> #include <signal.h> #include <sys/wait.h> +#include <sys/file.h> #include <glib.h> #include <dbus/dbus.h> @@ -1124,3 +1126,117 @@ hal_util_hexdump (const void *mem, unsigned int size) } } +gboolean +hal_util_is_mounted_by_hald (const char *mount_point) +{ + int i; + FILE *hal_mtab; + int hal_mtab_len; + int num_read; + char *hal_mtab_buf; + char **lines; + gboolean found; + int lock_mtab_fd; + + hal_mtab = NULL; + hal_mtab_buf = NULL; + found = FALSE; + + /* take the lock on /media/.hal-mtab-lock so we don't race with the Mount() and Unmount() methods */ + + /* do not attempt to create the file; tools/hal-storage-shared.c will create it and + * set the correct ownership so this unprivileged process (running as haldaemon) can + * lock it too + */ + lock_mtab_fd = open ("/media/.hal-mtab-lock", 0); + if (lock_mtab_fd < 0) { + HAL_INFO (("Cannot open /media/.hal-mtab for locking")); + goto out; + } + +tryagain: +#ifdef sun + if (lockf (lock_mtab_fd, F_LOCK, 0) != 0) { +#else + if (flock (lock_mtab_fd, LOCK_EX) != 0) { +#endif + if (errno == EINTR) + goto tryagain; + HAL_ERROR (("Cannot obtain lock on /media/.hal-mtab")); + goto out; + } + + /*HAL_DEBUG (("examining /media/.hal-mtab for %s", mount_point));*/ + + hal_mtab = fopen ("/media/.hal-mtab", "r"); + if (hal_mtab == NULL) { + HAL_ERROR (("Cannot open /media/.hal-mtab")); + goto out; + } + if (fseek (hal_mtab, 0L, SEEK_END) != 0) { + HAL_ERROR (("Cannot seek to end of /media/.hal-mtab")); + goto out; + } + hal_mtab_len = ftell (hal_mtab); + if (hal_mtab_len < 0) { + HAL_ERROR (("Cannot determine size of /media/.hal-mtab")); + goto out; + } + rewind (hal_mtab); + + hal_mtab_buf = g_new0 (char, hal_mtab_len + 1); + num_read = fread (hal_mtab_buf, 1, hal_mtab_len, hal_mtab); + if (num_read != hal_mtab_len) { + HAL_ERROR (("Cannot read from /media/.hal-mtab")); + goto out; + } + fclose (hal_mtab); + hal_mtab = NULL; + + /*HAL_DEBUG (("hal_mtab = '%s'\n", hal_mtab_buf));*/ + + lines = g_strsplit (hal_mtab_buf, "\n", 0); + g_free (hal_mtab_buf); + hal_mtab_buf = NULL; + + /* find the entry we're going to unmount */ + for (i = 0; lines[i] != NULL && !found; i++) { + char **line_elements; + + /*HAL_DEBUG ((" line = '%s'", lines[i]));*/ + + if ((lines[i])[0] == '#') + continue; + + line_elements = g_strsplit (lines[i], "\t", 6); + if (g_strv_length (line_elements) == 6) { +/* + HAL_DEBUG ((" devfile = '%s'", line_elements[0])); + HAL_DEBUG ((" uid = '%s'", line_elements[1])); + HAL_DEBUG ((" session id = '%s'", line_elements[2])); + HAL_DEBUG ((" fs = '%s'", line_elements[3])); + HAL_DEBUG ((" options = '%s'", line_elements[4])); + HAL_DEBUG ((" mount_point = '%s'", line_elements[5])); + HAL_DEBUG ((" (comparing against '%s')", mount_point)); +*/ + + if (strcmp (line_elements[5], mount_point) == 0) { + found = TRUE; + /*HAL_INFO (("device at '%s' is indeed mounted by HAL's Mount()", mount_point));*/ + } + + } + + g_strfreev (line_elements); + } + +out: + if (lock_mtab_fd >= 0) + close (lock_mtab_fd); + if (hal_mtab != NULL) + fclose (hal_mtab); + if (hal_mtab_buf != NULL) + g_free (hal_mtab_buf); + + return found; +} diff --git a/hald/util.h b/hald/util.h index 98ca5fa6..98d0ea34 100644 --- a/hald/util.h +++ b/hald/util.h @@ -109,4 +109,6 @@ gchar *hal_util_strdup_valid_utf8 (const char *str); void hal_util_hexdump (const void *buf, unsigned int size); +gboolean hal_util_is_mounted_by_hald (const char *mount_point); + #endif /* UTIL_H */ diff --git a/libhal/libhal.c b/libhal/libhal.c index b7eae2ec..ecc5df95 100644 --- a/libhal/libhal.c +++ b/libhal/libhal.c @@ -375,7 +375,7 @@ libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError DBusError _error; LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL); - + message = dbus_message_new_method_call ("org.freedesktop.Hal", udi, "org.freedesktop.Hal.Device", "GetAllProperties"); @@ -911,8 +911,8 @@ libhal_device_get_property_type (LibHalContext *ctx, const char *udi, const char int type; DBusError _error; - LIBHAL_CHECK_LIBHALCONTEXT(ctx, LIBHAL_PROPERTY_TYPE_INVALID); // or return NULL? - + LIBHAL_CHECK_LIBHALCONTEXT(ctx, LIBHAL_PROPERTY_TYPE_INVALID); /* or return NULL? */ + message = dbus_message_new_method_call ("org.freedesktop.Hal", udi, "org.freedesktop.Hal.Device", "GetPropertyType"); @@ -1398,7 +1398,7 @@ libhal_device_set_property_helper (LibHalContext *ctx, char *method_name = NULL; LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - + /** @todo sanity check incoming params */ switch (type) { case DBUS_TYPE_INVALID: @@ -3070,7 +3070,7 @@ dbus_bool_t libhal_ctx_set_device_added (LibHalContext *ctx, LibHalDeviceAdded callback) { LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - + ctx->device_added = callback; return TRUE; } @@ -3088,7 +3088,7 @@ dbus_bool_t libhal_ctx_set_device_removed (LibHalContext *ctx, LibHalDeviceRemoved callback) { LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - + ctx->device_removed = callback; return TRUE; } @@ -3106,7 +3106,7 @@ dbus_bool_t libhal_ctx_set_device_new_capability (LibHalContext *ctx, LibHalDeviceNewCapability callback) { LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - + ctx->device_new_capability = callback; return TRUE; } @@ -3124,7 +3124,7 @@ dbus_bool_t libhal_ctx_set_device_lost_capability (LibHalContext *ctx, LibHalDeviceLostCapability callback) { LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - + ctx->device_lost_capability = callback; return TRUE; } @@ -3142,7 +3142,7 @@ dbus_bool_t libhal_ctx_set_device_property_modified (LibHalContext *ctx, LibHalDevicePropertyModified callback) { LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - + ctx->device_property_modified = callback; return TRUE; } @@ -3160,7 +3160,7 @@ dbus_bool_t libhal_ctx_set_device_condition (LibHalContext *ctx, LibHalDeviceCondition callback) { LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - + ctx->device_condition = callback; return TRUE; } @@ -3201,13 +3201,13 @@ libhal_string_array_length (char **str_array) dbus_bool_t libhal_device_rescan (LibHalContext *ctx, const char *udi, DBusError *error) { - LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - DBusMessage *message; DBusMessageIter reply_iter; DBusMessage *reply; dbus_bool_t result; + LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); + message = dbus_message_new_method_call ("org.freedesktop.Hal", udi, "org.freedesktop.Hal.Device", "Rescan"); @@ -3260,13 +3260,13 @@ libhal_device_rescan (LibHalContext *ctx, const char *udi, DBusError *error) dbus_bool_t libhal_device_reprobe (LibHalContext *ctx, const char *udi, DBusError *error) { - LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - DBusMessage *message; DBusMessageIter reply_iter; DBusMessage *reply; dbus_bool_t result; + LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); + message = dbus_message_new_method_call ("org.freedesktop.Hal", udi, "org.freedesktop.Hal.Device", @@ -3326,14 +3326,14 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx, const char *condition_details, DBusError *error) { - LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - DBusMessage *message; DBusMessageIter iter; DBusMessageIter reply_iter; DBusMessage *reply; dbus_bool_t result; + LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); + message = dbus_message_new_method_call ("org.freedesktop.Hal", udi, "org.freedesktop.Hal.Device", @@ -3399,14 +3399,14 @@ libhal_device_claim_interface (LibHalContext *ctx, const char *introspection_xml, DBusError *error) { - LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); - DBusMessage *message; DBusMessageIter iter; DBusMessageIter reply_iter; DBusMessage *reply; dbus_bool_t result; + LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE); + message = dbus_message_new_method_call ("org.freedesktop.Hal", udi, "org.freedesktop.Hal.Device", diff --git a/tools/Makefile.am b/tools/Makefile.am index 888d03e3..bcfbf59c 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -20,7 +20,7 @@ INCLUDES = \ -DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \ -DPACKAGE_SCRIPT_DIR=\""$(datadir)/hal/scripts"\" \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ - -I$(top_srcdir) -I$(top_srcdir)/libhal \ + -I$(top_srcdir) -I$(top_srcdir)/libhal -I$(top_srcdir)/libhal-storage \ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @POLKIT_CFLAGS@ bin_PROGRAMS = \ diff --git a/tools/gen-libgphoto-hal-fdi b/tools/gen-libgphoto-hal-fdi index f932f56b..d26ff889 100755 --- a/tools/gen-libgphoto-hal-fdi +++ b/tools/gen-libgphoto-hal-fdi @@ -7,7 +7,7 @@ # tweaked by David Zeuthen <david@fubar.dk>. cat <<EOF -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <!-- To get back the original script which generated this file, use: cat libgphoto2.fdi | uudecode | gunzip >gen-libgphoto-hal-fdi diff --git a/tools/hal-device.c b/tools/hal-device.c index 9bc57a65..a37d2d6e 100644 --- a/tools/hal-device.c +++ b/tools/hal-device.c @@ -45,7 +45,7 @@ #endif #include <dbus/dbus.h> -#include <libhal/libhal.h> +#include <libhal.h> typedef struct { char *udi; diff --git a/tools/hal-storage-eject.c b/tools/hal-storage-eject.c index 6cb8ab42..516d078e 100644 --- a/tools/hal-storage-eject.c +++ b/tools/hal-storage-eject.c @@ -34,8 +34,8 @@ #include <sys/types.h> #include <unistd.h> -#include <libhal/libhal.h> -#include <libhal-storage/libhal-storage.h> +#include <libhal.h> +#include <libhal-storage.h> #ifdef HAVE_POLKIT #include <libpolkit.h> #endif diff --git a/tools/hal-storage-mount.c b/tools/hal-storage-mount.c index 37d7d6b5..3da83b81 100644 --- a/tools/hal-storage-mount.c +++ b/tools/hal-storage-mount.c @@ -49,8 +49,8 @@ #include <errno.h> #include <syslog.h> -#include <libhal/libhal.h> -#include <libhal-storage/libhal-storage.h> +#include <libhal.h> +#include <libhal-storage.h> #ifdef HAVE_POLKIT #include <libpolkit.h> #endif diff --git a/tools/hal-storage-shared.h b/tools/hal-storage-shared.h index 34b9f1ee..f87d5d18 100644 --- a/tools/hal-storage-shared.h +++ b/tools/hal-storage-shared.h @@ -24,8 +24,8 @@ #ifndef HAL_STORAGE_SHARED_H #define HAL_STORAGE_SHARED_H -#include <libhal/libhal.h> -#include <libhal-storage/libhal-storage.h> +#include <libhal.h> +#include <libhal-storage.h> #ifdef HAVE_POLKIT #include <libpolkit.h> #endif diff --git a/tools/hal-storage-unmount.c b/tools/hal-storage-unmount.c index 112adc20..d1239f70 100644 --- a/tools/hal-storage-unmount.c +++ b/tools/hal-storage-unmount.c @@ -48,8 +48,8 @@ #include <sys/types.h> #include <unistd.h> -#include <libhal/libhal.h> -#include <libhal-storage/libhal-storage.h> +#include <libhal.h> +#include <libhal-storage.h> #ifdef HAVE_POLKIT #include <libpolkit.h> #endif diff --git a/tools/hal_find_by_capability.c b/tools/hal_find_by_capability.c index a4b95ef1..20a7666e 100644 --- a/tools/hal_find_by_capability.c +++ b/tools/hal_find_by_capability.c @@ -33,7 +33,7 @@ #include <unistd.h> #include <getopt.h> -#include <libhal/libhal.h> +#include <libhal.h> /** Print out program usage. diff --git a/tools/hal_find_by_property.c b/tools/hal_find_by_property.c index 8c25710d..f9344fd3 100644 --- a/tools/hal_find_by_property.c +++ b/tools/hal_find_by_property.c @@ -33,7 +33,7 @@ #include <unistd.h> #include <getopt.h> -#include <libhal/libhal.h> +#include <libhal.h> /** Print out program usage. diff --git a/tools/hal_get_property.c b/tools/hal_get_property.c index 6df4a161..c2ec717d 100644 --- a/tools/hal_get_property.c +++ b/tools/hal_get_property.c @@ -33,7 +33,7 @@ #include <unistd.h> #include <getopt.h> -#include <libhal/libhal.h> +#include <libhal.h> /** * @defgroup HalGetProperty Get HAL device property diff --git a/tools/hal_set_property.c b/tools/hal_set_property.c index 7bb6094d..eaeb7fc5 100644 --- a/tools/hal_set_property.c +++ b/tools/hal_set_property.c @@ -34,7 +34,7 @@ #include <unistd.h> #include <getopt.h> -#include "libhal/libhal.h" +#include <libhal.h> static LibHalContext *hal_ctx; diff --git a/tools/lshal.c b/tools/lshal.c index 683f9b36..cb4fd157 100644 --- a/tools/lshal.c +++ b/tools/lshal.c @@ -38,7 +38,7 @@ #include <glib.h> #include <dbus/dbus-glib-lowlevel.h> #include <dbus/dbus-glib.h> -#include <libhal/libhal.h> +#include <libhal.h> #ifdef __SUNPRO_C #define __FUNCTION__ __func__ @@ -462,7 +462,7 @@ print_property (const char *udi, const char *key) } if (dbus_error_is_set (&error)) - LIBHAL_FREE_DBUS_ERROR (&error); + dbus_error_free (&error); } /** Invoked when a property of a device in the Global Device List is |