From owner-freebsd-arm@FreeBSD.ORG Wed May 7 11:40:00 2014 Return-Path: Delivered-To: freebsd-arm@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F10DA2FB for ; Wed, 7 May 2014 11:40:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB541C73 for ; Wed, 7 May 2014 11:40:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s47Be0qt089123 for ; Wed, 7 May 2014 11:40:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s47Be0ip089122; Wed, 7 May 2014 11:40:00 GMT (envelope-from gnats) Resent-Date: Wed, 7 May 2014 11:40:00 GMT Resent-Message-Id: <201405071140.s47Be0ip089122@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-arm@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Keith White Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1F4E4141 for ; Wed, 7 May 2014 11:30:03 +0000 (UTC) Received: from smtp2.vianet.ca (smtp2.vianet.ca [209.91.128.19]) by mx1.freebsd.org (Postfix) with ESMTP id ED4D4BB5 for ; Wed, 7 May 2014 11:30:02 +0000 (UTC) Received: from localhost.my.domain (unused-69-60-246-88.vianet.ca [69.60.246.88]) by smtp2.vianet.ca (Postfix) with ESMTPS id 779C315BE7B for ; Wed, 7 May 2014 07:20:36 -0400 (EDT) Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.my.domain (8.14.8/8.14.8) with ESMTP id s47BC2Rj012682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 7 May 2014 07:12:02 -0400 (EDT) (envelope-from kwhite@localhost.my.domain) Received: (from root@localhost) by localhost.my.domain (8.14.8/8.14.8/Submit) id s47BC2t6012681; Wed, 7 May 2014 07:12:02 -0400 (EDT) (envelope-from kwhite) Message-Id: <201405071112.s47BC2t6012681@localhost.my.domain> Date: Wed, 7 May 2014 07:12:02 -0400 (EDT) From: Keith White Reply-To: Keith White To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: arm/189415: [patch] mount_smbfs missing from arm X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2014 11:40:01 -0000 >Number: 189415 >Category: arm >Synopsis: [patch] mount_smbfs missing from arm >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-arm >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed May 07 11:40:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Keith White >Release: FreeBSD 11.0-CURRENT arm >Organization: Faculty of Engineering, University of Ottawa >Environment: System: FreeBSD beaglebone 11.0-CURRENT FreeBSD 11.0-CURRENT #46 r265404M: Mon May 5 19:27:21 EDT 2014 root@beaglebone:/usr/obj/usr/src/sys/BEAGLEBONE arm >Description: mount_smbfs is not included with base arm builds since libsmb uses casts to u_short that result in unaligned access to memory. Patch attached. >How-To-Repeat: >Fix: The following patch replaces potential unaligned access in libsmb with a function call to the internal function memsetw(), and adds libsmb and mount_smbfs to the base build. Index: contrib/smbfs/lib/smb/nb_name.c =================================================================== --- contrib/smbfs/lib/smb/nb_name.c (revision 265468) +++ contrib/smbfs/lib/smb/nb_name.c (working copy) @@ -146,14 +146,26 @@ #define NBENCODE(c) (htole16((u_short)(((u_char)(c) >> 4) | \ (((u_char)(c) & 0xf) << 8)) + 0x4141)) +#ifdef __arm__ static void memsetw(char *dst, int n, u_short word) { while (n--) { + ((u_char*)dst)[0] = word & 0xff; + ((u_char*)dst)[1] = word >> 8; + dst += 2; + } +} +#else +static void +memsetw(char *dst, int n, u_short word) +{ + while (n--) { *(u_short*)dst = word; dst += 2; } } +#endif int nb_name_encode(struct nb_name *np, u_char *dst) @@ -165,18 +177,30 @@ *cp++ = NB_ENCNAMELEN; name = np->nn_name; if (name[0] == '*' && name[1] == 0) { +#ifdef __arm__ + memsetw(cp, 1, NBENCODE('*')); +#else *(u_short*)cp = 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++) +#ifdef __arm__ + memsetw(cp, 1, NBENCODE(toupper(*name))); +#else *(u_short*)cp = NBENCODE(toupper(*name)); +#endif i = NB_NAMELEN - i - 1; if (i > 0) { memsetw(cp, i, NBENCODE(' ')); cp += i * 2; } +#ifdef __arm__ + memsetw(cp, 1, NBENCODE(np->nn_type)); +#else *(u_short*)cp = NBENCODE(np->nn_type); +#endif cp += 2; } *cp = 0; Index: lib/Makefile =================================================================== --- lib/Makefile (revision 265468) +++ lib/Makefile (working copy) @@ -217,6 +217,10 @@ _libvmmapi= libvmmapi .endif +.if ${MACHINE_CPUARCH} == "arm" +_libsmb= libsmb +.endif + .if ${MACHINE_CPUARCH} == "ia64" _libefi= libefi _libsmb= libsmb Index: usr.sbin/Makefile.arm =================================================================== --- usr.sbin/Makefile.arm (revision 265468) +++ usr.sbin/Makefile.arm (working copy) @@ -2,3 +2,4 @@ SUBDIR+= ofwdump SUBDIR+= kgmon +SUBDIR+= mount_smbfs >Release-Note: >Audit-Trail: >Unformatted: