Lines Matching full:error
194 int error;
203 if ((error = namei(&nd)) != 0)
204 return (error);
209 error = vfs_busy(mp, 0);
210 if (error != 0) {
212 return (error);
215 error = VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg, &mp_busy);
231 return (error);
278 int error;
282 error = vfs_busy(mp, 0);
284 if (error != 0)
285 return (error);
287 error = mac_mount_check_stat(td->td_ucred, mp);
288 if (error != 0)
291 error = VFS_STATFS(mp, buf);
292 if (error != 0)
300 return (error);
316 int error;
319 error = kern_statfs(td, uap->path, UIO_USERSPACE, sfp);
320 if (error == 0)
321 error = copyout(sfp, uap->buf, sizeof(struct statfs));
323 return (error);
332 int error;
335 error = namei(&nd);
336 if (error != 0)
337 return (error);
357 int error;
360 error = kern_fstatfs(td, uap->fd, sfp);
361 if (error == 0)
362 error = copyout(sfp, uap->buf, sizeof(struct statfs));
364 return (error);
373 int error;
376 error = getvnode_path(td, fd, &cap_fstatfs_rights, &fp);
377 if (error != 0)
378 return (error);
406 int error;
410 error = kern_getfsstat(td, &uap->buf, uap->bufsize, &count,
412 if (error == 0)
414 return (error);
429 int error;
537 error = VFS_STATFS(mp, sp);
538 if (error != 0) {
558 error = copyout(sp, sfsp, sizeof(*sp));
560 if (error != 0) {
562 return (error);
600 int error;
603 error = kern_statfs(td, uap->path, UIO_USERSPACE, sfp);
604 if (error == 0) {
606 error = copyout(&osb, uap->buf, sizeof(osb));
609 return (error);
626 int error;
629 error = kern_fstatfs(td, uap->fd, sfp);
630 if (error == 0) {
632 error = copyout(&osb, uap->buf, sizeof(osb));
635 return (error);
654 int error;
662 error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE,
664 if (error == 0)
668 while (count != 0 && error == 0) {
670 error = copyout(&osb, uap->buf, sizeof(osb));
677 return (error);
695 int error;
697 error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
698 if (error != 0)
699 return (error);
701 error = kern_fhstatfs(td, fh, sfp);
702 if (error == 0) {
704 error = copyout(&osb, uap->buf, sizeof(osb));
707 return (error);
754 int error;
757 error = kern_statfs(td, uap->path, UIO_USERSPACE, sfp);
758 if (error == 0) {
760 error = copyout(&osb, uap->buf, sizeof(osb));
763 return (error);
774 int error;
777 error = kern_fstatfs(td, uap->fd, sfp);
778 if (error == 0) {
780 error = copyout(&osb, uap->buf, sizeof(osb));
783 return (error);
802 int error;
809 error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE, mode);
810 if (error == 0)
814 while (count > 0 && error == 0) {
816 error = copyout(&osb, ubuf, sizeof(osb));
823 return (error);
835 int error;
837 error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
838 if (error)
839 return (error);
841 error = kern_fhstatfs(td, fh, sfp);
842 if (error == 0) {
844 error = copyout(&osb, uap->buf, sizeof(osb));
847 return (error);
898 int error;
901 error = getvnode_path(td, uap->fd, &cap_fchdir_rights,
903 if (error != 0)
904 return (error);
910 error = change_dir(vp, td);
911 while (!error && (mp = vp->v_mountedhere) != NULL) {
914 error = VFS_ROOT(mp, LK_SHARED, &tdp);
916 if (error != 0)
921 if (error != 0) {
923 return (error);
949 int error;
953 if ((error = namei(&nd)) != 0)
954 return (error);
955 if ((error = change_dir(nd.ni_vp, td)) != 0) {
958 return (error);
978 int error;
980 error = priv_check(td, PRIV_VFS_CHROOT);
981 if (error != 0) {
992 error = change_dir(vp, td);
993 if (error != 0)
996 error = mac_vnode_check_chroot(td->td_ucred, vp);
997 if (error != 0)
1001 error = pwd_chroot(td, vp);
1003 return (error);
1006 return (error);
1021 int error;
1025 error = namei(&nd);
1026 if (error != 0)
1027 return (error);
1029 error = kern_chroot(td, nd.ni_vp);
1030 return (error);
1046 int error;
1048 error = getvnode_path(td, uap->fd, &cap_fchroot_rights, &fp);
1049 if (error != 0)
1050 return (error);
1055 error = kern_chroot(td, vp);
1056 return (error);
1067 int error;
1074 error = mac_vnode_check_chdir(td->td_ucred, vp);
1075 if (error != 0)
1076 return (error);
1170 int cmode, error, indx;
1202 error = falloc_noinstall(td, &fp);
1203 if (error != 0)
1204 return (error);
1211 error = vn_open_cred(&nd, &flags, cmode, VN_OPEN_WANTIOCTLCAPS,
1213 if (error != 0) {
1219 if (error == ENXIO && fp->f_ops != &badfileops) {
1232 (error == ENODEV || error == ENXIO) &&
1235 error = dupfdopen(td, fdp, td->td_dupfd, flags, error,
1237 if (error == 0)
1271 error = fo_truncate(fp, 0, td->td_ucred, td);
1272 if (error != 0)
1277 MPASS(error == 0);
1293 error = finstall_refed(td, fp, &indx, flags, fcaps);
1295 if (error != 0) {
1309 return (error);
1323 int error, old_dupfd;
1327 error = openatfp(td, dirfd, path, pathseg, flags, mode, fpp);
1329 return (error);
1398 int error, whiteout = 0;
1405 error = priv_check(td, PRIV_VFS_MKNOD_DEV);
1406 if (error == 0 && dev == VNOVAL)
1407 error = EINVAL;
1410 error = priv_check(td, PRIV_VFS_MKNOD_WHT);
1417 error = EINVAL;
1420 if (error != 0)
1421 return (error);
1427 if ((error = namei(&nd)) != 0)
1428 return (error);
1462 if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
1463 return (error);
1467 if (error == 0 && !whiteout)
1468 error = mac_vnode_check_create(td->td_ucred, nd.ni_dvp,
1471 if (error == 0) {
1473 error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, CREATE);
1475 error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp,
1479 VOP_VPUT_PAIR(nd.ni_dvp, error == 0 && !whiteout ? &nd.ni_vp : NULL,
1483 if (error == ERELOOKUP)
1485 return (error);
1527 int error;
1535 if ((error = namei(&nd)) != 0)
1536 return (error);
1549 if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
1550 return (error);
1557 error = mac_vnode_check_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
1559 if (error != 0)
1562 error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
1566 VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true);
1569 if (error == ERELOOKUP)
1571 return (error);
1623 int error;
1628 error = VOP_GETATTR(vp, &va, cred);
1629 if (error != 0)
1630 return (error);
1633 error = priv_check_cred(cred, PRIV_VFS_LINK);
1634 if (error != 0)
1635 return (error);
1639 error = priv_check_cred(cred, PRIV_VFS_LINK);
1640 if (error != 0)
1641 return (error);
1652 int error;
1664 if ((error = namei(&nd)) != 0)
1665 return (error);
1668 error = priv_check(td, PRIV_VFS_FHOPEN);
1669 if (error != 0) {
1671 return (error);
1674 error = kern_linkat_vp(td, nd.ni_vp, fd2, path2, segflag);
1675 } while (error == EAGAIN || error == ERELOOKUP);
1676 return (error);
1685 int error;
1694 if ((error = namei(&nd)) == 0) {
1715 error = can_hardlink(vp, td->td_ucred);
1717 if (error == 0)
1718 error = mac_vnode_check_link(td->td_ucred,
1721 if (error != 0) {
1725 return (error);
1727 error = vn_start_write(vp, &mp, V_NOWAIT);
1728 if (error != 0) {
1732 error = vn_start_write(NULL, &mp,
1734 if (error != 0)
1735 return (error);
1738 error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
1752 return (error);
1796 int error;
1802 if ((error = copyinstr(path1, tmppath, MAXPATHLEN, NULL)) != 0)
1812 if ((error = namei(&nd)) != 0)
1822 error = EEXIST;
1828 if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
1836 error = mac_vnode_check_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
1838 if (error != 0)
1841 error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, syspath);
1845 VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true);
1848 if (error == ERELOOKUP)
1853 return (error);
1869 int error;
1876 error = namei(&nd);
1877 if (error != 0)
1878 return (error);
1893 if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
1894 return (error);
1897 error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE);
1901 if (error == ERELOOKUP)
1903 return (error);
1976 int error;
1980 error = getvnode_path(td, fd, &cap_no_rights, &fp);
1981 if (error != 0)
1982 return (error);
1991 if ((error = namei(&nd)) != 0) {
1992 if (error == EINVAL)
1993 error = EPERM;
1998 error = EPERM; /* POSIX */
2000 ((error = VOP_STAT(vp, &sb, td->td_ucred, NOCRED)) == 0) &&
2002 error = EIDRM; /* Identifier removed */
2005 error = EBADF;
2007 error = EDEADLK;
2015 error = EBUSY;
2017 if (error == 0) {
2025 if ((error = vn_start_write(NULL, &mp,
2032 error = mac_vnode_check_unlink(td->td_ucred, nd.ni_dvp, vp,
2034 if (error != 0)
2038 error = VOP_REMOVE(nd.ni_dvp, vp, &nd.ni_cnd);
2050 if (error == ERELOOKUP)
2055 return (error);
2080 int error;
2083 error = fget(td, fd, &cap_seek_rights, &fp);
2084 if (error != 0)
2085 return (error);
2086 error = (fp->f_ops->fo_flags & DFLAG_SEEKABLE) != 0 ?
2089 return (error);
2129 int error;
2143 error = mac_vnode_check_access(cred, vp, accmode);
2144 if (error != 0)
2145 return (error);
2147 if ((accmode & VWRITE) == 0 || (error = vn_writechk(vp)) == 0)
2148 error = VOP_ACCESS(vp, accmode, cred, td);
2149 return (error);
2192 int error;
2218 if ((error = namei(&nd)) != 0)
2222 error = vn_access(vp, amode, usecred, td);
2230 return (error);
2265 int error;
2267 error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, &sb);
2268 if (error != 0)
2269 return (error);
2288 int error;
2290 error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
2292 if (error != 0)
2293 return (error);
2329 "Error on truncation of device, file or inode number, or link count");
2341 * maximum for case 2, but ignore the error.
2407 int error;
2409 error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, &sb);
2410 if (error != 0)
2411 return (error);
2412 error = freebsd11_cvtstat(&sb, &osb);
2413 if (error == 0)
2414 error = copyout(&osb, uap->ub, sizeof(osb));
2415 return (error);
2423 int error;
2425 error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
2427 if (error != 0)
2428 return (error);
2429 error = freebsd11_cvtstat(&sb, &osb);
2430 if (error == 0)
2431 error = copyout(&osb, uap->ub, sizeof(osb));
2432 return (error);
2441 int error;
2443 error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
2444 if (error != 0)
2445 return (error);
2446 error = kern_fhstat(td, fh, &sb);
2447 if (error != 0)
2448 return (error);
2449 error = freebsd11_cvtstat(&sb, &osb);
2450 if (error == 0)
2451 error = copyout(&osb, uap->sb, sizeof(osb));
2452 return (error);
2460 int error;
2462 error = kern_statat(td, uap->flag, uap->fd, uap->path,
2464 if (error != 0)
2465 return (error);
2466 error = freebsd11_cvtstat(&sb, &osb);
2467 if (error == 0)
2468 error = copyout(&osb, uap->buf, sizeof(osb));
2469 return (error);
2488 int error;
2490 error = kern_statat(td, uap->flag, uap->fd, uap->path,
2492 if (error == 0)
2493 error = copyout(&sb, uap->buf, sizeof (sb));
2494 return (error);
2502 int error;
2512 if ((error = namei(&nd)) != 0) {
2513 if (error == ENOTDIR &&
2515 error = kern_fstat(td, fd, sbp);
2516 return (error);
2518 error = VOP_STAT(nd.ni_vp, sbp, td->td_ucred, NOCRED);
2529 ktrstat_error(sbp, error);
2531 return (error);
2542 int error;
2544 error = freebsd11_cvtstat(sb, &sb11);
2545 if (error != 0)
2546 return (error);
2579 int error;
2581 error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, &sb);
2582 if (error != 0)
2583 return (error);
2584 error = freebsd11_cvtnstat(&sb, &nsb);
2585 if (error == 0)
2586 error = copyout(&nsb, uap->ub, sizeof (nsb));
2587 return (error);
2604 int error;
2606 error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
2608 if (error != 0)
2609 return (error);
2610 error = freebsd11_cvtnstat(&sb, &nsb);
2611 if (error == 0)
2612 error = copyout(&nsb, uap->ub, sizeof (nsb));
2613 return (error);
2630 int error;
2632 error = kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name, FOLLOW,
2634 if (error == 0)
2636 return (error);
2649 int error;
2651 error = kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name,
2653 if (error == 0)
2655 return (error);
2663 int error;
2667 if ((error = namei(&nd)) != 0)
2668 return (error);
2671 error = VOP_PATHCONF(nd.ni_vp, name, valuep);
2673 return (error);
2715 int error;
2723 if ((error = namei(&nd)) != 0)
2724 return (error);
2728 error = kern_readlink_vp(vp, buf, bufseg, count, td);
2731 return (error);
2743 int error;
2747 error = mac_vnode_check_readlink(td->td_ucred, vp);
2748 if (error != 0)
2749 return (error);
2763 error = VOP_READLINK(vp, &auio, td->td_ucred);
2765 return (error);
2776 int error;
2789 error = priv_check(td, PRIV_VFS_CHFLAGS_DEV);
2790 if (error != 0)
2791 return (error);
2794 if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
2795 return (error);
2800 error = mac_vnode_check_setflags(td->td_ucred, vp, vattr.va_flags);
2801 if (error == 0)
2803 error = VOP_SETATTR(vp, &vattr, td->td_ucred);
2806 return (error);
2864 int error;
2874 if ((error = namei(&nd)) != 0)
2875 return (error);
2877 error = setfflags(td, nd.ni_vp, flags);
2879 return (error);
2895 int error;
2899 error = getvnode(td, uap->fd, &cap_fchflags_rights,
2901 if (error != 0)
2902 return (error);
2910 error = setfflags(td, fp->f_vnode, uap->flags);
2912 return (error);
2923 int error;
2925 if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
2926 return (error);
2931 error = mac_vnode_check_setmode(cred, vp, vattr.va_mode);
2932 if (error == 0)
2934 error = VOP_SETATTR(vp, &vattr, cred);
2937 return (error);
2995 int error;
3005 if ((error = namei(&nd)) != 0)
3006 return (error);
3008 error = setfmode(td, td->td_ucred, nd.ni_vp, mode);
3010 return (error);
3026 int error;
3031 error = fget(td, uap->fd, &cap_fchmod_rights, &fp);
3032 if (error != 0)
3033 return (error);
3034 error = fo_chmod(fp, uap->mode, td->td_ucred, td);
3036 return (error);
3048 int error;
3050 if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
3051 return (error);
3057 error = mac_vnode_check_setowner(cred, vp, vattr.va_uid,
3059 if (error == 0)
3061 error = VOP_SETATTR(vp, &vattr, cred);
3064 return (error);
3107 int error;
3118 if ((error = namei(&nd)) != 0)
3119 return (error);
3121 error = setfown(td, td->td_ucred, nd.ni_vp, uid, gid);
3123 return (error);
3158 int error;
3162 error = fget(td, uap->fd, &cap_fchown_rights, &fp);
3163 if (error != 0)
3164 return (error);
3165 error = fo_chown(fp, uap->uid, uap->gid, td->td_ucred, td);
3167 return (error);
3179 int error;
3188 if ((error = copyin(usrtvp, tv, sizeof(tv))) != 0)
3189 return (error);
3212 int error;
3225 } else if ((error = copyin(usrtsp, tsp, sizeof(*tsp) * 2)) != 0)
3226 return (error);
3257 int error;
3264 if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
3265 return (error);
3280 error = mac_vnode_check_setutimes(td->td_ucred, vp, vattr.va_atime,
3283 if (error == 0)
3284 error = VOP_SETATTR(vp, &vattr, td->td_ucred);
3287 return (error);
3328 int error;
3330 if ((error = getutimes(tptr, tptrseg, ts)) != 0)
3331 return (error);
3335 if ((error = namei(&nd)) != 0)
3336 return (error);
3338 error = setutimes(td, nd.ni_vp, ts, 2, tptr == NULL);
3340 return (error);
3366 int error;
3368 if ((error = getutimes(tptr, tptrseg, ts)) != 0)
3369 return (error);
3371 if ((error = namei(&nd)) != 0)
3372 return (error);
3374 error = setutimes(td, nd.ni_vp, ts, 2, tptr == NULL);
3376 return (error);
3401 int error;
3404 error = getutimes(tptr, tptrseg, ts);
3405 if (error != 0)
3406 return (error);
3407 error = getvnode(td, fd, &cap_futimes_rights, &fp);
3408 if (error != 0)
3409 return (error);
3417 error = setutimes(td, fp->f_vnode, ts, 2, tptr == NULL);
3419 return (error);
3435 int error, flags;
3438 error = getutimens(tptr, tptrseg, ts, &flags);
3439 if (error != 0)
3440 return (error);
3443 error = getvnode(td, fd, &cap_futimes_rights, &fp);
3444 if (error != 0)
3445 return (error);
3453 error = setutimes(td, fp->f_vnode, ts, 2, flags & UTIMENS_NULL);
3455 return (error);
3473 int error, flags;
3479 if ((error = getutimens(tptr, tptrseg, ts, &flags)) != 0)
3480 return (error);
3484 if ((error = namei(&nd)) != 0)
3485 return (error);
3494 error = setutimes(td, nd.ni_vp, ts, 2, flags & UTIMENS_NULL);
3496 return (error);
3524 int error;
3531 if ((error = namei(&nd)) != 0)
3532 return (error);
3536 if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0) {
3539 return (error);
3543 error = EISDIR;
3547 error = mac_vnode_check_write(td->td_ucred, NOCRED, vp);
3548 if (error != 0)
3551 error = VOP_ACCESS(vp, VWRITE, td->td_ucred, td);
3552 if (error != 0)
3555 error = vn_truncate_locked(vp, length, false, td->td_ucred);
3561 if (error == ERELOOKUP)
3563 return (error);
3607 int error;
3610 error = getvnode(td, fd, &cap_fsync_rights, &fp);
3611 if (error != 0)
3612 return (error);
3619 error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
3620 if (error != 0)
3625 error = fullsync ? VOP_FSYNC(vp, MNT_WAIT, td) : VOP_FDATASYNC(vp, td);
3628 if (error == ERELOOKUP)
3632 return (error);
3696 int error;
3700 if ((error = namei(fromnd)) != 0)
3701 return (error);
3702 error = mac_vnode_check_rename_from(td->td_ucred, fromnd->ni_dvp,
3707 if (error != 0) {
3712 return (error);
3724 int error;
3730 error = kern_renameat_mac(td, oldfd, old, newfd, new, pathseg,
3732 if (error != 0)
3733 return (error);
3738 if ((error = namei(&fromnd)) != 0)
3739 return (error);
3749 if ((error = namei(&tond)) != 0) {
3750 /* Translate error code for rename("dir1", "dir2/."). */
3751 if (error == EISDIR && fvp->v_type == VDIR)
3752 error = EINVAL;
3760 error = vn_start_write(fvp, &mp, V_NOWAIT);
3761 if (error != 0) {
3772 error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH);
3773 if (error != 0)
3774 return (error);
3779 error = ENOTDIR;
3782 error = EISDIR;
3791 error = cap_check(&tond.ni_filecaps.fc_rights,
3793 if (error != 0)
3799 error = EINVAL;
3807 error = ERESTART;
3810 error = mac_vnode_check_rename_to(td->td_ucred, tdvp,
3814 if (error == 0) {
3815 error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
3833 if (error == ERESTART)
3835 if (error == ERELOOKUP)
3837 return (error);
3878 int error;
3887 if ((error = namei(&nd)) != 0)
3888 return (error);
3892 if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
3893 return (error);
3900 error = mac_vnode_check_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
3902 if (error != 0)
3905 error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
3910 VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true);
3912 if (error == ERELOOKUP)
3914 return (error);
3942 int error;
3946 error = getvnode(td, fd, cap_rights_init_one(&rights,
3948 if (error != 0)
3949 return (error);
3958 if ((error = namei(&nd)) != 0)
3962 error = ENOTDIR;
3969 error = EINVAL;
3976 error = EBUSY;
3982 error = EBADF;
3984 error = EDEADLK;
3989 error = mac_vnode_check_unlink(td->td_ucred, nd.ni_dvp, vp,
3991 if (error != 0)
4001 if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
4006 error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
4015 if (error == ERELOOKUP)
4020 return (error);
4033 int error;
4040 error = kern_getdirentries(td, fd, dirbuf, count, &base, &resid,
4042 if (error != 0)
4065 error = EOVERFLOW;
4082 error = copyout(&dstdp, ubuf + ucount, dstdp.d_reclen);
4083 if (error != 0)
4091 if (error == 0)
4093 return (error);
4132 int error;
4134 error = kern_ogetdirentries(td, uap, &loff);
4135 if (error == 0)
4136 error = copyout(&loff, uap->basep, sizeof(long));
4137 return (error);
4145 int error;
4151 error = freebsd11_kern_getdirentries(td, uap->fd, uap->buf, uap->count,
4154 if (error == 0 && uap->basep != NULL)
4155 error = copyout(&base, uap->basep, sizeof(long));
4157 return (error);
4175 int error;
4177 error = freebsd11_kern_getdirentries(td, uap->fd, uap->buf, uap->count,
4180 if (error == 0 && uap->basep != NULL)
4181 error = copyout(&base, uap->basep, sizeof(long));
4182 return (error);
4205 int error;
4207 error = kern_getdirentries(td, uap->fd, uap->buf, uap->count, &base,
4209 if (error != 0)
4210 return (error);
4212 error = copyout(&base, uap->basep, sizeof(off_t));
4213 return (error);
4225 int error, eofflag;
4232 error = getvnode(td, fd, &cap_read_rights, &fp);
4233 if (error != 0)
4234 return (error);
4243 error = EINVAL;
4247 error = ENOENT;
4261 error = mac_vnode_check_readdir(td->td_ucred, vp);
4262 if (error == 0)
4264 error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL,
4267 if (error != 0) {
4291 return (error);
4330 int error;
4334 if ((error = namei(&nd)) != 0)
4335 return (error);
4339 error = EINVAL;
4343 error = mac_vnode_check_revoke(td->td_ucred, vp);
4344 if (error != 0)
4347 error = VOP_GETATTR(vp, &vattr, td->td_ucred);
4348 if (error != 0)
4351 error = priv_check(td, PRIV_VFS_ADMIN);
4352 if (error != 0)
4359 return (error);
4372 int error;
4374 error = fget_unlocked(td, fd, rightsp, &fp);
4375 if (error != 0)
4376 return (error);
4408 int error;
4410 error = getvnode_path(td, fd, rightsp, fpp);
4411 if (__predict_false(error != 0))
4412 return (error);
4421 error = EBADF;
4424 return (error);
4488 int error;
4492 error = priv_check(td, PRIV_VFS_GETFH);
4493 if (error != 0)
4494 return (error);
4498 error = namei(&nd);
4499 if (error != 0)
4500 return (error);
4505 error = VOP_VPTOFH(vp, &fh.fh_fid);
4507 if (error == 0) {
4509 error = copyout(&fh, fhp, sizeof (fh));
4513 return (error);
4550 int error;
4552 error = priv_check(td, PRIV_VFS_GETFH);
4553 if (error != 0)
4554 return (error);
4555 error = copyin(fhp, &fh, sizeof(fh));
4556 if (error != 0)
4557 return (error);
4562 error = VFS_FHTOVP(mp, &fh.fh_fid, LK_SHARED, &vp);
4564 if (error != 0)
4565 return (error);
4567 error = kern_linkat_vp(td, vp, fd, path, pathseg);
4568 } while (error == EAGAIN || error == ERELOOKUP);
4569 return (error);
4585 int error;
4587 error = priv_check(td, PRIV_VFS_GETFH);
4588 if (error != 0)
4589 return (error);
4592 error = copyin(uap->fhp, &fh, sizeof(fh));
4593 if (error != 0)
4594 return (error);
4597 error = VFS_FHTOVP(mp, &fh.fh_fid, LK_SHARED, &vp);
4599 if (error != 0)
4600 return (error);
4601 error = kern_readlink_vp(vp, uap->buf, UIO_USERSPACE, uap->bufsize, td);
4603 return (error);
4632 int fmode, error;
4635 error = priv_check(td, PRIV_VFS_FHOPEN);
4636 if (error != 0)
4637 return (error);
4643 error = copyin(u_fhp, &fhp, sizeof(fhp));
4644 if (error != 0)
4645 return(error);
4651 error = VFS_FHTOVP(mp, &fhp.fh_fid, LK_EXCLUSIVE, &vp);
4653 if (error != 0)
4654 return (error);
4656 error = falloc_noinstall(td, &fp);
4657 if (error != 0) {
4659 return (error);
4669 error = vn_open_vnode(vp, fmode, td->td_ucred, td, fp);
4670 if (error != 0) {
4686 error = fo_truncate(fp, 0, td->td_ucred, td);
4687 if (error != 0)
4691 error = finstall(td, fp, &indx, fmode, NULL);
4695 return (error);
4712 int error;
4714 error = copyin(uap->u_fhp, &fh, sizeof(fh));
4715 if (error != 0)
4716 return (error);
4717 error = kern_fhstat(td, fh, &sb);
4718 if (error == 0)
4719 error = copyout(&sb, uap->sb, sizeof(sb));
4720 return (error);
4728 int error;
4730 error = priv_check(td, PRIV_VFS_FHSTAT);
4731 if (error != 0)
4732 return (error);
4735 error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp);
4737 if (error != 0)
4738 return (error);
4739 error = VOP_STAT(vp, sb, td->td_ucred, NOCRED);
4741 return (error);
4758 int error;
4760 error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
4761 if (error != 0)
4762 return (error);
4764 error = kern_fhstatfs(td, fh, sfp);
4765 if (error == 0)
4766 error = copyout(sfp, uap->buf, sizeof(*sfp));
4768 return (error);
4776 int error;
4778 error = priv_check(td, PRIV_VFS_FHSTATFS);
4779 if (error != 0)
4780 return (error);
4783 error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp);
4784 if (error != 0) {
4786 return (error);
4789 error = prison_canseemount(td->td_ucred, mp);
4790 if (error != 0)
4793 error = mac_mount_check_stat(td->td_ucred, mp);
4794 if (error != 0)
4797 error = VFS_STATFS(mp, buf);
4800 return (error);
4817 int error;
4838 error = fget(td, fd, &cap_no_rights, &fp);
4839 if (error != 0)
4843 error = ESPIPE;
4847 error = ENODEV;
4852 error = ENODEV;
4921 error = VOP_ADVISE(vp, offset, end, advice);
4928 return (error);
4934 int error;
4936 error = kern_posix_fadvise(td, uap->fd, uap->offset, uap->len,
4938 return (kern_posix_error(td, error));
4947 int error;
4955 error = 0;
4959 error = EINVAL;
4971 error = fget_read(td, infd,
4973 if (error != 0)
4976 error = EBADF;
4980 error = EINVAL;
4983 error = fget_write(td, outfd,
4985 if (error != 0)
4988 error = EBADF;
4992 error = EINVAL;
5009 error = EBADF;
5024 error = EINVAL;
5044 error = vn_copy_file_range(invp, inoffp, outvp, outoffp, &retlen,
5051 if (savinoff != -1 && (error == EINTR || error == ERESTART)) {
5060 return (error);
5067 int error;
5071 error = copyin(uap->inoffp, &inoff, sizeof(off_t));
5072 if (error != 0)
5073 return (error);
5077 error = copyin(uap->outoffp, &outoff, sizeof(off_t));
5078 if (error != 0)
5079 return (error);
5082 error = kern_copy_file_range(td, uap->infd, inoffp, uap->outfd,
5084 if (error == 0 && uap->inoffp != NULL)
5085 error = copyout(inoffp, uap->inoffp, sizeof(off_t));
5086 if (error == 0 && uap->outoffp != NULL)
5087 error = copyout(outoffp, uap->outoffp, sizeof(off_t));
5088 return (error);