* Geographic naming of devices using Udev for ATCA system.
@ 2004-03-26 2:41 Sabharwal, Atul
2004-03-26 18:45 ` Greg KH
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Sabharwal, Atul @ 2004-03-26 2:41 UTC (permalink / raw)
To: linux-hotplug
Hi Greg,
I have developed a callout routine for ATCA based chassis systems where
we can generate
Descriptive device names based on geographic information of the device.
The geographic information being chasis#, slot# and host adaptor#. The
end results is a name tree which is three Level deep instead of the
usual one level tree.
The user has to Manually provision the disk(s) in a file (provision.tbl)
file and the chassis_id callout uses Scsi_id to find the serial# of the
device. The serial# being the key to
Get the geographic information.
Would you be interested in including this into udev as an extra module ?
Or is it too custom
In nature and does not belong here ?
Thanks,
Atul
-------------------------------------------------------------
P.S: All opinions are my personal opinion(s) & responsibility and do
not represent the view of my employer ( Intel Corporation ).
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&opÌk
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Geographic naming of devices using Udev for ATCA system. 2004-03-26 2:41 Geographic naming of devices using Udev for ATCA system Sabharwal, Atul @ 2004-03-26 18:45 ` Greg KH 2004-03-26 19:00 ` Sabharwal, Atul ` (5 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Greg KH @ 2004-03-26 18:45 UTC (permalink / raw) To: linux-hotplug On Thu, Mar 25, 2004 at 06:41:51PM -0800, Sabharwal, Atul wrote: > Hi Greg, Ick, don't use my us.ibm.com email address for udev stuff, it will get lost there... > I have developed a callout routine for ATCA based chassis systems where > we can generate > Descriptive device names based on geographic information of the device. > The geographic information being chasis#, slot# and host adaptor#. The > end results is a name tree which is three Level deep instead of the > usual one level tree. > > The user has to Manually provision the disk(s) in a file (provision.tbl) > file and the chassis_id callout uses Scsi_id to find the serial# of the > device. The serial# being the key to > Get the geographic information. > > Would you be interested in including this into udev as an extra module ? > Or is it too custom In nature and does not belong here ? Don't know, care to send a patch to the udev tree that adds your program to the extras/ directory? Then we can take a look and determine if it should be in the tarball or not. thanks, greg k-h ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Geographic naming of devices using Udev for ATCA system. 2004-03-26 2:41 Geographic naming of devices using Udev for ATCA system Sabharwal, Atul 2004-03-26 18:45 ` Greg KH @ 2004-03-26 19:00 ` Sabharwal, Atul 2004-03-26 19:10 ` Sabharwal, Atul ` (4 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Sabharwal, Atul @ 2004-03-26 19:00 UTC (permalink / raw) To: linux-hotplug [-- Attachment #1: Type: text/plain, Size: 419 bytes --] >> Would you be interested in including this into udev as an extra module ? >> Or is it too custom In nature and does not belong here ? >Don't know, care to send a patch to the udev tree that adds your program >to the extras/ directory? Then we can take a look and determine if it >should be in the tarball or not. Patch file attached with mail in Unix format against Udev-023 tree. Thanks, Atul [-- Attachment #2: chassis_id.patch --] [-- Type: application/octet-stream, Size: 8654 bytes --] diff -Nur udev-023.org/extras/chassis_id/chassis_id.c udev-023/extras/chassis_id/chassis_id.c --- udev-023.org/extras/chassis_id/chassis_id.c 1969-12-31 16:00:00.000000000 -0800 +++ udev-023/extras/chassis_id/chassis_id.c 2004-03-25 11:28:06.146140984 -0800 @@ -0,0 +1,112 @@ + + /* -*-c-*-: + ** + ** (C) 2003 Intel Corporation + ** Atul Sabharwal <atul.sabharwal@intel.com> + ** + ** $Id: chassis_id.c,v 1.8 2004/03/22 23:33:10 atul Exp $ + ** + ** Distributed under the terms of the GNU Public License, v2.0 or + ** later. + ** + ** Many parts heavily based on test-skeleton.c, by Ulrich Drepper; + ** with his permission, they have been re-licensed GPL, and his + ** copyright still applies on them. + ** + */ + +#include <stdio.h> +#include <stdlib.h> +#include <syslog.h> + +#include "chassis_id.h" + +//#define DEBUG 1 + +int main(int argc, char **argv, char ** envp) +{ + int chassis_num, slot_num, retval, host_num; + char disk_snum[255], devpath[255]; + char * ptr; + int disk_index; + + syslog( LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", "starting chassis_id" ); + +#if 0 + ptr = (char *) 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 = (char *) 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 = (char *) getenv( "DEVPATH"); + if( ptr == NULL ) + return -ERROR_NO_DEVPATH; + + sscanf(ptr, "%s", &devpath[0]); + #ifdef DEBUG + syslog( LOG_PID|LOG_DAEMON| LOG_ERR, "Devpath %s", devpath); + #endif + + retval = table_init(); + if(retval < 0 ) + return -ERROR_BAD_TABLE; + + getserial_number( devpath, disk_snum); + + + /* 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); + if ( disk_index == -1 ) + { + //typical provisioning error + return -ERROR_NO_DISK; + } + else + { + table_select_disk( disk_index ); + } + return 0; +} + + +/* Run SCSI id to find serial number of the device */ +int getserial_number( char * devpath, char * snumber ) +{ + FILE *fp; + char vendor [255], model[255], cmd[255]; + int retval; + + sprintf(cmd, "/sbin/scsi_id -s %s -p 0x80", devpath); + + fp = popen( cmd, "r"); + + if (fp == NULL) + return -ERROR_BAD_SNUMBER; + + fscanf( fp, "%s %s %s", vendor, model, snumber); + #ifdef DEBUG + syslog( LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", snumber ); + #endif + + retval = pclose(fp); + if (retval == -1) + return -ERROR_BAD_SNUMBER; + else + return NO_ERROR; + +} + diff -Nur udev-023.org/extras/chassis_id/chassis_id.h udev-023/extras/chassis_id/chassis_id.h --- udev-023.org/extras/chassis_id/chassis_id.h 1969-12-31 16:00:00.000000000 -0800 +++ udev-023/extras/chassis_id/chassis_id.h 2004-03-25 11:28:01.143901440 -0800 @@ -0,0 +1,34 @@ + + /* -*-c-*-: + ** + ** (C) 2003 Intel Corporation + ** Atul Sabharwal <atul.sabharwal@intel.com> + ** + ** $Id: chassis_id.h,v 1.1 2004/03/16 18:24:44 atul Exp $ + ** + ** Distributed under the terms of the GNU Public License, v2.0 or + ** later. + ** + ** Many parts heavily based on test-skeleton.c, by Ulrich Drepper; + ** with his permission, they have been re-licensed GPL, and his + ** copyright still applies on them. + ** + */ + +#ifndef _CHASSIS_ID_H +#define _CHASSIS_ID_H + +//#define DEBUG 1 +#define ERROR 1 +#define ERROR_NO_SLOT 2 +#define ERROR_NO_CHASSIS 3 +#define ERROR_NO_DEVPATH 4 +#define ERROR_BAD_SNUMBER 5 +#define ERROR_NO_DISK 6 +#define ERROR_BAD_TABLE 7 +#define ERROR_BAD_SCAN 8 +#define NO_ERROR 0 + +extern int table_init(); + +#endif diff -Nur udev-023.org/extras/chassis_id/Makefile udev-023/extras/chassis_id/Makefile --- udev-023.org/extras/chassis_id/Makefile 1969-12-31 16:00:00.000000000 -0800 +++ udev-023/extras/chassis_id/Makefile 2004-03-25 11:28:47.248892416 -0800 @@ -0,0 +1,26 @@ +# +# ** +# ** (C) 2003 Intel Corporation +# ** Atul Sabharwal <atul.sabharwal@intel.com> +# ** +# ** $Id: Makefile,v 1.3 2004/03/22 23:54:54 atul Exp $ +# ** +# ** Distributed under the terms of the GNU Public License, v2.0 or +# ** later. +# ** +# ** Many parts heavily based on test-skeleton.c, by Ulrich Drepper; +# ** with his permission, they have been re-licensed GPL, and his +# ** copyright still applies on them. +# ** +# */ +# +CFLAGS = -g +TARGET = chassis_id + +all: chassis_id + +chassis_id: chassis_id.c table.c + gcc -o $(TARGET) $(CFLAGS) chassis_id.c table.c + +clean: + rm -rf core a.out $(TARGET) diff -Nur udev-023.org/extras/chassis_id/provision.tbl udev-023/extras/chassis_id/provision.tbl --- udev-023.org/extras/chassis_id/provision.tbl 1969-12-31 16:00:00.000000000 -0800 +++ udev-023/extras/chassis_id/provision.tbl 2004-03-25 11:27:40.061106512 -0800 @@ -0,0 +1,5 @@ +id host number_of_disks chassis# slot# serial# name +1 1 2 1 2 3BM07NKA000070456Z6B disk1 +2 1 2 1 2 3BM07R68000070456ZCK disk2 +3 2 2 1 3 3EV08ANK00007219JAVA disk3 +4 2 2 1 4 3EV00NZB000072190Y90 disk4 diff -Nur udev-023.org/extras/chassis_id/table.c udev-023/extras/chassis_id/table.c --- udev-023.org/extras/chassis_id/table.c 1969-12-31 16:00:00.000000000 -0800 +++ udev-023/extras/chassis_id/table.c 2004-03-25 11:27:49.381689568 -0800 @@ -0,0 +1,102 @@ + /* -*-c-*-: + ** + ** (C) 2003 Intel Corporation + ** Atul Sabharwal <atul.sabharwal@intel.com> + ** + ** $Id: table.c,v 1.4 2004/03/18 21:56:24 atul Exp $ + ** + ** Distributed under the terms of the GNU Public License, v2.0 or + ** later. + ** + ** Many parts heavily based on test-skeleton.c, by Ulrich Drepper; + ** with his permission, they have been re-licensed GPL, and his + ** copyright still applies on them. + ** + */ + +#include <stdio.h> +#define TABLE_SIZE 100 +#define PROVISION_DB "/usr/local/bin/provision.tbl" + +struct provision_record +{ + int id; + int host_num; //port # or adaptor number + int num_disks; + int chassis_num; + int slot_num; + char serial_num[32]; + char name[32]; + +} ptable[TABLE_SIZE]; + +int ptable_size; + +/* Initialize the provisioning table by reading the data from special file provision.tbl * + Return error if something does not work appropriately. */ +int table_init() +{ + FILE *fp; + char ptr[255]; + int i; + + fp=fopen( PROVISION_DB, "r"); + + if ((fp== NULL) || feof(fp)) + return -1; + + //skip the first line of text which contains descriptive details. + fgets(ptr, 80, fp); + i = 0; + while (!feof(fp)) + { + fgets(ptr, 80, fp); + sscanf( ptr, "%d %d %d %d %d %s %s", &ptable[i].id, &ptable[i].host_num, + &ptable[i].num_disks, &ptable[i].chassis_num, &ptable[i].slot_num, + ptable[i].serial_num, ptable[i].name ); + i++; + } + + ptable_size = i; + fclose(fp); + return 0; +} + + +/* return -1 when no disk found. Otherwise return index of disk */ +int table_find_disk( char * serialnumber , int * host_num, int * chassis_num, int *slot_num) +{ + + int i; + + for(i = 0; i < ptable_size; i++) + { + + if(strcmp(ptable[i].serial_num, serialnumber) == 0) + { + + *host_num = ptable[i].host_num; + *chassis_num = ptable[i].chassis_num; + *slot_num = ptable[i].slot_num; + break; + } + } + + if(i == ptable_size) + return -1; + else + return i; +} + +/* This function is primarily there for passing the selected disk entry to udev so that * + * it can create descriptive GDN for it. So, for that we need to output this data to * + * stdout. */ +int table_select_disk( int diskindex ) +{ + printf("%d ", ptable[diskindex].chassis_num); + printf("%d ", ptable[diskindex].slot_num); + printf("%d ", ptable[diskindex].host_num); + printf("%s ", ptable[diskindex].name); + +} + ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Geographic naming of devices using Udev for ATCA system. 2004-03-26 2:41 Geographic naming of devices using Udev for ATCA system Sabharwal, Atul 2004-03-26 18:45 ` Greg KH 2004-03-26 19:00 ` Sabharwal, Atul @ 2004-03-26 19:10 ` Sabharwal, Atul 2004-03-31 18:30 ` Greg KH ` (3 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Sabharwal, Atul @ 2004-03-26 19:10 UTC (permalink / raw) To: linux-hotplug The udev rule to get GDN working is as below :: -- Atul BUS="scsi", PROGRAM="/usr/local/bin/chassis_id", NAME="/chassis%c{1}/slot%c{2}/host%c{3}/disk-%c{4}" ------------------------------------------------------------- P.S: All opinions are my personal opinion(s) & responsibility and do not represent the view of my employer ( Intel Corporation ). -----Original Message----- From: linux-hotplug-devel-admin@lists.sourceforge.net [mailto:linux-hotplug-devel-admin@lists.sourceforge.net] On Behalf Of Sabharwal, Atul Sent: Friday, March 26, 2004 11:00 AM To: Greg KH Cc: hotplug Subject: RE: Geographic naming of devices using Udev for ATCA system. >> Would you be interested in including this into udev as an extra module ? >> Or is it too custom In nature and does not belong here ? >Don't know, care to send a patch to the udev tree that adds your program >to the extras/ directory? Then we can take a look and determine if it >should be in the tarball or not. Patch file attached with mail in Unix format against Udev-023 tree. Thanks, Atul ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&opÌk _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Geographic naming of devices using Udev for ATCA system. 2004-03-26 2:41 Geographic naming of devices using Udev for ATCA system Sabharwal, Atul ` (2 preceding siblings ...) 2004-03-26 19:10 ` Sabharwal, Atul @ 2004-03-31 18:30 ` Greg KH 2004-03-31 18:30 ` Greg KH ` (2 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Greg KH @ 2004-03-31 18:30 UTC (permalink / raw) To: linux-hotplug On Fri, Mar 26, 2004 at 11:00:20AM -0800, Sabharwal, Atul wrote: > > >> Would you be interested in including this into udev as an extra > module ? > >> Or is it too custom In nature and does not belong here ? > > >Don't know, care to send a patch to the udev tree that adds your > program > >to the extras/ directory? Then we can take a look and determine if it > >should be in the tarball or not. > > Patch file attached with mail in Unix format against Udev-023 tree. Thanks, I've applied this patch, and then cleaned up the coding style of the .c and .h files. greg k-h ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Geographic naming of devices using Udev for ATCA system. 2004-03-26 2:41 Geographic naming of devices using Udev for ATCA system Sabharwal, Atul ` (3 preceding siblings ...) 2004-03-31 18:30 ` Greg KH @ 2004-03-31 18:30 ` Greg KH 2004-03-31 19:03 ` Sabharwal, Atul 2004-03-31 22:58 ` Greg KH 6 siblings, 0 replies; 8+ messages in thread From: Greg KH @ 2004-03-31 18:30 UTC (permalink / raw) To: linux-hotplug On Fri, Mar 26, 2004 at 11:10:30AM -0800, Sabharwal, Atul wrote: > The udev rule to get GDN working is as below :: > > -- > Atul > > BUS="scsi", PROGRAM="/usr/local/bin/chassis_id", > NAME="/chassis%c{1}/slot%c{2}/host%c{3}/disk-%c{4}" Care to send in a patch that adds a README file that shows this usage? Without it, it would be hard for users to determine this. thanks, greg k-h ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Geographic naming of devices using Udev for ATCA system. 2004-03-26 2:41 Geographic naming of devices using Udev for ATCA system Sabharwal, Atul ` (4 preceding siblings ...) 2004-03-31 18:30 ` Greg KH @ 2004-03-31 19:03 ` Sabharwal, Atul 2004-03-31 22:58 ` Greg KH 6 siblings, 0 replies; 8+ messages in thread From: Sabharwal, Atul @ 2004-03-31 19:03 UTC (permalink / raw) To: linux-hotplug [-- Attachment #1: Type: text/plain, Size: 748 bytes --] >>Care to send in a patch that adds a README file that shows this usage? >>Without it, it would be hard for users to determine this. Done. This addes the Readme file. -- Atul ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel [-- Attachment #2: readme.patch --] [-- Type: application/octet-stream, Size: 1568 bytes --] Binary files udev-023.org/extras/chassis_id/chassis_id and udev-023/extras/chassis_id/chassis_id differ diff -Nur udev-023.org/extras/chassis_id/README udev-023/extras/chassis_id/README --- udev-023.org/extras/chassis_id/README 1969-12-31 16:00:00.000000000 -0800 +++ udev-023/extras/chassis_id/README 2004-03-31 10:43:18.268636088 -0800 @@ -0,0 +1,28 @@ + README.txt + ~~~~~~~~~~ +Chassis_id is a callout program which is used to give geographic names to devices. It uses +another callout program scsi_id to determine the serial number of a device and then looks up +the provisioning table based on this key. It retrieves geographic information +( chassis#, slot# and host# ) about the device and prints it to stdout. These fields are +used by udev to create the device entry. + +Using Udev: +~~~~~~~~~~ +Chassis_id gets invoked by udev using the udev as below: + +BUS="scsi", PROGRAM="/usr/local/bin/chassis_id", NAME="/chassis%c{1}/slot%c{2}/host%c{3}/disk-%c{4} + +The provisioning table ( file provision.tbl ) has to be put in /usr/local/bin and as of now has +to be populated manually. This is the only place where the geographic map of devices is kept +in the system. + + +Usage Model: +~~~~~~~~~~~~ +On ATCA based blade architecture systems, blade insertion/removal is common. We create names +in a 3 level deep tree which represent the geographic map of the devices. + + +CONTACT: +~~~~~~~~ +Please feel free to contact atul.sabharwal@intel.com with questions, comments, suggestions. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Geographic naming of devices using Udev for ATCA system. 2004-03-26 2:41 Geographic naming of devices using Udev for ATCA system Sabharwal, Atul ` (5 preceding siblings ...) 2004-03-31 19:03 ` Sabharwal, Atul @ 2004-03-31 22:58 ` Greg KH 6 siblings, 0 replies; 8+ messages in thread From: Greg KH @ 2004-03-31 22:58 UTC (permalink / raw) To: linux-hotplug On Wed, Mar 31, 2004 at 11:03:27AM -0800, Sabharwal, Atul wrote: > > >>Care to send in a patch that adds a README file that shows this usage? > >>Without it, it would be hard for users to determine this. > > Done. This addes the Readme file. Applied, thanks. greg k-h ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-03-31 22:58 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-03-26 2:41 Geographic naming of devices using Udev for ATCA system Sabharwal, Atul 2004-03-26 18:45 ` Greg KH 2004-03-26 19:00 ` Sabharwal, Atul 2004-03-26 19:10 ` Sabharwal, Atul 2004-03-31 18:30 ` Greg KH 2004-03-31 18:30 ` Greg KH 2004-03-31 19:03 ` Sabharwal, Atul 2004-03-31 22:58 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).