From patchwork Fri Apr 3 14:04:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2104 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225183; bh=n37I4TGUOBXeNxtLanXFAoNRBclbKxN7ioNe+Uhcys8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Q7MLbZ+2YhPAlYkkXb9awBmCSR3mUuxw2NkOQrLCeWwSkANCl5g4fdzuHs8j4/B3E TJNGKFnMKW74vJ4KGzgrg6M9RpmwsNzNt5QPSZcvmSjMsZtTO9hxDnvGcl4elZt9Ye tIGbEsM6BIQF6PWrYYPmTH948r056dBetxrCFW6qtWiUlOYr8zG0POwq33YMU1WR+8 THflCoZArAZhsH5ATRwr+m1g0B6kdo8pdaxCJ7TieY/JmpHD3pZwv2QLQ85rkSi4tI W5cfRLIEC6zE/21JAzvrME4ixJiQhnLPLYg94v9Ay+0DN/4u8eUq6mzosYALfCN1ri nv5Maol8ejDqw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5BD5A6A370 for ; Fri, 3 Apr 2026 08:06:23 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id P2EICasl_SJk for ; Fri, 3 Apr 2026 08:06:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225182; bh=n37I4TGUOBXeNxtLanXFAoNRBclbKxN7ioNe+Uhcys8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lJT91rePChUwkE8vUWaCrCpRJEbN+42toMZFLpeFmrU7KR4WyNsEwEY1fKqG4BiZc Et/ikJgC2FHiEwMbe5UFqvQTeBWpD2DaCfEGRXsqiyBgZy+eHrKZs5WQraVuAOTp7o PijzBz7ZWTAZeeGemicq++LjIHsUnS2NWO0nU3hUF1i0G3vKrBXh/zGoVodA2iXQIt Biz0bxEMwf0HZdoZaOHa48GzEWCrY0mgvyr5atH2VjEuFsRJb8y2J2mP+P+MFAi3Jd /DVxJu5119eGuohTpAUnR3lNw/UdmPTfGUr5+PvTtWHHiVoSdOO+W4ug3bFHCXpXlI 9zt3YFi6x6swQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EB1866A35A for ; Fri, 3 Apr 2026 08:06:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225180; bh=1JaXGanODMFRmf1fDAJD7U77Pe1HdnM6bt0N+1Q37bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ac5E/9XXfLde3NaQVEns3KRkaHmLzMdfBO2UAeRL8/PAJJ3VIuJ2mYaO6fkB8S5ar +n7BzL7wXMM8GXfznwHikF76FAKMc487aLfvscIwTZw84yLD9D+Swu143A28N6l0fE axWxv3J4p8iPFFgmacmDa2Cb6KbqGoO7R/pNG7DIXVOgtdNr5PnqHeTqUUJJQv82ME 5P+C3QOXauyc9P0fIEJw8rj34WTbXhZ78En1zN2cXITR9PpJ1LeZlmZ0bVx6Jsn3Mz 2JOXKYEXq/5S8DfLe8DtzvyWXjyQafkM1xnMx67SdfTJjibcjNuCq6Gaymbth7pBU2 OYUag2GHo8+jQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 95C616A347; Fri, 3 Apr 2026 08:06:20 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id E_FLsWHVPItj; Fri, 3 Apr 2026 08:06:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775225174; bh=CuL68HHdNIUxSQZK4Qn8fiK7BhYRfIyDHxwU7cY+Keg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R5iLdwTPfZ7J0rTiy/QHaEzDOTP7viQlyb3G67ltdq2zuXySUfuv8Dd491VBThil2 MpPTzvAgBGjVLnC8DF1+M1d4lRG5EZ4EtfhZd/MHdcqRxQcLTYq57AWc3fKUUwzgS5 EyX+GIdB2C7Ez7GO3DafFir3fRx5mEnSEdR9Cs2gbZAOlHXjZUdwJOAZ9NsaKH276r ugzzawT4i4iS/gJbBdjM4l+e2jSyrplwgXivo+0b96vTZhVC21k4b7VTGspGrOw/QZ XJo6yST3WSewGNVSjdea6Y6gc8RSPjZXoKEFGh7SwFXo3MciXLVLR8YQwg6CJwxw17 ivfiADuTsn4KA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5305D6A367; Fri, 3 Apr 2026 08:06:14 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 3 Apr 2026 08:04:41 -0600 Message-ID: <20260403140523.1998228-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260403140523.1998228-1-sjg@u-boot.org> References: <20260403140523.1998228-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2EGR2PR7MJAHV4BPIAWMJXCHC7GLN6U7 X-Message-ID-Hash: 2EGR2PR7MJAHV4BPIAWMJXCHC7GLN6U7 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 19/34] vfs: Add boot integration and block-device mount List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add bootflow support for block-backed VFS filesystems. When a filesystem with a block device is mounted, its bootdev can discover boot scripts and extlinux configs through the standard bootmeth interface. Non-block filesystems (e.g. hostfs) return -ENOENT so the bootflow scanner skips them gracefully. Add fs_mount_blkdev() and fs_mount_blkdev_auto() for mounting filesystems from block devices. Auto-detection iterates all UCLASS_FS drivers whose name ends in '_fs' until one succeeds. Reject mounts on already-occupied mount points with -EBUSY. Extend the mount command to support 'mount ' and 'mount -t ' syntax. Signed-off-by: Simon Glass --- cmd/fs.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- fs/fs-uclass.c | 30 +++++++++++++++++++++++++++--- include/fs.h | 2 ++ 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/cmd/fs.c b/cmd/fs.c index 694222e5d10..7231e4efcd1 100644 --- a/cmd/fs.c +++ b/cmd/fs.c @@ -8,12 +8,15 @@ * Copyright 2026 Simon Glass */ +#include #include #include #include #include +#include #include #include +#include #include #include @@ -26,7 +29,7 @@ static int mount_handler(int argc, char *const argv[]) { struct udevice *vfs, *fsdev, *dir, *mnt; const char *subpath; - int ret; + int part_num, ret; vfs = vfs_root(); if (!vfs) @@ -37,6 +40,39 @@ static int mount_handler(int argc, char *const argv[]) return 0; } + /* mount -t */ + if (!strcmp(argv[1], "-t")) { + struct disk_partition info; + struct blk_desc *desc; + + if (argc < 6) + return -EINVAL; + + ret = blk_get_device_part_str(argv[3], argv[4], &desc, + &info, 1); + if (ret < 0) + return ret; + part_num = ret; + + return fs_mount_blkdev(argv[2], desc, part_num, &info, + argv[5]); + } + + /* mount - auto-detect type */ + if (argc == 4) { + struct disk_partition info; + struct blk_desc *desc; + + ret = blk_get_device_part_str(argv[1], argv[2], &desc, + &info, 1); + if (ret < 0) + return ret; + part_num = ret; + + return fs_mount_blkdev_auto(desc, part_num, &info, argv[3]); + } + + /* mount - mount an existing UCLASS_FS device */ if (argc < 3) return -EINVAL; @@ -71,11 +107,14 @@ static int do_mount(struct cmd_tbl *cmdtp, int flag, int argc, } U_BOOT_CMD( - mount, 3, 1, do_mount, + mount, 6, 1, do_mount, "mount a filesystem", "[ ]\n" " - With no args, list all mounts\n" - " - Mount device 'dev' at 'mountpoint'" + "mount \n" + " - Auto-detect and mount a filesystem\n" + "mount -t \n" + " - Mount a specific filesystem type" ); static int umount_handler(const char *path) diff --git a/fs/fs-uclass.c b/fs/fs-uclass.c index 4492ff60522..435fd32bc75 100644 --- a/fs/fs-uclass.c +++ b/fs/fs-uclass.c @@ -7,7 +7,9 @@ #define LOG_CATEGORY UCLASS_FS +#include #include +#include #include #include #include @@ -124,16 +126,38 @@ static int fs_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, struct bootflow *bflow) { struct udevice *fsdev = dev_get_parent(dev); + struct fs_plat *plat = dev_get_uclass_plat(fsdev); + char name[60]; int ret; log_debug("get_bootflow fs '%s'\n", fsdev->name); - /* for now, always fail here as we don't have FS support in bootmeths */ - return -ENOENT; + /* + * Block-backed filesystems expose their blk device and partition so + * that existing bootmeths (script, extlinux) can read files using the + * legacy FS layer. + */ + if (!plat->desc || !plat->desc->bdev) + return log_msg_ret("blk", -ENOENT); + + bflow->blk = plat->desc->bdev; + bflow->part = plat->part_num; + + snprintf(name, sizeof(name), "%s.bootflow", fsdev->name); + bflow->name = strdup(name); + if (!bflow->name) + return log_msg_ret("nam", -ENOMEM); + + bflow->state = BOOTFLOWST_MEDIA; ret = bootmeth_check(bflow->method, iter); if (ret) - return log_msg_ret("check", ret); + return log_msg_ret("chk", ret); + + /* Let the bootmeth discover files (extlinux.conf, boot.scr, etc.) */ + ret = bootmeth_read_bootflow(bflow->method, bflow); + if (ret) + return log_msg_ret("rd", ret); return 0; } diff --git a/include/fs.h b/include/fs.h index efca9b80611..925f810902b 100644 --- a/include/fs.h +++ b/include/fs.h @@ -30,11 +30,13 @@ enum { * * @name: Name of the filesystem, or empty if not available * @desc: Block device descriptor, or NULL if not block-backed + * @part_num: Partition number (valid only when @desc is non-NULL) * @part: Partition information (valid only when @desc is non-NULL) */ struct fs_plat { char name[FS_MAX_NAME_LEN]; struct blk_desc *desc; + int part_num; struct disk_partition part; };