MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sys_fchdir

Function sys_fchdir

freebsd/kern/vfs_syscalls.c:885–921  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

883};
884#endif
885int
886sys_fchdir(struct thread *td, struct fchdir_args *uap)
887{
888 struct vnode *vp, *tdp;
889 struct mount *mp;
890 struct file *fp;
891 int error;
892
893 AUDIT_ARG_FD(uap->fd);
894 error = getvnode(td, uap->fd, &cap_fchdir_rights,
895 &fp);
896 if (error != 0)
897 return (error);
898 vp = fp->f_vnode;
899 vrefact(vp);
900 fdrop(fp, td);
901 vn_lock(vp, LK_SHARED | LK_RETRY);
902 AUDIT_ARG_VNODE1(vp);
903 error = change_dir(vp, td);
904 while (!error && (mp = vp->v_mountedhere) != NULL) {
905 if (vfs_busy(mp, 0))
906 continue;
907 error = VFS_ROOT(mp, LK_SHARED, &tdp);
908 vfs_unbusy(mp);
909 if (error != 0)
910 break;
911 vput(vp);
912 vp = tdp;
913 }
914 if (error != 0) {
915 vput(vp);
916 return (error);
917 }
918 VOP_UNLOCK(vp);
919 pwd_chdir(td, vp);
920 return (0);
921}
922
923/*
924 * Change current working directory (``.'').

Callers

nothing calls this directly

Calls 8

getvnodeFunction · 0.85
vn_lockFunction · 0.85
change_dirFunction · 0.85
vfs_busyFunction · 0.85
vfs_unbusyFunction · 0.85
vputFunction · 0.85
pwd_chdirFunction · 0.85
vrefactFunction · 0.70

Tested by

no test coverage detected