int compat_20_netbsd32_statfs(struct lwp *l, const struct compat_20_netbsd32_statfs_args *uap, register_t *retval) { /* { syscallarg(const netbsd32_charp) path; syscallarg(netbsd32_statfsp_t) buf; } */ struct mount *mp; struct statvfs *sp; struct netbsd32_statfs s32; int error; struct vnode *vp; error = namei_simple_user(SCARG_P32(uap, path), NSM_FOLLOW_TRYEMULROOT, &vp); if (error != 0) return (error); mp = vp->v_mount; sp = &mp->mnt_stat; vrele(vp); if ((error = VFS_STATVFS(mp, sp)) != 0) return (error); sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK; compat_20_netbsd32_from_statvfs(sp, &s32); return copyout(&s32, SCARG_P32(uap, buf), sizeof(s32)); }
int compat_20_netbsd32_fstatfs(struct lwp *l, const struct compat_20_netbsd32_fstatfs_args *uap, register_t *retval) { /* { syscallarg(int) fd; syscallarg(netbsd32_statfsp_t) buf; } */ file_t *fp; struct mount *mp; struct statvfs *sp; struct netbsd32_statfs s32; int error; /* fd_getvnode() will use the descriptor for us */ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0) return (error); mp = ((struct vnode *)fp->f_data)->v_mount; sp = &mp->mnt_stat; if ((error = VFS_STATVFS(mp, sp)) != 0) goto out; sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK; compat_20_netbsd32_from_statvfs(sp, &s32); error = copyout(&s32, SCARG_P32(uap, buf), sizeof(s32)); out: fd_putfile(SCARG(uap, fd)); return (error); }
int compat_20_netbsd32_statfs(struct lwp *l, const struct compat_20_netbsd32_statfs_args *uap, register_t *retval) { /* { syscallarg(const netbsd32_charp) path; syscallarg(netbsd32_statfsp_t) buf; } */ struct mount *mp; struct statvfs *sp; struct netbsd32_statfs s32; int error; struct nameidata nd; NDINIT(&nd, LOOKUP, FOLLOW | TRYEMULROOT, UIO_USERSPACE, SCARG_P32(uap, path)); if ((error = namei(&nd)) != 0) return (error); mp = nd.ni_vp->v_mount; sp = &mp->mnt_stat; vrele(nd.ni_vp); if ((error = VFS_STATVFS(mp, sp)) != 0) return (error); sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK; compat_20_netbsd32_from_statvfs(sp, &s32); return copyout(&s32, SCARG_P32(uap, buf), sizeof(s32)); }
int compat_20_netbsd32_getfsstat(struct lwp *l, const struct compat_20_netbsd32_getfsstat_args *uap, register_t *retval) { /* { syscallarg(netbsd32_statfsp_t) buf; syscallarg(netbsd32_long) bufsize; syscallarg(int) flags; } */ struct mount *mp, *nmp; struct statvfs *sp; struct netbsd32_statfs sb32; void *sfsp; long count, maxcount, error; maxcount = SCARG(uap, bufsize) / sizeof(struct netbsd32_statfs); sfsp = SCARG_P32(uap, buf); mutex_enter(&mountlist_lock); count = 0; for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { if (vfs_busy(mp, &nmp)) { continue; } if (sfsp && count < maxcount) { sp = &mp->mnt_stat; /* * If MNT_NOWAIT or MNT_LAZY is specified, do not * refresh the fsstat cache. MNT_WAIT or MNT_LAZY * overrides MNT_NOWAIT. */ if (SCARG(uap, flags) != MNT_NOWAIT && SCARG(uap, flags) != MNT_LAZY && (SCARG(uap, flags) == MNT_WAIT || SCARG(uap, flags) == 0) && (error = VFS_STATVFS(mp, sp)) != 0) { mutex_enter(&mountlist_lock); vfs_unbusy(mp, false, &nmp); continue; } sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK; compat_20_netbsd32_from_statvfs(sp, &sb32); error = copyout(&sb32, sfsp, sizeof(sb32)); if (error) { vfs_unbusy(mp, false, NULL); return (error); } sfsp = (char *)sfsp + sizeof(sb32); } count++; mutex_enter(&mountlist_lock); vfs_unbusy(mp, false, &nmp); } mutex_exit(&mountlist_lock); if (sfsp && count > maxcount) *retval = maxcount; else *retval = count; return (0); }