uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uuid)
{
struct uuidCache_s *last;
-
+
if (!uuidCache) {
last = uuidCache = xzalloc(sizeof(*uuidCache));
} else {
int handleOnFirst;
char *chptr;
- procpt = xfopen("/proc/partitions", "r");
+ procpt = xfopen_for_read("/proc/partitions");
/*
# cat /proc/partitions
major minor #blocks name
colon = strchr(dev, ':');
if (!colon)
goto ret;
- *major = strtol(dev, NULL, 10);
- *minor = strtol(colon + 1, NULL, 10);
+ *major = bb_strtou(dev, NULL, 10);
+ *minor = bb_strtou(colon + 1, NULL, 10);
ret:
free(dev_path);
int ma, mi;
FILE *proccd;
- proccd = fopen(PROC_CDROMS, "r");
+ proccd = fopen_for_read(PROC_CDROMS);
if (!proccd) {
- static smallint warn = 0;
- if (!warn) {
- warn = 1;
- bb_error_msg("mount: could not open %s, so UUID and LABEL "
- "conversion cannot be done for CD-Roms.",
- PROC_CDROMS);
- }
+// static smallint warn = 0;
+// if (!warn) {
+// warn = 1;
+// bb_error_msg("can't open %s, UUID and LABEL "
+// "conversion cannot be done for CD-Roms",
+// PROC_CDROMS);
+// }
return;
}
while (fgets(line, sizeof(line), proccd)) {
- static const char drive_name_string[] ALIGN1 = "drive name:\t\t";
+ static const char drive_name_string[] ALIGN1 = "drive name:";
if (strncmp(line, drive_name_string, sizeof(drive_name_string) - 1) == 0) {
char *device_name;
- device_name = strtok(line + sizeof(drive_name_string) - 1, "\t\n");
- while (device_name) {
+
+ device_name = strtok(skip_whitespace(line + sizeof(drive_name_string) - 1), " \t\n");
+ while (device_name && device_name[0]) {
ma = mi = -1;
dev_get_major_minor(device_name, &ma, &mi);
uuidcache_check_device(device_name, ma, mi, 1);
- device_name = strtok(NULL, "\t\n");
+ device_name = strtok(NULL, " \t\n");
}
break;
}
uuidcache_init();
uc = uuidCache;
while (uc) {
- if (strcmp(spec, uc->uc_uuid) == 0) {
+ /* case of hex numbers doesn't matter */
+ if (strcasecmp(spec, uc->uc_uuid) == 0) {
return xstrdup(uc->device);
}
uc = uc->next;