3 ** (C) 2003 Intel Corporation
4 ** Atul Sabharwal <atul.sabharwal@intel.com>
6 ** $Id: table.c,v 1.4 2004/03/18 21:56:24 atul Exp $
8 ** Distributed under the terms of the GNU Public License, v2.0 or
11 ** Many parts heavily based on test-skeleton.c, by Ulrich Drepper;
12 ** with his permission, they have been re-licensed GPL, and his
13 ** copyright still applies on them.
18 #define TABLE_SIZE 100
19 #define PROVISION_DB "/usr/local/bin/provision.tbl"
21 struct provision_record
24 int host_num; //port # or adaptor number
35 /* Initialize the provisioning table by reading the data from special file provision.tbl *
36 Return error if something does not work appropriately. */
43 fp=fopen( PROVISION_DB, "r");
45 if ((fp== NULL) || feof(fp))
48 //skip the first line of text which contains descriptive details.
54 sscanf( ptr, "%d %d %d %d %d %s %s", &ptable[i].id, &ptable[i].host_num,
55 &ptable[i].num_disks, &ptable[i].chassis_num, &ptable[i].slot_num,
56 ptable[i].serial_num, ptable[i].name );
66 /* return -1 when no disk found. Otherwise return index of disk */
67 int table_find_disk( char * serialnumber , int * host_num, int * chassis_num, int *slot_num)
72 for(i = 0; i < ptable_size; i++)
75 if(strcmp(ptable[i].serial_num, serialnumber) == 0)
78 *host_num = ptable[i].host_num;
79 *chassis_num = ptable[i].chassis_num;
80 *slot_num = ptable[i].slot_num;
91 /* This function is primarily there for passing the selected disk entry to udev so that *
92 * it can create descriptive GDN for it. So, for that we need to output this data to *
94 int table_select_disk( int diskindex )
96 printf("%d ", ptable[diskindex].chassis_num);
97 printf("%d ", ptable[diskindex].slot_num);
98 printf("%d ", ptable[diskindex].host_num);
99 printf("%s ", ptable[diskindex].name);