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

Function sys_chroot

freebsd/kern/vfs_syscalls.c:967–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965};
966#endif
967int
968sys_chroot(struct thread *td, struct chroot_args *uap)
969{
970 struct nameidata nd;
971 int error;
972
973 error = priv_check(td, PRIV_VFS_CHROOT);
974 if (error != 0)
975 return (error);
976 NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1,
977 UIO_USERSPACE, uap->path, td);
978 error = namei(&nd);
979 if (error != 0)
980 goto error;
981 error = change_dir(nd.ni_vp, td);
982 if (error != 0)
983 goto e_vunlock;
984#ifdef MAC
985 error = mac_vnode_check_chroot(td->td_ucred, nd.ni_vp);
986 if (error != 0)
987 goto e_vunlock;
988#endif
989 VOP_UNLOCK(nd.ni_vp);
990 error = pwd_chroot(td, nd.ni_vp);
991 vrele(nd.ni_vp);
992 NDFREE_NOTHING(&nd);
993 return (error);
994e_vunlock:
995 vput(nd.ni_vp);
996error:
997 NDFREE_NOTHING(&nd);
998 return (error);
999}
1000
1001/*
1002 * Common routine for chroot and chdir. Callers must provide a locked vnode

Callers

nothing calls this directly

Calls 8

nameiFunction · 0.85
change_dirFunction · 0.85
mac_vnode_check_chrootFunction · 0.85
pwd_chrootFunction · 0.85
NDFREE_NOTHINGFunction · 0.85
vputFunction · 0.85
priv_checkFunction · 0.70
vreleFunction · 0.70

Tested by

no test coverage detected