Skip to contentSkip to conversation

udev - keep private data out of the database?

PATCH Kay Sievers 2 participants 2 messages Feb 12, 2004

lore
Share & tools
lore
#0 lore raw

Shouldn't we keep the temporary strings out of the database, or is this information useful for something?

It cuts the length of the data from 628 to 275 bytes.

And shouldn't we add a 'rm /udev/.udevdb' to the init scripts? Without it, we can't change the format of the records, cause udev refuses to work with the old file.

thanks,
Kay

===== udev.h 1.38 vs edited =====

udev.h +9 -5
@@ -24,6 +24,7 @@
 #define UDEV_H
 
 #include "libsysfs/libsysfs.h"
+#include <stddef.h>
 #include <sys/param.h>
 
 #define COMMENT_CHARACTER		'#'
@@ -33,6 +34,9 @@
 #define GROUP_SIZE	30
 #define MODE_SIZE	8
 
+/* length of public data */
+#define UDEVICE_LEN (offsetof(struct udevice, bus_id))
+
 struct udevice {
 	char name[NAME_SIZE];
 	char owner[OWNER_SIZE];
@@ -43,11 +47,11 @@
 	unsigned int mode;	/* not mode_t due to conflicting definitions in different libcs */
 	char symlink[NAME_SIZE];
 
-	/* fields that help us in building strings */
-	unsigned char bus_id[SYSFS_NAME_LEN];
-	unsigned char program_result[NAME_SIZE];
-	unsigned char kernel_number[NAME_SIZE];
-	unsigned char kernel_name[NAME_SIZE];
+	/* private data that help us in building strings */
+	char bus_id[SYSFS_NAME_LEN];
+	char program_result[NAME_SIZE];
+	char kernel_number[NAME_SIZE];
+	char kernel_name[NAME_SIZE];
 };
 
 #define strfieldcpy(to, from) \

===== udevdb.c 1.19 vs edited =====

udevdb.c +4 -3
@@ -58,8 +58,8 @@
 	key.dsize = strlen(keystr) + 1;
 
 	data.dptr = (void *)dev;
-	data.dsize = sizeof(*dev);
-	
+	data.dsize = UDEVICE_LEN;
+
 	return tdb_store(udevdb, key, data, TDB_REPLACE); 
 }
 
@@ -77,7 +77,8 @@
 	if (data.dptr == NULL || data.dsize == 0)
 		return -ENODEV;
 
-	memcpy(dev, data.dptr, sizeof(*dev));
+	memset(dev, 0, sizeof(struct udevice));
+	memcpy(dev, data.dptr, UDEVICE_LEN);
 	return 0;
 }
 
#1 lore raw
Quoted 4 lines · Kay Sievers

Shouldn't we keep the temporary strings out of the database, or is this information useful for something?

It cuts the length of the data from 628 to 275 bytes.

Nice, applied.

Quoted 3 lines

And shouldn't we add a 'rm /udev/.udevdb' to the init scripts? Without it, we can't change the format of the records, cause udev refuses to work with the old file.

Good point. I'll go add that.

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