1
0
mirror of https://github.com/systemd/systemd.git synced 2025-08-24 09:49:49 +03:00

[PATCH] Patch for chassis_id exras module

This commit is contained in:
atul.sabharwal@intel.com
2004-06-26 01:18:08 -07:00
committed by Greg KH
parent 57218a0873
commit c5d046b6c7
6 changed files with 144 additions and 80 deletions

View File

@ -1,19 +1,25 @@
# # *
# ** # * Makefile
# ** (C) 2003 Intel Corporation # *
# ** Atul Sabharwal <atul.sabharwal@intel.com> # * Copyright (C) 2004 Intel Corporation. All rights reserved.
# ** # *
# ** $Id: Makefile,v 1.3 2004/03/22 23:54:54 atul Exp $ # * This program is free software; you can redistribute it and/or
# ** # * modify it under the terms of the GNU General Public
# ** Distributed under the terms of the GNU Public License, v2.0 or # * License v2.0 as published by the Free Software Foundation;
# ** later. # *
# ** # * This program is distributed in the hope that it will be useful,
# ** Many parts heavily based on test-skeleton.c, by Ulrich Drepper; # * but WITHOUT ANY WARRANTY; without even the implied warranty of
# ** with his permission, they have been re-licensed GPL, and his # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# ** copyright still applies on them. # * General Public License for more details.
# ** # *
# */ # * You should have received a copy of the GNU General Public
# # * License along with this program; if not, write to the
# * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# * Boston, MA 021110-1307, USA.
# *
# * Authors: Atul Sabharwal
# *
# *
CFLAGS = -g CFLAGS = -g
TARGET = chassis_id TARGET = chassis_id

View File

