Skip to contentSkip to conversation

patches for udev 018

PATCH Marco d'Itri 2 participants 2 messages Feb 21, 2004 – Feb 28, 2004 Kbuild

lore
Share & tools
lore
#0 lore raw

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

Signature · 2 lines
ciao, |
Marco | [4695 sc.Be13Nezixw]
extras/ide-devfs.sh +3 -3
diff -ruN udev-018.orig/extras/ide-devfs.sh udev-018/extras/ide-devfs.sh
@@ -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
udev.c +6 -1
diff -ruN udev-018.orig/udev.c udev-018/udev.c
@@ -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) {
Makefile +1 -1
diff -ruN udev-018.orig/Makefile udev-018/Makefile
@@ -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 ; \
namedev.c +40 -16

70 lines not on this page · raw message

udev.h +6 -0
diff -ruN udev-018.orig/udev.h udev-018/udev.h
@@ -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);
namedev_parse.c +35 -5
diff -ruN udev-018.orig/namedev_parse.c udev-018/namedev_parse.c
@@ -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];
udev-remove.c +6 -0
diff -ruN udev-018.orig/udev-remove.c udev-018/udev-remove.c
@@ -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));
logging.h +1 -0
diff -ruN udev-016.orig/logging.h udev-016/logging.h
@@ -32,6 +32,7 @@
 #ifdef LOG
 #include <stdarg.h>
 #include <syslog.h>
+#include <unistd.h>
 
 #undef info
 #define info(format, arg...)								\
#1 lore raw

On Sat, Feb 21, 2004 at 07:12:22PM +0100, Marco d'Itri wrote:

Hm, next time can you CC: me so I am sure to see these patches? Most of them don't apply anymore :(

Can you redo them against the 019 release, and send them each in a separate email (one mail per patch.)

thanks,

greg k-h

-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel