diff options
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; -} - |