# * Authors: Atul Sabharwal
# *
# *
-CFLAGS = -g
+
TARGET = chassis_id
exec_prefix = ${prefix}
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)
+
* Boston, MA 021110-1307, USA.
*
* Authors: Atul Sabharwal
- *
+ *
*/
#include <stdio.h>
//#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];
}
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;
-}
-
* Boston, MA 021110-1307, USA.
*
* Authors: Atul Sabharwal
- *
+ *
*/
#ifndef _CHASSIS_ID_H
#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
* 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"
/* 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];
/* 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;
* 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;
}