diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/accelerometer/accelerometer.c | 11 | ||||
-rw-r--r-- | src/cdrom_id/cdrom_id.c | 2 | ||||
-rw-r--r-- | src/libudev/Makefile.am | 14 | ||||
-rw-r--r-- | src/scsi_id/scsi_serial.c | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-blkid.c | 16 | ||||
-rw-r--r-- | src/udev/udev-builtin-net_id.c | 49 | ||||
-rw-r--r-- | src/udev/udev-builtin-path_id.c | 17 | ||||
-rw-r--r-- | src/udev/udev-builtin-usb_id.c | 13 | ||||
-rw-r--r-- | src/udev/udevadm-hwdb.c | 8 |
10 files changed, 99 insertions, 35 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index fdcc0711a9..82732ca4bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,7 @@ endif if ENABLE_KEYMAP SUBDIRS += \ - keymap + keymap endif if ENABLE_LEGACYLIB diff --git a/src/accelerometer/accelerometer.c b/src/accelerometer/accelerometer.c index 67fed27c5e..76c64d753b 100644 --- a/src/accelerometer/accelerometer.c +++ b/src/accelerometer/accelerometer.c @@ -257,7 +257,6 @@ int main (int argc, char** argv) char devpath[PATH_MAX]; char *devnode; - const char *id_path; struct udev_enumerate *enumerate; struct udev_list_entry *list_entry; @@ -303,18 +302,10 @@ int main (int argc, char** argv) return 1; } - id_path = udev_device_get_property_value(dev, "ID_PATH"); - if (id_path == NULL) { - fprintf (stderr, "unable to get property ID_PATH for '%s'", devpath); - return 0; - } - /* Get the children devices and find the devnode */ - /* FIXME: use udev_enumerate_add_match_parent() instead */ devnode = NULL; enumerate = udev_enumerate_new(udev); - udev_enumerate_add_match_property(enumerate, "ID_PATH", id_path); - udev_enumerate_add_match_subsystem(enumerate, "input"); + udev_enumerate_add_match_parent(enumerate, dev); udev_enumerate_scan_devices(enumerate); udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(enumerate)) { struct udev_device *device; diff --git a/src/cdrom_id/cdrom_id.c b/src/cdrom_id/cdrom_id.c index 1056536b7d..b659cc31ee 100644 --- a/src/cdrom_id/cdrom_id.c +++ b/src/cdrom_id/cdrom_id.c @@ -513,6 +513,8 @@ static int cd_profiles_old_mmc(struct udev *udev, int fd) if (cd_media == 1) { log_debug("no current profile, but disc is present; assuming CD-ROM\n"); cd_media_cd_rom = 1; + cd_media_track_count = 1; + cd_media_track_count_data = 1; return 0; } else { log_debug("no current profile, assuming no media\n"); diff --git a/src/libudev/Makefile.am b/src/libudev/Makefile.am index 007f0defbd..687764e5e2 100644 --- a/src/libudev/Makefile.am +++ b/src/libudev/Makefile.am @@ -5,13 +5,13 @@ LIBUDEV_REVISION=0 LIBUDEV_AGE=2 define move-to-rootlibdir - if test "$(libdir)" != "$(rootlibdir)"; then \ - $(MKDIR_P) $(DESTDIR)$(rootlibdir) && \ - so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \ - so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\|\)[^/][^/]*,..,g') && \ - ln -sf $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \ - mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \ - fi + if test "$(libdir)" != "$(rootlibdir)"; then \ + $(MKDIR_P) $(DESTDIR)$(rootlibdir) && \ + so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \ + so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\|\)[^/][^/]*,..,g') && \ + ln -sf $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \ + mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \ + fi endef AM_CPPFLAGS = \ diff --git a/src/scsi_id/scsi_serial.c b/src/scsi_id/scsi_serial.c index 3c52dee62d..950b8adc0a 100644 --- a/src/scsi_id/scsi_serial.c +++ b/src/scsi_id/scsi_serial.c @@ -799,7 +799,7 @@ static int do_scsi_page80_inquiry(struct udev *udev, ser_ind = prepend_vendor_model(udev, dev_scsi, &serial[1]); if (ser_ind < 0) return 1; - ser_ind++; /* for the leading 'S' */ + ser_ind++; /* for the leading 'S' */ for (i = 4; i < len + 4; i++, ser_ind++) serial[ser_ind] = buf[i]; } diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 4293103046..e3a89973cb 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -78,6 +78,22 @@ static void print_property(struct udev_device *dev, bool test, const char *name, } else if (startswith(name, "PART_ENTRY_")) { util_strscpyl(s, sizeof(s), "ID_", name, NULL); udev_builtin_add_property(dev, test, s, value); + + } else if (streq(name, "SYSTEM_ID")) { + blkid_encode_string(value, s, sizeof(s)); + udev_builtin_add_property(dev, test, "ID_FS_SYSTEM_ID", s); + + } else if (streq(name, "PUBLISHER_ID")) { + blkid_encode_string(value, s, sizeof(s)); + udev_builtin_add_property(dev, test, "ID_FS_PUBLISHER_ID", s); + + } else if (streq(name, "APPLICATION_ID")) { + blkid_encode_string(value, s, sizeof(s)); + udev_builtin_add_property(dev, test, "ID_FS_APPLICATION_ID", s); + + } else if (streq(name, "BOOT_SYSTEM_ID")) { + blkid_encode_string(value, s, sizeof(s)); + udev_builtin_add_property(dev, test, "ID_FS_BOOT_SYSTEM_ID", s); } } diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 7c9564f4cd..36eec5aec0 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -94,6 +94,7 @@ enum netname_type{ NET_UNDEF, NET_PCI, NET_USB, + NET_BCMA, }; struct netnames { @@ -108,8 +109,9 @@ struct netnames { char pci_onboard[IFNAMSIZ]; const char *pci_onboard_label; - struct udev_device *usbdev; char usb_ports[IFNAMSIZ]; + + char bcma_core[IFNAMSIZ]; }; /* retrieve on-board index number and label from firmware */ @@ -251,7 +253,7 @@ static int names_pci(struct udev_device *dev, struct netnames *names) { if (!parent) return -ENOENT; /* check if our direct parent is a PCI device with no other bus in-between */ - if (streq("pci", udev_device_get_subsystem(parent))) { + if (streq_ptr("pci", udev_device_get_subsystem(parent))) { names->type = NET_PCI; names->pcidev = parent; } else { @@ -265,6 +267,7 @@ static int names_pci(struct udev_device *dev, struct netnames *names) { } static int names_usb(struct udev_device *dev, struct netnames *names) { + struct udev_device *usbdev; char name[256]; char *ports; char *config; @@ -272,12 +275,12 @@ static int names_usb(struct udev_device *dev, struct netnames *names) { size_t l; char *s; - names->usbdev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface"); - if (!names->usbdev) + usbdev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface"); + if (!usbdev) return -ENOENT; /* get USB port number chain, configuration, interface */ - util_strscpy(name, sizeof(name), udev_device_get_sysname(names->usbdev)); + util_strscpy(name, sizeof(name), udev_device_get_sysname(usbdev)); s = strchr(name, '-'); if (!s) return -EINVAL; @@ -316,6 +319,25 @@ static int names_usb(struct udev_device *dev, struct netnames *names) { return 0; } +static int names_bcma(struct udev_device *dev, struct netnames *names) { + struct udev_device *bcmadev; + unsigned int core; + + bcmadev = udev_device_get_parent_with_subsystem_devtype(dev, "bcma", NULL); + if (!bcmadev) + return -ENOENT; + + /* bus num:core num */ + if (sscanf(udev_device_get_sysname(bcmadev), "bcma%*d:%d", &core) != 1) + return -EINVAL; + /* suppress the common core == 0 */ + if (core > 0) + snprintf(names->bcma_core, sizeof(names->bcma_core), "b%d", core); + + names->type = NET_BCMA; + return 0; +} + static int names_mac(struct udev_device *dev, struct netnames *names) { const char *s; unsigned int i; @@ -452,7 +474,24 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool if (names.pci_slot[0]) if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.usb_ports) < (int)sizeof(str)) udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str); + goto out; } + + /* Broadcom bus */ + err = names_bcma(dev, &names); + if (err >= 0 && names.type == NET_BCMA) { + char str[IFNAMSIZ]; + + if (names.pci_path[0]) + if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_path, names.bcma_core) < (int)sizeof(str)) + udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str); + + if (names.pci_slot[0]) + if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.bcma_core) < (int)sizeof(str)) + udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str); + goto out; + } + out: return EXIT_SUCCESS; } diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index c2c9161c94..d6b3736aee 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -356,7 +356,7 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path) goto out; } - /* lousy scsi sysfs does not have a "subsystem" for the transport */ + /* scsi sysfs does not have a "subsystem" for the transport */ name = udev_device_get_syspath(parent); if (strstr(name, "/rport-") != NULL) { @@ -375,12 +375,15 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path) } /* - * We do not support the ATA transport class, it creates duplicated link - * names as the fake SCSI host adapters are all separated, they are all - * re-based as host == 0. ATA should just stop faking two duplicated - * hierarchies for a single topology and leave the SCSI stuff alone; - * until that happens, there are no by-path/ links for ATA devices behind - * an ATA transport class. + * We do not support the ATA transport class, it uses global counters + * to name the ata devices which numbers spread across multiple + * controllers. + * + * The real link numbers are not exported. Also, possible chains of ports + * behind port multipliers cannot be composed that way. + * + * Until all that is solved at the kernel level, there are no by-path/ + * links for ATA devices. */ if (strstr(name, "/ata") != NULL) { parent = NULL; diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index 13d1226393..ce9ffe7db8 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -189,7 +189,7 @@ static int dev_if_packed_info(struct udev_device *dev, char *ifs_str, size_t len pos = 0; strpos = 0; ifs_str[0] = '\0'; - while (pos < sizeof(buf) && strpos+7 < len-2) { + while (pos < size && strpos+7 < len-2) { struct usb_interface_descriptor *desc; char if_str[8]; @@ -432,6 +432,17 @@ fallback: usb_serial = udev_device_get_sysattr_value(dev_usb, "serial"); if (usb_serial) { + const unsigned char *p; + + /* http://msdn.microsoft.com/en-us/library/windows/hardware/gg487321.aspx */ + for (p = (unsigned char *)usb_serial; *p != '\0'; p++) + if (*p < 0x20 || *p > 0x7f || *p == ',') { + usb_serial = NULL; + break; + } + } + + if (usb_serial) { util_replace_whitespace(usb_serial, serial_str, sizeof(serial_str)-1); util_replace_chars(serial_str, NULL); } diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 917d1e0eaf..4f43953895 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -474,9 +474,10 @@ static int import_file(struct trie *trie, const char *filename) { } static void help(void) { - printf("Usage: udevadm hwdb [--create] [--help] [--root <root_path>]\n" + printf("Usage: udevadm hwdb OPTIONS\n" " --update update the hardware database\n" - " --test <modalias> query database and print result\n" + " --test=<modalias> query database and print result\n" + " --root=<path> alternative root path in the filesystem\n" " --help\n\n"); } @@ -488,7 +489,8 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) { { "help", no_argument, NULL, 'h' }, {} }; - const char *test = NULL, *root_path = NULL; + const char *test = NULL; + const char *root_path = NULL; char *udev_hwdb_path = UDEV_HWDB_BIN; bool update = false; struct trie *trie = NULL; |