pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/sysutils/hal Since people are bumping pkgrevison on th...
details: https://anonhg.NetBSD.org/pkgsrc/rev/e1c969d763d4
branches: trunk
changeset: 552089:e1c969d763d4
user: jmcneill <jmcneill%pkgsrc.org@localhost>
date: Fri Dec 26 15:30:06 2008 +0000
description:
Since people are bumping pkgrevison on this anyway..
hald-netbsd: use scsi identify to fill in storage.vendor/storage.model
where available so hal-info fdi matching rules will apply
hald-netbsd: if libvolume_id thinks that a partition is vfat, believe it
over the disklabel (stops USB devices lacking partition tables such as
an iPod from incorrectly being treated as ffs).
diffstat:
sysutils/hal/Makefile | 4 +-
sysutils/hal/files/hald-netbsd/devinfo_mass.c | 82 ++++++++++++++++++++++-
sysutils/hal/files/hald-netbsd/devinfo_optical.c | 2 +-
3 files changed, 79 insertions(+), 9 deletions(-)
diffs (183 lines):
diff -r bd4e2a4bd653 -r e1c969d763d4 sysutils/hal/Makefile
--- a/sysutils/hal/Makefile Fri Dec 26 13:31:37 2008 +0000
+++ b/sysutils/hal/Makefile Fri Dec 26 15:30:06 2008 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.28 2008/12/26 11:36:31 ahoka Exp $
+# $NetBSD: Makefile,v 1.29 2008/12/26 15:30:06 jmcneill Exp $
#
DISTNAME= hal-0.5.11
-PKGREVISION= 17
+PKGREVISION= 18
CATEGORIES= sysutils
MASTER_SITES= http://hal.freedesktop.org/releases/
EXTRACT_SUFX= .tar.bz2
diff -r bd4e2a4bd653 -r e1c969d763d4 sysutils/hal/files/hald-netbsd/devinfo_mass.c
--- a/sysutils/hal/files/hald-netbsd/devinfo_mass.c Fri Dec 26 13:31:37 2008 +0000
+++ b/sysutils/hal/files/hald-netbsd/devinfo_mass.c Fri Dec 26 15:30:06 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: devinfo_mass.c,v 1.1 2008/12/01 02:02:33 jmcneill Exp $ */
+/* $NetBSD: devinfo_mass.c,v 1.2 2008/12/26 15:30:06 jmcneill Exp $ */
/*-
* Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -33,6 +33,9 @@
#include <sys/disklabel.h>
#include <sys/bootblock.h>
#include <sys/ioctl.h>
+#include <sys/scsiio.h>
+#include <dev/scsipi/scsipi_all.h>
+#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -57,6 +60,9 @@
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);
+/* XXX from devinfo_optical */
+extern bool scsi_command(int, void *, size_t, void *, size_t, int, int);
+
DevinfoDevHandler devinfo_mass_handler = {
devinfo_mass_add,
NULL,
@@ -74,6 +80,24 @@
NULL
};
+static char *
+rtrim_copy(char *src, int len)
+{
+ char *dst, *p;
+
+ if (len == 0) {
+ len = strlen(src);
+ }
+ if ((dst = calloc(1, len + 1)) != NULL) {
+ strncpy(dst, src, len);
+ p = dst + len - 1;
+ while ((p >= dst) && (isspace((int)*p))) {
+ *p-- = '\0';
+ }
+ }
+ return (dst);
+}
+
static const char *
devinfo_mass_get_fstype(uint8_t fstype)
{
@@ -111,16 +135,21 @@
HalDevice *
devinfo_mass_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
{
- HalDevice *d = NULL;
+ HalDevice *d = NULL, *gparent = NULL;
prop_dictionary_t dict;
struct disklabel label;
struct stat st;
const char *driver;
char *rdevpath, *devpath;
char *childnode;
- char *parent_devnode;
+ char *parent_devnode, *gparent_devnode = NULL;
+ char *gparent_udi;
int16_t unit;
int i, fd;
+ struct scsipi_inquiry_data inqbuf;
+ struct scsipi_inquiry cmd;
+ bool scsiinq_status;
+ char *storage_model = NULL, *storage_vendor = NULL;
if (drvctl_find_device (devnode, &dict) == FALSE || dict == NULL)
return NULL;
@@ -158,6 +187,16 @@
return NULL;
}
+ if (strcmp (driver, "sd") == 0) {
+ memset(&cmd, 0, sizeof (cmd));
+ memset(&inqbuf, 0, sizeof (inqbuf));
+ cmd.opcode = INQUIRY;
+ cmd.length = sizeof (inqbuf);
+
+ scsiinq_status = scsi_command (fd, &cmd, sizeof (cmd), &inqbuf, sizeof (inqbuf), 10000, SCCMD_READ);
+ } else
+ scsiinq_status = false;
+
close (fd);
d = hal_device_new ();
@@ -178,7 +217,13 @@
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)
+ gparent_udi = hal_device_property_get_string (parent, "info.parent");
+ if (gparent_udi) {
+ gparent = hal_device_store_find (hald_get_gdl (), gparent_udi);
+ if (gparent)
+ gparent_devnode = hal_device_property_get_string (gparent, "netbsd.device");
+ }
+ if (gparent_devnode && strstr (gparent_devnode, "umass") == gparent_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");
@@ -207,8 +252,23 @@
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);
+
+ if (scsiinq_status == true) {
+ storage_model = rtrim_copy(inqbuf.product, sizeof (inqbuf.product));
+ storage_vendor = rtrim_copy(inqbuf.vendor, sizeof (inqbuf.vendor));
+ }
+
+ if (storage_model) {
+ hal_device_property_set_string (d, "storage.model", storage_model);
+ free (storage_model);
+ } else
+ hal_device_property_set_string (d, "storage.model", label.d_packname);
+
+ if (storage_vendor) {
+ hal_device_property_set_string (d, "storage.vendor", storage_vendor);
+ free (storage_vendor);
+ } else
+ hal_device_property_set_string (d, "storage.vendor", label.d_typename);
devinfo_add_enqueue (d, devfs_path, &devinfo_mass_handler);
@@ -322,10 +382,20 @@
vid = volume_id_open_fd (fd);
if (vid) {
if (volume_id_probe_all (vid, 0, psize) == 0) {
+ char *type;
+
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);
+
+ if (volume_id_get_type (vid, &type) && type != NULL)
+ if (strcmp (type, "vfat") == 0) {
+ HAL_INFO (("%s disklabel reports %s but libvolume_id says it is "
+ "%s, assuming disklabel is incorrect",
+ devpath, devinfo_mass_get_fstype (part->p_fstype)));
+ hal_device_property_set_string (d, "volume.fstype", type);
+ }
}
volume_id_close (vid);
}
diff -r bd4e2a4bd653 -r e1c969d763d4 sysutils/hal/files/hald-netbsd/devinfo_optical.c
--- a/sysutils/hal/files/hald-netbsd/devinfo_optical.c Fri Dec 26 13:31:37 2008 +0000
+++ b/sysutils/hal/files/hald-netbsd/devinfo_optical.c Fri Dec 26 15:30:06 2008 +0000
@@ -95,7 +95,7 @@
/* XXX i dont know how to link cdutils here XXX ! */
-static bool
+bool
scsi_command (int fd, void *cmd, size_t cmdlen, void *data, size_t datalen,
int timeout, int flags)
{
Home |
Main Index |
Thread Index |
Old Index