Skip to contentSkip to conversation

udev 004 release

ANNOUNCE Applied Greg KH 7 participants 15 messages Oct 21, 2003 – Nov 23, 2003 Kbuild

lore
Share & tools
lore

Greg KH

author
#0 lore raw

Hi,

I've released the 004 version of udev. It can be found at:
kernel.org/pub/linux/utils/kernel/hotplug/udev-004.tar.gz

Thanks to Robert Love, there are now rpms available at:

	kernel.org/pub/linux/utils/kernel/hotplug/udev-004-1.i386.rpm

with the source rpm at:
kernel.org/pub/linux/utils/kernel/hotplug/udev-004-1.src.rpm

udev is a implementation of devfs in userspace using sysfs and /sbin/hotplug. It requires a 2.6 kernel to run properly.

The major changes since the 003 release are:
- MAJOR speedups over the previous version. No more "sleep(1)" always, we now wait for the "dev" file to show up, and not blindly guess.
- partitions now work again.
- removal of devices that were named differently from the kernel name work properly.
- proper spec file.
- a man page with real content.
- sync up with current version of libsysfs.

Many thanks to Dan Stekloff, Kay Sievers, and Robert Love for their help with patches for this release. I really appreciate it.

The full ChangeLog can be found below.

The udev FAQ can be found at:
kernel.org/pub/linux/utils/kernel/hotplug/udev-FAQ

Development of udev is done in a BitKeeper tree available at:
bk://kernel.bkbits.net/gregkh/udev/

If anyone ever wants a snapshot of the current tree, due to not using BitKeeper, or other reasons, is always available at any time by asking.

thanks,

greg k-h

Summary of changes from v003 to v004
======================

Daniel E. F. Stekloff:
o new version of libsysfs patch

Greg Kroah-Hartman:
o 004 release
o major database cleanups
o Changed test.block and test.tty to take ACTION from the command line
o don't sleep if 'dev' file is already present on device add
o fix comment about how the "dev" file is made up
o more database work. Now we only store the info we really need right now
o add BUS= bug to TODO list so it will not get forgotten
o spec file changes
o test.block changes
o ok, rpm likes the "_" character instead of "-" better
o change the version to 003-bk to keep things sane with people using the bk tree
o got "remove of named devices" working
o fix segfaults when dealing with partitions

Kay Sievers:
o man file update
o man page update

Robert Love:
o udev: mode should be mode_t
o udev: trivial trivialities
o udev: cool test scripts again
o udev spec file symlink support
o udev: cool test scripts
o udev spec file bits

-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 4 lines · Greg KH

Hi,

I've released the 004 version of udev. It can be found at:
kernel.org/pub/linux/utils/kernel/hotplug/udev-004.tar.gz

Hi Greg,

