Page MenuHomeFreeBSD

D62024.1795648221.diff
No OneTemporary

Authored By
Unknown
Size
18 KB
Referenced Files
None
Subscribers
None

D62024.1795648221.diff

diff --git a/share/man/man4/nullfs.4 b/share/man/man4/nullfs.4
--- a/share/man/man4/nullfs.4
+++ b/share/man/man4/nullfs.4
@@ -22,7 +22,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd November 22, 2026
+.Dd November 24, 2026
.Dt NULLFS 4
.Os
.Sh NAME
@@ -54,6 +54,16 @@
.Nm
of a tree that contains the file.
A second mount of the same directory is rejected.
+A regular file may be mounted on a missing final component of a
+.Nm
+directory when the
+.Cm ephemeral
+option is set.
+The name is not written to the lower file system and does not appear
+in a directory listing.
+If the mount point exists,
+.Cm ephemeral
+has no effect.
.Sh EXAMPLES
To mount a
.Nm
diff --git a/sys/fs/nullfs/null.h b/sys/fs/nullfs/null.h
--- a/sys/fs/nullfs/null.h
+++ b/sys/fs/nullfs/null.h
@@ -36,15 +36,31 @@
#define FS_NULL_H
#include <sys/ck.h>
+#include <sys/queue.h>
+#include <sys/_mutex.h>
#include <vm/uma.h>
#define NULLM_CACHE 0x0001
#define NULLM_NOUNPBYPASS 0x0002
+/*
+ * A regular file name that exists only in this nullfs directory.
+ * The lower directory has no such entry.
+ */
+struct null_ephem {
+ struct vnode *ne_dir;
+ struct vnode *ne_vp;
+ char *ne_name;
+ u_int ne_len;
+ TAILQ_ENTRY(null_ephem) ne_link;
+};
+
struct null_mount {
struct mount *nullm_vfs;
struct vnode *nullm_lowerrootvp; /* Ref to lower root vnode */
uint64_t nullm_flags;
+ struct mtx nullm_ephem_lock;
+ TAILQ_HEAD(, null_ephem) nullm_ephem;
struct mount_upper_node upper_node;
struct mount_upper_node notify_node;
};
@@ -57,11 +73,13 @@
CK_SLIST_ENTRY(null_node) null_hash; /* Hash list */
struct vnode *null_lowervp; /* VREFed once */
struct vnode *null_vnode; /* Back pointer */
+ struct vnode *null_ephem_dir; /* Directory, ephemeral only */
u_int null_flags;
};
#define NULLV_NOUNLOCK 0x0001
#define NULLV_DROP 0x0002
+#define NULLV_EPHEMERAL 0x0004
#define MOUNTTONULLMOUNT(mp) ((struct null_mount *)((mp)->mnt_data))
#define VTONULL(vp) ((struct null_node *)(vp)->v_data)
@@ -71,6 +89,7 @@
int nullfs_init(struct vfsconf *vfsp);
int nullfs_uninit(struct vfsconf *vfsp);
int null_nodeget(struct mount *mp, struct vnode *target, struct vnode **vpp);
+void null_ephemeral_detach(struct vnode *vp);
struct vnode *null_hashget(struct mount *mp, struct vnode *lowervp);
void null_hashrem(struct null_node *xp);
int null_bypass(struct vop_generic_args *ap);
@@ -84,6 +103,7 @@
extern struct vop_vector null_vnodeops;
extern struct vop_vector null_vnodeops_no_unp_bypass;
+extern struct vop_vector null_ephemeral_vnodeops;
static inline bool
null_is_nullfs_vnode(struct vnode *vp)
@@ -91,7 +111,9 @@
const struct vop_vector *op;
op = vp->v_op;
- return (op == &null_vnodeops || op == &null_vnodeops_no_unp_bypass);
+ return (op == &null_vnodeops ||
+ op == &null_vnodeops_no_unp_bypass ||
+ op == &null_ephemeral_vnodeops);
}
extern uma_zone_t null_node_zone;
diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c
--- a/sys/fs/nullfs/null_subr.c
+++ b/sys/fs/nullfs/null_subr.c
@@ -333,7 +333,12 @@
}
#endif
if (a->null_lowervp == NULL) {
- /* Should never happen */
+ /*
+ * An ephemeral name has no lower vnode. Callers that
+ * walk to the lower layer treat NULL as "not stacked".
+ */
+ if ((a->null_flags & NULLV_EPHEMERAL) != 0)
+ return (NULL);
panic("null_checkvp %p", vp);
}
VI_LOCK_FLAGS(a->null_lowervp, MTX_DUPOK);
diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -43,6 +43,7 @@
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
+#include <sys/mutex.h>
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/proc.h>
@@ -192,6 +193,8 @@
xmp = malloc(sizeof(struct null_mount), M_NULLFSMNT,
M_WAITOK | M_ZERO);
+ mtx_init(&xmp->nullm_ephem_lock, "nullfs_ephem", NULL, MTX_DEF);
+ TAILQ_INIT(&xmp->nullm_ephem);
/*
* Save pointer to underlying FS and the reference to the
@@ -201,6 +204,7 @@
&xmp->upper_node);
if (xmp->nullm_vfs == NULL) {
vput(lowerrootvp);
+ mtx_destroy(&xmp->nullm_ephem_lock);
free(xmp, M_NULLFSMNT);
return (ENOENT);
}
@@ -215,6 +219,7 @@
if (error != 0) {
vfs_unregister_upper(xmp->nullm_vfs, &xmp->upper_node);
vrele(lowerrootvp);
+ mtx_destroy(&xmp->nullm_ephem_lock);
free(xmp, M_NULLFSMNT);
return (error);
}
@@ -318,7 +323,17 @@
}
vfs_unregister_upper(mntdata->nullm_vfs, &mntdata->upper_node);
vrele(mntdata->nullm_lowerrootvp);
+ /*
+ * A file mount drops the in-memory name it published in the
+ * directory it covers. The root mount's own list is empty by
+ * then: its file mounts are unmounted first.
+ */
+ if (mp->mnt_vnodecovered != NULL)
+ null_ephemeral_detach(mp->mnt_vnodecovered);
+ KASSERT(TAILQ_EMPTY(&mntdata->nullm_ephem),
+ ("nullfs_unmount: ephemeral name still published"));
mp->mnt_data = NULL;
+ mtx_destroy(&mntdata->nullm_ephem_lock);
free(mntdata, M_NULLFSMNT);
return (0);
}
diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c
--- a/sys/fs/nullfs/null_vnops.c
+++ b/sys/fs/nullfs/null_vnops.c
@@ -182,6 +182,11 @@
#include <fs/nullfs/null.h>
+static MALLOC_DEFINE(M_NULLFSEPHEM, "nullfs_ephem", "NULLFS ephemeral name");
+
+static struct vnode *null_ephemeral_lookup(struct vnode *dvp,
+ struct componentname *cnp);
+
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_object.h>
@@ -514,6 +519,19 @@
if (error == 0)
*ap->a_vpp = vp;
}
+ } else if (error == ENOENT && lvp == NULL &&
+ (flags & ISLASTCN) != 0 && cnp->cn_nameiop == LOOKUP &&
+ !VN_IS_DOOMED(dvp)) {
+ /*
+ * A regular file mounted with -o ephemeral publishes
+ * its final component here. The lower directory does
+ * not have the name, and readdir does not either.
+ */
+ vp = null_ephemeral_lookup(dvp, cnp);
+ if (vp != NULL) {
+ *ap->a_vpp = vp;
+ return (0);
+ }
}
return (error);
}
@@ -1251,6 +1269,260 @@
return (0);
}
+/*
+ * Drop an in-memory name. The directory reference stays with the
+ * vnode until reclaim, which may run with this vnode locked.
+ */
+void
+null_ephemeral_detach(struct vnode *vp)
+{
+ struct null_mount *xmp;
+ struct null_ephem *ne;
+
+ if (vp->v_op != &null_ephemeral_vnodeops || vp->v_mount == NULL)
+ return;
+ xmp = MOUNTTONULLMOUNT(vp->v_mount);
+ if (xmp == NULL)
+ return;
+ mtx_lock(&xmp->nullm_ephem_lock);
+ TAILQ_FOREACH(ne, &xmp->nullm_ephem, ne_link) {
+ if (ne->ne_vp == vp) {
+ TAILQ_REMOVE(&xmp->nullm_ephem, ne, ne_link);
+ break;
+ }
+ }
+ mtx_unlock(&xmp->nullm_ephem_lock);
+ if (ne == NULL)
+ return;
+ free(ne->ne_name, M_NULLFSEPHEM);
+ free(ne, M_NULLFSEPHEM);
+}
+
+/*
+ * vp is unlocked and is not on the ephemeral list.
+ */
+static void
+null_ephemeral_abort(struct vnode *vp, struct null_node *xp)
+{
+
+ lockmgr(&vp->v_lock, LK_EXCLUSIVE, NULL);
+ VI_LOCK(vp);
+ vp->v_data = NULL;
+ vp->v_op = &dead_vnodeops;
+ VI_UNLOCK(vp);
+ vgone(vp);
+ vput(vp);
+ uma_zfree_smr(null_node_zone, xp);
+}
+
+static int
+null_ephemeral_getattr(struct vop_getattr_args *ap)
+{
+ struct vattr *vap;
+ struct timespec ts;
+
+ vap = ap->a_vap;
+ vattr_null(vap);
+ vap->va_type = VREG;
+ vap->va_mode = S_IRUSR | S_IRGRP | S_IROTH;
+ vap->va_nlink = 1;
+ vap->va_uid = 0;
+ vap->va_gid = 0;
+ vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
+ vap->va_fileid = (uintptr_t)ap->a_vp;
+ vap->va_size = 0;
+ vap->va_bytes = 0;
+ vap->va_blocksize = PAGE_SIZE;
+ nanotime(&ts);
+ vap->va_atime = ts;
+ vap->va_mtime = ts;
+ vap->va_ctime = ts;
+ vap->va_birthtime = ts;
+ vap->va_gen = 0;
+ vap->va_flags = 0;
+ vap->va_rdev = NODEV;
+ vap->va_filerev = 0;
+ return (0);
+}
+
+static int
+null_ephemeral_inactive(struct vop_inactive_args *ap)
+{
+ struct vnode *vp;
+
+ vp = ap->a_vp;
+ if (vp->v_mountedhere == NULL)
+ vrecycle(vp);
+ return (0);
+}
+
+static int
+null_ephemeral_reclaim(struct vop_reclaim_args *ap)
+{
+ struct vnode *vp, *dir;
+ struct null_node *xp;
+
+ vp = ap->a_vp;
+ null_ephemeral_detach(vp);
+ xp = VTONULL(vp);
+ dir = xp->null_ephem_dir;
+ VI_LOCK(vp);
+ vp->v_data = NULL;
+ vp->v_object = NULL;
+ VI_UNLOCK(vp);
+ uma_zfree_smr(null_node_zone, xp);
+ /*
+ * The directory ref may be the last one. Drop the vnode lock
+ * first so that reclaim does not nest this lock under the
+ * directory lock that lookup holds.
+ */
+ if (dir != NULL) {
+ VOP_UNLOCK(vp);
+ vrele(dir);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+ }
+ return (0);
+}
+
+static struct vnode *
+null_ephemeral_lookup(struct vnode *dvp, struct componentname *cnp)
+{
+ struct null_mount *xmp;
+ struct null_ephem *ne;
+ struct vnode *vp;
+ enum vgetstate vs;
+ int error;
+
+ if (cnp->cn_namelen <= 0 || cnp->cn_namelen > NAME_MAX)
+ return (NULL);
+ xmp = MOUNTTONULLMOUNT(dvp->v_mount);
+ if (xmp == NULL)
+ return (NULL);
+ mtx_lock(&xmp->nullm_ephem_lock);
+ TAILQ_FOREACH(ne, &xmp->nullm_ephem, ne_link) {
+ if (ne->ne_dir == dvp &&
+ ne->ne_len == (u_int)cnp->cn_namelen &&
+ bcmp(ne->ne_name, cnp->cn_nameptr, ne->ne_len) == 0)
+ break;
+ }
+ if (ne == NULL) {
+ mtx_unlock(&xmp->nullm_ephem_lock);
+ return (NULL);
+ }
+ vp = ne->ne_vp;
+ vs = vget_prep(vp);
+ mtx_unlock(&xmp->nullm_ephem_lock);
+ error = vget_finish(vp, LK_EXCLUSIVE | LK_RETRY, vs);
+ if (error != 0)
+ return (NULL);
+ if (VN_IS_DOOMED(vp)) {
+ vput(vp);
+ return (NULL);
+ }
+ return (vp);
+}
+
+static int
+null_ephemeral(struct vop_ephemeral_args *ap)
+{
+ struct componentname *cnp;
+ struct null_mount *xmp;
+ struct null_ephem *ne;
+ struct null_node *xp;
+ struct null_ephem *exist;
+ struct vnode *dvp, *vp, *found, *dup;
+ char *name;
+ enum vgetstate vs;
+ int error;
+
+ dvp = ap->a_dvp;
+ cnp = ap->a_cnp;
+ *ap->a_vpp = NULL;
+ if (dvp->v_type != VDIR)
+ return (ENOTDIR);
+ if (cnp->cn_namelen <= 0 || cnp->cn_namelen > NAME_MAX)
+ return (EINVAL);
+ if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.')
+ return (EINVAL);
+ if (cnp->cn_namelen == 2 && cnp->cn_nameptr[0] == '.' &&
+ cnp->cn_nameptr[1] == '.')
+ return (EINVAL);
+ xmp = MOUNTTONULLMOUNT(dvp->v_mount);
+ if (xmp == NULL)
+ return (EOPNOTSUPP);
+ KASSERT((dvp->v_mount->mnt_kern_flag & MNTK_UNLOCKED_INSMNTQUE) != 0,
+ ("null_ephemeral: mount is not ready"));
+
+ found = null_ephemeral_lookup(dvp, cnp);
+ if (found != NULL) {
+ *ap->a_vpp = found;
+ return (0);
+ }
+
+ xp = uma_zalloc_smr(null_node_zone, M_WAITOK);
+ error = getnewvnode("nullfs", dvp->v_mount, &null_ephemeral_vnodeops,
+ &vp);
+ if (error != 0) {
+ uma_zfree_smr(null_node_zone, xp);
+ return (error);
+ }
+ xp->null_vnode = vp;
+ xp->null_lowervp = NULL;
+ xp->null_ephem_dir = NULL;
+ xp->null_flags = NULLV_EPHEMERAL;
+ vp->v_type = VREG;
+ vp->v_data = xp;
+ VOP_UNLOCK(vp);
+ error = insmntque1(vp, dvp->v_mount);
+ if (error != 0) {
+ null_ephemeral_abort(vp, xp);
+ return (error);
+ }
+
+ name = malloc(cnp->cn_namelen + 1, M_NULLFSEPHEM, M_WAITOK);
+ memcpy(name, cnp->cn_nameptr, cnp->cn_namelen);
+ name[cnp->cn_namelen] = '\0';
+ ne = malloc(sizeof(*ne), M_NULLFSEPHEM, M_WAITOK | M_ZERO);
+ ne->ne_dir = dvp;
+ ne->ne_vp = vp;
+ ne->ne_name = name;
+ ne->ne_len = cnp->cn_namelen;
+
+ vref(dvp);
+ xp->null_ephem_dir = dvp;
+ mtx_lock(&xmp->nullm_ephem_lock);
+ TAILQ_FOREACH(exist, &xmp->nullm_ephem, ne_link) {
+ if (exist->ne_dir == dvp && exist->ne_len == ne->ne_len &&
+ bcmp(exist->ne_name, name, ne->ne_len) == 0)
+ break;
+ }
+ if (exist != NULL) {
+ dup = exist->ne_vp;
+ vs = vget_prep(dup);
+ mtx_unlock(&xmp->nullm_ephem_lock);
+ free(name, M_NULLFSEPHEM);
+ free(ne, M_NULLFSEPHEM);
+ xp->null_ephem_dir = NULL;
+ vrele(dvp);
+ null_ephemeral_abort(vp, xp);
+ error = vget_finish(dup, LK_EXCLUSIVE | LK_RETRY, vs);
+ if (error != 0)
+ return (error);
+ if (VN_IS_DOOMED(dup)) {
+ vput(dup);
+ return (ENOENT);
+ }
+ *ap->a_vpp = dup;
+ return (0);
+ }
+ TAILQ_INSERT_TAIL(&xmp->nullm_ephem, ne, ne_link);
+ mtx_unlock(&xmp->nullm_ephem_lock);
+ vn_set_state(vp, VSTATE_CONSTRUCTED);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+ *ap->a_vpp = vp;
+ return (0);
+}
+
/*
* Global vfs data structures
*/
@@ -1285,6 +1557,7 @@
.vop_add_writecount = null_add_writecount,
.vop_vput_pair = null_vput_pair,
.vop_copy_file_range = VOP_PANIC,
+ .vop_ephemeral = null_ephemeral,
};
VFS_VOP_VECTOR_REGISTER(null_vnodeops);
@@ -1295,3 +1568,14 @@
.vop_unp_detach = vop_stdunp_detach,
};
VFS_VOP_VECTOR_REGISTER(null_vnodeops_no_unp_bypass);
+
+struct vop_vector null_ephemeral_vnodeops = {
+ .vop_default = &default_vnodeops,
+ .vop_getattr = null_ephemeral_getattr,
+ .vop_inactive = null_ephemeral_inactive,
+ .vop_islocked = vop_stdislocked,
+ .vop_lock1 = vop_stdlock,
+ .vop_reclaim = null_ephemeral_reclaim,
+ .vop_unlock = vop_stdunlock,
+};
+VFS_VOP_VECTOR_REGISTER(null_ephemeral_vnodeops);
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1627,6 +1627,65 @@
return (error != 0 ? error : export_error);
}
+/*
+ * Publish a missing final component and return it locked, with the
+ * parent directory referenced and unlocked. The name lives only in
+ * memory on the parent filesystem. A filesystem that cannot do that
+ * returns EOPNOTSUPP.
+ */
+static int
+vfs_ephemeral_cover(struct thread *td, char *fspath, struct vnode **vpp,
+ struct vnode **dvpp, struct componentname *cnp)
+{
+ struct nameidata nd;
+ struct vnode *dvp, *vp;
+ char parent[MNAMELEN];
+ char *slash, *leaf;
+ size_t plen;
+ int error;
+
+ slash = strrchr(fspath, '/');
+ if (slash == NULL || slash[1] == '\0')
+ return (ENOENT);
+ leaf = slash + 1;
+ if (slash == fspath) {
+ parent[0] = '/';
+ parent[1] = '\0';
+ } else {
+ plen = slash - fspath;
+ if (plen >= sizeof(parent))
+ return (ENAMETOOLONG);
+ memcpy(parent, fspath, plen);
+ parent[plen] = '\0';
+ }
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, parent);
+ error = namei(&nd);
+ if (error != 0)
+ return (error);
+ dvp = nd.ni_vp;
+ NDFREE_PNBUF(&nd);
+ if (dvp->v_type != VDIR) {
+ vput(dvp);
+ return (ENOTDIR);
+ }
+ memset(cnp, 0, sizeof(*cnp));
+ cnp->cn_nameiop = LOOKUP;
+ cnp->cn_flags = ISLASTCN | LOCKLEAF;
+ cnp->cn_lkflags = LK_EXCLUSIVE;
+ cnp->cn_cred = td->td_ucred;
+ cnp->cn_nameptr = leaf;
+ cnp->cn_namelen = strlen(leaf);
+ error = VOP_EPHEMERAL(dvp, &vp, cnp);
+ if (error != 0) {
+ vput(dvp);
+ return (error);
+ }
+ VOP_UNLOCK(dvp);
+ *vpp = vp;
+ *dvpp = dvp;
+ return (0);
+}
+
/*
* vfs_domount(): actually attempt a filesystem mount.
*/
@@ -1646,9 +1705,12 @@
{
struct vfsconf *vfsp;
struct nameidata nd;
- struct vnode *vp;
+ struct componentname ephem_cn;
+ struct componentname *leafcn;
+ struct vnode *vp, *dvp;
char *pathbuf;
fsid_t check_fsid;
+ bool ephem;
int error;
/*
@@ -1718,13 +1780,31 @@
/*
* Get vnode to be covered or mount point's vnode in case of MNT_UPDATE.
+ * ephemeral is a no-op when that vnode exists. A missing final
+ * component is published only when the option is set, so a typo
+ * in an ordinary mount still fails.
*/
+ ephem = false;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1 | WANTPARENT,
UIO_SYSSPACE, fspath);
error = namei(&nd);
- if (error != 0)
- return (error);
- vp = nd.ni_vp;
+ if (error != 0) {
+ if (error == ENOENT && (fsflags & MNT_UPDATE) == 0 &&
+ *optlist != NULL &&
+ vfs_flagopt(*optlist, "ephemeral", NULL, 0) != 0) {
+ error = vfs_ephemeral_cover(td, fspath, &vp, &dvp,
+ &ephem_cn);
+ if (error != 0)
+ return (error);
+ ephem = true;
+ leafcn = &ephem_cn;
+ } else
+ return (error);
+ } else {
+ vp = nd.ni_vp;
+ dvp = nd.ni_dvp;
+ leafcn = &nd.ni_cnd;
+ }
if (check_fsid_str != NULL) {
struct mount *mp;
@@ -1764,8 +1844,8 @@
MNAMELEN);
else
error = vn_path_to_global_path_hardlink(td, vp,
- nd.ni_dvp, pathbuf, MNAMELEN,
- nd.ni_cnd.cn_nameptr, nd.ni_cnd.cn_namelen);
+ dvp, pathbuf, MNAMELEN,
+ leafcn->cn_nameptr, leafcn->cn_namelen);
if (error == 0) {
error = vfs_domount_first(td, vfsp, pathbuf, vp,
fsflags, optlist);
@@ -1776,8 +1856,12 @@
jail_export, optlist);
out:
- NDFREE_PNBUF(&nd);
- vrele(nd.ni_dvp);
+ if (ephem)
+ vrele(dvp);
+ else {
+ NDFREE_PNBUF(&nd);
+ vrele(nd.ni_dvp);
+ }
return (error);
}
diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src
--- a/sys/kern/vnode_if.src
+++ b/sys/kern/vnode_if.src
@@ -106,6 +106,16 @@
};
+%% ephemeral dvp E E E
+%% ephemeral vpp - L -
+
+vop_ephemeral {
+ IN struct vnode *dvp;
+ OUT struct vnode **vpp;
+ IN struct componentname *cnp;
+};
+
+
%% mknod dvp E E E
%% mknod vpp - L -
%! mknod pre vop_mknod_pre
diff --git a/usr.sbin/jail/command.c b/usr.sbin/jail/command.c
--- a/usr.sbin/jail/command.c
+++ b/usr.sbin/jail/command.c
@@ -73,6 +73,7 @@
static int term_procs(struct cfjail *j);
static int get_user_info(struct cfjail *j, const char *username,
const struct passwd **pwdp, login_cap_t **lcapp);
+static int mount_has_ephemeral(const char *opts);
static int check_path(struct cfjail *j, const char *pname, const char *path,
int isfile, const char *umount_type);
@@ -501,9 +502,23 @@
j->intparams[comparam]->name, comstring->s);
return -1;
}
- if (check_path(j, j->intparams[comparam]->name, argv[1], 0,
- down ? argv[2] : NULL) < 0)
- return -1;
+ {
+ int isfile;
+
+ /*
+ * ephemeral publishes a missing final component.
+ * Parents must still exist. The umount path
+ * still requires a live mount point.
+ */
+ isfile = 0;
+ if (!down && argc == 4 &&
+ strcmp(argv[2], "nullfs") == 0 &&
+ mount_has_ephemeral(argv[3]))
+ isfile = 1;
+ if (check_path(j, j->intparams[comparam]->name,
+ argv[1], isfile, down ? argv[2] : NULL) < 0)
+ return -1;
+ }
if (down) {
argv[4] = NULL;
argv[3] = argv[1];
@@ -1000,6 +1015,29 @@
return 0;
}
+/*
+ * True when the comma-separated options contain the ephemeral token.
+ */
+static int
+mount_has_ephemeral(const char *opts)
+{
+ const char *p;
+ size_t len;
+
+ if (opts == NULL)
+ return (0);
+ for (p = opts; *p != '\0'; ) {
+ len = strcspn(p, ",");
+ if (len == sizeof("ephemeral") - 1 &&
+ strncmp(p, "ephemeral", len) == 0)
+ return (1);
+ p += len;
+ if (*p == ',')
+ p++;
+ }
+ return (0);
+}
+
/*
* Make sure a mount or consolelog path is a valid absolute pathname
* with no symlinks.

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 25, 11:10 PM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42001200
Default Alt Text
D62024.1795648221.diff (18 KB)

Event Timeline