From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: [udev] updated man, subdirs, ownership, namedev enum patches
Date: Wed, 05 Nov 2003 19:38:04 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-106809434224013@msgid-missing> (raw)
[-- Attachment #1: Type: text/plain, Size: 880 bytes --]
Hi Greg,
here are the updated patches for udev, please ignore all previous sent.
Included is the man page update, support for subdir creation/removal,
basic node ownership support and a namedev correction.
thanks,
Kay
01-udev.8.diff:
man page style fixes
present the tiny udev in bold font :)
02-udev-add.c-subdirs.diff:
02-udev-remove.c-subdirs.diff:
support subdirectory creation/removal for NAME="/devfs/is/crazy/video0"
create parent subdirs for device node if needed
remove subdirs when last node is removed
03-udev-add.c-set_owner.diff
set uid/gid of node specified in udev.permissions
only numeric id's are supported cause we can't resolve with
klibc or libc before real /etc is mounted
04-namedev.c-cleanup.diff
remove part of udev that appends the kernel enumeration to character devices
in LABEL method: NAME="webcam" results in /udev/webcam0
[-- Attachment #2: 01-udev.8.diff --]
[-- Type: text/plain, Size: 1495 bytes --]
--- udev.8 2003-10-22 01:09:41.000000000 +0200
+++ /home/kay/udev/udev.8 2003-10-24 15:06:41.000000000 +0200
@@ -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 <greg@kroah.com> with much help from
+.B udev
+was developed by Greg Kroah-Hartman <greg@kroah.com> with much help from
Dan Stekloff <dsteklof@us.ibm.com> and many others.
[-- Attachment #3: 02-udev-add.c-subdirs.diff --]
[-- Type: text/plain, Size: 844 bytes --]
--- ../udev/udev-add.c 2003-10-30 22:46:08.000000000 +0100
+++ udev-add.c 2003-10-31 14:38:48.000000000 +0100
@@ -100,6 +100,32 @@
return -EINVAL;
}
+ /* create subdirectories if requested */
+ if (strchr(dev->name, '/')) {
+ char path[255];
+ char *pos;
+ struct stat stats;
+
+ strncpy(path, filename, sizeof(path));
+ pos = strchr(path+1, '/');
+ while (1) {
+ pos = strchr(pos+1, '/');
+ if (pos == NULL)
+ break;
+ *pos = 0x00;
+ if (stat(path, &stats)) {
+ retval = mkdir(path, 0755);
+ if (retval) {
+ dbg("mkdir(%s) failed with error '%s'",
+ path, strerror(errno));
+ return retval;
+ }
+ dbg("created %s", path);
+ }
+ *pos = '/';
+ }
+ }
+
dbg("mknod(%s, %#o, %u, %u)", filename, dev->mode, dev->major, dev->minor);
retval = mknod(filename, dev->mode, res);
if (retval)
[-- Attachment #4: 02-udev-remove.c-subdirs.diff --]
[-- Type: text/plain, Size: 1121 bytes --]
--- ../udev/udev-remove.c 2003-10-30 22:46:08.000000000 +0100
+++ udev-remove.c 2003-11-04 15:07:35.000000000 +0100
@@ -69,12 +69,45 @@
static int delete_node(char *name)
{
char filename[255];
+ int retval;
strncpy(filename, udev_root, sizeof(filename));
strncat(filename, name, sizeof(filename));
dbg("unlinking %s", filename);
- return unlink(filename);
+ retval = unlink(filename);
+ if (retval) {
+ dbg("unlink(%s) failed with error '%s'",
+ filename, strerror(errno));
+ return retval;
+ }
+
+ /* remove subdirectories */
+ if (strchr(name, '/')) {
+ char *pos;
+
+ pos = strrchr(filename, '/');
+ while (1) {
+ *pos = 0x00;
+ pos = strrchr(filename, '/');
+
+ /* don't remove the last one */
+ if ((pos == filename) || (pos == NULL))
+ break;
+
+ /* remove if empty */
+ retval = rmdir(filename);
+ if (retval) {
+ if (errno == ENOTEMPTY)
+ return 0;
+ dbg("rmdir(%s) failed with error '%s'",
+ filename, strerror(errno));
+ break;
+ }
+ dbg("removed %s", filename);
+ }
+ }
+ return retval;
}
int udev_remove_device(char *device, char *subsystem)
[-- Attachment #5: 03-udev-add.c-set_owner.diff --]
[-- Type: text/plain, Size: 1259 bytes --]
--- /tmp/udev-add.c 2003-11-05 18:58:53.000000000 +0100
+++ udev-add.c 2003-11-05 18:58:58.000000000 +0100
@@ -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)
{
@@ -132,7 +133,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;
}
[-- Attachment #6: 04-namedev.c-cleanup.diff --]
[-- Type: text/plain, Size: 960 bytes --]
--- ../udev/namedev.c 2003-10-30 22:46:08.000000000 +0100
+++ namedev.c 2003-11-05 20:13:38.000000000 +0100
@@ -623,10 +623,6 @@
}
strcpy(udev->name, dev->name);
- if (isdigit(class_dev->path[strlen(class_dev->path)-1])) {
- temp = &class_dev->path[strlen(class_dev->path)-1];
- strcat(udev->name, temp);
- }
if (dev->mode != 0) {
udev->mode = dev->mode;
strcpy(udev->owner, dev->owner);
@@ -671,8 +667,8 @@
strcpy(udev->group, dev->group);
}
dbg_parse("device id '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
- dev->id, udev->name,
- dev->owner, dev->group, dev->mode);
+ dev->id, udev->name,
+ dev->owner, dev->group, dev->mode);
goto done;
break;
}
@@ -683,7 +679,7 @@
if (!class_dev->sysdevice)
continue;
- found = 0;
+ found = 0;
strcpy(path, class_dev->sysdevice->path);
temp = strrchr(path, '/');
dbg_parse("TOPOLOGY path = '%s'", path);
next reply other threads:[~2003-11-05 19:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-05 19:38 Kay Sievers [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-11-12 3:53 [udev] updated man, subdirs, ownership, namedev enum patches Greg KH
2003-11-12 13:23 ` Kay Sievers
2003-11-13 6:23 ` Greg KH
2003-11-13 8:30 ` Kay Sievers
2003-11-13 19:49 ` Greg KH
2003-11-15 16:09 ` Kay Sievers
2003-11-17 17:33 ` Arnd Bergmann
2003-11-18 1:00 ` Greg KH
2003-11-18 1:14 ` Greg KH
2003-11-18 3:15 ` Kay Sievers
2003-11-18 12:09 ` Arnd Bergmann
2003-11-18 12:17 ` Arnd Bergmann
2003-11-19 0:24 ` Greg KH
2003-11-19 23:40 ` Greg KH
2003-11-19 23:42 ` 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-106809434224013@msgid-missing \
--to=kay.sievers@vrfy.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.