From nobody Sat Nov 06 02:25:19 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8D039183BEE7; Sat, 6 Nov 2021 02:25:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmLnW4VGxz3j4y; Sat, 6 Nov 2021 02:25:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 20A1822FB9; Sat, 6 Nov 2021 02:25:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A62PJ2G077417; Sat, 6 Nov 2021 02:25:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A62PJrd077416; Sat, 6 Nov 2021 02:25:19 GMT (envelope-from git) Date: Sat, 6 Nov 2021 02:25:19 GMT Message-Id: <202111060225.1A62PJrd077416@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b94df11d52f1 - stable/13 - Make vn_fullpath_hardlink() externally callable List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b94df11d52f13bea30af86500692fd268d049748 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b94df11d52f13bea30af86500692fd268d049748 commit b94df11d52f13bea30af86500692fd268d049748 Author: Konstantin Belousov AuthorDate: 2021-10-23 00:23:17 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-06 02:12:31 +0000 Make vn_fullpath_hardlink() externally callable (cherry picked from commit 9a0bee9f6a77a85e4dfb27c9a33d4e210d05b469) --- sys/kern/vfs_cache.c | 28 +++++++++++++--------------- sys/sys/vnode.h | 3 +++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 54a87ced2218..cf2e2dd72e63 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -581,8 +581,6 @@ DEBUGNODE_ULONG(vnodes_cel_3_failures, cache_lock_vnodes_cel_3_failures, "Number of times 3-way vnode locking failed"); static void cache_zap_locked(struct namecache *ncp); -static int vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, - char **freebuf, size_t *buflen); static int vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, size_t *buflen, size_t addend); static int vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, @@ -3134,7 +3132,8 @@ kern___realpathat(struct thread *td, int fd, const char *path, char *buf, pathseg, path, fd, &cap_fstat_rights, td); if ((error = namei(&nd)) != 0) return (error); - error = vn_fullpath_hardlink(&nd, &retbuf, &freebuf, &size); + error = vn_fullpath_hardlink(nd.ni_vp, nd.ni_dvp, nd.ni_cnd.cn_nameptr, + nd.ni_cnd.cn_namelen, &retbuf, &freebuf, &size); if (error == 0) { error = copyout(retbuf, buf, size); free(freebuf, M_TEMP); @@ -3595,8 +3594,9 @@ vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, /* * Resolve an arbitrary vnode to a pathname (taking care of hardlinks). * - * Since the namecache does not track hardlinks, the caller is expected to first - * look up the target vnode with SAVENAME | WANTPARENT flags passed to namei. + * Since the namecache does not track hardlinks, the caller is + * expected to first look up the target vnode with SAVENAME | + * WANTPARENT flags passed to namei to get dvp and vp. * * Then we have 2 cases: * - if the found vnode is a directory, the path can be constructed just by @@ -3604,14 +3604,13 @@ vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, * - otherwise we populate the buffer with the saved name and start resolving * from the parent */ -static int -vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, - size_t *buflen) +int +vn_fullpath_hardlink(struct vnode *vp, struct vnode *dvp, + const char *hrdl_name, size_t hrdl_name_length, + char **retbuf, char **freebuf, size_t *buflen) { char *buf, *tmpbuf; struct pwd *pwd; - struct componentname *cnp; - struct vnode *vp; size_t addend; int error; enum vtype type; @@ -3624,7 +3623,7 @@ vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, buf = malloc(*buflen, M_TEMP, M_WAITOK); addend = 0; - vp = ndp->ni_vp; + /* * Check for VBAD to work around the vp_crossmp bug in lookup(). * @@ -3650,8 +3649,7 @@ vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, goto out_bad; } if (type != VDIR) { - cnp = &ndp->ni_cnd; - addend = cnp->cn_namelen + 2; + addend = hrdl_name_length + 2; if (*buflen < addend) { error = ENOMEM; goto out_bad; @@ -3659,9 +3657,9 @@ vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, *buflen -= addend; tmpbuf = buf + *buflen; tmpbuf[0] = '/'; - memcpy(&tmpbuf[1], cnp->cn_nameptr, cnp->cn_namelen); + memcpy(&tmpbuf[1], hrdl_name, hrdl_name_length); tmpbuf[addend - 1] = '\0'; - vp = ndp->ni_dvp; + vp = dvp; } vfs_smr_enter(); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 4a2581cb3db3..ebd9577004fc 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -694,6 +694,9 @@ int vn_vptocnp(struct vnode **vp, char *buf, size_t *buflen); int vn_getcwd(char *buf, char **retbuf, size_t *buflen); int vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf); int vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf); +int vn_fullpath_hardlink(struct vnode *vp, struct vnode *dvp, + const char *hdrl_name, size_t hrdl_name_length, char **retbuf, + char **freebuf, size_t *buflen); struct vnode * vn_dir_dd_ino(struct vnode *vp); int vn_commname(struct vnode *vn, char *buf, u_int buflen);