@ -1,15 +1,24 @@
/* -*-c-*-: /*
** * chassis_id.c
** (C) 2003 Intel Corporation *
** Atul Sabharwal <atul.sabharwal@intel.com> * Copyright (C) 2004 Intel Corporation. All rights reserved.
** *
** Distributed under the terms of the GNU Public License, v2.0 or * This program is free software; you can redistribute it and/or
** later. * modify it under the terms of the GNU General Public
** * License v 2.0 as published by the Free Software Foundation;
** Many parts heavily based on test-skeleton.c, by Ulrich Drepper; *
** with his permission, they have been re-licensed GPL, and his * This program is distributed in the hope that it will be useful,
** copyright still applies on them * but WITHOUT ANY WARRANTY; without even the implied warranty of
** * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
* Authors: Atul Sabharwal
*
*/ */
#include <stdio.h> #include <stdio.h>
@ -22,33 +31,13 @@
int main(int argc, char **argv, char ** envp) int main(int argc, char **argv, char ** envp)
{ {
int chassis_num, slot_num, retval, host_num; int chassis_num, slot_num, retval;
char disk_snum[255], devpath[255]; char disk_snum[255], devpath[255];
char *ptr; char *ptr;
int disk_index; int disk_index;
syslog( LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", "starting chassis_id" ); syslog( LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", "starting chassis_id" );
#if 0
ptr = getenv("CHASSIS");
if (ptr == NULL)
return -ERROR_NO_CHASSIS;
sscanf(ptr, "%d", &chassis_num);
#ifdef DEBUG
syslog(LOG_PID| LOG_DAEMON| LOG_ERR, "Chassis %d", chassis_num);
#endif
ptr = getenv("SLOT");
if (ptr== NULL)
return -ERROR_NO_SLOT;
sscanf(ptr, "%d", &slot_num);
#ifdef DEBUG
syslog( LOG_PID|LOG_DAEMON| LOG_ERR, "Slot %d", slot_num);
#endif
#endif
ptr = getenv("DEVPATH"); ptr = getenv("DEVPATH");
if (ptr == NULL) if (ptr == NULL)
return -ERROR_NO_DEVPATH; return -ERROR_NO_DEVPATH;
@ -65,7 +54,7 @@ int main(int argc, char **argv, char ** envp)
getserial_number(devpath, disk_snum); getserial_number(devpath, disk_snum);
/* Now we open the provisioning table t find actual entry for the serial number*/ /* Now we open the provisioning table t find actual entry for the serial number*/
disk_index = table_find_disk(disk_snum, &host_num, &chassis_num, &slot_num); disk_index = table_find_disk(disk_snum, &chassis_num, &slot_num);
if ( disk_index == -1 ) { if ( disk_index == -1 ) {
// typical provisioning error // typical provisioning error
return -ERROR_NO_DISK; return -ERROR_NO_DISK;

View File

@ -1,15 +1,24 @@
/* -*-c-*-: /*
** * chassis_id.h
** (C) 2003 Intel Corporation *
** Atul Sabharwal <atul.sabharwal@intel.com> * Copyright (C) 2004 Intel Corporation. All rights reserved.
** *
** Distributed under the terms of the GNU Public License, v2.0 or * This program is free software; you can redistribute it and/or
** later. * modify it under the terms of the GNU General Public
** * License v 2.0 as published by the Free Software Foundation;
** Many parts heavily based on test-skeleton.c, by Ulrich Drepper; *
** with his permission, they have been re-licensed GPL, and his * This program is distributed in the hope that it will be useful,
** copyright still applies on them. * but WITHOUT ANY WARRANTY; without even the implied warranty of
** * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
* Authors: Atul Sabharwal
*
*/ */
#ifndef _CHASSIS_ID_H #ifndef _CHASSIS_ID_H

View File

@ -0,0 +1,49 @@
Udev does not come pre-installed on a Linux system. Hence, we need to do the following before
a Linux system is ready ::
Steps:
~~~~~
1. Install libsysfs shared libraries by installing sysfsutils-0.4.0.
2. Download latest version of udev from www.kernel.org site. It is
under repository->utils->kernel path chain.
Do make and make install so as to install udev. To install scsi_id,
go into extras/scsi_id folder to compile scsi_id. Typically, this
would be in /sbin folder. Now, change scsi_id.cfg and set the
global option to work with all devices ( -g) and comment out the
black list option ( -b ).
3. Download chassis_id callout code and compile. Install chassis_id and
provision.tbl file in /usr/local/bin.
4. In /etc/rc.sysinit, add mount command to mount the sys memory file
system. ( mount -t sysfs sys /sys ). The /sys is necessary as
lot of the software components expect it to be in /sys.
5. Now, in /etc/udev/udev.rules, install the udev rules file. This
is the GDN config file which is used by udev to create folders
in the form chasis<N>/slot<M>/port<O>/disk<P>.
6. Now, you are almost there. Refer to PROVISIONING file.
PROVISIONING:
1. For GDN, the provisioning file is in the format :
<id> <host> <number_of_disks> <chassis#> <slot#> <serial#> <name>
<host> SCSI host on which the device is connected
<Number of disks> how many disks on this blade ?
<chassis#> chassis Number
<slot#> Physical slot number
<serial#> Serial Number for the disk
<name> Name of the disk device.
2. To fill the provisioning table, the user needs to collect this information and
fill provision.tbl.
The serial number is found from the command scsi_id -p 0x80 -s <device name>.
The host number is availble from the sys file system. The chassis & slot
are visual data and should be enetered into provision.tbl.

View File

@ -1,17 +1,24 @@
/* -*-c-*-: /*
** * table.c
** (C) 2003 Intel Corporation *
** Atul Sabharwal <atul.sabharwal@intel.com> * Copyright (C) 2004 Intel Corporation. All rights reserved.
** *
** $Id: table.c,v 1.4 2004/03/18 21:56:24 atul Exp $ * This program is free software; you can redistribute it and/or
** * modify it under the terms of the GNU General Public
** Distributed under the terms of the GNU Public License, v2.0 or * License v2.0 as published by the Free Software Foundation;
** later. *
** * This program is distributed in the hope that it will be useful,
** Many parts heavily based on test-skeleton.c, by Ulrich Drepper; * but WITHOUT ANY WARRANTY; without even the implied warranty of
** with his permission, they have been re-licensed GPL, and his * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** copyright still applies on them. * General Public License for more details.
** *
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
* Authors: Atul Sabharwal
*
*/ */
#include <stdio.h> #include <stdio.h>
@ -22,7 +29,6 @@
struct provision_record struct provision_record
{ {
int id; int id;
int host_num; //port # or adaptor number
int num_disks; int num_disks;
int chassis_num; int chassis_num;
int slot_num; int slot_num;
@ -51,7 +57,7 @@ int table_init()
while (!feof(fp)) { while (!feof(fp)) {
fgets(ptr, 80, fp); fgets(ptr, 80, fp);
sscanf(ptr, "%d %d %d %d %d %s %s", &ptable[i].id, sscanf(ptr, "%d %d %d %d %d %s %s", &ptable[i].id,
&ptable[i].host_num, &ptable[i].num_disks, &ptable[i].num_disks,
&ptable[i].chassis_num, &ptable[i].slot_num, &ptable[i].chassis_num, &ptable[i].slot_num,
ptable[i].serial_num, ptable[i].name); ptable[i].serial_num, ptable[i].name);
i++; i++;
@ -70,7 +76,6 @@ int table_find_disk( char * serialnumber , int * host_num, int * chassis_num, in
for (i = 0; i < ptable_size; i++) { for (i = 0; i < ptable_size; i++) {
if (strcmp(ptable[i].serial_num, serialnumber) == 0) { if (strcmp(ptable[i].serial_num, serialnumber) == 0) {
*host_num = ptable[i].host_num;
*chassis_num = ptable[i].chassis_num; *chassis_num = ptable[i].chassis_num;
*slot_num = ptable[i].slot_num; *slot_num = ptable[i].slot_num;
break; break;
@ -91,7 +96,6 @@ int table_select_disk( int diskindex )
{ {
printf("%d ", ptable[diskindex].chassis_num); printf("%d ", ptable[diskindex].chassis_num);
printf("%d ", ptable[diskindex].slot_num); printf("%d ", ptable[diskindex].slot_num);
printf("%d ", ptable[diskindex].host_num);
printf("%s ", ptable[diskindex].name); printf("%s ", ptable[diskindex].name);
} }

View File

@ -0,0 +1,7 @@
# There are a number of modifiers that are allowed to be used in some of the
# fields. See the udev man page for a full description of them.
#
# See the udev.rules.examples file for more examples of how to create rules
#
BUS="scsi", PROGRAM="/usr/local/bin/chassis_id", NAME="/chassis%c{1}/slot%c{2}/%c{3}"