From owner-p4-projects@FreeBSD.ORG Sat Nov 6 17:25:23 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A0E1C16A4D0; Sat, 6 Nov 2004 17:25:23 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6520A16A4D5 for ; Sat, 6 Nov 2004 17:25:23 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4803743D31 for ; Sat, 6 Nov 2004 17:25:23 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id iA6HPNuT013303 for ; Sat, 6 Nov 2004 17:25:23 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id iA6HPMpe013299 for perforce@freebsd.org; Sat, 6 Nov 2004 17:25:22 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sat, 6 Nov 2004 17:25:22 GMT Message-Id: <200411061725.iA6HPMpe013299@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 64433 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2004 17:25:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=64433 Change 64433 by rwatson@rwatson_zoo on 2004/11/06 17:25:09 Integ md(4) tweaks to netperf_socket. Affected files ... .. //depot/projects/netperf_socket/sys/dev/md/md.c#24 integrate .. //depot/projects/netperf_socket/sys/sys/mdioctl.h#6 integrate Differences ... ==== //depot/projects/netperf_socket/sys/dev/md/md.c#24 (text+ko) ==== @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $FreeBSD: src/sys/dev/md/md.c,v 1.142 2004/10/23 20:50:06 phk Exp $ + * $FreeBSD: src/sys/dev/md/md.c,v 1.144 2004/11/06 13:16:35 pjd Exp $ * */ @@ -174,6 +174,7 @@ /* MD_VNODE related fields */ struct vnode *vnode; + char file[PATH_MAX]; struct ucred *cred; /* MD_SWAP related fields */ @@ -440,7 +441,7 @@ } if (osp > 255) uma_zfree(sc->uma, (void*)osp); - if (error) + if (error != 0) break; secno++; dst += sc->sectorsize; @@ -721,7 +722,7 @@ mtx_init(&sc->queue_mtx, "md bio queue", NULL, MTX_DEF); sprintf(sc->name, "md%d", unit); error = kthread_create(md_kthread, sc, &sc->procp, 0, 0,"%s", sc->name); - if (error) { + if (error != 0) { free(sc, M_MD); return (NULL); } @@ -861,19 +862,23 @@ struct nameidata nd; int error, flags; + if (strlcpy(sc->file, mdio->md_file, sizeof(sc->file)) >= + sizeof(sc->file)) { + return (ENAMETOOLONG); + } flags = FREAD|FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, sc->file, td); error = vn_open(&nd, &flags, 0, -1); - if (error) { + if (error != 0) { NDFREE(&nd, NDF_ONLY_PNBUF); if (error != EACCES && error != EPERM && error != EROFS) return (error); flags &= ~FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, sc->file, td); error = vn_open(&nd, &flags, 0, -1); } NDFREE(&nd, NDF_ONLY_PNBUF); - if (error) + if (error != 0) return (error); if (nd.ni_vp->v_type != VREG || (error = VOP_GETATTR(nd.ni_vp, &vattr, td->td_ucred, td))) { @@ -984,7 +989,7 @@ } } error = mdsetcred(sc, td->td_ucred); - if (error) { + if (error != 0) { vm_object_deallocate(sc->object); sc->object = NULL; } @@ -1097,11 +1102,15 @@ mdio->md_mediasize = sc->mediasize; mdio->md_sectorsize = sc->sectorsize; if (sc->type == MD_VNODE) { - /* XXX fill this in */ - mdio->md_file = NULL; + if (strlcpy(mdio->md_file, sc->file, + sizeof(mdio->md_file)) >= sizeof(mdio->md_file)) { + return (ENAMETOOLONG); + } } return (0); case MDIOCLIST: + if (mdio->md_version != MDIOVERSION) + return (EINVAL); i = 1; LIST_FOREACH(sc, &md_softc_list, list) { if (i == MDNPAD - 1) ==== //depot/projects/netperf_socket/sys/sys/mdioctl.h#6 (text+ko) ==== @@ -37,7 +37,7 @@ * * From: src/sys/sys/vnioctl.h,v 1.4 * - * $FreeBSD: src/sys/sys/mdioctl.h,v 1.17 2004/09/16 21:32:13 pjd Exp $ + * $FreeBSD: src/sys/sys/mdioctl.h,v 1.18 2004/11/06 13:07:02 pjd Exp $ */ #ifndef _SYS_MDIOCTL_H_ @@ -54,20 +54,20 @@ unsigned md_version; /* Structure layout version */ unsigned md_unit; /* unit number */ enum md_types md_type ; /* type of disk */ - char *md_file; /* pathname of file to mount */ off_t md_mediasize; /* size of disk in bytes */ unsigned md_sectorsize; /* sectorsize */ unsigned md_options; /* options */ u_int64_t md_base; /* base address */ int md_fwheads; /* firmware heads */ int md_fwsectors; /* firmware sectors */ + char md_file[PATH_MAX]; /* pathname of file to mount */ int md_pad[MDNPAD]; /* padding for future ideas */ }; #define MD_NAME "md" #define MD_MODNAME "g_md" #define MDCTL_NAME "mdctl" -#define MDIOVERSION 0 +#define MDIOVERSION 1 /* * Before you can use a unit, it must be configured with MDIOCSET.