linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] avoid unaligned access to data
@ 2004-02-29 20:45 Olaf Hering
  2004-03-05 22:21 ` Olaf Hering
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Olaf Hering @ 2004-02-29 20:45 UTC (permalink / raw)
  To: linux-hotplug


the data access in udevinfo is usually unaligned, due to the fact that
the struct is at offset strlen(sysfspath). That makes an ia64 kernel
rather unhappy. Unless I miss something, this change makes it happy by
making an incompatible change to the database.


diff -p -purN udev-018/udevdb.c udev-018.align/udevdb.c
--- udev-018/udevdb.c	2004-02-19 19:38:36.000000000 +0100
+++ udev-018.align/udevdb.c	2004-02-22 13:05:15.000000000 +0100
@@ -44,6 +44,8 @@
 static TDB_CONTEXT *udevdb;
 
 
+#define	my_key_align (__alignof__(char *))
+
 int udevdb_add_dev(const char *path, const struct udevice *dev)
 {
 	TDB_DATA key, data;
@@ -57,6 +59,11 @@ int udevdb_add_dev(const char *path, con
 	key.dptr = keystr;
 	key.dsize = strlen(keystr) + 1;
 
+	if (key.dsize & (my_key_align - 1))
+		key.dsize = (key.dsize & ~(my_key_align - 1)) + my_key_align;
+	if (key.dsize > SYSFS_PATH_MAX)
+		key.dsize = SYSFS_PATH_MAX;
+
 	data.dptr = (void *)dev;
 	data.dsize = UDEVICE_LEN;
 
@@ -73,6 +80,11 @@ int udevdb_get_dev(const char *path, str
 	key.dptr = (void *)path;
 	key.dsize = strlen(path) + 1;
 
+	if (key.dsize & (my_key_align - 1))
+		key.dsize = (key.dsize & ~(my_key_align - 1)) + my_key_align;
+	if (key.dsize > SYSFS_PATH_MAX)
+		key.dsize = SYSFS_PATH_MAX;
+
 	data = tdb_fetch(udevdb, key);
 	if (data.dptr = NULL || data.dsize = 0)
 		return -ENODEV;
@@ -96,6 +108,11 @@ int udevdb_delete_dev(const char *path)
 	key.dptr = keystr;
 	key.dsize = strlen(keystr) + 1;
 
+	if (key.dsize & (my_key_align - 1))
+		key.dsize = (key.dsize & ~(my_key_align - 1)) + my_key_align;
+	if (key.dsize > SYSFS_PATH_MAX)
+		key.dsize = SYSFS_PATH_MAX;
+
 	return tdb_delete(udevdb, key);
 }
 
-- 
USB is for mice, FireWire is for men!

sUse lINUX ag, n√úRNBERG


-------------------------------------------------------
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_id\x1356&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-03-13 16:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
2004-03-05 22:21 ` Olaf Hering
2004-03-12 23:40 ` Greg KH
2004-03-12 23:41 ` Greg KH
2004-03-12 23:59 ` Olaf Hering
2004-03-13  0:03 ` Olaf Hering
2004-03-13  0:11 ` Greg KH
2004-03-13  9:58 ` Olaf Hering
2004-03-13 16:57 ` Johannes Erdfelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).