* udev: provide temporary device nodes for callouts
@ 2005-02-10 11:19 Kay Sievers
2005-02-10 17:26 ` Patrick Mansfield
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Kay Sievers @ 2005-02-10 11:19 UTC (permalink / raw)
To: linux-hotplug
I've added some code to udev to solve the problem of accessing devices
from a callout while no device node is created at that time, cause
obviously the callout runs to return the name for the node to be created.
Some programs need to access the device to read labels or serial numbers
from, but can't know where to create a temporary node, cause udev_root
may be at an unknown location or /tmp is read-only.
%N - create a temporary node and substitute its name
It will be created in udev_root as .tmp-<major>-<minor>
The node is removed after the namedev call.
%p - substitute the DEVPATH of the device
For scsi_id to be called from the command line.
%P - substitute the name of the parent device
The node name of the parent device is queried from the udevdb.
This makes it easy to name partitions after the main device,
especially if the main device gets its name from a callout
or to get the disklabel of the main device to name a partition.
%r - substitute udev_root
Needed to pass the absolute name of the parent device node
to a callout
The following examples of disklabel reading apply with different commandline
parameters also to scsi_id, that reads the serial number from the main device.
Name partitions after disklabel of the parent:
SUBSYSTEM="block", KERNEL="*[1-9]", PROGRAM="/sbin/udev_volume_id -l %r/%P" NAME="%c-part%n"
Name main device after disklabel and let partitions follow the name of
the main device. udevd serializes the events, so that we can be sure,
that the node of the main device is created before the partition event
tries to access it:
SUBSYSTEM="block", KERNEL="*[a-z]", PROGRAM="/sbin/udev_volume_id -l %N, NAME="%c"
SUBSYSTEM="block", KERNEL="*[1-9]", NAME="%P-part%n"
Name partitions after filestem label:
SUBSYSTEM="block", KERNEL="*[1-9]", PROGRAM="/sbin/udev_volume_id -l %N"
udev_volume_id does not longer create any temporary device node or searches
the parent device by itself. It expects the name of the node as illustrated
in the examples.
Thanks,
Kay
-------------------------------------------------------
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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
@ 2005-02-10 17:26 ` Patrick Mansfield
2005-02-10 17:41 ` Kay Sievers
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Patrick Mansfield @ 2005-02-10 17:26 UTC (permalink / raw)
To: linux-hotplug
On Thu, Feb 10, 2005 at 12:19:51PM +0100, Kay Sievers wrote:
> %N - create a temporary node and substitute its name
> It will be created in udev_root as .tmp-<major>-<minor>
> The node is removed after the namedev call.
Hi Kay -
I tested with scsi_id, and found no S_IF* was being set for the mknod
mode.
The following patch fixed the problem.
=== namedev.c 1.176 vs edited ==--- 1.176/namedev.c Wed Feb 9 16:03:54 2005
+++ edited/namedev.c Thu Feb 10 09:07:55 2005
@@ -184,6 +184,7 @@
struct sysfs_attribute *tmpattr;
unsigned int next_free_number;
struct sysfs_class_device *class_dev_parent;
+ mode_t mode;
pos = string;
while (1) {
@@ -316,8 +317,11 @@
case 'N':
if (udev->tmp_node[0] = '\0') {
dbg("create temporary device node for callout");
+ mode = get_mode_type(udev);
+ if (!mode)
+ break;
snprintf(udev->tmp_node, NAME_SIZE-1, "%s/.tmp-%u-%u", udev_root, udev->major, udev->minor);
- udev_make_node(udev, udev->tmp_node, udev->major, udev->minor, 0600, 0, 0);
+ udev_make_node(udev, udev->tmp_node, udev->major, udev->minor, mode | 0600, 0, 0);
}
strfieldcatmax(string, udev->tmp_node, maxsize);
dbg("substitute temporary device node name '%s'", udev->tmp_node);
=== udev_add.c 1.91 vs edited ==--- 1.91/udev_add.c Tue Feb 8 15:43:18 2005
+++ edited/udev_add.c Thu Feb 10 09:13:31 2005
@@ -126,26 +126,16 @@
int tail;
char *pos;
int len;
+ mode_t mode;
int i;
snprintf(filename, NAME_SIZE, "%s/%s", udev_root, udev->name);
filename[NAME_SIZE-1] = '\0';
- switch (udev->type) {
- case 'b':
- udev->mode |= S_IFBLK;
- break;
- case 'c':
- case 'u':
- udev->mode |= S_IFCHR;
- break;
- case 'p':
- udev->mode |= S_IFIFO;
- break;
- default:
- dbg("unknown node type %c\n", udev->type);
+ mode = get_mode_type(udev);
+ if (!mode)
return -EINVAL;
- }
+ udev->mode |= mode;
/* create parent directories if needed */
if (strrchr(udev->name, '/'))
=== udev_utils.c 1.29 vs edited ==--- 1.29/udev_utils.c Wed Feb 9 12:51:41 2005
+++ edited/udev_utils.c Thu Feb 10 09:09:33 2005
@@ -314,3 +314,19 @@
closedir(dir);
return 0;
}
+
+mode_t get_mode_type (struct udevice *udev)
+{
+ switch (udev->type) {
+ case 'b':
+ return S_IFBLK;
+ case 'c':
+ case 'u':
+ return S_IFCHR;
+ case 'p':
+ return S_IFIFO;
+ default:
+ dbg("unknown node type %c\n", udev->type);
+ return 0;
+ }
+}
=== udev_utils.h 1.22 vs edited ==--- 1.22/udev_utils.h Tue Feb 8 11:37:31 2005
+++ edited/udev_utils.h Thu Feb 10 09:04:52 2005
@@ -88,5 +88,6 @@
typedef int (*file_fnct_t)(const char *filename, void *data);
extern int call_foreach_file(file_fnct_t fnct, const char *dirname,
const char *suffix, void *data);
+extern mode_t get_mode_type (struct udevice *udev);
#endif
-------------------------------------------------------
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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
2005-02-10 17:26 ` Patrick Mansfield
@ 2005-02-10 17:41 ` Kay Sievers
2005-02-10 17:43 ` Patrick Mansfield
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2005-02-10 17:41 UTC (permalink / raw)
To: linux-hotplug
On Thu, 2005-02-10 at 09:26 -0800, Patrick Mansfield wrote:
> On Thu, Feb 10, 2005 at 12:19:51PM +0100, Kay Sievers wrote:
> > %N - create a temporary node and substitute its name
> > It will be created in udev_root as .tmp-<major>-<minor>
> > The node is removed after the namedev call.
>
> Hi Kay -
>
> I tested with scsi_id, and found no S_IF* was being set for the mknod
> mode.
Yeah, sorry. It's already fixed in my tree.
Kay
-------------------------------------------------------
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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
2005-02-10 17:26 ` Patrick Mansfield
2005-02-10 17:41 ` Kay Sievers
@ 2005-02-10 17:43 ` Patrick Mansfield
2005-02-10 18:01 ` Kay Sievers
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Patrick Mansfield @ 2005-02-10 17:43 UTC (permalink / raw)
To: linux-hotplug
On Thu, Feb 10, 2005 at 06:41:20PM +0100, Kay Sievers wrote:
> On Thu, 2005-02-10 at 09:26 -0800, Patrick Mansfield wrote:
> > On Thu, Feb 10, 2005 at 12:19:51PM +0100, Kay Sievers wrote:
> > > %N - create a temporary node and substitute its name
> > > It will be created in udev_root as .tmp-<major>-<minor>
> > > The node is removed after the namedev call.
> >
> > Hi Kay -
> >
> > I tested with scsi_id, and found no S_IF* was being set for the mknod
> > mode.
>
> Yeah, sorry. It's already fixed in my tree.
Okay ... I checked greg's tree.
Why was the test passing?
-- 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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
` (2 preceding siblings ...)
2005-02-10 17:43 ` Patrick Mansfield
@ 2005-02-10 18:01 ` Kay Sievers
2005-02-10 18:05 ` Greg KH
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2005-02-10 18:01 UTC (permalink / raw)
To: linux-hotplug
On Thu, 2005-02-10 at 09:43 -0800, Patrick Mansfield wrote:
> On Thu, Feb 10, 2005 at 06:41:20PM +0100, Kay Sievers wrote:
> > On Thu, 2005-02-10 at 09:26 -0800, Patrick Mansfield wrote:
> > > On Thu, Feb 10, 2005 at 12:19:51PM +0100, Kay Sievers wrote:
> > > > %N - create a temporary node and substitute its name
> > > > It will be created in udev_root as .tmp-<major>-<minor>
> > > > The node is removed after the namedev call.
> > >
> > > Hi Kay -
> > >
> > > I tested with scsi_id, and found no S_IF* was being set for the mknod
> > > mode.
> >
> > Yeah, sorry. It's already fixed in my tree.
>
> Okay ... I checked greg's tree.
>
> Why was the test passing?
The test tested that it was _no_ block device. :)
Kay
-------------------------------------------------------
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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
` (3 preceding siblings ...)
2005-02-10 18:01 ` Kay Sievers
@ 2005-02-10 18:05 ` Greg KH
2005-02-10 18:05 ` Patrick Mansfield
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2005-02-10 18:05 UTC (permalink / raw)
To: linux-hotplug
On Thu, Feb 10, 2005 at 09:43:34AM -0800, Patrick Mansfield wrote:
> On Thu, Feb 10, 2005 at 06:41:20PM +0100, Kay Sievers wrote:
> > On Thu, 2005-02-10 at 09:26 -0800, Patrick Mansfield wrote:
> > > On Thu, Feb 10, 2005 at 12:19:51PM +0100, Kay Sievers wrote:
> > > > %N - create a temporary node and substitute its name
> > > > It will be created in udev_root as .tmp-<major>-<minor>
> > > > The node is removed after the namedev call.
> > >
> > > Hi Kay -
> > >
> > > I tested with scsi_id, and found no S_IF* was being set for the mknod
> > > mode.
> >
> > Yeah, sorry. It's already fixed in my tree.
>
> Okay ... I checked greg's tree.
Kay's fix is in my tree now too, I just pushed it out.
Looks like it's time for another release...
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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
` (4 preceding siblings ...)
2005-02-10 18:05 ` Greg KH
@ 2005-02-10 18:05 ` Patrick Mansfield
2005-02-10 18:18 ` Kay Sievers
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Patrick Mansfield @ 2005-02-10 18:05 UTC (permalink / raw)
To: linux-hotplug
On Thu, Feb 10, 2005 at 09:43:34AM -0800, Patrick Mansfield wrote:
>
> Why was the test passing?
>
I was confused by the test rule that was *not* supposed to match, i.e.
this is easier to read:
=== test/udev-test.pl 1.80 vs edited ==--- 1.80/test/udev-test.pl Thu Feb 10 02:46:49 2005
+++ edited/test/udev-test.pl Thu Feb 10 10:03:59 2005
@@ -1066,9 +1066,9 @@
desc => "temporary node creation test",
subsys => "block",
devpath => "/block/sda",
- exp_name => "sda",
+ exp_name => "node",
conf => <<EOF
-BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test ! -b %N" NAME="%N"
+BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test -b %N" NAME="node"
EOF
},
{
-------------------------------------------------------
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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
` (5 preceding siblings ...)
2005-02-10 18:05 ` Patrick Mansfield
@ 2005-02-10 18:18 ` Kay Sievers
2005-02-10 18:18 ` Patrick Mansfield
2005-02-10 18:26 ` Greg KH
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2005-02-10 18:18 UTC (permalink / raw)
To: linux-hotplug
On Thu, 2005-02-10 at 10:05 -0800, Patrick Mansfield wrote:
> On Thu, Feb 10, 2005 at 09:43:34AM -0800, Patrick Mansfield wrote:
> >
> > Why was the test passing?
> >
>
> I was confused by the test rule that was *not* supposed to match, i.e.
> this is easier to read:
>
> === test/udev-test.pl 1.80 vs edited ==> --- 1.80/test/udev-test.pl Thu Feb 10 02:46:49 2005
> +++ edited/test/udev-test.pl Thu Feb 10 10:03:59 2005
> @@ -1066,9 +1066,9 @@
> desc => "temporary node creation test",
> subsys => "block",
> devpath => "/block/sda",
> - exp_name => "sda",
> + exp_name => "node",
> conf => <<EOF
> -BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test ! -b %N" NAME="%N"
> +BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test -b %N" NAME="node"
> EOF
> },
> {
Yes, that's much better.
Thanks,
Kay
-------------------------------------------------------
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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
` (6 preceding siblings ...)
2005-02-10 18:18 ` Kay Sievers
@ 2005-02-10 18:18 ` Patrick Mansfield
2005-02-10 18:26 ` Greg KH
8 siblings, 0 replies; 10+ messages in thread
From: Patrick Mansfield @ 2005-02-10 18:18 UTC (permalink / raw)
To: linux-hotplug
On Thu, Feb 10, 2005 at 10:05:11AM -0800, Greg KH wrote:
> Kay's fix is in my tree now too, I just pushed it out.
>
> Looks like it's time for another release...
Can you wait a day or so?
I still have to fix scsi_id to set its hotplug_mode, probably if DEVPATH
and/or UDEV_LOG are set, so it will log errors via strlog when run with
"-d" option when invoked via udev.
-- 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] 10+ messages in thread
* Re: udev: provide temporary device nodes for callouts
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
` (7 preceding siblings ...)
2005-02-10 18:18 ` Patrick Mansfield
@ 2005-02-10 18:26 ` Greg KH
8 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2005-02-10 18:26 UTC (permalink / raw)
To: linux-hotplug
On Thu, Feb 10, 2005 at 10:18:38AM -0800, Patrick Mansfield wrote:
> On Thu, Feb 10, 2005 at 10:05:11AM -0800, Greg KH wrote:
>
> > Kay's fix is in my tree now too, I just pushed it out.
> >
> > Looks like it's time for another release...
>
> Can you wait a day or so?
>
> I still have to fix scsi_id to set its hotplug_mode, probably if DEVPATH
> and/or UDEV_LOG are set, so it will log errors via strlog when run with
> "-d" option when invoked via udev.
Sure, let me know when you are ready. There's already a 052 release out
there that I forgot to announce...
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] 10+ messages in thread
end of thread, other threads:[~2005-02-10 18:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-10 11:19 udev: provide temporary device nodes for callouts Kay Sievers
2005-02-10 17:26 ` Patrick Mansfield
2005-02-10 17:41 ` Kay Sievers
2005-02-10 17:43 ` Patrick Mansfield
2005-02-10 18:01 ` Kay Sievers
2005-02-10 18:05 ` Greg KH
2005-02-10 18:05 ` Patrick Mansfield
2005-02-10 18:18 ` Kay Sievers
2005-02-10 18:18 ` Patrick Mansfield
2005-02-10 18:26 ` 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).