From owner-freebsd-arm@FreeBSD.ORG Fri Jan 23 21:28:31 2015 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C0734822 for ; Fri, 23 Jan 2015 21:28:31 +0000 (UTC) Received: from moon.peach.ne.jp (moon.peach.ne.jp [203.141.148.98]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7FBA261B for ; Fri, 23 Jan 2015 21:28:30 +0000 (UTC) Received: from moon.peach.ne.jp (localhost [127.0.0.1]) by moon.peach.ne.jp (Postfix) with ESMTP id 2F8236811E; Sat, 24 Jan 2015 06:28:28 +0900 (JST) Received: from artemis (unknown [172.18.0.21]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by moon.peach.ne.jp (Postfix) with ESMTPSA id 12A7468118; Sat, 24 Jan 2015 06:28:27 +0900 (JST) Message-ID: <62AC231D96DE425FB72E0C6DA6ACBF1F@ad.peach.ne.jp> From: "Daisuke Aoyama" To: "John-Mark Gurney" References: <54B9DCD1.3040306@foxvalley.net> <4759EAA0-D4AA-4923-9350-B7E753819169@me.com> <6E32991C3BD8465DB8DB0E65DFDA47AA@ad.peach.ne.jp> <20150123195403.GO1949@funkthat.com> In-Reply-To: <20150123195403.GO1949@funkthat.com> Subject: Re: mount_smbfs Date: Sat, 24 Jan 2015 06:28:36 +0900 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_01CF_01D0379E.FC2618E0" X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 14.0.8117.416 X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416 X-Virus-Scanned: ClamAV using ClamSMTP Cc: freebsd-arm@freebsd.org, Rui Paulo X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jan 2015 21:28:31 -0000 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--