From: "Surekha.PC" <surekhap@cisco.com>
To: linux-hotplug@vger.kernel.org
Subject: RE: udev does not create scsi disk entries during bootup
Date: Thu, 27 Nov 2003 11:36:37 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-106993237819787@msgid-missing> (raw)
In-Reply-To: <marc-linux-hotplug-106870290127081@msgid-missing>
[-- Attachment #1: Type: text/plain, Size: 2644 bytes --]
Hi,
>Can you split this up into 2 different patches, both generated with
'diff -u' so we can
>see the changes easier?
I have generated the patch in the suggested format. The patch for
appending partition name is just a one liner, so it is part of patch
enclosed alongwith. Line #34, is the change with this statement.
+ strcat(pos, "s");
>> 1)To include new field in the NUMBER rule specially for iSCSI
devices.
>>
>> The current rule provided by udev is as below.
>>
>> NUMBER, BUS="scsi", ID=2:0:0:0", NAME="disk%n"
>>
>> For iSCSI devices, since hostid is not consistent, we are defining a
>> new iSCSI device attribute in sysfs, which will be checked while
>> naming the device.
>>
>> NUMBER, BUS="scsi", ID="0:0:0", device_type="ISCSI", NAME="ib0t0l0%n"
>Where does the device_type come from? Is it a sysfs file?
It is a sysfs file which is a device attribute defined for iSCSI devices
in the iSCSI driver.
>> 2) Device partition name needs to be appended with "s" before
>> partition id.
>>
>> If the device name consists of bus,target info like "c0b0t0l0" it
will
>> be easier to identify the partition as in "c0b0t0l0s1".
>It looks like your patch just always adds a 's' whenever you use a %n
field. Why not
>just put the 's' in your NAME? Otherwise you just broke everyone's
rules who do not want >a 's' :)
The string 's' (it could be named as 'part' also) has be used only on
partition names like 'sda1', 'sda2' and not on block device name 'sda'.
So it can't be put in the NAME field.
Below is the how the output for iSCSI device looks with this patch.
This will help separately identify the partition number from lun number.
#ls -l /udev
total 0
brw-rw-rw- 1 root root 8, 32 Nov 27 07:17 ib0t4l0
brw-rw-rw- 1 root root 8, 33 Nov 27 07:17 ib0t4l0s1
brw-rw-rw- 1 root root 8, 34 Nov 27 07:17 ib0t4l0s2
>Can't you do everything you need with a simple callout script right now
with no changes
>needed for udev?
Persistent naming of iSCSI devices require bus, target and lun info.
This is in conjunction with persistent target binding done internally in
our driver where we bind each iSCSI device to a unique bus/target pair
based on the iSCSI targetname.
In a case where there are many targets connected to iSCSI host,
udev.config is automatically generated by looking up the bus and target
id allocated for the iSCSI device.
This needs to be matched with iSCSI specific device attribute
'device_type' to make sure this naming applies only for a iSCSI device.
It is not possible to achieve this funtionality with CALLOUT
configuration.
Thanks,
surekha
[-- Attachment #2: namedev.c.diff --]
[-- Type: application/octet-stream, Size: 2591 bytes --]
--- namedev.c.org 2003-11-27 14:52:50.738368424 -0500
+++ namedev.c 2003-11-25 16:45:18.000000000 -0500
@@ -298,13 +298,23 @@
break;
strfieldcpy(dev.id, temp3);
- /* NAME="new_name" */
+ /* file="value" OR NAME="new_name" */
temp2 = strsep(&temp, ",");
- retval = get_value("NAME", &temp, &temp3);
+ retval = get_pair(&temp, &temp2, &temp3);
if (retval)
break;
- strfieldcpy(dev.name, temp3);
+ if(strcmp("NAME", temp2) != 0) {
+ /* file="value" */
+ strfieldcpy(dev.sysfs_file, temp2);
+ strfieldcpy(dev.sysfs_value, temp3);
+ /* NAME="new_name" */
+ temp2 = strsep(&temp, ",");
+ retval = get_value("NAME", &temp, &temp3);
+ dbg_parse("sysfs_file='%s' sysfs_value='%s'",
+ dev.sysfs_file, dev.sysfs_value);
+ }
+ strfieldcpy(dev.name, temp3);
dbg_parse("NUMBER name='%s', bus='%s', id='%s'",
dev.name, dev.bus, dev.id);
}
@@ -520,6 +530,7 @@
case 'n':
if (strlen(udev->kernel_number) == 0)
break;
+ strcat(pos, "s");
strcat(pos, udev->kernel_number);
dbg("substitute kernel number '%s'", udev->kernel_number);
break;
@@ -724,6 +735,7 @@
char path[SYSFS_PATH_MAX];
int found;
char *temp = NULL;
+ struct sysfs_attribute *tmpattr = NULL;
/* we have to have a sysfs device for NUMBER to work */
if (!sysfs_device)
@@ -749,6 +761,36 @@
}
if (!found)
continue;
+
+ if (strcmp(dev->sysfs_file, "device_type") == 0) {
+ dbg_parse("look for device_type attribute '%s'",
+ dev->sysfs_file);
+ /* try to find the attribute in the class device directory */
+ tmpattr = sysfs_get_classdev_attr(class_dev, dev->sysfs_file);
+ if (tmpattr)
+ goto number_found;
+
+ /* look in the class device directory if present */
+ if (sysfs_device) {
+ tmpattr = sysfs_get_device_attr(sysfs_device, dev->sysfs_file);
+ if (tmpattr)
+ goto number_found;
+ }
+
+ continue;
+number_found:
+ tmpattr->value[strlen(tmpattr->value)-1] = '\0';
+ dbg_parse("compare attribute '%s' value '%s' with '%s'",
+ dev->sysfs_file, tmpattr->value,
+ dev->sysfs_value);
+ if (strncmp(dev->sysfs_value, tmpattr->value, strlen(dev->sysfs_value)) != 0)
+ continue;
+
+ dbg_parse("found matching attribute '%s', '%s' becomes"
+ " '%s' - owner='%s', group='%s', mode=%#o",
+ dev->sysfs_file, class_dev->name, udev->name,
+ dev->owner, dev->group, dev->mode);
+ }
strfieldcpy(udev->name, dev->name);
if (dev->mode != 0) {
udev->mode = dev->mode;
next prev parent reply other threads:[~2003-11-27 11:36 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-13 5:28 udev does not create scsi disk entries during bootup Surekha.PC
2003-11-13 6:25 ` Greg KH
2003-11-13 8:13 ` Surekha.PC
2003-11-14 1:07 ` Greg KH
2003-11-14 3:55 ` Surekha.PC
2003-11-17 4:54 ` Surekha.PC
2003-11-17 13:02 ` Martin Hicks
2003-11-18 8:23 ` Surekha.PC
2003-11-19 13:48 ` Surekha.PC
2003-11-19 23:57 ` Greg KH
2003-11-20 15:11 ` Surekha.PC
2003-11-20 16:46 ` Greg KH
2003-11-20 16:53 ` Greg KH
2003-11-20 18:38 ` Clay Haapala
2003-11-20 18:41 ` Greg KH
2003-11-20 19:11 ` Clay Haapala
2003-11-21 5:49 ` Surekha.PC
2003-11-21 6:12 ` Greg KH
2003-11-21 6:52 ` Surekha.PC
2003-11-22 18:12 ` Greg KH
2003-11-24 12:50 ` Surekha.PC
2003-11-24 22:14 ` Greg KH
2003-11-25 12:56 ` Surekha.PC
2003-11-25 13:12 ` Martin Hicks
2003-11-25 13:40 ` Surekha.PC
2003-11-25 16:36 ` Greg KH
2003-11-27 11:36 ` Surekha.PC [this message]
2003-12-01 23:59 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-hotplug-106993237819787@msgid-missing \
--to=surekhap@cisco.com \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).