int ibcs2_sys_fstatfs(struct lwp *l, const struct ibcs2_sys_fstatfs_args *uap, register_t *retval) { /* { syscallarg(int) fd; syscallarg(struct ibcs2_statfs *) buf; syscallarg(int) len; syscallarg(int) fstype; } */ file_t *fp; struct mount *mp; struct statvfs *sp; 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; error = cvt_statfs(sp, (void *)SCARG(uap, buf), SCARG(uap, len)); out: fd_putfile(SCARG(uap, fd)); return (error); }
int ibcs2_sys_statfs(struct lwp *l, const struct ibcs2_sys_statfs_args *uap, register_t *retval) { /* { syscallarg(const char *) path; syscallarg(struct ibcs2_statfs *) buf; syscallarg(int) len; syscallarg(int) fstype; } */ struct mount *mp; struct statvfs *sp; int error; struct vnode *vp; error = namei_simple_user(SCARG(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; return cvt_statfs(sp, (void *)SCARG(uap, buf), SCARG(uap, len)); }
int nix_bsd_fstatfs(int fd, struct nix_statfs *buf, nix_env_t *env) { #if defined(HAVE_FSTATFS) struct statfs nsfs; #elif defined(HAVE_FSTATVFS) struct statvfs nsfs; #endif int rc; int rfd; if (buf == NULL) { nix_env_set_errno(env, EFAULT); return (-1); } if ((rfd = nix_fd_get(fd)) < 0) { nix_env_set_errno (env, EBADF); return (-1); } #if defined(HAVE_FSTATFS) rc = fstatfs(rfd, &nsfs); #elif defined(HAVE_FSTATVFS) rc = fstatvfs(rfd, &nsfs); #else errno = ENOSYS; rc = -1; #endif if (rc != 0) { nix_env_set_errno (env, errno); return (-1); } __nix_try { #if defined(HAVE_FSTATFS) || defined(HAVE_FSTATVFS) cvt_statfs(&nsfs, buf); #endif #if defined(HAVE_GETEXTMNTENT) rc = setmntpaths_fd(rfd, buf, env); #else rc = 0; #endif } __nix_catch_any { nix_env_set_errno(env, EFAULT); rc = -1; } __nix_end_try return (rc); }
int nix_bsd_getfsstat(struct nix_statfs *buf, size_t bufsiz, int flags, nix_env_t *env) { #ifdef HAVE_GETFSSTAT struct statfs *nfs; int n, maxcount; int nflags = 0; int count = 0; #ifdef MNT_NOWAIT if (flags == NIX_MNT_NOWAIT) nflags = MNT_NOWAIT; #endif if (buf == NULL) { count = getfsstat(NULL, 0, nflags); if (count < 0) { nix_env_set_errno(env, errno); return (-1); } return (count); } maxcount = bufsiz / sizeof(struct nix_statfs); if (maxcount == 0) { nix_env_set_errno(env, EINVAL); return (-1); } nfs = xec_mem_alloc_ntype(struct statfs, maxcount, 0); if (nfs == NULL) { nix_env_set_errno(env, ENOMEM); return (-1); } if ((count = getfsstat(nfs, maxcount * sizeof(struct statfs), nflags)) < 0) { xec_mem_free(nfs); nix_env_set_errno(env, errno); return (-1); } for (n = 0; n < count; n++) cvt_statfs(&nfs[n], &buf[n]); xec_mem_free(nfs); return (count); #else return (nix_nosys(env)); #endif }
int nix_bsd_statfs(char const *path, struct nix_statfs *buf, nix_env_t *env) { #if defined(HAVE_FSTATFS) struct statfs nsfs; #elif defined(HAVE_FSTATVFS) struct statvfs nsfs; #endif int rc; if (path == NULL || buf == NULL) { nix_env_set_errno(env, EFAULT); return (-1); } #if defined(HAVE_STATFS) rc = statfs(path, &nsfs); #elif defined(HAVE_STATVFS) rc = statvfs(path, &nsfs); #else errno = ENOSYS; rc = -1; #endif if (rc != 0) { nix_env_set_errno(env, errno); return (-1); } __nix_try { #if defined(HAVE_FSTATFS) || defined(HAVE_FSTATVFS) cvt_statfs(&nsfs, buf); #endif #if defined(HAVE_GETEXTMNTENT) rc = setmntpaths_path(path, buf, env); #else rc = 0; #endif } __nix_catch_any { nix_env_set_errno(env, EFAULT); rc = -1; } __nix_end_try return (rc); }