summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2005-02-05 02:36:54 +0100
committerGreg KH <gregkh@suse.de>2005-04-26 23:24:19 -0700
commit9172c95c77e8f1377b6c8becc84995e6e28a61eb (patch)
treeecc549e85a5669c5180885ccd7e9aeb84e0ce027 /extras
parent61599bdd06b059e7a5792b0417828d0a87541038 (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')
-rw-r--r--extras/chassis_id/Makefile24
-rw-r--r--extras/chassis_id/chassis_id.c58
-rw-r--r--extras/chassis_id/chassis_id.h6
-rw-r--r--extras/chassis_id/table.c13
4 files changed, 58 insertions, 43 deletions
diff --git a/extras/chassis_id/Makefile b/extras/chassis_id/Makefile
index 141d23c7b8..ae5c95961c 100644
--- a/extras/chassis_id/Makefile
+++ b/extras/chassis_id/Makefile
@@ -20,7 +20,7 @@
# * Authors: Atul Sabharwal
# *
# *
-CFLAGS = -g
+
TARGET = chassis_id
exec_prefix = ${prefix}
@@ -28,14 +28,24 @@ sbindir = ${exec_prefix}/sbin
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
-all: chassis_id
+all: chassis_id
+ifneq ($(strip $(USE_KLIBC)),true)
chassis_id: chassis_id.c table.c
- gcc -o $(TARGET) $(CFLAGS) chassis_id.c table.c
-
-clean:
- rm -rf core a.out $(TARGET)
+ $(QUIET) $(CC) -o $(TARGET) $(CFLAGS) chassis_id.c table.c
install: all
$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(sbindir)/$(TARGET)
-
+else
+chassis_id:
+ @echo
+ @echo "!!! chassis_id is incompatible with klibc !!!"
+ @echo
+ @exit 0
+
+install: all
+endif
+
+clean:
+ rm -rf core a.out $(TARGET)
+
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;
-}
-
diff --git a/extras/chassis_id/chassis_id.h b/extras/chassis_id/chassis_id.h
index 9937e3dfac..1463bd22c7 100644
--- a/extras/chassis_id/chassis_id.h
+++ b/extras/chassis_id/chassis_id.h
@@ -18,7 +18,7 @@
* Boston, MA 021110-1307, USA.
*
* Authors: Atul Sabharwal
- *
+ *
*/
#ifndef _CHASSIS_ID_H
@@ -35,6 +35,8 @@
#define ERROR_BAD_SCAN 8
#define NO_ERROR 0
-extern int table_init();
+extern int table_init(void);
+extern int table_find_disk(const char *serialnumber , int *chassis_num, int *slot_num);
+extern int table_select_disk(int diskindex);
#endif
diff --git a/extras/chassis_id/table.c b/extras/chassis_id/table.c
index f4689ae243..8d14cd1b59 100644
--- a/extras/chassis_id/table.c
+++ b/extras/chassis_id/table.c
@@ -18,10 +18,13 @@
* Boston, MA 021110-1307, USA.
*
* Authors: Atul Sabharwal
- *
+ *
*/
#include <stdio.h>
+#include <string.h>
+
+#include "chassis_id.h"
#define TABLE_SIZE 100
#define PROVISION_DB "/usr/local/bin/provision.tbl"
@@ -40,7 +43,7 @@ int ptable_size;
/* Initialize the provisioning table by reading the data from special file provision.tbl *
Return error if something does not work appropriately. */
-int table_init()
+int table_init(void)
{
FILE *fp;
char ptr[255];
@@ -70,7 +73,7 @@ int table_init()
/* return -1 when no disk found. Otherwise return index of disk */
-int table_find_disk( char * serialnumber , int * host_num, int * chassis_num, int *slot_num)
+int table_find_disk(const char *serialnumber , int *chassis_num, int *slot_num)
{
int i;
@@ -92,10 +95,12 @@ int table_find_disk( char * serialnumber , int * host_num, int * chassis_num, in
* so that it can create descriptive GDN for it. So, for that we need to output
* this data to stdout.
*/
-int table_select_disk( int diskindex )
+int table_select_disk(int diskindex)
{
printf("%d ", ptable[diskindex].chassis_num);
printf("%d ", ptable[diskindex].slot_num);
printf("%s ", ptable[diskindex].name);
+
+ return 0;
}