1Auto-detect disks if none specified
2
3Refer to:
4https://bugzilla.redhat.com/show_bug.cgi?id=717479
5
6Index: hddtemp-0.3-beta15/doc/hddtemp.8
7===================================================================
8--- hddtemp-0.3-beta15.orig/doc/hddtemp.8
9+++ hddtemp-0.3-beta15/doc/hddtemp.8
10@@ -19,7 +19,7 @@
11 hddtemp \- Utility to monitor hard drive temperature
12 .SH SYNOPSIS
13 .B hddtemp
14-.RI [ options ] " [type:]disk" ...
15+.RI [ options ] " [[type:]disk]" ...
16 .SH "DESCRIPTION"
17 .PP
18 .B hddtemp
19@@ -35,7 +35,8 @@ You can specify one or more device drive
20 with a
21 .B type
22 like PATA, SATA or SCSI to force hddtemp too use one of these type
23-(because detection can fail).
24+(because detection can fail). If no paths are specified, autodetection of
25+installed drives is attempted.
26
27
28 .SH "OPTIONS"
29Index: hddtemp-0.3-beta15/src/hddtemp.c
30===================================================================
31--- hddtemp-0.3-beta15.orig/src/hddtemp.c
32+++ hddtemp-0.3-beta15/src/hddtemp.c
33@@ -54,6 +54,7 @@
34 #include <linux/hdreg.h>
35 #include <ctype.h>
36 #include <assert.h>
37+#include <glob.h>
38
39 // Application specific includes
40 #include "ata.h"
41@@ -255,6 +256,7 @@ int main(int argc, char* argv[]) {
42   int 		ret = 0;
43   int           show_db;
44   struct        disk * ldisks;
45+  glob_t        diskglob;
46
47   backtrace_sigsegv();
48   backtrace_sigill();
49@@ -423,11 +425,6 @@ int main(int argc, char* argv[]) {
50      exit(0);
51   }
52
53-  if(argc - optind <= 0) {
54-    fprintf(stderr, _("Too few arguments: you must specify one drive, at least.\n"));
55-    exit(1);
56-  }
57-
58   if(debug) {
59     /*    argc = optind + 1;*/
60     quiet = 1;
61@@ -438,6 +435,23 @@ int main(int argc, char* argv[]) {
62     exit(1);
63   }
64
65+  memset(&diskglob, 0, sizeof(glob_t));
66+  if(argc - optind <= 0) {
67+    if(glob("/dev/[hs]d[a-z]", 0, NULL, &diskglob) == 0) {
68+      argc = diskglob.gl_pathc;
69+      argv = diskglob.gl_pathv;
70+      optind = 0;
71+    } else {
72+      argc = 0;
73+    }
74+  }
75+
76+  if(argc - optind <= 0) {
77+    globfree(&diskglob);
78+    fprintf(stderr, _("Too few arguments: you must specify one drive, at least.\n"));
79+    exit(1);
80+  }
81+
82   init_bus_types();
83
84   /* collect disks informations */
85@@ -531,6 +545,7 @@ int main(int argc, char* argv[]) {
86   else {
87     do_direct_mode(ldisks);
88   }
89+  globfree(&diskglob);
90
91   return ret;
92 }
93