From nobody Wed Aug 20 22:46:57 2025 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 4c6hQp3Jgfz65M0D; Wed, 20 Aug 2025 22:46:58 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c6hQp0hj8z3r2j; Wed, 20 Aug 2025 22:46:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755730018; 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=pO30mu44itdtxsHizLAV/9MHBASQgZW8K875uNEeRJY=; b=Vbv0E71N/5v1DosiZf/AYPpYt+f+XhhwNFzTFUUT/5cwp6BFTcauEPImKjjVe/cOuWxNIm plfSk4mPi5KJ3kzyIBE6iQCcOCDexkxvUPxUNjb2p3HaqoZufAaM3qH2qktKZ1YqXvq5pJ oXcmtQLHWg+gLQ/zNxia8Pw1hoXdixkYthNy3FLM8i7cRmYAuCx01lAUsWF3N32KKR6zCe 0EtK9Ulyor0SXFMA8sFOZNm4L7UKXQCUVv8Yb9lR1/LZym8i42VaHgPW2X9Vga+htgiXzA Ag520jWdsku2lZUHWv8Al7bmJ5Q1pXpAD5Qe4SkXXqJ4SLEnBbTQL9PWDpdkHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755730018; 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=pO30mu44itdtxsHizLAV/9MHBASQgZW8K875uNEeRJY=; b=T6hBVdv7SRV7dlNuElirqiocHT8L+z8Q/S4ONdtSkvBRvbH6/GFuzGQGxCFn8sZGBLcQ7A +JVvuUrQ/MZJnO6eEozThLQTSdJQza/VgCZsiRQqt40SmCHUMznwm7VlWTXI8wBGpv05Wi iNzeAVfqtM+No4oLtQkZnJ+CSi97UWkfwrSzwq/4PSw0+j1m9XBbbEYp7dqw9wHngl9BZn yxyrdePrZxPl+95Tb8+4dvaC2Qy3d9ld/tX0fRl34H75hiu7Mua/uhZvKiFwHXMbxUldT6 1R/rUs0/aB67dWB7b4MggtAifU6PFXy/MskaZhygo4hWOhyehO1uXzEBs+VHJA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1755730018; a=rsa-sha256; cv=none; b=ZKEz/3NtaE6Iqkgf6oCeuuU0eeeqGDlQ+6pHnrGLLvwBNf6rsxTsa4CNSizBKEy56X4pxy tIVQrjdnaCPpR5MVojcs3kMOBW5lORPyyzw6YBZrrnbl5b8hsxrlvVl5WZgYQ8jyafG6x/ K3Q4FZX2smJD1Ag3E4EgldrTqP9LmhghzcoCTGzdoRP5Ykcvu3RQu269wxQS7GJ+xxGWSf mgUTWhqmy10mT+wOClQ3W4wA1163Ac28u7Wb22IXSiWs7TLUkB67XBvr7YGPOQU1v77X3/ QSsBya+IqmC/TEok/QfysosU2f0jsYOk87XPiHfb1O2LeXgQXqCPeNi025FMfA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4c6hQp0J4DzZ3W; Wed, 20 Aug 2025 22:46:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57KMkvGl015680; Wed, 20 Aug 2025 22:46:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57KMkvAN015677; Wed, 20 Aug 2025 22:46:57 GMT (envelope-from git) Date: Wed, 20 Aug 2025 22:46:57 GMT Message-Id: <202508202246.57KMkvAN015677@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Simon J. Gerraty" Subject: git: aaf65a13c06a - main - stand: add fs_ops.fs_flag 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aaf65a13c06a2555257a75b7f2fe63319238cf4f Auto-Submitted: auto-generated The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=aaf65a13c06a2555257a75b7f2fe63319238cf4f commit aaf65a13c06a2555257a75b7f2fe63319238cf4f Author: Simon J. Gerraty AuthorDate: 2025-08-20 22:42:35 +0000 Commit: Simon J. Gerraty CommitDate: 2025-08-20 22:42:35 +0000 stand: add fs_ops.fs_flag To avoid a layering violation in open() allow fs_ops to indicate that devopen() should be skipped. This is only true for pkgfs. Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D51684 --- stand/libsa/bzipfs.c | 1 + stand/libsa/cd9660.c | 1 + stand/libsa/dosfs.c | 1 + stand/libsa/ext2fs.c | 1 + stand/libsa/gzipfs.c | 1 + stand/libsa/nfs.c | 1 + stand/libsa/open.c | 33 +++++++++++++++++++-------------- stand/libsa/pkgfs.c | 1 + stand/libsa/splitfs.c | 1 + stand/libsa/stand.h | 3 +++ stand/libsa/tftp.c | 1 + stand/libsa/ufs.c | 1 + 12 files changed, 32 insertions(+), 14 deletions(-) diff --git a/stand/libsa/bzipfs.c b/stand/libsa/bzipfs.c index f4002796f0ae..ff7ec16e7dc6 100644 --- a/stand/libsa/bzipfs.c +++ b/stand/libsa/bzipfs.c @@ -68,6 +68,7 @@ static int bzf_stat(struct open_file *f, struct stat *sb); #ifndef REGRESSION struct fs_ops bzipfs_fsops = { .fs_name = "bzip", + .fs_flags = 0, .fo_open = bzf_open, .fo_close = bzf_close, .fo_read = bzf_read, diff --git a/stand/libsa/cd9660.c b/stand/libsa/cd9660.c index 973a7dddcda9..d1da39aa479a 100644 --- a/stand/libsa/cd9660.c +++ b/stand/libsa/cd9660.c @@ -81,6 +81,7 @@ static ISO_SUSP_HEADER *susp_lookup_record(struct open_file *f, struct fs_ops cd9660_fsops = { .fs_name = "cd9660", + .fs_flags = 0, .fo_open = cd9660_open, .fo_close = cd9660_close, .fo_read = cd9660_read, diff --git a/stand/libsa/dosfs.c b/stand/libsa/dosfs.c index aca198cdf6fa..38610d917007 100644 --- a/stand/libsa/dosfs.c +++ b/stand/libsa/dosfs.c @@ -61,6 +61,7 @@ static int dos_unmount(const char *dev, void *data); struct fs_ops dosfs_fsops = { .fs_name = "dosfs", + .fs_flags = 0, .fo_open = dos_open, .fo_close = dos_close, .fo_read = dos_read, diff --git a/stand/libsa/ext2fs.c b/stand/libsa/ext2fs.c index 47812f4543a1..f7096282f156 100644 --- a/stand/libsa/ext2fs.c +++ b/stand/libsa/ext2fs.c @@ -106,6 +106,7 @@ static int dtmap[] = { DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, struct fs_ops ext2fs_fsops = { .fs_name = "ext2fs", + .fs_flags = 0, .fo_open = ext2fs_open, .fo_close = ext2fs_close, .fo_read = ext2fs_read, diff --git a/stand/libsa/gzipfs.c b/stand/libsa/gzipfs.c index 6c2b8cac9e34..6b22f750f3ef 100644 --- a/stand/libsa/gzipfs.c +++ b/stand/libsa/gzipfs.c @@ -50,6 +50,7 @@ static int zf_stat(struct open_file *f, struct stat *sb); struct fs_ops gzipfs_fsops = { .fs_name = "zip", + .fs_flags = 0, .fo_open = zf_open, .fo_close = zf_close, .fo_read = zf_read, diff --git a/stand/libsa/nfs.c b/stand/libsa/nfs.c index ee6af8a726c7..f3e9060c9881 100644 --- a/stand/libsa/nfs.c +++ b/stand/libsa/nfs.c @@ -131,6 +131,7 @@ struct nfs_iodesc nfs_root_node; struct fs_ops nfs_fsops = { .fs_name = "nfs", + .fs_flags = 0, .fo_open = nfs_open, .fo_close = nfs_close, .fo_read = nfs_read, diff --git a/stand/libsa/open.c b/stand/libsa/open.c index ccee4aa5c07b..c97aa5977f9e 100644 --- a/stand/libsa/open.c +++ b/stand/libsa/open.c @@ -154,27 +154,32 @@ open(const char *fname, int mode) f->f_devdata = NULL; file = NULL; + if (exclusive_file_system == NULL || + (exclusive_file_system->fs_flags & FS_OPS_NO_DEVOPEN) == 0) { + error = devopen(f, fname, &file); + if (error || + (((f->f_flags & F_NODEV) == 0) && f->f_dev == NULL)) + goto err; + + /* see if we opened a raw device; otherwise, 'file' is the file name. */ + if (file == NULL || *file == '\0') { + f->f_flags |= F_RAW; + f->f_rabuf = NULL; + TSEXIT(); + return (fd); + } + } else + file = fname; + if (exclusive_file_system != NULL) { + /* loader is forcing the filesystem to be used */ fs = exclusive_file_system; - error = (fs->fo_open)(fname, f); + error = (fs->fo_open)(file, f); if (error == 0) goto ok; goto err; } - error = devopen(f, fname, &file); - if (error || - (((f->f_flags & F_NODEV) == 0) && f->f_dev == NULL)) - goto err; - - /* see if we opened a raw device; otherwise, 'file' is the file name. */ - if (file == NULL || *file == '\0') { - f->f_flags |= F_RAW; - f->f_rabuf = NULL; - TSEXIT(); - return (fd); - } - /* pass file name to the different filesystem open routines */ besterror = ENOENT; for (i = 0; file_system[i] != NULL; i++) { diff --git a/stand/libsa/pkgfs.c b/stand/libsa/pkgfs.c index 32d488de5cfb..6eb3badf7068 100644 --- a/stand/libsa/pkgfs.c +++ b/stand/libsa/pkgfs.c @@ -41,6 +41,7 @@ static off_t pkg_atol(const char *, unsigned); struct fs_ops pkgfs_fsops = { .fs_name = "pkg", + .fs_flags = FS_OPS_NO_DEVOPEN, .fo_open = pkg_open, .fo_close = pkg_close, .fo_read = pkg_read, diff --git a/stand/libsa/splitfs.c b/stand/libsa/splitfs.c index 69912522000e..eb4b3a1feb11 100644 --- a/stand/libsa/splitfs.c +++ b/stand/libsa/splitfs.c @@ -50,6 +50,7 @@ static int splitfs_stat(struct open_file *f, struct stat *sb); struct fs_ops splitfs_fsops = { .fs_name = "split", + .fs_flags = 0, .fo_open = splitfs_open, .fo_close = splitfs_close, .fo_read = splitfs_read, diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h index 0e99d8778fa6..c6a08be2f7e3 100644 --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -94,6 +94,8 @@ __BEGIN_DECLS struct open_file; +#define FS_OPS_NO_DEVOPEN 1 + /* * This structure is used to define file system operations in a file system * independent way. @@ -104,6 +106,7 @@ struct open_file; */ struct fs_ops { const char *fs_name; + int fs_flags; int (*fo_open)(const char *path, struct open_file *f); int (*fo_close)(struct open_file *f); int (*fo_read)(struct open_file *f, void *buf, diff --git a/stand/libsa/tftp.c b/stand/libsa/tftp.c index c6cc8f11a765..0584246a6dea 100644 --- a/stand/libsa/tftp.c +++ b/stand/libsa/tftp.c @@ -73,6 +73,7 @@ static int tftp_preload(struct open_file *); struct fs_ops tftp_fsops = { .fs_name = "tftp", + .fs_flags = 0, .fo_open = tftp_open, .fo_close = tftp_close, .fo_read = tftp_read, diff --git a/stand/libsa/ufs.c b/stand/libsa/ufs.c index e1d540ed2321..86cd3be9a27a 100644 --- a/stand/libsa/ufs.c +++ b/stand/libsa/ufs.c @@ -93,6 +93,7 @@ static int ufs_unmount(const char *dev, void *data); struct fs_ops ufs_fsops = { .fs_name = "ufs", + .fs_flags = 0, .fo_open = ufs_open, .fo_close = ufs_close, .fo_read = ufs_read,