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.
19 #define TABLE_SIZE 100
20 #define PROVISION_DB "/usr/local/bin/provision.tbl"
22 struct provision_record
25 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.
53 sscanf(ptr, "%d %d %d %d %d %s %s", &ptable[i].id,
54 &ptable[i].host_num, &ptable[i].num_disks,
55 &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)
71 for (i = 0; i < ptable_size; i++) {
72 if (strcmp(ptable[i].serial_num, serialnumber) == 0) {
73 *host_num = ptable[i].host_num;
74 *chassis_num = ptable[i].chassis_num;
75 *slot_num = ptable[i].slot_num;
86 /* This function is primarily there for passing the selected disk entry to udev
87 * so that it can create descriptive GDN for it. So, for that we need to output
88 * this data to stdout.
90 int table_select_disk( int diskindex )
92 printf("%d ", ptable[diskindex].chassis_num);
93 printf("%d ", ptable[diskindex].slot_num);
94 printf("%d ", ptable[diskindex].host_num);
95 printf("%s ", ptable[diskindex].name);