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 v2.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
26 #define TABLE_SIZE 100
27 #define PROVISION_DB "/usr/local/bin/provision.tbl"
29 struct provision_record
41 /* Initialize the provisioning table by reading the data from special file provision.tbl *
42 Return error if something does not work appropriately. */
49 fp = fopen( PROVISION_DB, "r");
51 if ((fp== NULL) || feof(fp))
54 // skip the first line of text which contains descriptive details.
59 sscanf(ptr, "%d %d %d %d %d %s %s", &ptable[i].id,
61 &ptable[i].chassis_num, &ptable[i].slot_num,
62 ptable[i].serial_num, ptable[i].name);
72 /* return -1 when no disk found. Otherwise return index of disk */
73 int table_find_disk( char * serialnumber , int * host_num, int * chassis_num, int *slot_num)
77 for (i = 0; i < ptable_size; i++) {
78 if (strcmp(ptable[i].serial_num, serialnumber) == 0) {
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
92 * so that it can create descriptive GDN for it. So, for that we need to output
93 * this data to stdout.
95 int table_select_disk( int diskindex )
97 printf("%d ", ptable[diskindex].chassis_num);
98 printf("%d ", ptable[diskindex].slot_num);
99 printf("%s ", ptable[diskindex].name);