From nobody Thu Jan 12 18:20:15 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 4NtCWz2cGPz2pKCb; Thu, 12 Jan 2023 18:20:15 +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 4NtCWz26F0z4Cxq; Thu, 12 Jan 2023 18:20:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673547615; 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=0zth6kJQ0MtlqrhV34VAGZ1ZHXllY3lOmF4+PbeZl7g=; b=F7wAuKTPp/cY2o1YNRAAJxxeWXGYeK316L7FtOktuYpOaZsYeuZfs76kxqc4wLgL5sMkgT pQQmwuuhN5ASSfYGTk5NXfCzuQhgeQ6Uz/Ej1MUEkn8pSZqVkW9S/IZI6WZ2XbgAA3DiFb QZnbocacZRBByS++9X+mPeEj2FoSxnhEBmis/gIS29TVDX29Jh22V7bddk7CN22s/6rLUm CGUU6Yrl+Ha0V1h2eeia0h+btz0aOMy9U7ygCWsw2+LUwtoWQ02H/5oK62AmNxlZxXMPKI JHnpm1j4pFbug3Qd+gmkOIb24wJsruN5ieHg9cCveogySfL1PYtm8nLcQ77I0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673547615; 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=0zth6kJQ0MtlqrhV34VAGZ1ZHXllY3lOmF4+PbeZl7g=; b=I3HYU6Iu5BgedGPSiPSB8liNH/t/uM4ZNdVIvkVvNqD1h28i8pNuU7I2t+5k3/JYd+pAbm XxwwDCls2DIY+F1RYQo8WfkAwnHeuU6mZePUZ4OfO8fP5ZFhZuEuZHDgfcs7WqGCyXICGG LUAndPuL/ufSeDSxOshts3YLmCEnv0X9myjN8Ia/CXMthQ+oQrle6i+QjXbYMK2CVVOniP hELyFs0KRUms8QW5pWwp7inNtxE49XWZgj6AJqJX8SEAyhKLvOmIxQzPWfN98eP3zB8bNn +b31uZToNpII8yy+9X9VvLV/aXi6tPLArcwCxZUS7APdZmnixaTpCR3xHruTPg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673547615; a=rsa-sha256; cv=none; b=MU9VtNFFqHNzF+B02ffE3h5rsq81HZHEyddO3RYJsaWEcoc3ozJzbAwxB0YrHASDuBnU1b 5IlJE92b1rw3R7YD54v714eJj5HHvjX1Dr1czXQj4jOGEO9Ox5KVFZJt61XC+Oo+KOkD7c nCnguI/v00zAlgRRmFr6kEEDjMh48ngJUvca1ehX4OsRlcvJt43UKYOfeC69kZrEp2gwnx iXX7QaHvlArbpPyjXKlpIGW/Z2kHGqxWXRbFZFiCduIuRG112kUrbfk5ydsrxtOlsWXziv LFJbptWcvuioaqr/39msbm1f4I5F95Rpe6CfcvKVDF7tlLZg7//s1zsAeyIzwA== 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 4NtCWz1C04zd88; Thu, 12 Jan 2023 18:20:15 +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 30CIKFZv014683; Thu, 12 Jan 2023 18:20:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30CIKFWN014674; Thu, 12 Jan 2023 18:20:15 GMT (envelope-from git) Date: Thu, 12 Jan 2023 18:20:15 GMT Message-Id: <202301121820.30CIKFWN014674@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: 794154149f95 - main - makefs: don't needlessly require directories to exist 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: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 794154149f95d0cbc11aade166f9da919747e397 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=794154149f95d0cbc11aade166f9da919747e397 commit 794154149f95d0cbc11aade166f9da919747e397 Author: Brooks Davis AuthorDate: 2023-01-12 18:19:14 +0000 Commit: Brooks Davis CommitDate: 2023-01-12 18:19: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. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38029 --- usr.sbin/makefs/zfs/fs.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/usr.sbin/makefs/zfs/fs.c b/usr.sbin/makefs/zfs/fs.c index 3cf328122df8..7f74e300f5d7 100644 --- a/usr.sbin/makefs/zfs/fs.c +++ b/usr.sbin/makefs/zfs/fs.c @@ -292,6 +292,16 @@ 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) +{ + 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 +600,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;