/*
* temporary names for mknod.
*/
-#define TMP_DIR "/tmp"
-#define TMP_PREFIX "scsi"
+#define TMP_DIR "/dev"
+#define TMP_PREFIX "tmp-scsi"
/*
* XXX Note the 'e' (send output to stderr in all cases), and 'c' (callout)
static int sys_specified;
static char config_file[MAX_NAME_LEN] = SCSI_ID_CONFIG_FILE;
static int display_bus_id;
-static int default_page_code;
+static enum page_code default_page_code;
static int use_stderr;
static int debug;
static int hotplug_mode;
/* strip trailing whitespace */
len = strnlen(from, count);
- while (isspace(from[len-1]))
+ while (len && isspace(from[len-1]))
len--;
/* strip leading whitespace */
to[j] = '\0';
}
-static void set_type(char *to, const char *from, int count)
+static void set_type(char *to, const char *from, size_t len)
{
int type_num;
char *eptr;
+ char *type = "generic";
type_num = strtoul(from, &eptr, 0);
if (eptr != from) {
switch (type_num) {
case 0:
- sprintf(to, "disk");
+ type = "disk";
break;
case 1:
- sprintf(to, "tape");
+ type = "tape";
break;
case 4:
- sprintf(to, "optical");
+ type = "optical";
break;
case 5:
- sprintf(to, "cd");
+ type = "cd";
break;
case 7:
- sprintf(to, "optical");
+ type = "optical";
break;
case 0xe:
- sprintf(to, "disk");
+ type = "disk";
break;
case 0xf:
- sprintf(to, "optical");
+ type = "optical";
break;
default:
- sprintf(to, "generic");
break;
}
- } else {
- sprintf(to, "generic");
}
+ strncpy(to, type, len);
+ to[len-1] = '\0';
}
static int get_major_minor(struct sysfs_class_device *class_dev, int *maj,
*/
optind = 1;
while (1) {
- option = getopt(argc, argv, short_options);
+ option = getopt(argc, argv, short_opts);
if (option == -1)
break;
case 'p':
if (strcmp(optarg, "0x80") == 0) {
- default_page_code = 0x80;
+ default_page_code = PAGE_80;
} else if (strcmp(optarg, "0x83") == 0) {
- default_page_code = 0x83;
+ default_page_code = PAGE_83;
+ } else if (strcmp(optarg, "pre-spc3-83") == 0) {
+ default_page_code = PAGE_83_PRE_SPC3;
} else {
log_message(LOG_WARNING,
"Unknown page code '%s'\n", optarg);
scsi_dev->name);
return -1;
}
- set_type(type_str, type->value, sizeof(type_str)-1);
+ set_type(type_str, type->value, sizeof(type_str));
type = sysfs_get_device_attr(scsi_dev, "rev");
if (!type) {
case 'p':
if (strcmp(optarg, "0x80") == 0) {
- *page_code = 0x80;
+ *page_code = PAGE_80;
} else if (strcmp(optarg, "0x83") == 0) {
- *page_code = 0x83;
+ *page_code = PAGE_83;
+ } else if (strcmp(optarg, "pre-spc3-83") == 0) {
+ *page_code = PAGE_83_PRE_SPC3;
} else {
log_message(LOG_WARNING,
"Unknown page code '%s'\n", optarg);