Module Name: src Committed By: dholland Date: Tue Jun 29 22:38:10 UTC 2021
Modified Files: src/sys/rump/librump/rumpvfs: rumpfs.c Log Message: Add parsepath for rumpfs in place of using cn_consume. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/rump/librump/rumpvfs/rumpfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.163 src/sys/rump/librump/rumpvfs/rumpfs.c:1.164 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.163 Tue Jun 29 22:34:09 2021 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Tue Jun 29 22:38:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfs.c,v 1.163 2021/06/29 22:34:09 dholland Exp $ */ +/* $NetBSD: rumpfs.c,v 1.164 2021/06/29 22:38:10 dholland Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.163 2021/06/29 22:34:09 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.164 2021/06/29 22:38:10 dholland Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -61,6 +61,7 @@ __KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1 #include <rump/rumpfs.h> #include <rump/rumpuser.h> +static int rump_vop_parsepath(void *); static int rump_vop_lookup(void *); static int rump_vop_getattr(void *); static int rump_vop_setattr(void *); @@ -90,7 +91,7 @@ static int rump_vop_fcntl(void *); int (**rump_vnodeop_p)(void *); const struct vnodeopv_entry_desc rump_vnodeop_entries[] = { { &vop_default_desc, vn_default_error }, - { &vop_parsepath_desc, genfs_parsepath }, + { &vop_parsepath_desc, rump_vop_parsepath }, { &vop_lookup_desc, rump_vop_lookup }, { &vop_getattr_desc, rump_vop_getattr }, { &vop_setattr_desc, rump_vop_setattr }, @@ -634,6 +635,33 @@ rumpfs_update(int flags, struct vnode *v } /* + * parsepath for rump file systems - check for etfs entries. + */ +static int +rump_vop_parsepath(void *v) +{ + struct vop_parsepath_args /* { + struct vnode *a_dvp; + const char *a_name; + size_t *a_retval; + }; */ *ap = v; + struct etfs *et; + bool found; + + /* check for etfs */ + if (ap->a_dvp == rootvnode) { + mutex_enter(&etfs_lock); + found = etfs_find(ap->a_name, &et, false); + mutex_exit(&etfs_lock); + if (found) { + *ap->a_retval = et->et_keylen; + return 0; + } + } + return genfs_parsepath(v); +} + +/* * Simple lookup for rump file systems. * * uhm, this is twisted. C F C C, hope of C C F C looming @@ -654,7 +682,6 @@ rump_vop_lookup(void *v) struct etfs *et; bool dotdot = (cnp->cn_flags & ISDOTDOT) != 0; int rv = 0; - const char *cp; *vpp = NULL; @@ -687,19 +714,18 @@ rump_vop_lookup(void *v) mutex_exit(&etfs_lock); if (found) { + if (et->et_keylen != cnp->cn_namelen) { + /* + * This can theoretically happen if an + * etfs entry is added or removed + * while lookups are being done as we + * don't hold etfs_lock across here + * and parsepath. Won't ordinarily be + * the case. No biggie, just retry. + */ + return ERESTART; + } rn = et->et_rn; - cnp->cn_consume += et->et_keylen - cnp->cn_namelen; - /* - * consume trailing slashes if any and clear - * REQUIREDIR if we consumed the full path. - */ - cp = &cnp->cn_nameptr[cnp->cn_namelen]; - cp += cnp->cn_consume; - KASSERT(*cp == '\0' || *cp == '/'); - if (*cp == '\0' && rn->rn_va.va_type != VDIR) - cnp->cn_flags &= ~REQUIREDIR; - while (*cp++ == '/') - cnp->cn_consume++; goto getvnode; } }