Date: Sat, 24 Jan 2015 06:28:36 +0900 From: "Daisuke Aoyama" <aoyama@peach.ne.jp> To: "John-Mark Gurney" <jmg@funkthat.com> Cc: freebsd-arm@freebsd.org, Rui Paulo <rpaulo@me.com> Subject: Re: mount_smbfs Message-ID: <62AC231D96DE425FB72E0C6DA6ACBF1F@ad.peach.ne.jp> In-Reply-To: <20150123195403.GO1949@funkthat.com> References: <54B9DCD1.3040306@foxvalley.net> <4759EAA0-D4AA-4923-9350-B7E753819169@me.com> <6E32991C3BD8465DB8DB0E65DFDA47AA@ad.peach.ne.jp> <20150123195403.GO1949@funkthat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Thank you for a comment.
I didn't think about endian functions.
>Please use {l,b}e16dec, or if the code is suppose to be native endian,
>make it dependant on __NO_STRICT_ALIGNMENT and add the proper endian
>swap, not __arm__ as there are other arches that require the same fix...
I make a patch again for supporting BE CPU.
man page don't mention about strict alignment, if le16enc is not using byte access,
you need expand it like this:
+ le16enc(cp, le16toh(NBENCODE(toupper(*name))));
vvvvvv
+ *(cp + 0) = le16toh(NBENCODE(toupper(*name))) & 0xffU;
+ *(cp + 1) = (le16toh(NBENCODE(toupper(*name))) >> 8) & 0xffU;
--
Daisuke Aoyama
[-- Attachment #2 --]
Index: contrib/smbfs/lib/smb/nb_name.c
===================================================================
--- contrib/smbfs/lib/smb/nb_name.c (revision 277169)
+++ contrib/smbfs/lib/smb/nb_name.c (working copy)
@@ -150,7 +150,12 @@
memsetw(char *dst, int n, u_short word)
{
while (n--) {
+#if defined(__NO_STRICT_ALIGNMENT)
*(u_short*)dst = word;
+#else
+ /* NBENCODE() use htole16 */
+ le16enc(dst, le16toh(word));
+#endif
dst += 2;
}
}
@@ -165,18 +170,30 @@
*cp++ = NB_ENCNAMELEN;
name = np->nn_name;
if (name[0] == '*' && name[1] == 0) {
+#if defined(__NO_STRICT_ALIGNMENT)
*(u_short*)cp = NBENCODE('*');
+#else
+ le16enc(cp, le16toh(NBENCODE('*')));
+#endif
memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' '));
cp += NB_ENCNAMELEN;
} else {
for (i = 0; *name && i < NB_NAMELEN - 1; i++, cp += 2, name++)
+#if defined(__NO_STRICT_ALIGNMENT)
*(u_short*)cp = NBENCODE(toupper(*name));
+#else
+ le16enc(cp, le16toh(NBENCODE(toupper(*name))));
+#endif
i = NB_NAMELEN - i - 1;
if (i > 0) {
memsetw(cp, i, NBENCODE(' '));
cp += i * 2;
}
+#if defined(__NO_STRICT_ALIGNMENT)
*(u_short*)cp = NBENCODE(np->nn_type);
+#else
+ le16enc(cp, le16toh(NBENCODE(np->nn_type)));
+#endif
cp += 2;
}
*cp = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?62AC231D96DE425FB72E0C6DA6ACBF1F>
