* udev: remove node only if major/minor matches
@ 2005-02-17 3:13 Kay Sievers
2005-02-17 17:16 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kay Sievers @ 2005-02-17 3:13 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 261 bytes --]
Hi Hannes,
here we remove the device node only if the major/minor number matches
the one in our database. Will this solve the possible issue with the multipath
setup, where a device remove event may delete a node which belongs to a
different path?
Thanks,
Kay
[-- Attachment #2: udev-check-removal-01.patch --]
[-- Type: text/plain, Size: 5538 bytes --]
===== udev_db.c 1.41 vs edited =====
--- 1.41/udev_db.c 2005-02-04 18:38:55 +01:00
+++ edited/udev_db.c 2005-02-17 02:24:49 +01:00
@@ -79,6 +79,7 @@ int udev_db_add_device(struct udevice *u
fprintf(f, "P:%s\n", udev->devpath);
fprintf(f, "N:%s\n", udev->name);
fprintf(f, "S:%s\n", udev->symlink);
+ fprintf(f, "M:%u:%u\n", udev->major, udev->minor);
fprintf(f, "A:%u\n", udev->partitions);
fprintf(f, "R:%u\n", udev->ignore_remove);
@@ -90,6 +91,7 @@ int udev_db_add_device(struct udevice *u
static int parse_db_file(struct udevice *udev, const char *filename)
{
char line[NAME_SIZE];
+ char temp[NAME_SIZE];
char *bufline;
char *buf;
size_t bufsize;
@@ -119,6 +121,13 @@ static int parse_db_file(struct udevice
count = NAME_SIZE-1;
strncpy(udev->name, &bufline[2], count-2);
udev->name[count-2] = '\0';
+ break;
+ case 'M':
+ if (count > NAME_SIZE)
+ count = NAME_SIZE-1;
+ strncpy(temp, &bufline[2], count-2);
+ temp[count-2] = '\0';
+ sscanf(temp, "%u:%u", &udev->major, &udev->minor);
break;
case 'S':
if (count > NAME_SIZE)
===== udev_remove.c 1.45 vs edited =====
--- 1.45/udev_remove.c 2005-02-09 00:43:18 +01:00
+++ edited/udev_remove.c 2005-02-17 02:55:21 +01:00
@@ -71,6 +71,7 @@ static int delete_node(struct udevice *u
{
char filename[NAME_SIZE];
char partitionname[NAME_SIZE];
+ struct stat stats;
int retval;
int i;
char *pos;
@@ -79,6 +80,15 @@ static int delete_node(struct udevice *u
snprintf(filename, NAME_SIZE, "%s/%s", udev_root, udev->name);
filename[NAME_SIZE-1] = '\0';
+
+ dbg("checking major/minor of device node '%s'", filename);
+ if (stat(filename, &stats) != 0)
+ return -1;
+
+ if (udev->major && stats.st_rdev != makedev(udev->major, udev->minor)) {
+ info("device node '%s' points to a different device, skip removal", filename);
+ return -1;
+ }
info("removing device node '%s'", filename);
retval = unlink_secure(filename);
===== test/udev-test.pl 1.82 vs edited =====
--- 1.82/test/udev-test.pl 2005-02-13 22:03:06 +01:00
+++ edited/test/udev-test.pl 2005-02-17 03:28:45 +01:00
@@ -758,23 +758,13 @@ BUS="scsi", KERNEL="sda", NAME="link", S
EOF
},
{
- desc => "symlink name empty",
- subsys => "block",
- devpath => "/block/sda",
- exp_name => "",
- exp_target => "link",
- exp_error => "yes",
- conf => <<EOF
-BUS="scsi", KERNEL="sda", NAME="link", SYMLINK=""
-EOF
- },
- {
desc => "symlink name '.'",
subsys => "block",
devpath => "/block/sda",
exp_name => ".",
exp_target => "link",
- exp_error => "yes",
+ exp_add_error => "yes",
+ exp_rem_error => "yes",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="link", SYMLINK="."
EOF
@@ -785,7 +775,7 @@ EOF
devpath => "/block/sda",
exp_name => "symlink",
exp_target => "",
- exp_error => "yes",
+ exp_add_error => "yes",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="", SYMLINK="symlink"
EOF
@@ -796,7 +786,8 @@ EOF
devpath => "/block/sda",
exp_name => "",
exp_target => "",
- exp_error => "yes",
+ exp_add_error => "yes",
+ exp_rem_error => "yes",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="", SYMLINK=""
EOF
@@ -807,6 +798,8 @@ EOF
devpath => "/class/tty/tty0",
exp_name => "link",
exp_target => "link",
+ exp_rem_error => "yes",
+ option => "clear",
conf => <<EOF
KERNEL="tty0", NAME="link", SYMLINK="link"
EOF
@@ -1025,7 +1018,7 @@ EOF
subsys => "block",
devpath => "/block/sda",
exp_name => "node",
- exp_error => "yes",
+ exp_add_error => "yes",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="node", OPTIONS="ignore"
EOF
@@ -1045,7 +1038,7 @@ EOF
subsys => "block",
devpath => "/block/sda/sda1",
exp_name => "node6",
- exp_error => "yes",
+ exp_add_error => "yes",
conf => <<EOF
SUBSYSTEM="block", OPTIONS="all_partitions"
BUS="scsi", KERNEL="sda", NAME="node"
@@ -1056,7 +1049,7 @@ EOF
subsys => "block",
devpath => "/block/sda",
exp_name => "node",
- exp_error => "yes",
+ exp_rem_error => "yes",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="node", OPTIONS="ignore_remove"
EOF
@@ -1066,7 +1059,7 @@ EOF
subsys => "block",
devpath => "/block/sda",
exp_name => "node14",
- exp_error => "yes",
+ exp_rem_error => "yes",
option => "clear",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="node", OPTIONS="ignore_remove, all_partitions"
@@ -1225,7 +1218,7 @@ sub symlink_test {
} else {
print "expected symlink from: \'$config->{exp_name}\' to \'$config->{exp_target}\'\n";
print "created symlink from: \'$config->{exp_name}\' to \'$2\'\n";
- if ($config->{exp_error}) {
+ if ($config->{exp_add_error}) {
print "as expected ";
} else {
$error++;
@@ -1234,7 +1227,7 @@ sub symlink_test {
} else {
print "expected symlink from: \'$config->{exp_name}\' to \'$config->{exp_target}\'\n";
print "symlink: not created ";
- if ($config->{exp_error}) {
+ if ($config->{exp_add_error}) {
print "as expected ";
} else {
$error++;
@@ -1273,7 +1266,7 @@ sub run_test {
print "add: ok ";
} else {
print "add: error ";
- if ($config->{exp_error}) {
+ if ($config->{exp_add_error}) {
print "as expected ";
} else {
print "\n\n";
@@ -1292,7 +1285,7 @@ sub run_test {
if ((-e "$PWD/$udev_root$config->{exp_name}") ||
(-l "$PWD/$udev_root$config->{exp_name}")) {
print "remove: error ";
- if ($config->{exp_error}) {
+ if ($config->{exp_rem_error}) {
print "as expected\n\n";
} else {
print "\n\n";
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: udev: remove node only if major/minor matches
2005-02-17 3:13 udev: remove node only if major/minor matches Kay Sievers
@ 2005-02-17 17:16 ` Greg KH
2005-02-18 18:59 ` Hannes Reinecke
2005-02-18 19:13 ` Patrick Mansfield
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2005-02-17 17:16 UTC (permalink / raw)
To: linux-hotplug
On Thu, Feb 17, 2005 at 04:13:13AM +0100, Kay Sievers wrote:
> Hi Hannes,
> here we remove the device node only if the major/minor number matches
> the one in our database. Will this solve the possible issue with the multipath
> setup, where a device remove event may delete a node which belongs to a
> different path?
Patch looks good to me. Bah, I hate multipath...
thanks,
greg k-h
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id\x14396&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] 4+ messages in thread
* Re: udev: remove node only if major/minor matches
2005-02-17 3:13 udev: remove node only if major/minor matches Kay Sievers
2005-02-17 17:16 ` Greg KH
@ 2005-02-18 18:59 ` Hannes Reinecke
2005-02-18 19:13 ` Patrick Mansfield
2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2005-02-18 18:59 UTC (permalink / raw)
To: linux-hotplug
Kay Sievers wrote:
> Hi Hannes,
> here we remove the device node only if the major/minor number matches
> the one in our database. Will this solve the possible issue with the multipath
> setup, where a device remove event may delete a node which belongs to a
> different path?
>
Could be. Having the Major/Minor numbers in udev is a Good Thing (tm),
regardless. I'll check the iSCSI thing.
Cheers,
Hannes
--
Dr. Hannes Reinecke hare@suse.de
SUSE Linux Products GmbH S390 & zSeries
Maxfeldstraße 5 +49 911 74053 688
90409 Nürnberg http://www.suse.de
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id\x14396&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] 4+ messages in thread
* Re: udev: remove node only if major/minor matches
2005-02-17 3:13 udev: remove node only if major/minor matches Kay Sievers
2005-02-17 17:16 ` Greg KH
2005-02-18 18:59 ` Hannes Reinecke
@ 2005-02-18 19:13 ` Patrick Mansfield
2 siblings, 0 replies; 4+ messages in thread
From: Patrick Mansfield @ 2005-02-18 19:13 UTC (permalink / raw)
To: linux-hotplug
On Thu, Feb 17, 2005 at 04:13:13AM +0100, Kay Sievers wrote:
> Hi Hannes,
> here we remove the device node only if the major/minor number matches
> the one in our database. Will this solve the possible issue with the multipath
> setup, where a device remove event may delete a node which belongs to a
> different path?
If device nodes are being overwritten, how does not removing an
overwritten /dev help?
Don't the multipath tools already require a separate sd /dev for proper usage
(i.e. path checker)?
It would be much better to never overwrite a correct /dev entry. Paths (i.e.
sd's) should really be named based on their sysfs or physical path, or
just the default name; the dm device should be named based on disk or
device specific attributes (scsi_id, volume_id, etc.). There is no good
way to know if dm is going to use an sd in a dm multipath.
If "%e" would always work, that might help.
-- Patrick Mansfield
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id\x14396&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] 4+ messages in thread
end of thread, other threads:[~2005-02-18 19:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-17 3:13 udev: remove node only if major/minor matches Kay Sievers
2005-02-17 17:16 ` Greg KH
2005-02-18 18:59 ` Hannes Reinecke
2005-02-18 19:13 ` Patrick Mansfield
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).