X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/f3c3de585db0822eb4ec29588b57f95ff7d00221..29ca4fd6da8bb70ae90d8e73ea3c47fda22491a7:/sys/vfs/tmpfs/tmpfs_vfsops.c diff --git a/sys/vfs/tmpfs/tmpfs_vfsops.c b/sys/vfs/tmpfs/tmpfs_vfsops.c index 940643a569..de23cb7d3b 100644 --- a/sys/vfs/tmpfs/tmpfs_vfsops.c +++ b/sys/vfs/tmpfs/tmpfs_vfsops.c @@ -186,14 +186,21 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) pages_limit = vm_swap_max + vmstats.v_page_count / 2; - if (size_max == 0) + if (size_max == 0) { pages = pages_limit / 2; - else if (size_max < PAGE_SIZE) + } else if (size_max < PAGE_SIZE) { pages = 1; - else if (OFF_TO_IDX(size_max) > pages_limit) - pages = pages_limit; - else + } else if (OFF_TO_IDX(size_max) > pages_limit) { + /* + * do not force pages = pages_limit for this case, otherwise + * we might not honor tmpfs size requests from /etc/fstab + * during boot because they are mounted prior to swap being + * turned on. + */ + pages = OFF_TO_IDX(size_max); + } else { pages = OFF_TO_IDX(size_max); + } if (nodes_max == 0) nodes = 3 + pages * PAGE_SIZE / 1024; @@ -244,6 +251,8 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) tmpfs_node_init, tmpfs_node_fini, &tmp->tm_node_zone_malloc_args); + tmp->tm_ino = 2; + /* Allocate the root node. */ error = tmpfs_alloc_node(tmp, VDIR, root_uid, root_gid, root_mode & ALLPERMS, NULL, NULL, @@ -342,8 +351,8 @@ tmpfs_unmount(struct mount *mp, int mntflags) if (node->tn_type == VDIR) { struct tmpfs_dirent *de; - while (!TAILQ_EMPTY(&node->tn_dir.tn_dirhead)) { - de = TAILQ_FIRST(&node->tn_dir.tn_dirhead); + while (!RB_EMPTY(&node->tn_dir.tn_dirtree)) { + de = RB_FIRST(tmpfs_dirtree, &node->tn_dir.tn_dirtree); tmpfs_dir_detach(node, de); tmpfs_free_dirent(tmp, de); node->tn_size -= sizeof(struct tmpfs_dirent); @@ -518,6 +527,26 @@ tmpfs_vptofh(struct vnode *vp, struct fid *fhp) /* --------------------------------------------------------------------- */ +static int +tmpfs_checkexp(struct mount *mp, struct sockaddr *nam, int *exflagsp, + struct ucred **credanonp) +{ + struct tmpfs_mount *tmp; + struct netcred *nc; + + tmp = (struct tmpfs_mount *) mp->mnt_data; + nc = vfs_export_lookup(mp, &tmp->tm_export, nam); + if (nc == NULL) + return (EACCES); + + *exflagsp = nc->netc_exflags; + *credanonp = &nc->netc_anon; + + return (0); +} + +/* --------------------------------------------------------------------- */ + /* * tmpfs vfs operations. */ @@ -529,7 +558,8 @@ static struct vfsops tmpfs_vfsops = { .vfs_statfs = tmpfs_statfs, .vfs_fhtovp = tmpfs_fhtovp, .vfs_vptofh = tmpfs_vptofh, - .vfs_sync = vfs_stdsync + .vfs_sync = vfs_stdsync, + .vfs_checkexp = tmpfs_checkexp, }; VFS_SET(tmpfs_vfsops, tmpfs, 0);