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

Function kern_symlinkat

freebsd/kern/vfs_syscalls.c:1675–1742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1673}
1674
1675int
1676kern_symlinkat(struct thread *td, const char *path1, int fd, const char *path2,
1677 enum uio_seg segflg)
1678{
1679 struct mount *mp;
1680 struct vattr vattr;
1681 const char *syspath;
1682 char *tmppath;
1683 struct nameidata nd;
1684 int error;
1685
1686 if (segflg == UIO_SYSSPACE) {
1687 syspath = path1;
1688 } else {
1689 tmppath = uma_zalloc(namei_zone, M_WAITOK);
1690 if ((error = copyinstr(path1, tmppath, MAXPATHLEN, NULL)) != 0)
1691 goto out;
1692 syspath = tmppath;
1693 }
1694 AUDIT_ARG_TEXT(syspath);
1695restart:
1696 bwillwrite();
1697 NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
1698 NOCACHE, segflg, path2, fd, &cap_symlinkat_rights,
1699 td);
1700 if ((error = namei(&nd)) != 0)
1701 goto out;
1702 if (nd.ni_vp) {
1703 NDFREE(&nd, NDF_ONLY_PNBUF);
1704 if (nd.ni_vp == nd.ni_dvp)
1705 vrele(nd.ni_dvp);
1706 else
1707 vput(nd.ni_dvp);
1708 vrele(nd.ni_vp);
1709 nd.ni_vp = NULL;
1710 error = EEXIST;
1711 goto out;
1712 }
1713 if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
1714 NDFREE(&nd, NDF_ONLY_PNBUF);
1715 vput(nd.ni_dvp);
1716 if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
1717 goto out;
1718 goto restart;
1719 }
1720 VATTR_NULL(&vattr);
1721 vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_pd->pd_cmask;
1722#ifdef MAC
1723 vattr.va_type = VLNK;
1724 error = mac_vnode_check_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
1725 &vattr);
1726 if (error != 0)
1727 goto out2;
1728#endif
1729 error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, syspath);
1730#ifdef MAC
1731out2:
1732#endif

Callers 3

vfs_mountroot_devfsFunction · 0.85
sys_symlinkFunction · 0.85
sys_symlinkatFunction · 0.85

Calls 11

nameiFunction · 0.85
NDFREEFunction · 0.85
vputFunction · 0.85
vn_start_writeFunction · 0.85
mac_vnode_check_createFunction · 0.85
vn_finished_writeFunction · 0.85
bwillwriteFunction · 0.70
vreleFunction · 0.70
uma_zallocFunction · 0.50
copyinstrFunction · 0.50
uma_zfreeFunction · 0.50

Tested by

no test coverage detected