aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/hddtemp/hddtemp/hddtemp-0.3-beta15-autodetect-717479.patch
blob: 1a541e32fd91c8fdcce37b8631228bb37f49e6f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Upstream-Status: Pending

Auto-detect disks if none specified

Refer to:
https://bugzilla.redhat.com/show_bug.cgi?id=717479

Index: hddtemp-0.3-beta15/doc/hddtemp.8
===================================================================
--- hddtemp-0.3-beta15.orig/doc/hddtemp.8
+++ hddtemp-0.3-beta15/doc/hddtemp.8
@@ -19,7 +19,7 @@
 hddtemp \- Utility to monitor hard drive temperature
 .SH SYNOPSIS
 .B hddtemp
-.RI [ options ] " [type:]disk" ...
+.RI [ options ] " [[type:]disk]" ...
 .SH "DESCRIPTION"
 .PP
 .B hddtemp 
@@ -35,7 +35,8 @@ You can specify one or more device drive
 with a
 .B type
 like PATA, SATA or SCSI to force hddtemp too use one of these type
-(because detection can fail).
+(because detection can fail). If no paths are specified, autodetection of
+installed drives is attempted.
 
 
 .SH "OPTIONS"
Index: hddtemp-0.3-beta15/src/hddtemp.c
===================================================================
--- hddtemp-0.3-beta15.orig/src/hddtemp.c
+++ hddtemp-0.3-beta15/src/hddtemp.c
@@ -54,6 +54,7 @@
 #include <linux/hdreg.h>
 #include <ctype.h>
 #include <assert.h>
+#include <glob.h>
 
 // Application specific includes
 #include "ata.h"
@@ -255,6 +256,7 @@ int main(int argc, char* argv[]) {
   int 		ret = 0;
   int           show_db;
   struct        disk * ldisks;
+  glob_t        diskglob;
 
   backtrace_sigsegv();
   backtrace_sigill();
@@ -423,11 +425,6 @@ int main(int argc, char* argv[]) {
      exit(0);
   }
   
-  if(argc - optind <= 0) {
-    fprintf(stderr, _("Too few arguments: you must specify one drive, at least.\n"));
-    exit(1);
-  }
-
   if(debug) {
     /*    argc = optind + 1;*/
     quiet = 1;
@@ -438,6 +435,23 @@ int main(int argc, char* argv[]) {
     exit(1);
   }
 
+  memset(&diskglob, 0, sizeof(glob_t));
+  if(argc - optind <= 0) {
+    if(glob("/dev/[hs]d[a-z]", 0, NULL, &diskglob) == 0) {
+      argc = diskglob.gl_pathc;
+      argv = diskglob.gl_pathv;
+      optind = 0;
+    } else {
+      argc = 0;
+    }
+  }
+
+  if(argc - optind <= 0) {
+    globfree(&diskglob);
+    fprintf(stderr, _("Too few arguments: you must specify one drive, at least.\n"));
+    exit(1);
+  }
+
   init_bus_types();
 
   /* collect disks informations */
@@ -531,6 +545,7 @@ int main(int argc, char* argv[]) {
   else {
     do_direct_mode(ldisks);
   }
+  globfree(&diskglob);
 
   return ret;
 }