diff options
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/firmload.c | 10 | ||||
| -rw-r--r-- | sys/dev/fss.c | 20 | ||||
| -rw-r--r-- | sys/dev/kloader.c | 14 | ||||
| -rw-r--r-- | sys/dev/vnd.c | 42 |
4 files changed, 43 insertions, 43 deletions
diff --git a/sys/dev/firmload.c b/sys/dev/firmload.c index 34bff469a6f..8785e727b4e 100644 --- a/sys/dev/firmload.c +++ b/sys/dev/firmload.c @@ -1,4 +1,4 @@ -/* $NetBSD: firmload.c,v 1.22 2016/05/30 02:33:49 dholland Exp $ */ +/* $NetBSD: firmload.c,v 1.23 2021/06/29 22:40:53 dholland Exp $ */ /*- * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.22 2016/05/30 02:33:49 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.23 2021/06/29 22:40:53 dholland Exp $"); /* * The firmload API provides an interface for device drivers to access @@ -204,7 +204,6 @@ int firmware_open(const char *drvname, const char *imgname, firmware_handle_t *fhp) { struct pathbuf *pb; - struct nameidata nd; struct vattr va; char *pnbuf, *path, *prefix; firmware_handle_t fh; @@ -236,8 +235,7 @@ firmware_open(const char *drvname, const char *imgname, firmware_handle_t *fhp) error = ENOMEM; break; } - NDINIT(&nd, LOOKUP, FOLLOW | NOCHROOT, pb); - error = vn_open(&nd, FREAD, 0); + error = vn_open(NULL, pb, NOCHROOT, FREAD, 0, &vp, NULL, NULL); pathbuf_destroy(pb); if (error == ENOENT) { continue; @@ -251,8 +249,6 @@ firmware_open(const char *drvname, const char *imgname, firmware_handle_t *fhp) return (error); } - vp = nd.ni_vp; - error = VOP_GETATTR(vp, &va, kauth_cred_get()); if (error) { VOP_UNLOCK(vp); diff --git a/sys/dev/fss.c b/sys/dev/fss.c index 01969bedfda..04aa2db2226 100644 --- a/sys/dev/fss.c +++ b/sys/dev/fss.c @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.110 2020/12/26 14:50:50 nia Exp $ */ +/* $NetBSD: fss.c,v 1.111 2021/06/29 22:40:53 dholland Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.110 2020/12/26 14:50:50 nia Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.111 2021/06/29 22:40:53 dholland Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -699,10 +699,9 @@ fss_create_files(struct fss_softc *sc, struct fss_set *fss, uint64_t numsec; unsigned int secsize; struct timespec ts; - /* nd -> nd2 to reduce mistakes while updating only some namei calls */ + /* distinguish lookup 1 from lookup 2 to reduce mistakes */ struct pathbuf *pb2; - struct nameidata nd2; - struct vnode *vp; + struct vnode *vp, *vp2; /* * Get the mounted file system. @@ -789,16 +788,17 @@ fss_create_files(struct fss_softc *sc, struct fss_set *fss, if (error) { return error; } - NDINIT(&nd2, LOOKUP, FOLLOW, pb2); - if ((error = vn_open(&nd2, FREAD|FWRITE, 0)) != 0) { + error = vn_open(NULL, pb2, 0, FREAD|FWRITE, 0, &vp2, NULL, NULL); + if (error != 0) { pathbuf_destroy(pb2); return error; } - VOP_UNLOCK(nd2.ni_vp); + VOP_UNLOCK(vp2); - sc->sc_bs_vp = nd2.ni_vp; + sc->sc_bs_vp = vp2; - if (nd2.ni_vp->v_type != VREG && nd2.ni_vp->v_type != VCHR) { + if (vp2->v_type != VREG && vp2->v_type != VCHR) { + vrele(vp2); pathbuf_destroy(pb2); return EINVAL; } diff --git a/sys/dev/kloader.c b/sys/dev/kloader.c index 2dcb1e02fe3..265faa5f030 100644 --- a/sys/dev/kloader.c +++ b/sys/dev/kloader.c @@ -1,4 +1,4 @@ -/* $NetBSD: kloader.c,v 1.28 2020/09/05 16:30:11 riastradh Exp $ */ +/* $NetBSD: kloader.c,v 1.29 2021/06/29 22:40:53 dholland Exp $ */ /*- * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kloader.c,v 1.28 2020/09/05 16:30:11 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kloader.c,v 1.29 2021/06/29 22:40:53 dholland Exp $"); #include "debug_kloader.h" @@ -586,6 +586,7 @@ kloader_open(const char *filename) { struct pathbuf *pb; struct nameidata nid; + struct vnode *vp; int error; pb = pathbuf_create(filename); @@ -594,8 +595,11 @@ kloader_open(const char *filename) return (NULL); } - NDINIT(&nid, LOOKUP, FOLLOW, pb); + /* + * XXX why does this call both namei and vn_open? + */ + NDINIT(&nid, LOOKUP, FOLLOW, pb); error = namei(&nid); if (error != 0) { PRINTF("%s: namei failed, errno=%d\n", filename, error); @@ -603,7 +607,7 @@ kloader_open(const char *filename) return (NULL); } - error = vn_open(&nid, FREAD, 0); + error = vn_open(NULL, pb, 0, FREAD, 0, &vp, NULL, NULL); if (error != 0) { PRINTF("%s: open failed, errno=%d\n", filename, error); pathbuf_destroy(pb); @@ -611,7 +615,7 @@ kloader_open(const char *filename) } pathbuf_destroy(pb); - return (nid.ni_vp); + return vp; } void diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index b149376ac38..c21c19d3fc2 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.281 2021/06/13 10:01:43 mlelstv Exp $ */ +/* $NetBSD: vnd.c,v 1.282 2021/06/29 22:40:53 dholland Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.281 2021/06/13 10:01:43 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.282 2021/06/29 22:40:53 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -1145,7 +1145,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) struct vnd_ioctl *vio; struct vattr vattr; struct pathbuf *pb; - struct nameidata nd; + struct vnode *vp; int error, part, pmask; uint64_t geomsize; int fflags; @@ -1273,20 +1273,20 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) if (error) { goto unlock_and_exit; } - NDINIT(&nd, LOOKUP, FOLLOW, pb); - if ((error = vn_open(&nd, fflags, 0)) != 0) { + error = vn_open(NULL, pb, 0, fflags, 0, &vp, NULL, NULL); + if (error != 0) { pathbuf_destroy(pb); goto unlock_and_exit; } KASSERT(l); - error = VOP_GETATTR(nd.ni_vp, &vattr, l->l_cred); - if (!error && nd.ni_vp->v_type != VREG) + error = VOP_GETATTR(vp, &vattr, l->l_cred); + if (!error && vp->v_type != VREG) error = EOPNOTSUPP; if (!error && vattr.va_bytes < vattr.va_size) /* File is definitely sparse, use vn_rdwr() */ vnd->sc_flags |= VNF_USE_VN_RDWR; if (error) { - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); goto close_and_exit; } @@ -1304,19 +1304,19 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) M_TEMP, M_WAITOK); /* read compressed file header */ - error = vn_rdwr(UIO_READ, nd.ni_vp, (void *)ch, + error = vn_rdwr(UIO_READ, vp, (void *)ch, sizeof(struct vnd_comp_header), 0, UIO_SYSSPACE, IO_UNIT|IO_NODELOCKED, l->l_cred, NULL, NULL); if (error) { free(ch, M_TEMP); - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); goto close_and_exit; } if (be32toh(ch->block_size) == 0 || be32toh(ch->num_blocks) > UINT32_MAX - 1) { free(ch, M_TEMP); - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); goto close_and_exit; } @@ -1326,7 +1326,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) vnd->sc_comp_numoffs = be32toh(ch->num_blocks) + 1; free(ch, M_TEMP); if (!DK_DEV_BSIZE_OK(vnd->sc_comp_blksz)) { - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); error = EINVAL; goto close_and_exit; } @@ -1340,7 +1340,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) */ #if SIZE_MAX <= UINT32_MAX*(64/CHAR_BIT) if (SIZE_MAX/sizeof(uint64_t) < vnd->sc_comp_numoffs) { - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); error = EINVAL; goto close_and_exit; } @@ -1350,7 +1350,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) sizeof(uint64_t)*vnd->sc_comp_numoffs) || (UQUAD_MAX/vnd->sc_comp_blksz < vnd->sc_comp_numoffs - 1)) { - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); error = EINVAL; goto close_and_exit; } @@ -1369,13 +1369,13 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) M_DEVBUF, M_WAITOK); /* read in the offsets */ - error = vn_rdwr(UIO_READ, nd.ni_vp, + error = vn_rdwr(UIO_READ, vp, (void *)vnd->sc_comp_offsets, sizeof(uint64_t) * vnd->sc_comp_numoffs, sizeof(struct vnd_comp_header), UIO_SYSSPACE, IO_UNIT|IO_NODELOCKED, l->l_cred, NULL, NULL); if (error) { - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); goto close_and_exit; } /* @@ -1414,21 +1414,21 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) if (vnd->sc_comp_stream.msg) printf("vnd%d: compressed file, %s\n", unit, vnd->sc_comp_stream.msg); - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); error = EINVAL; goto close_and_exit; } vnd->sc_flags |= VNF_COMP | VNF_READONLY; #else /* !VND_COMPRESSION */ - VOP_UNLOCK(nd.ni_vp); + VOP_UNLOCK(vp); error = EOPNOTSUPP; goto close_and_exit; #endif /* VND_COMPRESSION */ } - VOP_UNLOCK(nd.ni_vp); - vnd->sc_vp = nd.ni_vp; + VOP_UNLOCK(vp); + vnd->sc_vp = vp; vnd->sc_size = btodb(vattr.va_size); /* note truncation */ /* get smallest I/O size for underlying device, fall back to @@ -1553,7 +1553,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) break; close_and_exit: - (void) vn_close(nd.ni_vp, fflags, l->l_cred); + (void) vn_close(vp, fflags, l->l_cred); pathbuf_destroy(pb); unlock_and_exit: #ifdef VND_COMPRESSION |
