From: "Marco d'Itri" <md@Linux.IT>
To: linux-hotplug@vger.kernel.org
Subject: patches for udev 018
Date: Sat, 21 Feb 2004 18:12:22 +0000 [thread overview]
Message-ID: <20040221181222.GA14818@wonderland.linux.it> (raw)
[-- Attachment #1: Type: text/plain, Size: 545 bytes --]
fix_expr: remove usage of expr in ide-devfs.sh, because it may be in
/usr/bin and not available at early boot time.
fix_segfault: fix a segfault when udev is started without the command
line parameter.
makefile_clean: delete all binaries when cleaning
merge_symlinks: allow multiple KERNEL=... SYMLINK=... directives
multiple_rules: allow listing more than one rules file in udev.conf
no_error_on_enoent: do not exit with an error and delete all files
remove_warnings: fix a compile time warning
--
ciao, |
Marco | [4695 sc.Be13Nezixw]
[-- Attachment #2: fix_expr --]
[-- Type: text/plain, Size: 700 bytes --]
diff -ruN udev-018.orig/extras/ide-devfs.sh udev-018/extras/ide-devfs.sh
--- udev-018.orig/extras/ide-devfs.sh 2004-02-19 19:38:37.000000000 +0100
+++ udev-018/extras/ide-devfs.sh 2004-02-21 17:57:06.000000000 +0100
@@ -8,7 +8,7 @@
TARGET="${2#[0-9]\.}"
if [ -z "${HOST#[13579]}" ]; then
- HOST=`expr ${HOST} - 1`
+ HOST=$((${HOST} - 1))
BUS="1"
else
BUS="0"
@@ -24,7 +24,7 @@
if [ -e "${x}" ]; then
MEDIA=`cat ${x}`
if [ "${MEDIA}" = "$2" ]; then
- num=`expr ${num} + 1`
+ num=$((${num} + 1))
fi
if [ "${x}" = "/proc/ide/${DRIVE}/media" ]; then
break
@@ -32,7 +32,7 @@
fi
done
- echo `expr ${num} - 1`
+ echo $((${num} - 1))
}
if [ -z "$3" ]; then
[-- Attachment #3: fix_segfault --]
[-- Type: text/plain, Size: 478 bytes --]
diff -ruN udev-018.orig/udev.c udev-018/udev.c
--- udev-018.orig/udev.c 2004-02-19 19:38:35.000000000 +0100
+++ udev-018/udev.c 2004-02-21 11:40:26.000000000 +0100
@@ -129,8 +129,13 @@
goto exit;
}
- /* skip blacklisted subsystems */
subsystem = argv[1];
+ if (!subsystem) {
+ dbg ("no subsystem?");
+ goto exit;
+ }
+
+ /* skip blacklisted subsystems */
i = 0;
while (subsystem_blacklist[i][0] != '\0') {
if (strcmp(subsystem, subsystem_blacklist[i]) == 0) {
[-- Attachment #4: makefile_clean --]
[-- Type: text/plain, Size: 579 bytes --]
diff -ruN udev-018.orig/Makefile udev-018/Makefile
--- udev-018.orig/Makefile 2004-02-19 19:38:36.000000000 +0100
+++ udev-018/Makefile 2004-02-21 13:41:36.000000000 +0100
@@ -278,7 +278,7 @@
clean:
-find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
| xargs rm -f
- -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(HELPER) $(DAEMON) $(SENDER)
+ -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(TESTER) $(HELPER) $(DAEMON) $(SENDER)
$(MAKE) -C klibc clean
@extras="$(EXTRAS)" ; for target in $$extras ; do \
echo $$target ; \
[-- Attachment #5: merge_symlinks --]
[-- Type: text/plain, Size: 3092 bytes --]
diff -ruN udev-018.orig/namedev.c udev-018/namedev.c
--- udev-018.orig/namedev.c 2004-02-19 19:38:37.000000000 +0100
+++ udev-018/namedev.c 2004-02-21 12:57:35.000000000 +0100
@@ -805,30 +805,54 @@
list_for_each_entry(dev, &config_device_list, node) {
dbg("process rule");
if (match_rule(dev, class_dev, udev, sysfs_device) == 0) {
- if (dev->name[0] == '\0') {
+ if (dev->name[0] == '\0' && dev->name[0] == '\0'
+ && dev->symlink[0] == '\0') {
info("configured rule in '%s' at line %i applied, '%s' is ignored",
udev_rules_filename, dev->config_line, udev->kernel_name);
return -1;
}
- info("configured rule in '%s' at line %i applied, '%s' becomes '%s'",
- udev_rules_filename, dev->config_line, udev->kernel_name, dev->name);
- strfieldcpy(udev->name, dev->name);
- strfieldcpy(udev->symlink, dev->symlink);
- goto found;
+ /* if everything matched add symlink to list of aliases */
+ if (dev->symlink[0] != '\0') {
+ char temp[NAME_MAX];
+
+ /* do not clobber dev */
+ strfieldcpy(temp, dev->symlink);
+ apply_format(udev, temp, class_dev, sysfs_device);
+ if (strlen(udev->symlink) + strlen(temp) + 2
+ > sizeof(udev->symlink)) {
+ dbg("could not append symlink %s for %s",
+ dev->symlink, udev->kernel_name);
+ } else {
+ strfieldcat(udev->symlink, temp);
+ strfieldcat(udev->symlink, " ");
+ }
+ }
+
+ /* is this symlink only rule? */
+ if (dev->name[0] == '\0')
+ continue;
+
+ /* Yup, this rule belongs to us!
+ * but continue to collect symlinks */
+ if (udev->name[0] == '\0') {
+ info("configured rule line %i applied, '%s' becomes '%s'",
+ dev->config_line, udev->kernel_name, dev->name);
+ strfieldcpy(udev->name, dev->name);
+ /* substitute placeholder */
+ apply_format(udev, udev->name, class_dev, sysfs_device);
+ } else {
+ dbg("conflicting rule for '%s' would become '%s'",
+ dev->kernel, dev->name);
+ }
}
}
- /* no rule was found so we use the kernel name */
- strfieldcpy(udev->name, udev->kernel_name);
- goto done;
-
-found:
- /* substitute placeholder */
- apply_format(udev, udev->name, class_dev, sysfs_device);
- apply_format(udev, udev->symlink, class_dev, sysfs_device);
- udev->partitions = dev->partitions;
-done:
+ /* no rule was found, so we use the kernel name */
+ if (udev->name[0] == '\0')
+ strfieldcpy(udev->name, class_dev->name);
+ dbg("symlinks for '%s' are: '%s'", udev->name, udev->symlink);
+
perm = find_perm(udev->name);
if (perm) {
udev->mode = perm->mode;
diff -ruN udev-018.orig/udev.h udev-018/udev.h
--- udev-018.orig/udev.h 2004-02-19 19:38:37.000000000 +0100
+++ udev-018/udev.h 2004-02-21 12:12:58.000000000 +0100
@@ -61,6 +61,12 @@
strncpy(to, from, sizeof(to)-1); \
} while (0)
+#define strfieldcat(to, from) \
+do { \
+ to[sizeof(to)-1] = '\0'; \
+ strncat(to, from, sizeof(to)-1); \
+} while (0)
+
extern int udev_add_device(char *path, char *subsystem, int fake);
extern int udev_remove_device(char *path, char *subsystem);
extern void udev_init_config(void);
[-- Attachment #6: multiple_rules --]
[-- Type: text/plain, Size: 1638 bytes --]
diff -ruN udev-018.orig/namedev_parse.c udev-018/namedev_parse.c
--- udev-018.orig/namedev_parse.c 2004-02-19 19:38:35.000000000 +0100
+++ udev-018/namedev_parse.c 2004-02-21 15:30:29.000000000 +0100
@@ -114,7 +114,32 @@
return NULL;
}
-int namedev_init_rules(void)
+static int call_foreach_file(int parser (const char *f) , char *filenames)
+{
+ char *start = filenames;
+ int retval = 0;
+
+ while (1) {
+ char *end, *file;
+
+ for (end = start; !isspace(*end) && *end != '\0'; end++)
+ ;
+
+ file = malloc(end - start + 1);
+ strncpy(file, start, end - start);
+ file[end - start] = '\0';
+ retval += parser(file);
+ free(file);
+
+ if (*end == '\0')
+ break;
+ start = end + 1;
+ }
+
+ return retval;
+}
+
+static int namedev_parse_rules(const char *filename)
{
char line[255];
int lineno;
@@ -127,11 +152,11 @@
int retval = 0;
struct config_device dev;
- fd = fopen(udev_rules_filename, "r");
+ fd = fopen(filename, "r");
if (fd != NULL) {
- dbg("reading '%s' as rules file", udev_rules_filename);
+ dbg("reading '%s' as rules file", filename);
} else {
- dbg("can't open '%s' as a rules file", udev_rules_filename);
+ dbg("can't open '%s' as a rules file", filename);
return -ENODEV;
}
@@ -262,7 +287,7 @@
continue;
error:
dbg("%s:%d:%d: parse error, rule skipped",
- udev_rules_filename, lineno, temp - line);
+ filename, lineno, temp - line);
}
}
exit:
@@ -270,6 +295,11 @@
return retval;
}
+int namedev_init_rules(void)
+{
+ return call_foreach_file(namedev_parse_rules, udev_rules_filename);
+}
+
int namedev_init_permissions(void)
{
char line[255];
[-- Attachment #7: no_error_on_enoent --]
[-- Type: text/plain, Size: 826 bytes --]
diff -ruN udev-018.orig/udev-remove.c udev-018/udev-remove.c
--- udev-018.orig/udev-remove.c 2004-02-19 19:38:35.000000000 +0100
+++ udev-018/udev-remove.c 2004-02-21 13:40:21.000000000 +0100
@@ -51,6 +51,8 @@
/* remove if empty */
retval = rmdir(path);
+ if (errno == ENOENT)
+ retval = 0;
if (retval) {
if (errno == ENOTEMPTY)
return 0;
@@ -77,6 +79,8 @@
info("removing device node '%s'", filename);
retval = unlink(filename);
+ if (errno == ENOENT)
+ retval = 0;
if (retval) {
dbg("unlink(%s) failed with error '%s'",
filename, strerror(errno));
@@ -108,6 +112,8 @@
dbg("unlinking symlink '%s'", filename);
retval = unlink(filename);
+ if (errno == ENOENT)
+ retval = 0;
if (retval) {
dbg("unlink(%s) failed with error '%s'",
filename, strerror(errno));
[-- Attachment #8: remove_warnings --]
[-- Type: text/plain, Size: 323 bytes --]
diff -ruN udev-016.orig/logging.h udev-016/logging.h
--- udev-016.orig/logging.h 2004-02-02 10:34:49.000000000 +0100
+++ udev-016/logging.h 2004-02-03 22:27:43.000000000 +0100
@@ -32,6 +32,7 @@
#ifdef LOG
#include <stdarg.h>
#include <syslog.h>
+#include <unistd.h>
#undef info
#define info(format, arg...) \
next reply other threads:[~2004-02-21 18:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-21 18:12 Marco d'Itri [this message]
2004-02-28 1:07 ` patches for udev 018 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=20040221181222.GA14818@wonderland.linux.it \
--to=md@linux.it \
--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.