From nobody Mon May 29 08:20:12 2023 X-Original-To: dev-commits-src-all@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 4QV7kP2Jsxz4XNpv; Mon, 29 May 2023 08:20:13 +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 4QV7kN6Rr1z47xK; Mon, 29 May 2023 08:20:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685348412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OvoIerxaYfRx9SvTgb4tfpc3xNV5BjPe6lFM5zNLkpQ=; b=O5seaSWLyRtlOg9+Dm473dQkRanZE/r5Tftz2x5zJv+JdtrCWiFVkLM4LfhSkc/LPGNVQq 6qpTBCvEsaLZjDpfWD5vO/Jtnqx1YvwldVT951BjqCVjkSK3txw5vOCUxyMbPQCtCZ9uqc eei+FxEVrWAWLV59qwkoRD/caV59LQ32XWTUY1n4/1x+wykvE0YvRuNh37b7fjbuysBu3G OV1MSqQGI1Bry4X2pMIVv43oVDlrYMLqt43KzJTt0cmSVjtgWcq1BOyXH4CoQqbOAuaiPC 2yuWsNESNmfae9184CS0IZYMMSJyJKpFOzlyhRt94pdKRyQhCpzOtkCQ/fIraA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685348412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OvoIerxaYfRx9SvTgb4tfpc3xNV5BjPe6lFM5zNLkpQ=; b=Vzbf9OfBIuf3+uHl9zZBWbgIE6G0d1lZi7dqlfysC1UkFchZl79h7ELWKLPKalDf/Utdhg LpcamrBU9vdtHcSRonxE9lWZx4FN+6S6j4++iXNbB9jVNWxm3XuddfY1FgobOSnzSoYWtA IzN9ld0Jc6e6yuEai+wUvIGJJbBpdckKnuGNr7tXnezCZco1WWbmAxnW5HF+ob3fHY1elS NvpdoM9ftnqk/BxlBDbH2fk2xLA2Ls1KycvSjZ4c1SYrNFRjFawUvwHz/I7pj8jdlUVas+ jVjBS/70CxEyAwKd8z/XGwX4g14NTJ1W77GSdpH2rqrWIJlR0BAtp4g9D/ALHQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685348412; a=rsa-sha256; cv=none; b=hd94scmhnEvk1cYeJGzCQrbbKKvHwR/CAkUbquZ4xu68d3dtfjTw61bIiDkvWWlMJdRMj4 DgIk4d5B5CZ7uTymGW49dsXbSXpZ/Lktulv3Wx/S1kOFSL0lnQIkgmF/xtO+HaChDGGfoj JFlTLOe1twEm0/7A1P2FNQxWvs59xJbLCud9CvGId7TvAQeVkXvyrgiGIl2dQdRpPd8CRI mUv++6U8MENGiUVji2sRxUNYwOxyAAz260a19LFHm8rH0e7INT8l5fxoIokAZVt8nyh/e3 2r+IHmVG7Ccvrckukci4zoxWTlep84vz9e5wVEwXgfVk+bAvsAZb/CZt9hSNgw== 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 4QV7kN5M1qz13kv; Mon, 29 May 2023 08:20:12 +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 34T8KCeY070156; Mon, 29 May 2023 08:20:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34T8KCZT070153; Mon, 29 May 2023 08:20:12 GMT (envelope-from git) Date: Mon, 29 May 2023 08:20:12 GMT Message-Id: <202305290820.34T8KCZT070153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 07c0b6e535c5 - main - vfs: Retire kern_alternate_path() as unused anymore List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 07c0b6e535c5c5bdbbb562a04e21a1a4d039b942 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=07c0b6e535c5c5bdbbb562a04e21a1a4d039b942 commit 07c0b6e535c5c5bdbbb562a04e21a1a4d039b942 Author: Dmitry Chagin AuthorDate: 2023-05-29 08:19:41 +0000 Commit: Dmitry Chagin CommitDate: 2023-05-29 08:19:41 +0000 vfs: Retire kern_alternate_path() as unused anymore From now a non-native ABI should use pwd_altroot() ability to tell to the namei() its root directory to dynamically reroots lookups. Differential Revision: https://reviews.freebsd.org/D40093 MFC after: 2 month --- sys/kern/vfs_lookup.c | 114 -------------------------------------------------- sys/sys/syscallsubr.h | 2 - 2 files changed, 116 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 593e1e487c6f..c813296b4931 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1597,117 +1597,3 @@ NDVALIDATE_impl(struct nameidata *ndp, int line) } #endif - -/* - * Determine if there is a suitable alternate filename under the specified - * prefix for the specified path. If the create flag is set, then the - * alternate prefix will be used so long as the parent directory exists. - * This is used by the various compatibility ABIs so that Linux binaries prefer - * files under /compat/linux for example. The chosen path (whether under - * the prefix or under /) is returned in a kernel malloc'd buffer pointed - * to by pathbuf. The caller is responsible for free'ing the buffer from - * the M_TEMP bucket if one is returned. - */ -int -kern_alternate_path(const char *prefix, const char *path, enum uio_seg pathseg, - char **pathbuf, int create, int dirfd) -{ - struct nameidata nd, ndroot; - char *ptr, *buf, *cp; - size_t len, sz; - int error; - - buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK); - *pathbuf = buf; - - /* Copy the prefix into the new pathname as a starting point. */ - len = strlcpy(buf, prefix, MAXPATHLEN); - if (len >= MAXPATHLEN) { - *pathbuf = NULL; - free(buf, M_TEMP); - return (EINVAL); - } - sz = MAXPATHLEN - len; - ptr = buf + len; - - /* Append the filename to the prefix. */ - if (pathseg == UIO_SYSSPACE) - error = copystr(path, ptr, sz, &len); - else - error = copyinstr(path, ptr, sz, &len); - - if (error) { - *pathbuf = NULL; - free(buf, M_TEMP); - return (error); - } - - /* Only use a prefix with absolute pathnames. */ - if (*ptr != '/') { - error = EINVAL; - goto keeporig; - } - - if (dirfd != AT_FDCWD) { - /* - * We want the original because the "prefix" is - * included in the already opened dirfd. - */ - bcopy(ptr, buf, len); - return (0); - } - - /* - * We know that there is a / somewhere in this pathname. - * Search backwards for it, to find the file's parent dir - * to see if it exists in the alternate tree. If it does, - * and we want to create a file (cflag is set). We don't - * need to worry about the root comparison in this case. - */ - - if (create) { - for (cp = &ptr[len] - 1; *cp != '/'; cp--); - *cp = '\0'; - - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf); - error = namei(&nd); - *cp = '/'; - if (error != 0) - goto keeporig; - } else { - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf); - - error = namei(&nd); - if (error != 0) - goto keeporig; - - /* - * We now compare the vnode of the prefix to the one - * vnode asked. If they resolve to be the same, then we - * ignore the match so that the real root gets used. - * This avoids the problem of traversing "../.." to find the - * root directory and never finding it, because "/" resolves - * to the emulation root directory. This is expensive :-( - */ - NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, prefix); - - /* We shouldn't ever get an error from this namei(). */ - error = namei(&ndroot); - if (error == 0) { - if (nd.ni_vp == ndroot.ni_vp) - error = ENOENT; - - NDFREE_PNBUF(&ndroot); - vrele(ndroot.ni_vp); - } - } - - NDFREE_PNBUF(&nd); - vrele(nd.ni_vp); - -keeporig: - /* If there was an error, use the original path name. */ - if (error) - bcopy(ptr, buf, len); - return (error); -} diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index 9486135b9ce2..64f1b16f92b9 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -94,8 +94,6 @@ int kern_accessat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, int flags, int mode); int kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta); -int kern_alternate_path(const char *prefix, const char *path, - enum uio_seg pathseg, char **pathbuf, int create, int dirfd); int kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa); int kern_break(struct thread *td, uintptr_t *addr); int kern_cap_ioctls_limit(struct thread *td, int fd, u_long *cmds,