diff options
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/nfs/nfs_commonport.c | 2 | ||||
-rw-r--r-- | sys/fs/nfsclient/nfs_clport.c | 7 | ||||
-rw-r--r-- | sys/fs/nfsclient/nfs_clvnops.c | 7 | ||||
-rw-r--r-- | sys/fs/nfsserver/nfs_nfsdport.c | 3 | ||||
-rw-r--r-- | sys/fs/procfs/procfs.c | 68 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_status.c | 8 | ||||
-rw-r--r-- | sys/fs/pseudofs/pseudofs.c | 69 | ||||
-rw-r--r-- | sys/fs/pseudofs/pseudofs.h | 19 | ||||
-rw-r--r-- | sys/fs/tarfs/tarfs_vnops.c | 4 |
9 files changed, 103 insertions, 84 deletions
diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index e5fdb395c9f7..862780741ee7 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -371,8 +371,6 @@ nfsrv_atroot(struct vnode *vp, uint64_t *retp) /* * Set the credentials to refer to root. - * If only the various BSDen could agree on whether cr_gid is a separate - * field or cr_groups[0]... */ void newnfs_setroot(struct ucred *cred) diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index e9f1dc23ddbe..77e71d4153c9 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -1098,9 +1098,10 @@ newnfs_copyincred(struct ucred *cr, struct nfscred *nfscr) KASSERT(cr->cr_ngroups >= 0, ("newnfs_copyincred: negative cr_ngroups")); nfscr->nfsc_uid = cr->cr_uid; - nfscr->nfsc_ngroups = MIN(cr->cr_ngroups, NFS_MAXGRPS + 1); - for (i = 0; i < nfscr->nfsc_ngroups; i++) - nfscr->nfsc_groups[i] = cr->cr_groups[i]; + nfscr->nfsc_ngroups = MIN(cr->cr_ngroups + 1, NFS_MAXGRPS + 1); + nfscr->nfsc_groups[0] = cr->cr_gid; + for (i = 1; i < nfscr->nfsc_ngroups; i++) + nfscr->nfsc_groups[i] = cr->cr_groups[i - 1]; } /* diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index a8b06fdb261b..eee571a04821 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3474,7 +3474,7 @@ nfs_advlock(struct vop_advlock_args *ap) u_quad_t size; struct nfsmount *nmp; - error = NFSVOPLOCK(vp, LK_SHARED); + error = NFSVOPLOCK(vp, LK_EXCLUSIVE); if (error != 0) return (EBADF); nmp = VFSTONFS(vp->v_mount); @@ -3511,11 +3511,6 @@ nfs_advlock(struct vop_advlock_args *ap) cred = p->p_ucred; else cred = td->td_ucred; - NFSVOPLOCK(vp, LK_UPGRADE | LK_RETRY); - if (VN_IS_DOOMED(vp)) { - error = EBADF; - goto out; - } /* * If this is unlocking a write locked region, flush and diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index b2966934f9b7..7040c4afb797 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -2607,6 +2607,7 @@ again: * rpc reply */ if (siz == 0) { +ateof: vput(vp); if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, getret, &at); @@ -2648,6 +2649,8 @@ again: ncookies--; } if (cpos >= cend || ncookies == 0) { + if (eofflag != 0) + goto ateof; siz = fullsiz; toff = off; goto again; diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c index ab60ba47f322..cd66dd6f8b3b 100644 --- a/sys/fs/procfs/procfs.c +++ b/sys/fs/procfs/procfs.c @@ -156,42 +156,42 @@ procfs_init(PFS_INIT_ARGS) root = pi->pi_root; - pfs_create_link(root, "curproc", procfs_docurproc, - NULL, NULL, NULL, 0); - pfs_create_link(root, "self", procfs_docurproc, - NULL, NULL, NULL, 0); - - dir = pfs_create_dir(root, "pid", - procfs_attr_all_rx, NULL, NULL, PFS_PROCDEP); - pfs_create_file(dir, "cmdline", procfs_doproccmdline, - NULL, NULL, NULL, PFS_RD); - pfs_create_file(dir, "dbregs", procfs_doprocdbregs, + pfs_create_link(root, NULL, "curproc", procfs_docurproc, NULL, NULL, + NULL, 0); + pfs_create_link(root, NULL, "self", procfs_docurproc, NULL, NULL, NULL, + 0); + + pfs_create_dir(root, &dir, "pid", procfs_attr_all_rx, NULL, NULL, + PFS_PROCDEP); + pfs_create_file(dir, NULL, "cmdline", procfs_doproccmdline, NULL, NULL, + NULL, PFS_RD); + pfs_create_file(dir, NULL, "dbregs", procfs_doprocdbregs, procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - pfs_create_file(dir, "etype", procfs_doproctype, - NULL, NULL, NULL, PFS_RD); - pfs_create_file(dir, "fpregs", procfs_doprocfpregs, + pfs_create_file(dir, NULL, "etype", procfs_doproctype, NULL, NULL, NULL, + PFS_RD); + pfs_create_file(dir, NULL, "fpregs", procfs_doprocfpregs, procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - pfs_create_file(dir, "map", procfs_doprocmap, - NULL, procfs_notsystem, NULL, PFS_RD); - pfs_create_file(dir, "mem", procfs_doprocmem, - procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - pfs_create_file(dir, "note", procfs_doprocnote, - procfs_attr_w, procfs_candebug, NULL, PFS_WR); - pfs_create_file(dir, "notepg", procfs_doprocnote, - procfs_attr_w, procfs_candebug, NULL, PFS_WR); - pfs_create_file(dir, "regs", procfs_doprocregs, - procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - pfs_create_file(dir, "rlimit", procfs_doprocrlimit, - NULL, NULL, NULL, PFS_RD); - pfs_create_file(dir, "status", procfs_doprocstatus, - NULL, NULL, NULL, PFS_RD); - pfs_create_file(dir, "osrel", procfs_doosrel, - procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR); - - pfs_create_link(dir, "file", procfs_doprocfile, - NULL, procfs_notsystem, NULL, 0); - pfs_create_link(dir, "exe", procfs_doprocfile, - NULL, procfs_notsystem, NULL, 0); + pfs_create_file(dir, NULL, "map", procfs_doprocmap, NULL, + procfs_notsystem, NULL, PFS_RD); + pfs_create_file(dir, NULL, "mem", procfs_doprocmem, procfs_attr_rw, + procfs_candebug, NULL, PFS_RDWR | PFS_RAW); + pfs_create_file(dir, NULL, "note", procfs_doprocnote, procfs_attr_w, + procfs_candebug, NULL, PFS_WR); + pfs_create_file(dir, NULL, "notepg", procfs_doprocnote, procfs_attr_w, + procfs_candebug, NULL, PFS_WR); + pfs_create_file(dir, NULL, "regs", procfs_doprocregs, procfs_attr_rw, + procfs_candebug, NULL, PFS_RDWR | PFS_RAW); + pfs_create_file(dir, NULL, "rlimit", procfs_doprocrlimit, NULL, NULL, + NULL, PFS_RD); + pfs_create_file(dir, NULL, "status", procfs_doprocstatus, NULL, NULL, + NULL, PFS_RD); + pfs_create_file(dir, NULL, "osrel", procfs_doosrel, procfs_attr_rw, + procfs_candebug, NULL, PFS_RDWR); + + pfs_create_link(dir, NULL, "file", procfs_doprocfile, NULL, + procfs_notsystem, NULL, 0); + pfs_create_link(dir, NULL, "exe", procfs_doprocfile, NULL, + procfs_notsystem, NULL, 0); return (0); } diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 38070e0946bb..49c084d02ff8 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -141,13 +141,9 @@ procfs_doprocstatus(PFS_FILL_ARGS) (u_long)cr->cr_uid, (u_long)cr->cr_ruid, (u_long)cr->cr_rgid); - - /* egid (cr->cr_svgid) is equal to cr_ngroups[0] - see also getegid(2) in /sys/kern/kern_prot.c */ - - for (i = 0; i < cr->cr_ngroups; i++) { + sbuf_printf(sb, ",%lu", (u_long)cr->cr_gid); + for (i = 0; i < cr->cr_ngroups; i++) sbuf_printf(sb, ",%lu", (u_long)cr->cr_groups[i]); - } if (jailed(cr)) { mtx_lock(&cr->cr_prison->pr_mtx); diff --git a/sys/fs/pseudofs/pseudofs.c b/sys/fs/pseudofs/pseudofs.c index ef45f96a6192..7a4e67455214 100644 --- a/sys/fs/pseudofs/pseudofs.c +++ b/sys/fs/pseudofs/pseudofs.c @@ -133,7 +133,7 @@ pfs_add_node(struct pfs_node *parent, struct pfs_node *pn) for (iter = parent->pn_nodes; iter != NULL; iter = iter->pn_next) { if (strcmp(pn->pn_name, iter->pn_name) != 0) continue; - printf("pfs_add_node: homonymous siblings: '%s/%s' type %d", + printf("pfs_add_node: homonymous siblings: '%s/%s' type %d\n", parent->pn_name, pn->pn_name, pn->pn_type); /* Do not detach, because we are not yet attached. */ pn->pn_parent = NULL; @@ -234,81 +234,101 @@ pfs_fixup_dir(struct pfs_node *parent) /* * Create a directory */ -struct pfs_node * -pfs_create_dir(struct pfs_node *parent, const char *name, - pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, - int flags) +int +pfs_create_dir(struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_attr_t attr, pfs_vis_t vis, + pfs_destroy_t destroy, int flags) { - struct pfs_node *pn; + struct pfs_node *pdir, *pn; int rc; - pn = pfs_alloc_node_flags(parent->pn_info, name, + /* Preserve in case the caller is reusing the one pointer for both. */ + pdir = parent; + if (opn != NULL) + *opn = NULL; + pn = pfs_alloc_node_flags(pdir->pn_info, name, (flags & PFS_PROCDEP) ? pfstype_procdir : pfstype_dir, flags); if (pn == NULL) - return (NULL); + return (ENOMEM); pn->pn_attr = attr; pn->pn_vis = vis; pn->pn_destroy = destroy; pn->pn_flags = flags; - rc = pfs_add_node(parent, pn); + rc = pfs_add_node(pdir, pn); if (rc == 0) rc = pfs_fixup_dir_flags(pn, flags); if (rc != 0) { pfs_destroy(pn); pn = NULL; + } else if (opn != NULL) { + *opn = pn; } - return (pn); + + return (rc); } /* * Create a file */ -struct pfs_node * -pfs_create_file(struct pfs_node *parent, const char *name, pfs_fill_t fill, - pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, - int flags) +int +pfs_create_file(struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_fill_t fill, pfs_attr_t attr, + pfs_vis_t vis, pfs_destroy_t destroy, int flags) { struct pfs_node *pn; + int rc; + if (opn != NULL) + *opn = NULL; pn = pfs_alloc_node_flags(parent->pn_info, name, pfstype_file, flags); if (pn == NULL) - return (NULL); + return (ENOMEM); + pn->pn_fill = fill; pn->pn_attr = attr; pn->pn_vis = vis; pn->pn_destroy = destroy; pn->pn_flags = flags; - if (pfs_add_node(parent, pn) != 0) { + if ((rc = pfs_add_node(parent, pn)) != 0) { pfs_destroy(pn); pn = NULL; + } else if (opn != NULL) { + *opn = pn; } - return (pn); + + return (rc); } /* * Create a symlink */ -struct pfs_node * -pfs_create_link(struct pfs_node *parent, const char *name, pfs_fill_t fill, - pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, - int flags) +int +pfs_create_link(struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_fill_t fill, pfs_attr_t attr, + pfs_vis_t vis, pfs_destroy_t destroy, int flags) { struct pfs_node *pn; + int rc; + if (opn != NULL) + *opn = NULL; pn = pfs_alloc_node_flags(parent->pn_info, name, pfstype_symlink, flags); if (pn == NULL) - return (NULL); + return (ENOMEM); + pn->pn_fill = fill; pn->pn_attr = attr; pn->pn_vis = vis; pn->pn_destroy = destroy; pn->pn_flags = flags; - if (pfs_add_node(parent, pn) != 0) { + if ((rc = pfs_add_node(parent, pn)) != 0) { pfs_destroy(pn); pn = NULL; + } else if (opn != NULL) { + *opn = pn; } - return (pn); + return (rc); } /* @@ -475,6 +495,7 @@ pfs_init(struct pfs_info *pi, struct vfsconf *vfc) if (error) { pfs_destroy(root); pi->pi_root = NULL; + pfs_fileno_uninit(pi); return (error); } diff --git a/sys/fs/pseudofs/pseudofs.h b/sys/fs/pseudofs/pseudofs.h index c60dd7b339d1..2b08dcad978d 100644 --- a/sys/fs/pseudofs/pseudofs.h +++ b/sys/fs/pseudofs/pseudofs.h @@ -255,17 +255,18 @@ int pfs_uninit (struct pfs_info *pi, struct vfsconf *vfc); /* * Directory structure construction and manipulation */ -struct pfs_node *pfs_create_dir (struct pfs_node *parent, const char *name, - pfs_attr_t attr, pfs_vis_t vis, - pfs_destroy_t destroy, int flags); -struct pfs_node *pfs_create_file(struct pfs_node *parent, const char *name, - pfs_fill_t fill, pfs_attr_t attr, - pfs_vis_t vis, pfs_destroy_t destroy, - int flags); -struct pfs_node *pfs_create_link(struct pfs_node *parent, const char *name, - pfs_fill_t fill, pfs_attr_t attr, +int pfs_create_dir (struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, int flags); +int pfs_create_file (struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_fill_t fill, + pfs_attr_t attr, pfs_vis_t vis, + pfs_destroy_t destroy, int flags); +int pfs_create_link (struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_fill_t fill, + pfs_attr_t attr, pfs_vis_t vis, + pfs_destroy_t destroy, int flags); struct pfs_node *pfs_find_node (struct pfs_node *parent, const char *name); void pfs_purge (struct pfs_node *pn); int pfs_destroy (struct pfs_node *pn); diff --git a/sys/fs/tarfs/tarfs_vnops.c b/sys/fs/tarfs/tarfs_vnops.c index acf18de5ab51..c110107bb210 100644 --- a/sys/fs/tarfs/tarfs_vnops.c +++ b/sys/fs/tarfs/tarfs_vnops.c @@ -334,6 +334,10 @@ tarfs_readdir(struct vop_readdir_args *ap) tnp, tnp->name, uio->uio_offset, uio->uio_resid); if (uio->uio_offset == TARFS_COOKIE_EOF) { + if (eofflag != NULL) { + TARFS_DPF(VNODE, "%s: Setting EOF flag\n", __func__); + *eofflag = 1; + } TARFS_DPF(VNODE, "%s: EOF\n", __func__); return (0); } |