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
27 #include "chassis_id.h"
29 #define TABLE_SIZE 100
30 #define PROVISION_DB "/usr/local/bin/provision.tbl"
32 struct provision_record
44 /* Initialize the provisioning table by reading the data from special file provision.tbl *
45 Return error if something does not work appropriately. */
52 fp = fopen( PROVISION_DB, "r");
54 if ((fp== NULL) || feof(fp))
57 // skip the first line of text which contains descriptive details.
62 sscanf(ptr, "%d %d %d %d %d %s %s", &ptable[i].id,
64 &ptable[i].chassis_num, &ptable[i].slot_num,
65 ptable[i].serial_num, ptable[i].name);
75 /* return -1 when no disk found. Otherwise return index of disk */
76 int table_find_disk(const char *serialnumber , int *chassis_num, int *slot_num)
80 for (i = 0; i < ptable_size; i++) {
81 if (strcmp(ptable[i].serial_num, serialnumber) == 0) {
82 *chassis_num = ptable[i].chassis_num;
83 *slot_num = ptable[i].slot_num;
94 /* This function is primarily there for passing the selected disk entry to udev
95 * so that it can create descriptive GDN for it. So, for that we need to output
96 * this data to stdout.
98 int table_select_disk(int diskindex)
100 printf("%d ", ptable[diskindex].chassis_num);
101 printf("%d ", ptable[diskindex].slot_num);
102 printf("%s ", ptable[diskindex].name);