Lines 149-155
static void find_media(void)
Link Here
|
149 |
while ((dirent = readdir(dir)) != NULL) { |
149 |
while ((dirent = readdir(dir)) != NULL) { |
150 |
if (!strcmp(dirent->d_name, ".") || |
150 |
if (!strcmp(dirent->d_name, ".") || |
151 |
!strcmp(dirent->d_name, "..")) continue; |
151 |
!strcmp(dirent->d_name, "..")) continue; |
152 |
|
152 |
|
153 |
memset(path, 0, SYSFS_PATH_MAX); |
153 |
memset(path, 0, SYSFS_PATH_MAX); |
154 |
strcpy(path, "/sys/block/"); |
154 |
strcpy(path, "/sys/block/"); |
155 |
strcat(path, dirent->d_name); |
155 |
strcat(path, dirent->d_name); |
Lines 161-171
static void find_media(void)
Link Here
|
161 |
tmp[count].name = strdup(dirent->d_name); |
161 |
tmp[count].name = strdup(dirent->d_name); |
162 |
tmp[count].type = UNKNOWN_MEDIA; |
162 |
tmp[count].type = UNKNOWN_MEDIA; |
163 |
if ((f = fopen(path, "r")) != NULL) { |
163 |
if ((f = fopen(path, "r")) != NULL) { |
164 |
int type; |
164 |
int type = SCSI_TYPE_DISK; |
165 |
if (fgets(buf, sizeof(buf), f) && sscanf(buf, "%d", &type)) { |
165 |
if (fgets(buf, sizeof(buf), f) > 0) { |
166 |
if (type == SCSI_TYPE_DISK) tmp[count].type = DISK; |
166 |
if (strncmp(buf, "MMC", 3) == 0) |
167 |
else if (type == SCSI_TYPE_ROM) tmp[count].type = CDROM; |
167 |
tmp[count].type = DISK; |
168 |
else if (type == SCSI_TYPE_TAPE) tmp[count].type = TAPE; |
168 |
else if (sscanf(buf, "%d", &type) > 0) { |
|
|
169 |
if (type == SCSI_TYPE_DISK) tmp[count].type = DISK; |
170 |
else if (type == SCSI_TYPE_ROM) tmp[count].type = CDROM; |
171 |
else if (type == SCSI_TYPE_TAPE) tmp[count].type = TAPE; |
172 |
} |
169 |
} |
173 |
} |
170 |
fclose(f); |
174 |
fclose(f); |
171 |
} |
175 |
} |