4 * Copyright (C) 2004 Intel Corporation. All rights reserved.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License v 2.0 as published by the Free Software Foundation;
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 021110-1307, USA.
20 * Authors: Atul Sabharwal
28 #include "chassis_id.h"
32 int main(int argc, char **argv, char ** envp)
34 int chassis_num, slot_num, retval;
35 char disk_snum[255], devpath[255];
39 syslog( LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", "starting chassis_id" );
41 ptr = getenv("DEVPATH");
43 return -ERROR_NO_DEVPATH;
45 sscanf(ptr, "%s", &devpath[0]);
47 syslog(LOG_PID|LOG_DAEMON| LOG_ERR, "Devpath %s", devpath);
50 retval = table_init();
52 return -ERROR_BAD_TABLE;
54 getserial_number(devpath, disk_snum);
56 /* Now we open the provisioning table t find actual entry for the serial number*/
57 disk_index = table_find_disk(disk_snum, &chassis_num, &slot_num);
58 if ( disk_index == -1 ) {
59 // typical provisioning error
60 return -ERROR_NO_DISK;
62 table_select_disk( disk_index );
68 /* Run SCSI id to find serial number of the device */
69 int getserial_number( char * devpath, char * snumber )
72 char vendor[255], model[255], cmd[255];
75 sprintf(cmd, "/sbin/scsi_id -s %s -p 0x80", devpath);
80 return -ERROR_BAD_SNUMBER;
82 fscanf(fp, "%s %s %s", vendor, model, snumber);
84 syslog(LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", snumber );
89 return -ERROR_BAD_SNUMBER;