Skip site navigation (1)Skip section navigation (2)
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
This is a multi-part message in MIME format.

------=_NextPart_000_01CF_01D0379E.FC2618E0
Content-Type: text/plain;
	format=flowed;
	charset="iso-8859-1";
	reply-type=original
Content-Transfer-Encoding: 7bit

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
 
------=_NextPart_000_01CF_01D0379E.FC2618E0
Content-Type: application/octet-stream;
	name="nb_name.c.patch2"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="nb_name.c.patch2"

Index: contrib/smbfs/lib/smb/nb_name.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
--- contrib/smbfs/lib/smb/nb_name.c	(revision 277169)=0A=
+++ contrib/smbfs/lib/smb/nb_name.c	(working copy)=0A=
@@ -150,7 +150,12 @@=0A=
 memsetw(char *dst, int n, u_short word)=0A=
 {=0A=
 	while (n--) {=0A=
+#if defined(__NO_STRICT_ALIGNMENT)=0A=
 		*(u_short*)dst =3D word;=0A=
+#else=0A=
+		/* NBENCODE() use htole16 */=0A=
+		le16enc(dst, le16toh(word));=0A=
+#endif=0A=
 		dst +=3D 2;=0A=
 	}=0A=
 }=0A=
@@ -165,18 +170,30 @@=0A=
 	*cp++ =3D NB_ENCNAMELEN;=0A=
 	name =3D np->nn_name;=0A=
 	if (name[0] =3D=3D '*' && name[1] =3D=3D 0) {=0A=
+#if defined(__NO_STRICT_ALIGNMENT)=0A=
 		*(u_short*)cp =3D NBENCODE('*');=0A=
+#else=0A=
+		le16enc(cp, le16toh(NBENCODE('*')));=0A=
+#endif=0A=
 		memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' '));=0A=
 		cp +=3D NB_ENCNAMELEN;=0A=
 	} else {=0A=
 		for (i =3D 0; *name && i < NB_NAMELEN - 1; i++, cp +=3D 2, name++)=0A=
+#if defined(__NO_STRICT_ALIGNMENT)=0A=
 			*(u_short*)cp =3D NBENCODE(toupper(*name));=0A=
+#else=0A=
+			le16enc(cp, le16toh(NBENCODE(toupper(*name))));=0A=
+#endif=0A=
 		i =3D NB_NAMELEN - i - 1;=0A=
 		if (i > 0) {=0A=
 			memsetw(cp, i, NBENCODE(' '));=0A=
 			cp +=3D i * 2;=0A=
 		}=0A=
+#if defined(__NO_STRICT_ALIGNMENT)=0A=
 		*(u_short*)cp =3D NBENCODE(np->nn_type);=0A=
+#else=0A=
+		le16enc(cp, le16toh(NBENCODE(np->nn_type)));=0A=
+#endif=0A=
 		cp +=3D 2;=0A=
 	}=0A=
 	*cp =3D 0;=0A=

------=_NextPart_000_01CF_01D0379E.FC2618E0--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?62AC231D96DE425FB72E0C6DA6ACBF1F>