here a new patch for the man page:
o namdev.permissions added
o corrected a few typos
o corrected text for config line format.
owner, group mode are only in namedev.permissions (don't know what i was dreaming, while i wrote this :))

and a patch for namdev.c comments + debug
o correct 'device device'
o correct permission file to config file

I was looking how to set permissions on the created node. What is the future of struct device_attr?
Same values are in struct udevice now?

thanks,
Kay

udev.8 renamed from usr/src/udev/udev.8 +38 -13
@@ -2,28 +2,30 @@
 .SH NAME
 udev \- Linux configurable dynamic device naming support
 .SH SYNOPSIS
-.B udev
+.BI udev " hotplug-subsystem"
 .SH "DESCRIPTION"
 .B udev
 creates or removes device node files usually located in the /dev directory.
+Its goal is to provide a dynamic device directory that contains only the files
+for devices that are actually present.
+.P
 As part of the
 .B hotplug
 subsystem,
 .B udev
-is exectuted if a kernel device is added or removed from the system.
-.P
+is executed if a kernel device is added or removed from the system.
 On device creation,
 .B udev
-reads the sysfs directory of the given device, to collect device attributes
+reads the sysfs directory of the given device to collect device attributes
 like label, serial number or bus device number.
 These attributes are passed as a key to the namedev subsystem
 to receive a unique name for device file creation.
 namedev maintains a database for devices present on the system.
-.P
+.br
 On device removal,
 .B udev
-queries the namedev database for the name of the device file to delete.
-.P
+queries the namedev database for the name of the device file to be deleted.
+.SH "CONFIGURATION"
 namedev expects its configuration at
 .I /etc/udev/namedev.config.
 The file consists of a set of lines. All empty lines and
@@ -31,11 +33,16 @@
 .br
 Every line defines the mapping between device attributes and the device file
 name. It starts with a keyword defining the method used to match, followed by
-one ore more keys to compare, optional ownwership and permission settings and
-the filename for the device. If no matching configuration is found,
-the default kernel device name is used.
+one ore more keys to compare and the filename for the device. If no matching
+configuration is found, the default kernel device name is used.
 .P
-.I method, key,[key,...] [owner,] [group,] [mode,] name
+The line format is:
+.RS
+.sp
+.I method, key,[key,...] name
+.sp
+.RE
+where valid methods with corresponding keys are:
 .TP
 .B LABEL
 device label or serial number, like USB serial number, SCSI UUID or
@@ -62,7 +69,9 @@
 calling external program, that returns a string to match
 .br
 keys: \fBBUS\fP, \fBPROGRAM\fP, \fBID\fP
-.SH "EXAMPLE"
+.P
+A sample \fInamedev.conf\fP might look like this:
+.sp
 .nf
 # USB printer to be called lp_color
 LABEL, BUS="usb", serial="W09090207101241330", NAME="lp_color"
@@ -79,6 +88,22 @@
 # if /sbin/dev_id returns "V0815" device will be called dev0815
 CALLOUT, PROGRAM="/sbin/dev_id", BUS="pci", ID="V0815", NAME="dev0815"
 .fi
+.P
+Permissions and ownership for the created device files may specified at
+.I /etc/udev/namedev.permissions.
+The file consists of a set of lines. All empty lines and
+lines beginning with a '#' will be ignored.
+.br
+Every line lists a device name followed by owner, group and permission mode. All values are separated by colons.
+.sp
+A sample \fInamedev.permissions\fP might look like this:
+.sp
+.nf
+#name:user:group:mode
+ttyUSB1:root:uucp:0666
+dsp1:::0666
+.fi
+
 .SH "FILES"
 .nf
 .ft B
@@ -89,7 +114,7 @@
 .fi
 .LP
 .SH "SEE ALSO"
-.B hotplug (8)
+.BR hotplug (8)
 .PP
 The
 .I http://linux-hotplug.sourceforge.net/
namedev.c.1 renamed from namedev.c +3 -3
@@ -207,7 +207,7 @@
 	struct config_device dev;
 
 	strcpy(filename, UDEV_CONFIG_DIR NAMEDEV_CONFIG_FILE);
-	dbg("opening %s to read as permissions config", filename);
+	dbg("opening %s to read as config", filename);
 	fd = fopen(filename, "r");
 	if (fd == NULL) {
 		dbg("Can't open %s", filename);
@@ -568,7 +568,7 @@
 			if (tmpattr)
 				goto label_found;
 
-			/* look in the class device device directory if present */
+			/* look in the class device directory if present */
 			if (class_dev->sysdevice) {
 				tmpattr = sysfs_get_classdev_attr(class_dev, dev->sysfs_file);
 				if (tmpattr)
@@ -601,7 +601,7 @@
 					if (tmpattr) 
 						goto label_found;
 
-					/* look in the class device device directory if present */
+					/* look in the class device directory if present */
 					if (class_dev_parent->sysdevice) {
 						tmpattr = sysfs_get_classdev_attr(class_dev_parent, dev->sysfs_file);
 						if (tmpattr) 
author Applied
#2 lore raw
In reply to Greg KH
Quoted 16 lines · Kay Sievers
Quoted 4 lines · Greg KH

Hi,

I've released the 004 version of udev. It can be found at:
kernel.org/pub/linux/utils/kernel/hotplug/udev-004.tar.gz

Hi Greg,

here a new patch for the man page:
o namdev.permissions added
o corrected a few typos
o corrected text for config line format.
owner, group mode are only in namedev.permissions (don't know what i was dreaming, while i wrote this :))

Quoted 3 lines

and a patch for namdev.c comments + debug
o correct 'device device'
o correct permission file to config file

I've applied both of these, thanks.

Quoted 3 lines

I was looking how to set permissions on the created node. What is the future of struct device_attr?
Same values are in struct udevice now?

device_attr will go away. I was leaving the namedev.c file alone when I did the udevice cleanups so that merging with Dan's changes would be easier. Now I'm about to go clean that up.

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Greg KH

Thanks for the new release, Greg. I just tried it out on a system with some disks, but a bunch of udev processes ended up hanging. Is there something I'm missing or do you need a patch like this?

Thanks,
Jesse

udev-add.c +1 -1
@@ -141,7 +141,7 @@
 	strcat(filename, path);
 	strcat(filename, "/dev");
 
-	while (loop < SECONDS_TO_WAIT_FOR_DEV) {
+	while (loop++ < SECONDS_TO_WAIT_FOR_DEV) {
 		dbg("looking for %s", filename);
 		retval = stat(filename, &buf);
 		if (retval = 0) {

-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#4 lore raw
In reply to Greg KH
Quoted 3 lines · Jesse Barnes

Thanks for the new release, Greg. I just tried it out on a system with some disks, but a bunch of udev processes ended up hanging. Is there something I'm missing or do you need a patch like this?

Yeah, sorry, this kind of fix is required :(

It's fixed in my bk tree now.

Oh, and it looks like the LABEL rule is also broken due to the libsysfs changes... I'm working on adding regression tests right now to prevent things like this from slipping through.

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#5 lore raw
In reply to Greg KH
Quoted 5 lines · Greg KH
Quoted 3 lines · Jesse Barnes

Thanks for the new release, Greg. I just tried it out on a system with some disks, but a bunch of udev processes ended up hanging. Is there something I'm missing or do you need a patch like this?

Quoted 7 lines

Yeah, sorry, this kind of fix is required :(

It's fixed in my bk tree now.

Oh, and it looks like the LABEL rule is also broken due to the libsysfs changes... I'm working on adding regression tests right now to prevent things like this from slipping through.

Here's a patch for this. It fixes the problem of LABEL rules on the device, not the class device. LABEL rules on the class device seem to work just fine.

Thanks to Dan Stekloff for help in finding this bug.

thanks,

greg k-h

# fix LABEL bug for device files (not class files.)
namedev.c +2 -2
diff -Nru a/namedev.c b/namedev.c
@@ -566,7 +566,7 @@
 
 			/* look in the class device directory if present */
 			if (class_dev->sysdevice) {
-				tmpattr = sysfs_get_classdev_attr(class_dev, dev->sysfs_file);
+				tmpattr = sysfs_get_device_attr(class_dev->sysdevice, dev->sysfs_file);
 				if (tmpattr)
 					goto label_found;
 			}
@@ -599,7 +599,7 @@
 
 					/* look in the class device directory if present */
 					if (class_dev_parent->sysdevice) {
-						tmpattr = sysfs_get_classdev_attr(class_dev_parent, dev->sysfs_file);
+						tmpattr = sysfs_get_device_attr(class_dev_parent->sysdevice, dev->sysfs_file);
 						if (tmpattr) 
 							goto label_found;
 					}

-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#6 lore raw
In reply to Greg KH
Quoted 9 lines · Greg KH
Quoted 3 lines · Kay Sievers

I was looking how to set permissions on the created node. What is the future of struct device_attr?
Same values are in struct udevice now?

device_attr will go away. I was leaving the namedev.c file alone when I did the udevice cleanups so that merging with Dan's changes would be easier. Now I'm about to go clean that up.

Hi,

attached is a patch for udev-add.c to set file permissions. The problem is that the resolving of owner/group name to its numeric id needs shared libc libs. What does this mean for klibc?

gcc --static -o udev udev.o udev-add.o udev-remove.o udevdb.o logging.o namedev.o tdb/tdb.o tdb/spinlock.o -lsysfs -lc -Llibsysfs
udev-add.o(.text+0x3bf): In function `create_node':
udev-add.o(.text+0x2f6):/usr/src/udev/udev-add.c:122: warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking udev-add.o(.text+0x32d):/usr/src/udev/udev-add.c:128: warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

thanks,

Kay

udev-add.c renamed from udev-add.c.orig +59 -1
@@ -27,6 +27,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include <pwd.h>
+#include <grp.h>
 
 #include "udev.h"
 #include "udev_version.h"
@@ -98,7 +100,63 @@
 		dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
 		    filename, dev->mode, dev->major, dev->minor, strerror(errno));
 
-	// FIXME set the ownership of the node
+	/* set the ownership of the node if requested */
+	if ((*dev->owner == 0x00) && (*dev->group == 0x00))
+		return retval;
+
+	uid_t uid;
+	gid_t gid;
+
+	/* get current ownership */
+	struct stat file_stat;
+	lstat (filename, &file_stat);
+	uid = file_stat.st_uid;
+	gid = file_stat.st_gid;
+
+	if (*dev->owner != 0x00) {
+		char *endptr;
+		unsigned long id = strtoul(dev->owner, &endptr, 10);
+		/* if id is not numeric, ask system */
+		if (*endptr) {
+			dbg("got ascii owner: %s", dev->owner);
+			struct passwd *pwd = getpwnam (dev->owner);
+			if (pwd)
+				uid = pwd->pw_uid;
+			else
+				dbg("unable to resolve uid from string: %s",
+				    dev->owner);
+			endpwent();
+		} else {
+			uid = (uid_t) id;
+			dbg("got numeric owner: %u", uid);
+		}
+	}
+
+	if (*dev->group != 0x00) {
+		char *endptr;
+		unsigned long id = strtoul(dev->group, &endptr, 10);
+		/* if id is not numeric, ask system */
+		if (*endptr) {
+			dbg("got ascii group: %s", dev->group);
+			struct group *grp = getgrnam (dev->group);
+			if (grp)
+				gid = grp->gr_gid;
+			else
+				dbg("unable to resolve gid from string: %s",
+				    dev->group);
+			endgrent();
+		} else {
+			gid = (gid_t) id;
+			dbg("got numeric group: %u", gid);
+		}
+	}
+
+	dbg("chown(%s, %u, %u)", filename, uid, gid);
+	retval = chown(filename, uid, gid);
+	if (retval)
+		dbg("chown(%s, %u, %u) failed with error '%s'", filename,
+		    uid, gid, strerror(errno));
+
 	return retval;
 }
 
#7 lore raw
In reply to Greg KH
Quoted 8 lines · Ananth N Mavinakayanahalli
Quoted 7 lines · Greg KH
Quoted 6 lines · Kay Sievers
Quoted 4 lines · Greg KH

Hi,

I've released the 004 version of udev. It can be found at:
kernel.org/pub/linux/utils/kernel/hotplug/udev-004.tar.gz

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

and a patch for namdev.c comments + debug
o correct 'device device'

I suppose the original code is correct. If we do not find the attribute in the "class device" attributes list, look for the attribute in the actual (physical) "device" for this class device. However, the code does not seem to look for the attribute in the class_dev(_parent)->sysdevice. Inlined below is a patch to correct this.

This was my boo boo. I had two trees for putting the recent libsysfs code into udev. In copying from one tree to the other I forgot the sysfs_get_device_attr function and just blindly copied sysfs_get_classdev_attr. My bad.Just a stupid mistake. Sorry for the error. Greg has already corrected this in his tree.

Thanks,

Dan

Quoted 2 lines

Thanks,
Ananth

Signature · 13 lines
Daniel Stekloff <[email protected]>



-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#8 lore raw
In reply to Greg KH
Quoted 9 lines · Greg KH
Quoted 8 lines · Kay Sievers
Quoted 4 lines · Greg KH

Hi,

I've released the 004 version of udev. It can be found at:
kernel.org/pub/linux/utils/kernel/hotplug/udev-004.tar.gz

and a patch for namdev.c comments + debug
o correct 'device device'

I suppose the original code is correct. If we do not find the attribute in the "class device" attributes list, look for the attribute in the actual (physical) "device" for this class device. However, the code does not seem to look for the attribute in the class_dev(_parent)->sysdevice. Inlined below is a patch to correct this.

Thanks,
Ananth

Signature · 43 lines
Ananth Narayan <[email protected]>
Linux Technology Center,
IBM Software Lab, INDIA


diff -Naur udev-004/namedev.c temp/udev-004/namedev.c
--- udev-004/namedev.c	2003-10-20 14:12:44.000000000 +0500
+++ temp/udev-004/namedev.c	2003-10-22 14:05:25.000000000 +0500
@@ -568,9 +568,9 @@
 			if (tmpattr)
 				goto label_found;
 
-			/* look in the class device device directory if present */
+			/* look in the "device" directory of the class device if present */
 			if (class_dev->sysdevice) {
-				tmpattr = sysfs_get_classdev_attr(class_dev, dev->sysfs_file);
+				tmpattr = sysfs_get_device_attr(class_dev->sysdevice, dev->sysfs_file);
 				if (tmpattr)
 					goto label_found;
 			}
@@ -601,9 +601,9 @@
 					if (tmpattr) 
 						goto label_found;
 
-					/* look in the class device device directory if present */
+					/* look in the "device" directory of the class device if present */
 					if (class_dev_parent->sysdevice) {
-						tmpattr = sysfs_get_classdev_attr(class_dev_parent, dev->sysfs_file);
+						tmpattr = sysfs_get_device_attr(class_dev_parent->sysdevice, dev->sysfs_file);
 						if (tmpattr) 
 							goto label_found;
 					}


-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
author
#9 lore raw
In reply to Greg KH
Quoted 7 lines · Kay Sievers
Quoted 6 lines · Greg KH
Quoted 3 lines · Kay Sievers

I was looking how to set permissions on the created node. What is the future of struct device_attr?
Same values are in struct udevice now?

Quoted 7 lines
Quoted 3 lines

device_attr will go away. I was leaving the namedev.c file alone when I did the udevice cleanups so that merging with Dan's changes would be easier. Now I'm about to go clean that up.

Hi,

attached is a patch for udev-add.c to set file permissions.

Nice.

Quoted 2 lines

The problem is that the resolving of owner/group name to its numeric id needs shared libc libs. What does this mean for klibc?

Hm, not good. udev has to be able to be linked statically. I just got the klibc build working properly, and it makes a world of difference in size compared to glibc.

Could we convert the permissions file to numbers at build time? That way the /etc/* file parsing would not be needed. Yeah, it's not the nicest solution. Anyone know of any other way we can do this properly?

Remember we have to be able to create nodes before the real /etc is even mounted.

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#10 lore raw
In reply to Greg KH
Quoted 9 lines · Greg KH
Quoted 2 lines · Kay Sievers

attached is a patch for udev-add.c to set file permissions.

Nice.

Quoted 2 lines

The problem is that the resolving of owner/group name to its numeric id needs shared libc libs. What does this mean for klibc?

Quoted 7 lines

Hm, not good. udev has to be able to be linked statically. I just got the klibc build working properly, and it makes a world of difference in size compared to glibc.

Could we convert the permissions file to numbers at build time? That way the /etc/* file parsing would not be needed. Yeah, it's not the nicest solution. Anyone know of any other way we can do this properly?

Hi,
here is the patch for ownership setting on the ceated device node, supporting only numeric id's given in udev.permissions. For now, it may be better than nothing.

o set ownership of device node
for now, we only accept numeric id's in udev.permissions cause we are unable to resolve it with klibc and/or before real /etc is even mounted

and for the man page:

o present the tiny udev in bold font :)
o make CALLOUT example look less fictious

thanks,
Kay

udev-add.c renamed from udev-add.c.orig +31 -2
@@ -67,7 +67,8 @@
 }
 
 /*
- * We also want to add some permissions here, and possibly some symlinks
+ * we possibly want to add some symlinks here
+ * only numeric owner/group id's are supported
  */
 static int create_node(struct udevice *dev)
 {
@@ -106,7 +107,35 @@
 		dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
 		    filename, dev->mode, dev->major, dev->minor, strerror(errno));
 
-	// FIXME set the ownership of the node
+	uid_t uid = 0;
+	gid_t gid = 0;
+
+	if (*dev->owner) {
+		char *endptr;
+		unsigned long id = strtoul(dev->owner, &endptr, 10);
+		if (*endptr == 0x00)
+			uid = (uid_t) id;
+		else
+			dbg("only numeric owner id supported: %s", dev->owner);
+	}
+
+	if (*dev->group) {
+		char *endptr;
+		unsigned long id = strtoul(dev->group, &endptr, 10);
+		if (*endptr == 0x00)
+			gid = (gid_t) id;
+		else
+			dbg("only numeric group id supported: %s", dev->group);
+	}
+
+	if (uid || gid) {
+		dbg("chown(%s, %u, %u)", filename, uid, gid);
+		retval = chown(filename, uid, gid);
+		if (retval)
+			dbg("chown(%s, %u, %u) failed with error '%s'", filename,
+			    uid, gid, strerror(errno));
+	}
+
 	return retval;
 }
 
home/kay/udev/udev.8 renamed from udev.8 +8 -5
@@ -20,13 +20,15 @@
 like label, serial number or bus device number.
 These attributes are treated as a key 
 to determine a unique name for device file creation.
-udev maintains a database for devices present on the system.
+.B udev
+maintains a database for devices present on the system.
 .br
 On device removal,
 .B udev
 queries the internal database for the name of the device file to be deleted.
 .SH "CONFIGURATION"
-udev expects its configuration at
+.B udev
+expects its configuration at
 .I /etc/udev/udev.config.
 The file consists of a set of lines. All empty lines and
 lines beginning with a '#' will be ignored.
@@ -85,8 +87,8 @@
 # ttyUSB1 should always be called pda
 REPLACE, KERNEL="ttyUSB1", NAME="pda"
 
-# if /sbin/dev_id returns "V0815" device will be called dev0815
-CALLOUT, PROGRAM="/sbin/dev_id", BUS="pci", ID="V0815", NAME="dev0815"
+# if /sbin/scsi_id returns "OEM 0815" device will be called disk1
+CALLOUT, PROGRAM="/sbin/scsi_id" BUS="scsi", ID="OEM 0815" NAME="disk1"
 .fi
 .P
 Permissions and ownership for the created device files may specified at
@@ -120,5 +122,6 @@
 .I http://linux-hotplug.sourceforge.net/
 web site.
 .SH AUTHORS
-udev was developed by Greg Kroah-Hartman <[email protected]> with much help from
+.B udev
+was developed by Greg Kroah-Hartman <[email protected]> with much help from
 Dan Stekloff <[email protected]> and many others.
#11 lore raw
In reply to Greg KH
Quoted 9 lines · Kay Sievers
Quoted 8 lines · Greg KH
Quoted 2 lines · Kay Sievers

The problem is that the resolving of owner/group name to its numeric id needs shared libc libs. What does this mean for klibc?

Hm, not good. udev has to be able to be linked statically. I just got the klibc build working properly, and it makes a world of difference in size compared to glibc.

Quoted 7 lines
Quoted 3 lines

Could we convert the permissions file to numbers at build time? That way the /etc/* file parsing would not be needed. Yeah, it's not the nicest solution. Anyone know of any other way we can do this properly?

here is the patch for ownership setting on the ceated device node, supporting only numeric id's given in udev.permissions. For now, it may be better than nothing.

What about the following approach?

- You don't want uid/gid resolved at build time or specified numericaly, it would make the sysadm very unhappy.
- On the other hand, nobody cares much about device ownership before /etc/passwd is mounted and the nsswitch is operational. At that time, it is sufficient for udev to just create the device, so that root can mount it.
- So you really need two versions of udev, one suitable for use on initramfs (linked to klibc) that ignores ownership while creating devices, another (linked to glibc) that does proper user/group name resolution, using /etc/group, LDAP or whatever they'll think up next.
- Somewhere early in the boot cycle you will need a script that switches from the minimal udev to full udev and that applies the ownership info from the config file to devices that already have been created.

Regards,
Erik

-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program. Do you like what SourceForge.net is doing for the Open Source Community? Make a contribution, and help us add new features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#12 lore raw
In reply to Greg KH
Quoted 9 lines · Kay Sievers
Quoted 8 lines · Greg KH
Quoted 2 lines · Kay Sievers

The problem is that the resolving of owner/group name to its numeric id needs shared libc libs. What does this mean for klibc?

Hm, not good. udev has to be able to be linked statically. I just got the klibc build working properly, and it makes a world of difference in size compared to glibc.

Quoted 7 lines
Quoted 3 lines

Could we convert the permissions file to numbers at build time? That way the /etc/* file parsing would not be needed. Yeah, it's not the nicest solution. Anyone know of any other way we can do this properly?

here is the patch for ownership setting on the ceated device node, supporting only numeric id's given in udev.permissions. For now, it may be better than nothing.

What about the following approach?

- You don't want uid/gid resolved at build time or specified numericaly, it would make the sysadm very unhappy.
- On the other hand, nobody cares much about device ownership before /etc/passwd is mounted and the nsswitch is operational. At that time, it is sufficient for udev to just create the device, so that root can mount it.
- So you really need two versions of udev, one suitable for use on initramfs (linked to klibc) that ignores ownership while creating devices, another (linked to glibc) that does proper user/group name resolution, using /etc/group, LDAP or whatever they'll think up next.
- Somewhere early in the boot cycle you will need a script that switches from the minimal udev to full udev and that applies the ownership info from the config file to devices that already have been created.

Regards,
Erik

-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program. Do you like what SourceForge.net is doing for the Open Source Community? Make a contribution, and help us add new features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#13 lore raw
In reply to Greg KH
Quoted 9 lines · Erik van Konijnenburg

- So you really need two versions of udev, one suitable for use on initramfs (linked to klibc) that ignores ownership while creating devices, another (linked to glibc) that does proper user/group name resolution, using /etc/group, LDAP or whatever they'll think up next.
- Somewhere early in the boot cycle you will need a script that switches from the minimal udev to full udev and that applies the ownership info from the config file to devices that already have been created.

Sounds good to me. Care to help with it? :)

thanks,

greg k-h

-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest developments in Apache, PHP, Perl, XML, Java, MySQL, WebDAV, and more! http://www.apachecon.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#14 lore raw
In reply to Greg KH
Quoted 11 lines · Kay Sievers
Quoted 9 lines · Greg KH
Quoted 3 lines · Kay Sievers

I was looking how to set permissions on the created node. What is the future of struct device_attr?
Same values are in struct udevice now?

device_attr will go away. I was leaving the namedev.c file alone when I did the udevice cleanups so that merging with Dan's changes would be easier. Now I'm about to go clean that up.

Quoted 5 lines

Hi,

attached is a patch for udev-add.c to set file permissions. The problem is that the resolving of owner/group name to its numeric id needs shared libc libs. What does this mean for klibc?

I've just applied a patch to the bk tree that adds this kind of support to udev, but works with glibc. If building with klibc, you can not use string group name and user names. It's a comprimise, and something the Debian people have been wanting.

Thanks to Marco d'Itri for the patch.

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel