From nobody Thu Jan 12 19:21:34 2023 X-Original-To: dev-commits-src-main@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 4NtDtk2fR9z2pS5x; Thu, 12 Jan 2023 19:21:34 +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 4NtDtk2C4Kz4L3k; Thu, 12 Jan 2023 19:21:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673551294; 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=91honjD0BQY2G24hfeosOaERwPL8rwS1PgaAPqsWJWo=; b=Zd7bQ8AO3n4JN63pXX5eK7WAjtq9cg/NhQDP+AXER06Y3JAdGqJCqkaNXd51H8Bilg1eSV OjzPDNaKPYfeMMTwbQqDoTJ4MqViizeggw8Ttea9uxooNao2DoMADAxabigKnhfn2mB0kS d8CpqzMNfgj1W3r1CCL2FO+wzBAPGzvtXqvPeckFTjZH4hXbz5qoxBvyq7pY5BkS5e1NgT DhnTVOUAE8tUeKmCOCOwHjfaiPDEAoFRELX4Im3EZm11tNToTtD1qVvlSbYyvPuB5rCQL2 GWprJk2nQ7GEIqBfMVP/21hxFOVStibSFQJWvGstVfymjW+OnJfbIBtxfNyU1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673551294; 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=91honjD0BQY2G24hfeosOaERwPL8rwS1PgaAPqsWJWo=; b=mSvVc+FkPSbwfeFh9ag5nY74U6rV2DWN8WO0vMEMStXqXpWlquBfAi1qBT0nKDKnxJUS+e 86nVVA4A8WlhlXKAz8dkRfBePteiX+OsZoMBa0GC9iytCjrbGANQYPd6x8tFzmmZFNW2Mh +8l/lvrmEXEzXHDui3YFGN9VQWabGleyTsxN5l3XKFiz6Gd+cm43Puc1Mlh11xrTt9Lvdx Kxz5NzHOVltkr+1/90JxeKRJN5cLngcaWGytZ80SBBFE0MVznC1hPVh2B8DUPVNbX/n+Eq qX9tfv4f9JQdznR4HPGf2tQ8lisp+kYfGXkQiWYhquW5LcoSsznQymew7vzzog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673551294; a=rsa-sha256; cv=none; b=a+JalVVinPtdm2jTcirIc6MYCSEb2pcE1ZJmskHittx3Lbrmx/MjHjz6TSHFwwHQyxVmYM hqORLwejmbdgAJkzIu+l1lSAn4exrRiiiNKfzg1D1PZS1Gqku0DzvJtPdUtBmUksqm21gB kvLUPuZ5rhEnM2KRNKxYXDUST1Xxh4YaBWaJDm6jXuN9lACC5RZJ6DSZUHDdIFhlBP1m4h eUA9CC4PUlaNHd7t36rgtBhb5g1N5NwC8AKhfQRLwarLMzXh+DuT62NAzA1JOlgVAXHozi v+I65SCedAP6xYFkmLZCbFqZtDQkLbk4ec3sqDfrmLSdOuE1I6Ta/5ZZJJXjHA== 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 4NtDtk1FXczfXl; Thu, 12 Jan 2023 19:21:34 +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 30CJLYbo004664; Thu, 12 Jan 2023 19:21:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30CJLYZo004663; Thu, 12 Jan 2023 19:21:34 GMT (envelope-from git) Date: Thu, 12 Jan 2023 19:21:34 GMT Message-Id: <202301121921.30CJLYZo004663@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 6e011d15031a - main - makefs: don't needlessly require directories to exist List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6e011d15031a73956912ca8b0e476484a58f905c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=6e011d15031a73956912ca8b0e476484a58f905c commit 6e011d15031a73956912ca8b0e476484a58f905c Author: Brooks Davis AuthorDate: 2023-01-12 18:19:14 +0000 Commit: Brooks Davis CommitDate: 2023-01-12 19:16:14 +0000 makefs: don't needlessly require directories to exist If a type=dir entry exists and all contents are directories, files added with contents=, or symlinks with link= attributes then it doesn't need to exist. Just let openat fail in that case. It's conceivable this will make debugging some cases weird, but it's sufficent to handle the way we add /root/.ssh in CheriBSD VM images. This is a recommit of 794154149f95d0cbc11aade166f9da919747e397 with bugfixes. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38029 --- usr.sbin/makefs/zfs/fs.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/usr.sbin/makefs/zfs/fs.c b/usr.sbin/makefs/zfs/fs.c index 3cf328122df8..6a90396cb155 100644 --- a/usr.sbin/makefs/zfs/fs.c +++ b/usr.sbin/makefs/zfs/fs.c @@ -292,6 +292,17 @@ fs_open(const fsnode *cur, struct fs_populate_arg *arg, int flags) return (fd); } +static int +fs_open_can_fail(const fsnode *cur, struct fs_populate_arg *arg, int flags) +{ + int fd; + char path[PATH_MAX]; + + fs_populate_path(cur, arg, path, sizeof(path), &fd); + + return (openat(fd, path, flags)); +} + static void fs_readlink(const fsnode *cur, struct fs_populate_arg *arg, char *buf, size_t bufsz) @@ -590,7 +601,12 @@ fs_populate_dir(fsnode *cur, struct fs_populate_arg *arg) */ if (!SLIST_EMPTY(&arg->dirs)) { fs_populate_dirent(arg, cur, dnid); - dirfd = fs_open(cur, arg, O_DIRECTORY | O_RDONLY); + /* + * We only need the directory fd if we're finding files in + * it. If it's just there for other directories or + * files using contents= we don't need to succeed here. + */ + dirfd = fs_open_can_fail(cur, arg, O_DIRECTORY | O_RDONLY); } else { arg->rootdirid = dnid; dirfd = arg->rootdirfd;