summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmcneill <jmcneill@pkgsrc.org>2008-12-01 02:02:33 +0000
committerjmcneill <jmcneill@pkgsrc.org>2008-12-01 02:02:33 +0000
commit040f3e646d1499d6225902ac3593f15c634fc5be (patch)
tree702709299e5329bb8a024772bc5810f79bd40cba
parent5e0075b6e72f2c861353a21db463d0d8249b87c0 (diff)
downloadpkgsrc-040f3e646d1499d6225902ac3593f15c634fc5be.tar.gz
hald-netbsd: add basic support for automounting non-optical media. Still
some bugs to work out, but it's a start. Bump PKGREVISION.
-rw-r--r--sysutils/hal/Makefile17
-rw-r--r--sysutils/hal/distinfo4
-rw-r--r--sysutils/hal/files/hald-netbsd/Makefile.am7
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo.c2
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo_mass.c341
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo_mass.h37
-rw-r--r--sysutils/hal/files/hald-netbsd/osspec.c20
-rw-r--r--sysutils/hal/files/hald-netbsd/vfsstat.c157
-rw-r--r--sysutils/hal/files/hald-netbsd/vfsstat.h36
-rw-r--r--sysutils/hal/patches/patch-aa71
10 files changed, 656 insertions, 36 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile
index 193653a32a6..4866ad51b33 100644
--- a/sysutils/hal/Makefile
+++ b/sysutils/hal/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.14 2008/11/27 22:19:10 jmcneill Exp $
+# $NetBSD: Makefile,v 1.15 2008/12/01 02:02:33 jmcneill Exp $
#
DISTNAME= hal-0.5.11
-PKGREVISION= 10
+PKGREVISION= 11
CATEGORIES= sysutils
MASTER_SITES= http://hal.freedesktop.org/releases/
EXTRACT_SUFX= .tar.bz2
@@ -13,9 +13,6 @@ COMMENT= FreeDesktop hardware abstraction layer
BUILD_DEFS+= VARBASE
-HAL_USER?= haldaemon
-HAL_GROUP?= haldaemon
-
GNU_CONFIGURE= YES
USE_DIRS+= xdg-1.4
USE_PKGLOCALEDIR= YES
@@ -33,8 +30,6 @@ CONF_FILES= ${EGDIR}/hal.conf ${PREFIX}/etc/dbus-1/system.d/hal.conf
CONFIGURE_ARGS+= --localstatedir=${VARBASE}
CONFIGURE_ARGS+= --with-pci-ids=${PREFIX}/share/pciids
CONFIGURE_ARGS+= --with-usb-ids=${PREFIX}/share/usbids
-CONFIGURE_ARGS+= --with-hal-user=${HAL_USER}
-CONFIGURE_ARGS+= --with-hal-group=${HAL_GROUP}
.include "../../mk/bsd.prefs.mk"
@@ -47,6 +42,7 @@ PLIST_SRC= PLIST.FreeBSD PLIST
.if !empty(MACHINE_PLATFORM:MNetBSD-[5-9]*)
CONFIGURE_ARGS+= --with-backend=netbsd
PLIST_SRC= PLIST.NetBSD PLIST
+HAL_GROUP= operator
.elif ${OPSYS} == "NetBSD"
# Pull in the dummy backend for older NetBSD
CONFIGURE_ARGS+= --with-backend=dummy
@@ -65,9 +61,16 @@ REPLACE.bash.new= ${SH}
REPLACE_FILES.bash+= tools/hal-${halscript}
.endfor
+HAL_USER?= haldaemon
+HAL_GROUP?= haldaemon
+CONFIGURE_ARGS+= --with-hal-user=${HAL_USER}
+CONFIGURE_ARGS+= --with-hal-group=${HAL_GROUP}
+
RCD_SCRIPTS= hal
+.if ${HAL_GROUP} != "operator"
PKG_GROUPS= ${HAL_GROUP}
+.endif
PKG_USERS= ${HAL_USER}:${HAL_GROUP}
PKG_HOME.haldaemon= ${VARBASE}/run/hal
diff --git a/sysutils/hal/distinfo b/sysutils/hal/distinfo
index 497da06f0f6..674680ffe9d 100644
--- a/sysutils/hal/distinfo
+++ b/sysutils/hal/distinfo
@@ -1,9 +1,9 @@
-$NetBSD: distinfo,v 1.6 2008/11/27 03:32:19 jmcneill Exp $
+$NetBSD: distinfo,v 1.7 2008/12/01 02:02:33 jmcneill Exp $
SHA1 (hal-0.5.11.tar.bz2) = 1ddb7895d2ddc2464b553ad11f7ba38860478ae9
RMD160 (hal-0.5.11.tar.bz2) = 741cfe82f0bc2d67106b24cfe526a754ab36e45f
Size (hal-0.5.11.tar.bz2) = 1281251 bytes
-SHA1 (patch-aa) = 120079700424a3c199b58f87bb3f160263f84ce1
+SHA1 (patch-aa) = 1380aca775e5be6b21f755bc36656163394a9c32
SHA1 (patch-ab) = 8712f8bd3ab5d4f7f6d4ea2c30c11f8384615772
SHA1 (patch-ac) = cffdb9caa947366ff88310a750ab502bd2d98db8
SHA1 (patch-ad) = 2a2732f82a4fd8d7ffa311b4a0e747208dc9ad1c
diff --git a/sysutils/hal/files/hald-netbsd/Makefile.am b/sysutils/hal/files/hald-netbsd/Makefile.am
index 95adf63394b..6f278ee4e8c 100644
--- a/sysutils/hal/files/hald-netbsd/Makefile.am
+++ b/sysutils/hal/files/hald-netbsd/Makefile.am
@@ -8,16 +8,17 @@ AM_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
-I$(top_srcdir) -I.. \
- @GLIB_CFLAGS@ @DBUS_CFLAGS@ @POLKIT_CFLAGS@
+ @GLIB_CFLAGS@ @DBUS_CFLAGS@ @POLKIT_CFLAGS@ @VOLUME_ID_CFLAGS@
if HALD_COMPILE_NETBSD
noinst_LTLIBRARIES = libhald_netbsd.la
endif
libhald_netbsd_la_SOURCES = \
- osspec.c drvctl.c envsys.c \
+ osspec.c drvctl.c envsys.c vfsstat.c \
devinfo.c devinfo_misc.c devinfo_audio.c devinfo_video.c \
+ devinfo_mass.c \
hotplug.c hal-file-monitor.c
# devinfo_pci.c devinfo_storage.c devinfo_usb.c
-libhald_netbsd_la_LDFLAGS = -lprop
+libhald_netbsd_la_LDFLAGS = -lprop @VOLUME_ID_LIBS@
diff --git a/sysutils/hal/files/hald-netbsd/devinfo.c b/sysutils/hal/files/hald-netbsd/devinfo.c
index 9e894b80571..a92f4929fa2 100644
--- a/sysutils/hal/files/hald-netbsd/devinfo.c
+++ b/sysutils/hal/files/hald-netbsd/devinfo.c
@@ -32,6 +32,7 @@
#include "devinfo_video.h"
#include "devinfo_pci.h"
#include "devinfo_storage.h"
+#include "devinfo_mass.h"
#include "devinfo_usb.h"
#include "devinfo_misc.h"
#include "devinfo_cpu.h"
@@ -153,6 +154,7 @@ static DevinfoDevHandler *devinfo_handlers[] = {
&devinfo_audio_mixer_handler,
&devinfo_audio_dsp_handler,
&devinfo_video_handler,
+ &devinfo_mass_handler,
&devinfo_default_handler,
NULL
};
diff --git a/sysutils/hal/files/hald-netbsd/devinfo_mass.c b/sysutils/hal/files/hald-netbsd/devinfo_mass.c
new file mode 100644
index 00000000000..ee355b6c9a9
--- /dev/null
+++ b/sysutils/hal/files/hald-netbsd/devinfo_mass.c
@@ -0,0 +1,341 @@
+/* $NetBSD: devinfo_mass.c,v 1.1 2008/12/01 02:02:33 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/disklabel.h>
+#include <sys/bootblock.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <paths.h>
+#include <unistd.h>
+
+#include "../osspec.h"
+#include "../logger.h"
+#include "../hald.h"
+#include "../hald_dbus.h"
+#include "../device_info.h"
+#include "../util.h"
+#include "../ids.h"
+#include "hotplug.h"
+#include "devinfo.h"
+#include "devinfo_mass.h"
+#include "drvctl.h"
+
+#include <libvolume_id.h>
+
+HalDevice *devinfo_mass_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type);
+HalDevice *devinfo_mass_disklabel_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type);
+
+DevinfoDevHandler devinfo_mass_handler = {
+ devinfo_mass_add,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+DevinfoDevHandler devinfo_mass_disklabel_handler = {
+ devinfo_mass_disklabel_add,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+static const char *
+devinfo_mass_get_fstype(uint8_t fstype)
+{
+ switch (fstype) {
+ case FS_BSDFFS:
+ return "ffs";
+ case FS_MSDOS:
+ return "vfat";
+ case FS_EX2FS:
+ return "ext2";
+ case FS_NTFS:
+ return "ntfs";
+ default:
+ return NULL;
+ }
+}
+
+static uint8_t
+devinfo_mass_get_mbrtype(uint8_t fstype)
+{
+ switch (fstype) {
+ case FS_BSDFFS:
+ return MBR_PTYPE_NETBSD;
+ case FS_MSDOS:
+ return MBR_PTYPE_FAT32; /* XXX */
+ case FS_EX2FS:
+ return MBR_PTYPE_LNXEXT2;
+ case FS_NTFS:
+ return MBR_PTYPE_NTFS;
+ default:
+ return MBR_PTYPE_UNUSED;
+ }
+}
+
+HalDevice *
+devinfo_mass_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
+{
+ HalDevice *d = NULL;
+ prop_dictionary_t dict;
+ struct disklabel label;
+ struct stat st;
+ const char *driver;
+ char *rdevpath, *devpath;
+ char *childnode;
+ char *parent_devnode;
+ int16_t unit;
+ int i, fd;
+
+ if (drvctl_find_device (devnode, &dict) == FALSE || dict == NULL)
+ return NULL;
+
+ if (prop_dictionary_get_int16 (dict, "device-unit", &unit) == false ||
+ prop_dictionary_get_cstring_nocopy (dict, "device-driver", &driver) == false) {
+ prop_object_release (dict);
+ return NULL;
+ }
+
+ if (strcmp (driver, "wd") != 0 && strcmp (driver, "sd") != 0) {
+ prop_object_release (dict);
+ return NULL;
+ }
+
+ sleep (1);
+
+ devpath = g_strdup_printf ("/dev/%s%c", devnode, RAW_PART + 'a');
+ rdevpath = g_strdup_printf ("/dev/r%s%c", devnode, RAW_PART + 'a');
+ HAL_INFO ((" going to open %s", rdevpath));
+ fd = open (rdevpath, O_RDONLY);
+ if (fd < 0) {
+ HAL_WARNING (("couldn't open %s: %s", rdevpath, strerror (errno)));
+ g_free (rdevpath);
+ g_free (devpath);
+ return NULL;
+ }
+
+ HAL_INFO ((" going to DIOCGDINFO %s", rdevpath));
+ if (ioctl (fd, DIOCGDINFO, &label) == -1) {
+ HAL_WARNING (("DIOCGDINFO failed on %s: %s", rdevpath, strerror (errno)));
+ g_free (rdevpath);
+ g_free (devpath);
+ close (fd);
+ return NULL;
+ }
+
+ close (fd);
+
+ d = hal_device_new ();
+
+ devinfo_set_default_properties (d, parent, devnode, devfs_path);
+
+ hal_device_add_capability (d, "block");
+ hal_device_property_set_string (d, "info.subsystem", "block");
+ hal_device_property_set_string (d, "block.device", devpath);
+ if (stat (devpath, &st) == 0) {
+ hal_device_property_set_int (d, "block.major", major (st.st_rdev));
+ hal_device_property_set_int (d, "block.minor", minor (st.st_rdev));
+ }
+ hal_device_property_set_bool (d, "block.is_volume", FALSE);
+ hal_device_property_set_bool (d, "block.no_partitions", FALSE);
+ hal_device_property_set_bool (d, "block.have_scanned", TRUE);
+
+ hal_device_add_capability (d, "storage");
+ hal_device_property_set_string (d, "info.category", "storage");
+ parent_devnode = hal_device_property_get_string (parent, "netbsd.device");
+ if (strstr (parent_devnode, "umass") == parent_devnode)
+ hal_device_property_set_string (d, "storage.bus", "usb");
+ else if (strstr (parent_devnode, "atabus") == parent_devnode)
+ hal_device_property_set_string (d, "storage.bus", "ide");
+ else
+ hal_device_property_set_string (d, "storage.bus", "scsi");
+ hal_device_property_set_string (d, "storage.device_type", "disk");
+ hal_device_property_set_bool (d, "storage.removable", label.d_flags & D_REMOVABLE ? TRUE : FALSE);
+ if (label.d_flags & D_REMOVABLE) {
+ hal_device_property_set_bool (d, "storage.removable.media_available", TRUE);
+ hal_device_property_set_uint64 (d, "storage.removable.media_size",
+ (uint64_t)label.d_secsize * (uint64_t)label.d_secperunit);
+ hal_device_property_set_uint64 (d, "storage.size", 0);
+ hal_device_property_set_bool (d, "storage.hotpluggable", TRUE);
+ hal_device_property_set_bool (d, "storage.automount_enabled_hint", TRUE);
+ } else {
+ hal_device_property_set_bool (d, "storage.removable.media_available", FALSE);
+ hal_device_property_set_uint64 (d, "storage.removable.media_size", 0);
+ hal_device_property_set_uint64 (d, "storage.size",
+ (uint64_t)label.d_secsize * (uint64_t)label.d_secperunit);
+ hal_device_property_set_bool (d, "storage.hotpluggable", FALSE);
+ hal_device_property_set_bool (d, "storage.automount_enabled_hint", FALSE);
+ }
+ hal_device_property_set_bool (d, "storage.no_partitions_hint", FALSE);
+ hal_device_property_set_bool (d, "storage.requires_eject", FALSE);
+ hal_device_property_set_bool (d, "storage.removable.support_async_notification", FALSE);
+ hal_device_property_set_string (d, "storage.partitioning_scheme", "mbr");
+ hal_device_property_set_string (d, "storage.originating_device",
+ hal_device_property_get_string (d, "info.udi"));
+ hal_device_property_set_string (d, "storage.model", label.d_packname);
+ hal_device_property_set_string (d, "storage.vendor", label.d_typename);
+
+ devinfo_add_enqueue (d, devfs_path, &devinfo_mass_handler);
+
+ for (i = 0; i < MAXPARTITIONS; i++) {
+ const char *fstype;
+
+ fstype = devinfo_mass_get_fstype(label.d_partitions[i].p_fstype);
+ if (fstype == NULL)
+ continue;
+
+ childnode = g_strdup_printf ("%s%c", devnode, 'a' + i);
+ HAL_INFO ((" adding %s on %s", childnode, rdevpath));
+ devinfo_mass_disklabel_add (d, childnode, childnode, childnode);
+ g_free (childnode);
+ }
+
+ HAL_INFO ((" returning"));
+ g_free (rdevpath);
+ g_free (devpath);
+
+done:
+ prop_object_release (dict);
+
+ return d;
+}
+
+HalDevice *
+devinfo_mass_disklabel_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
+{
+ HalDevice *d = NULL;
+ struct disklabel label;
+ struct partition *part;
+ struct stat st;
+ const char *driver;
+ char *devpath, *rdevpath, *partname;
+ char *childnode;
+ char unit;
+ struct volume_id *vid;
+ uint64_t psize, msize;
+ int i, fd;
+
+ partname = devnode;
+ unit = partname[strlen (partname) - 1] - 'a';
+
+ if (unit >= MAXPARTITIONS)
+ return NULL;
+
+ devpath = g_strdup_printf ("/dev/%s", partname);
+ rdevpath = g_strdup_printf ("/dev/r%s", partname);
+ fd = open (rdevpath, O_RDONLY);
+ if (fd < 0) {
+ HAL_WARNING (("couldn't open %s: %s", rdevpath, strerror (errno)));
+ g_free (rdevpath);
+ return NULL;
+ }
+
+ if (ioctl (fd, DIOCGDINFO, &label) == -1) {
+ HAL_WARNING (("DIOCGDINFO failed on %s: %s", rdevpath, strerror (errno)));
+ g_free (rdevpath);
+ close (fd);
+ return NULL;
+ }
+ part = &label.d_partitions[unit];
+
+ d = hal_device_new ();
+
+ devinfo_set_default_properties (d, parent, devnode, devfs_path);
+
+ hal_device_add_capability (d, "block");
+ hal_device_property_set_string (d, "info.subsystem", "block");
+ hal_device_property_set_string (d, "info.category", "volume");
+ hal_device_property_set_string (d, "block.device", devpath);
+ hal_device_property_set_string (d, "block.storage_device",
+ hal_device_property_get_string (parent, "info.udi"));
+
+ if (stat (devpath, &st) == 0) {
+ hal_device_property_set_int (d, "block.major", major (st.st_rdev));
+ hal_device_property_set_int (d, "block.minor", minor (st.st_rdev));
+ }
+
+ hal_device_property_set_bool (d, "block.is_volume", TRUE);
+ hal_device_property_set_bool (d, "block.no_partitions", FALSE);
+ hal_device_property_set_bool (d, "block.have_scanned", TRUE);
+
+ hal_device_add_capability (d, "volume");
+ hal_device_property_set_bool (d, "volume.ignore", FALSE);
+ hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
+ hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE);
+ hal_device_property_set_string (d, "volume.mount_point", "");
+ hal_device_property_set_string (d, "volume.fsusage", "filesystem");
+ hal_device_property_set_string (d, "volume.fstype", devinfo_mass_get_fstype (part->p_fstype));
+ hal_device_property_set_bool (d, "volume.is_disc", FALSE);
+
+ hal_device_property_set_string (d, "volume.label", "");
+ hal_device_property_set_string (d, "volume.partition.label", "");
+ hal_device_property_set_string (d, "volume.uuid", "");
+ hal_device_property_set_string (d, "volume.partition.uuid", "");
+
+ psize = (uint64_t)part->p_size * (uint64_t)label.d_secsize;
+ msize = (uint64_t)label.d_secsize * (uint64_t)label.d_secperunit;
+
+ hal_device_property_set_uint64 (d, "volume.size", psize);
+ hal_device_property_set_int (d, "volume.block_size", label.d_secsize);
+ hal_device_property_set_uint64 (d, "volume.num_blocks", part->p_size);
+ hal_device_property_set_uint64 (d, "volume.partition.media_size", msize);
+
+ hal_device_property_set_bool (d, "volume.is_partition", TRUE);
+ hal_device_property_set_int (d, "volume.partition.number", unit);
+ hal_device_property_set_string (d, "volume.partition.scheme", "mbr");
+
+ vid = volume_id_open_fd (fd);
+ if (vid) {
+ if (volume_id_probe_all (vid, 0, psize) == 0) {
+ hal_device_property_set_string (d, "volume.label", vid->label);
+ hal_device_property_set_string (d, "volume.partition.label", vid->label);
+ hal_device_property_set_string (d, "volume.uuid", vid->uuid);
+ hal_device_property_set_string (d, "volume.partition.uuid", vid->uuid);
+ }
+ volume_id_close (vid);
+ }
+
+ devinfo_add_enqueue (d, devfs_path, &devinfo_mass_disklabel_handler);
+
+ close (fd);
+
+ g_free (rdevpath);
+ g_free (devpath);
+
+ return d;
+}
diff --git a/sysutils/hal/files/hald-netbsd/devinfo_mass.h b/sysutils/hal/files/hald-netbsd/devinfo_mass.h
new file mode 100644
index 00000000000..1b7bdc91f48
--- /dev/null
+++ b/sysutils/hal/files/hald-netbsd/devinfo_mass.h
@@ -0,0 +1,37 @@
+/* $NetBSD: devinfo_mass.h,v 1.1 2008/12/01 02:02:33 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DEVINFO_MASS_H
+#define DEVINFO_MASS_H
+
+#include "devinfo.h"
+
+extern DevinfoDevHandler devinfo_mass_handler;
+extern DevinfoDevHandler devinfo_mass_disklabel_handler;
+
+#endif /* DEVINFO_MASS_H */
diff --git a/sysutils/hal/files/hald-netbsd/osspec.c b/sysutils/hal/files/hald-netbsd/osspec.c
index da891e96f72..44a035dd81a 100644
--- a/sysutils/hal/files/hald-netbsd/osspec.c
+++ b/sysutils/hal/files/hald-netbsd/osspec.c
@@ -164,23 +164,14 @@ dsk_to_rdsk(char *dsk)
static void
mntinfo_event_init ()
{
-#if notyet
- g_timeout_add(1000, mntinfo_timeout, NULL);
-#endif
+ g_timeout_add (1000, mntinfo_timeout, NULL);
}
static gboolean
mntinfo_timeout (gpointer user_data)
{
-#if notyet
- struct statvfs *statvfs;
-
- HAL_INFO (("mntinfo timeout"));
-
- if (!hald_is_initialising) {
- devinfo_storage_mnttab_event (NULL);
- }
-#endif
+ if (!hald_is_initialising)
+ vfsstat_event (NULL);
return TRUE;
}
@@ -188,8 +179,5 @@ mntinfo_timeout (gpointer user_data)
void
osspec_refresh_mount_state_for_block_device (HalDevice *d)
{
-#warning osspec_refresh_mount_state_for_block_device TODO
-#if notyet
- devinfo_storage_mnttab_event (d);
-#endif
+ vfsstat_event (d);
}
diff --git a/sysutils/hal/files/hald-netbsd/vfsstat.c b/sysutils/hal/files/hald-netbsd/vfsstat.c
new file mode 100644
index 00000000000..9a09c0ef531
--- /dev/null
+++ b/sysutils/hal/files/hald-netbsd/vfsstat.c
@@ -0,0 +1,157 @@
+/* $NetBSD: vfsstat.c,v 1.1 2008/12/01 02:02:33 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/statvfs.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <paths.h>
+#include <unistd.h>
+
+#include "../osspec.h"
+#include "../logger.h"
+#include "../hald.h"
+#include "../hald_dbus.h"
+#include "../hald_runner.h"
+#include "../device_info.h"
+#include "../util.h"
+#include "../ids.h"
+#include "hotplug.h"
+#include "devinfo.h"
+#include "vfsstat.h"
+#include "drvctl.h"
+
+static void
+vfsstat_cleanup_mountpoint_cb(HalDevice *d, guint32 exit_type,
+ gint return_code, gchar **error, gpointer data1, gpointer data2)
+{
+ char *mount_point = data1;
+
+ HAL_INFO (("cleaned up mount point %s", mount_point));
+
+ g_free (mount_point);
+}
+
+void
+vfsstat_event(HalDevice *volume)
+{
+ GSList *volumes, *v;
+ HalDevice *d;
+ struct statvfs *statvfs;
+ int nmounts, i;
+
+ if (volume == NULL)
+ volumes = hal_device_store_match_multiple_key_value_string (hald_get_gdl (), "info.category", "volume");
+ else
+ volumes = g_slist_append (NULL, volume);
+
+ if (volumes == NULL)
+ return;
+
+ nmounts = getvfsstat (NULL, 0, ST_WAIT);
+ if (nmounts <= 0)
+ return;
+ statvfs = calloc (nmounts, sizeof (*statvfs));
+ if (statvfs == NULL)
+ return;
+ nmounts = getvfsstat (statvfs, nmounts * sizeof (*statvfs), ST_WAIT);
+ if (nmounts <= 0)
+ goto done;
+
+ for (i = 0; i < nmounts; i++)
+ for (v = volumes; v; v = g_slist_next (v)) {
+ const char *devpath;
+
+ d = HAL_DEVICE (v->data);
+ devpath = hal_device_property_get_string (d, "block.device");
+ if (devpath == NULL || strlen (devpath) == 0)
+ continue;
+ if (strcmp (devpath, statvfs[i].f_mntfromname) != 0)
+ continue;
+
+ device_property_atomic_update_begin ();
+ hal_device_property_set_bool (d, "volume.is_mounted", TRUE);
+ hal_device_property_set_bool (d, "volume.is_mounted_read_only",
+ statvfs[i].f_flag & ST_RDONLY ? TRUE : FALSE);
+ hal_device_property_set_string (d, "volume.mount_point", statvfs[i].f_mntonname);
+ device_property_atomic_update_end ();
+
+ volumes = g_slist_delete_link (volumes, v);
+ }
+
+ for (v = volumes; v; v = g_slist_next (v)) {
+ const char *mount_path;
+
+ d = HAL_DEVICE (v->data);
+ mount_path = g_strdup (hal_device_property_get_string (d, "volume.mount_point"));
+ if (mount_path == NULL || strlen (mount_path) == 0) {
+ if (mount_path)
+ g_free (mount_path);
+ continue;
+ }
+
+ device_property_atomic_update_begin ();
+ hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
+ hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE);
+ hal_device_property_set_string (d, "volume.mount_point", "");
+ device_property_atomic_update_end ();
+
+ if (hal_util_is_mounted_by_hald (mount_path)) {
+ char *cleanup_stdin;
+ char *extra_env[2];
+
+ extra_env[0] = g_strdup_printf ("HALD_CLEANUP=%s", mount_path);
+ extra_env[1] = NULL;
+ cleanup_stdin = "\n";
+
+ hald_runner_run_method (d,
+ "hal-storage-cleanup-mountpoint",
+ extra_env,
+ cleanup_stdin, TRUE,
+ 0,
+ vfsstat_cleanup_mountpoint_cb,
+ g_strdup (mount_path), NULL);
+
+ g_free (extra_env[0]);
+ }
+
+ g_free (mount_path);
+ }
+
+ g_slist_free (volumes);
+
+done:
+ free (statvfs);
+}
diff --git a/sysutils/hal/files/hald-netbsd/vfsstat.h b/sysutils/hal/files/hald-netbsd/vfsstat.h
new file mode 100644
index 00000000000..a78bc7aa527
--- /dev/null
+++ b/sysutils/hal/files/hald-netbsd/vfsstat.h
@@ -0,0 +1,36 @@
+/* $NetBSD: vfsstat.h,v 1.1 2008/12/01 02:02:33 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef VFSSTAT_H
+#define VFSSTAT_H
+
+#include "devinfo.h"
+
+void vfsstat_event(HalDevice *volume);
+
+#endif /* VFSSTAT_H */
diff --git a/sysutils/hal/patches/patch-aa b/sysutils/hal/patches/patch-aa
index 592569e6c41..925eddd66dd 100644
--- a/sysutils/hal/patches/patch-aa
+++ b/sysutils/hal/patches/patch-aa
@@ -1,7 +1,7 @@
-$NetBSD: patch-aa,v 1.2 2008/11/23 21:50:51 hasso Exp $
+$NetBSD: patch-aa,v 1.3 2008/12/01 02:02:33 jmcneill Exp $
---- tools/hal-storage-mount.c.orig 2008-05-08 02:24:23 +0300
-+++ tools/hal-storage-mount.c 2008-11-23 13:25:17 +0200
+--- tools/hal-storage-mount.c.orig 2008-05-07 19:24:23.000000000 -0400
++++ tools/hal-storage-mount.c 2008-11-30 20:50:05.000000000 -0500
@@ -31,7 +31,7 @@
#include <string.h>
#include <glib.h>
@@ -11,7 +11,7 @@ $NetBSD: patch-aa,v 1.2 2008/11/23 21:50:51 hasso Exp $
#include <fstab.h>
#include <sys/param.h>
#include <sys/ucred.h>
-@@ -41,6 +41,10 @@
+@@ -41,6 +41,13 @@
#elif sun
#include <sys/mnttab.h>
#include <sys/vfstab.h>
@@ -19,10 +19,13 @@ $NetBSD: patch-aa,v 1.2 2008/11/23 21:50:51 hasso Exp $
+#include <fstab.h>
+#include <sys/param.h>
+#include <sys/mount.h>
++#include <fcntl.h>
++#include <sys/stat.h>
++#include <unistd.h>
#else
#include <mntent.h>
#endif
-@@ -54,10 +58,14 @@
+@@ -54,10 +61,14 @@
#include "hal-storage-shared.h"
@@ -38,7 +41,7 @@ $NetBSD: patch-aa,v 1.2 2008/11/23 21:50:51 hasso Exp $
#elif sun
#define MOUNT "/sbin/mount"
#define MOUNT_OPTIONS "noexec,nosuid"
-@@ -421,7 +429,7 @@ device_is_mounted (const char *device, c
+@@ -421,7 +432,7 @@ device_is_mounted (const char *device, c
static const char *
map_fstype (const char *fstype)
{
@@ -47,7 +50,7 @@ $NetBSD: patch-aa,v 1.2 2008/11/23 21:50:51 hasso Exp $
if (! strcmp (fstype, "iso9660"))
return "cd9660";
else if (! strcmp (fstype, "ext2"))
-@@ -430,6 +438,13 @@ map_fstype (const char *fstype)
+@@ -430,6 +441,13 @@ map_fstype (const char *fstype)
return "ext2fs";
else if (! strcmp (fstype, "vfat"))
return "msdosfs";
@@ -57,7 +60,59 @@ $NetBSD: patch-aa,v 1.2 2008/11/23 21:50:51 hasso Exp $
+ else if (! strcmp (fstype, "ext2"))
+ return "ext2fs";
+ else if (! strcmp (fstype, "vfat"))
-+ return "msdosfs";
++ return "msdos";
#elif sun
if (! strcmp (fstype, "iso9660"))
return "hsfs";
+@@ -475,6 +493,11 @@ handle_mount (LibHalContext *hal_ctx,
+ uid_t calling_uid;
+ gid_t calling_gid;
+ #endif
++ gboolean have_rump = FALSE;
++#ifdef __NetBSD__
++ char *rump_cmd;
++ struct stat st;
++#endif
+ const char *label;
+ const char *uuid;
+
+@@ -731,7 +754,6 @@ handle_mount (LibHalContext *hal_ctx,
+ /* construct arguments to mount */
+ na = 0;
+
+- args[na++] = MOUNT;
+ if (strlen (mount_fstype) > 0) {
+ mount_do_fstype = (char *) map_fstype (mount_fstype);
+ } else if (volume == NULL) {
+@@ -742,8 +764,29 @@ handle_mount (LibHalContext *hal_ctx,
+ } else {
+ mount_do_fstype = "auto";
+ }
+- args[na++] = MOUNT_TYPE_OPT;
+- args[na++] = mount_do_fstype;
++
++#ifdef __NetBSD__
++ rump_cmd = g_strdup_printf ("/usr/sbin/rump_%s", mount_do_fstype);
++ if (stat (rump_cmd, &st) == 0) {
++ int rump_fd = open ("/dev/puffs", O_RDONLY);
++ if (rump_fd >= 0) {
++ have_rump = TRUE;
++ close (rump_fd);
++ }
++ }
++
++ /* XXX rump_* option handling is different, disable for now */
++ have_rump = FALSE;
++
++ if (have_rump == TRUE)
++ args[na++] = rump_cmd;
++ else
++#endif
++ {
++ args[na++] = MOUNT;
++ args[na++] = MOUNT_TYPE_OPT;
++ args[na++] = mount_do_fstype;
++ }
+
+ args[na++] = "-o";
+ #ifdef HAVE_UMOUNT_HAL