From: Olaf Hering <olh@suse.de>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] avoid unaligned access to data
Date: Sun, 29 Feb 2004 20:45:31 +0000 [thread overview]
Message-ID: <20040229204531.GA25308@suse.de> (raw)
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
next reply other threads:[~2004-02-29 20:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-29 20:45 Olaf Hering [this message]
2004-03-05 22:21 ` [PATCH] avoid unaligned access to data 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
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=20040229204531.GA25308@suse.de \
--to=olh@suse.de \
--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.