summaryrefslogtreecommitdiff
path: root/hardinfo2
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2006-11-20 17:06:42 +0000
committerLeandro A. F. Pereira <leandro@hardinfo.org>2006-11-20 17:06:42 +0000
commit154ebd70f6d085331accd921b9a24df9d6dad2a6 (patch)
tree7b19b743e456eef7b590d651e33948fd6bbf0d6a /hardinfo2
parentdd1e13d0d459db5847649b0b45b84a68a3b2b667 (diff)
Workaround for slow CD-ROM drives, or drives with inserted media.
Diffstat (limited to 'hardinfo2')
-rw-r--r--hardinfo2/arch/linux/common/storage.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/hardinfo2/arch/linux/common/storage.h b/hardinfo2/arch/linux/common/storage.h
index b13d3639..4c9b5633 100644
--- a/hardinfo2/arch/linux/common/storage.h
+++ b/hardinfo2/arch/linux/common/storage.h
@@ -177,12 +177,12 @@ scan_ide(void)
for (i = 0; i <= 16; i++) {
device = g_strdup_printf("/proc/ide/hd%c/model", iface);
if (g_file_test(device, G_FILE_TEST_EXISTS)) {
- gchar buf[64];
+ gchar buf[128];
cache = 0;
proc_ide = fopen(device, "r");
- fgets(buf, 64, proc_ide);
+ fgets(buf, 128, proc_ide);
fclose(proc_ide);
buf[strlen(buf) - 1] = 0;
@@ -193,18 +193,25 @@ scan_ide(void)
device = g_strdup_printf("/proc/ide/hd%c/media", iface);
proc_ide = fopen(device, "r");
- fgets(buf, 64, proc_ide);
+ fgets(buf, 128, proc_ide);
fclose(proc_ide);
buf[strlen(buf) - 1] = 0;
media = g_strdup(buf);
if (g_str_equal(media, "cdrom")) {
/* obtain cd-rom drive information from cdrecord */
- gchar *tmp = g_strdup_printf("cdrecord dev=/dev/hd%c -prcap 2>/dev/null", iface);
+ GTimer *timer;
+ gchar *tmp = g_strdup_printf("cdrecord dev=/dev/hd%c -prcap 2>/dev/stdout", iface);
FILE *prcap;
if ((prcap = popen(tmp, "r"))) {
- while (fgets(buf, 64, prcap)) {
+ /* we need a timeout so cdrecord does not try to get information on cd drives
+ with inserted media, which is not possible currently. half second should be
+ enough. */
+ timer = g_timer_new();
+ g_timer_start(timer);
+
+ while (fgets(buf, 128, prcap) && g_timer_elapsed(timer, NULL) < 0.5) {
if (g_str_has_prefix(buf, " Does")) {
if (g_str_has_suffix(buf, "media\n") && !strstr(buf, "speed")) {
gchar *media_type = g_strstrip(strstr(buf, "Does "));
@@ -240,8 +247,9 @@ scan_ide(void)
driver = g_strdup_printf("Driver=%s\n", strchr(buf, ':') + 1);
}
}
-
+
pclose(prcap);
+ g_timer_destroy(timer);
}
g_free(tmp);