chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge rsync://rsync.kernel.org/pub/scm/linux/hotplug/udev
[elogind.git]
/
extras
/
scsi_id
/
scsi_id.c
diff --git
a/extras/scsi_id/scsi_id.c
b/extras/scsi_id/scsi_id.c
index 4003ee6af5a66dcaf436cf06a7097eb144856240..a46d1b377da97dfd08075a76b37f6ebdc4da0cac 100644
(file)
--- a/
extras/scsi_id/scsi_id.c
+++ b/
extras/scsi_id/scsi_id.c
@@
-52,7
+52,7
@@
* options are not supported, but other code is still left in place for
* now.
*/
* options are not supported, but other code is still left in place for
* now.
*/
-static const char short_options[] = "bd:f:gip:s:uvVx";
+static const char short_options[] = "
a
bd:f:gip:s:uvVx";
/*
* Just duplicate per dev options.
*/
/*
* Just duplicate per dev options.
*/
@@
-61,6
+61,7
@@
static const char dev_short_options[] = "bgp:";
char sysfs_mnt_path[SYSFS_PATH_MAX];
static int all_good;
char sysfs_mnt_path[SYSFS_PATH_MAX];
static int all_good;
+static int always_info;
static char *default_callout;
static int dev_specified;
static int sys_specified;
static char *default_callout;
static int dev_specified;
static int sys_specified;
@@
-100,10
+101,9
@@
void log_message (int level, const char *format, ...)
return;
}
return;
}
-static void set_str(char *to, const
unsigned char *from, in
t count)
+static void set_str(char *to, const
char *from, size_
t count)
{
{
- int i, j;
- int len;
+ size_t i, j, len;
/* strip trailing whitespace */
len = strnlen(from, count);
/* strip trailing whitespace */
len = strnlen(from, count);
@@
-133,42
+133,42
@@
static void set_str(char *to, const unsigned char *from, int count)
to[j] = '\0';
}
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;
{
int type_num;
char *eptr;
+ char *type = "generic";
type_num = strtoul(from, &eptr, 0);
if (eptr != from) {
switch (type_num) {
case 0:
type_num = strtoul(from, &eptr, 0);
if (eptr != from) {
switch (type_num) {
case 0:
-
sprintf(to, "disk")
;
+
type = "disk"
;
break;
case 1:
break;
case 1:
-
sprintf(to, "tape")
;
+
type = "tape"
;
break;
case 4:
break;
case 4:
-
sprintf(to, "optical")
;
+
type = "optical"
;
break;
case 5:
break;
case 5:
-
sprintf(to, "cd")
;
+
type = "cd"
;
break;
case 7:
break;
case 7:
-
sprintf(to, "optical")
;
+
type = "optical"
;
break;
case 0xe:
break;
case 0xe:
-
sprintf(to, "disk")
;
+
type = "disk"
;
break;
case 0xf:
break;
case 0xf:
-
sprintf(to, "optical")
;
+
type = "optical"
;
break;
default:
break;
default:
- sprintf(to, "generic");
break;
}
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,
}
static int get_major_minor(struct sysfs_class_device *class_dev, int *maj,
@@
-475,7
+475,7
@@
static int set_options(int argc, char **argv, const char *short_opts,
*/
optind = 1;
while (1) {
*/
optind = 1;
while (1) {
- option = getopt(argc, argv, short_opt
ion
s);
+ option = getopt(argc, argv, short_opts);
if (option == -1)
break;
if (option == -1)
break;
@@
-485,6
+485,9
@@
static int set_options(int argc, char **argv, const char *short_opts,
dprintf("option '%c'\n", option);
switch (option) {
dprintf("option '%c'\n", option);
switch (option) {
+ case 'a':
+ always_info = 1;
+ break;
case 'b':
all_good = 0;
break;
case 'b':
all_good = 0;
break;
@@
-598,7
+601,7
@@
static int per_dev_options(struct sysfs_device *scsi_dev, int *good_bad,
scsi_dev->name);
return -1;
}
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) {
type = sysfs_get_device_attr(scsi_dev, "rev");
if (!type) {
@@
-810,7
+813,7
@@
static int scsi_id(const char *target_path, char *maj_min_dev)
retval = 1;
} else if (scsi_get_serial(scsi_dev, maj_min_dev, page_code,
serial, MAX_SERIAL_LEN)) {
retval = 1;
} else if (scsi_get_serial(scsi_dev, maj_min_dev, page_code,
serial, MAX_SERIAL_LEN)) {
- retval = 1;
+ retval =
always_info?0:
1;
} else {
retval = 0;
}
} else {
retval = 0;
}
@@
-823,6
+826,7
@@
static int scsi_id(const char *target_path, char *maj_min_dev)
set_str(serial_str, serial, sizeof(serial_str));
printf("ID_SERIAL=%s\n", serial_str);
printf("ID_TYPE=%s\n", type_str);
set_str(serial_str, serial, sizeof(serial_str));
printf("ID_SERIAL=%s\n", serial_str);
printf("ID_TYPE=%s\n", type_str);
+ printf("ID_BUS=scsi\n");
} else {
if (reformat_serial)
format_serial(serial);
} else {
if (reformat_serial)
format_serial(serial);