fs: Add support for a directory

Filesystems can have a number of directories within them. U-Boot only
worries about directories that have been accessed. Add the concept of
a directory, with the filesystem as parent.

Note that this is not a hierarchical device structure, so UCLASS_DIR
devices always have a UCLASS_FS as the parent.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-06-25 07:54:20 -06:00
parent d347548467
commit 4ae46c7db4
9 changed files with 285 additions and 0 deletions

View File

@@ -54,6 +54,17 @@ struct fs_ops {
* Return 0 if OK, -ENOTCONN if not mounted, other -ve on error
*/
int (*unmount)(struct udevice *dev);
/**
* lookup_dir() - Look up a directory on a filesystem
*
* @dev: Filesystem device
* @path: Path to look up, empty or "/" for the root
* @dirp: Returns associated directory device, creating if necessary
* Return 0 if OK, -ENOENT, other -ve on error
*/
int (*lookup_dir)(struct udevice *dev, const char *path,
struct udevice **dirp);
};
/* Get access to a filesystem's operations */
@@ -75,4 +86,14 @@ int fs_mount(struct udevice *dev);
*/
int fs_unmount(struct udevice *dev);
/**
* fs_lookup_dir() - Look up a directory on a filesystem
*
* @dev: Filesystem device
* @path: Path to look up, empty or "/" for the root
* @dirp: Returns associated directory device, creating if necessary
* Return 0 if OK, -ENOENT, other -ve on error
*/
int fs_lookup_dir(struct udevice *dev, const char *path, struct udevice **dirp);
#endif