mirror of
https://github.com/systemd/systemd.git
synced 2025-03-21 02:50:18 +03:00
[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.
This commit is contained in:
parent
61599bdd06
commit
9172c95c77
@ -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)
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user