diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2005-02-05 02:36:54 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:24:19 -0700 |
commit | 9172c95c77e8f1377b6c8becc84995e6e28a61eb (patch) | |
tree | ecc549e85a5669c5180885ccd7e9aeb84e0ce027 /extras/chassis_id/chassis_id.c | |
parent | 61599bdd06b059e7a5792b0417828d0a87541038 (diff) |
[PATCH] chassis_id: clean compilation and fix bad function parameter passing
Adding prototypes for functions resulted in an error, cause:
table_find_disk(disk_snum, &chassis_num, &slot_num);
is called but the function is defined as:
int table_find_disk(char *serialnumber , int *host_num, int *chassis_num, int *slot_num)
which can obviously not work correctly.
Using popen() is not klibc compatible, so skip the compilation if
a klibc compile is requested.
Diffstat (limited to 'extras/chassis_id/chassis_id.c')
-rw-r--r-- | extras/chassis_id/chassis_id.c | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/extras/chassis_id/chassis_id.c b/extras/chassis_id/chassis_id.c index 3fdfa96018..de86087921 100644 --- a/extras/chassis_id/chassis_id.c +++ b/extras/chassis_id/chassis_id.c @@ -18,7 +18,7 @@ * Boston, MA 021110-1307, USA. * * Authors: Atul Sabharwal - * + * */ #include <stdio.h> @@ -29,7 +29,33 @@ //#define DEBUG 1 -int main(int argc, char **argv, char ** envp) +/* Run SCSI id to find serial number of the device */ +static int getserial_number(char * devpath, char * snumber) +{ + FILE *fp; + char vendor[255], model[255], cmd[255]; + int retval; + + sprintf(cmd, "/sbin/scsi_id -s %s -p 0x80", devpath); + + fp = popen(cmd, "r"); + + if (fp == NULL) + return -ERROR_BAD_SNUMBER; + + fscanf(fp, "%s %s %s", vendor, model, snumber); + #ifdef DEBUG + syslog(LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", snumber ); + #endif + + retval = pclose(fp); + if (retval == -1) + return -ERROR_BAD_SNUMBER; + else + return NO_ERROR; +} + +int main(int argc, char **argv, char **envp) { int chassis_num, slot_num, retval; char disk_snum[255], devpath[255]; @@ -63,31 +89,3 @@ int main(int argc, char **argv, char ** envp) } return 0; } - - -/* Run SCSI id to find serial number of the device */ -int getserial_number( char * devpath, char * snumber ) -{ - FILE *fp; - char vendor[255], model[255], cmd[255]; - int retval; - - sprintf(cmd, "/sbin/scsi_id -s %s -p 0x80", devpath); - - fp = popen(cmd, "r"); - - if (fp == NULL) - return -ERROR_BAD_SNUMBER; - - fscanf(fp, "%s %s %s", vendor, model, snumber); - #ifdef DEBUG - syslog(LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", snumber ); - #endif - - retval = pclose(fp); - if (retval == -1) - return -ERROR_BAD_SNUMBER; - else - return NO_ERROR; -} - |