X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=extras%2Fscsi_id%2Fscsi_id.c;h=e893987868cf2f7a7ddb5674b0d6dda975c764d5;hb=062db23d5eb303ef49d2ff805381229932f44246;hp=1cd6981e5e3700ea773d0e4de1daf291497e5b10;hpb=c59a72105d0ff8a47b31f1829dd3c166ebd859d0;p=elogind.git diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c index 1cd6981e5..e89398786 100644 --- a/extras/scsi_id/scsi_id.c +++ b/extras/scsi_id/scsi_id.c @@ -111,7 +111,7 @@ int sysfs_get_attr(const char *devpath, const char *attr, char *value, return sysfs_read_attribute_value(attr_path, value, SYSFS_NAME_LEN); } -static int get_major_minor(const char *devpath, int *major, int *minor) +static int get_major_minor(const char *devpath, int *maj, int *min) { char dev_value[MAX_ATTR_LEN]; @@ -129,7 +129,7 @@ static int get_major_minor(const char *devpath, int *major, int *minor) } dprintf("dev value %s", dev_value); /* dev_value has a trailing \n */ - if (sscanf(dev_value, "%u:%u", major, minor) != 2) { + if (sscanf(dev_value, "%u:%u", maj, min) != 2) { log_message(LOG_WARNING, "%s: invalid dev major/minor\n", devpath); return -1; @@ -140,18 +140,18 @@ static int get_major_minor(const char *devpath, int *major, int *minor) static int create_tmp_dev(const char *devpath, char *tmpdev, int dev_type) { - int major, minor; + int maj, min; dprintf("(%s)\n", devpath); - if (get_major_minor(devpath, &major, &minor)) + if (get_major_minor(devpath, &maj, &min)) return -1; snprintf(tmpdev, MAX_NAME_LEN, "%s/%s-maj%d-min%d-%u", - TMP_DIR, TMP_PREFIX, major, minor, getpid()); + TMP_DIR, TMP_PREFIX, maj, min, getpid()); dprintf("tmpdev '%s'\n", tmpdev); - if (mknod(tmpdev, 0600 | dev_type, makedev(major, minor))) { + if (mknod(tmpdev, 0600 | dev_type, makedev(maj, min))) { log_message(LOG_WARNING, "mknod failed: %s\n", strerror(errno)); return -1; } @@ -759,10 +759,6 @@ int main(int argc, char **argv) strncpy(target_path, sysfs_mnt_path, MAX_NAME_LEN); strncat(target_path, devpath, MAX_NAME_LEN); - } else { - if (set_options(argc, argv, short_options, target_path, - maj_min_dev) < 0) - exit(1); } /* @@ -779,6 +775,11 @@ int main(int argc, char **argv) exit(1); free(newargv); } + if (!hotplug_mode) { + if (set_options(argc, argv, short_options, target_path, + maj_min_dev) < 0) + exit(1); + } if (!sys_specified) { log_message(LOG_WARNING, "-s must be specified\n");