From 4080b7727fb623a4f7c093a4fab887cf58778140 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Sat, 31 Oct 2020 16:28:12 -0500 Subject: [PATCH] fs: provide access to DT-defined mount structures Use a devicetree fstab entry node identifier to provide a unique identifier for a fs_mount_t structure that is defined with everything necessary to mount the file system associated with a partition. The fs_mount_t structure will be defined in the implementation for each file system type. Signed-off-by: Peter Bigot --- include/devicetree/fixed-partitions.h | 13 ------------- include/fs/fs.h | 28 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/include/devicetree/fixed-partitions.h b/include/devicetree/fixed-partitions.h index 5d1956e0ce1..4eeb31055c5 100644 --- a/include/devicetree/fixed-partitions.h +++ b/include/devicetree/fixed-partitions.h @@ -79,19 +79,6 @@ extern "C" { (DT_PARENT(DT_GPARENT(node_id))), \ (DT_GPARENT(node_id))) -/* - * @brief Get the common mount flags for an fstab entry. - - * @param node_id the node identifier for a child entry in a - * zephyr,fstab node. - * @return a value suitable for initializing an fs_mount_t flags - * member. - */ -#define DT_FSTAB_ENTRY_MOUNT_FLAGS(node_id) \ - ((DT_PROP(node_id, automount) ? FS_MOUNT_FLAG_AUTOMOUNT : 0) \ - | (DT_PROP(node_id, read_only) ? FS_MOUNT_FLAG_READ_ONLY : 0) \ - | (DT_PROP(node_id, no_format) ? FS_MOUNT_FLAG_NO_FORMAT : 0)) - /** * @} */ diff --git a/include/fs/fs.h b/include/fs/fs.h index b0dd027e6aa..7aef7c78d38 100644 --- a/include/fs/fs.h +++ b/include/fs/fs.h @@ -192,6 +192,34 @@ struct fs_statvfs { * @} */ +/* + * @brief Get the common mount flags for an fstab entry. + + * @param node_id the node identifier for a child entry in a + * zephyr,fstab node. + * @return a value suitable for initializing an fs_mount_t flags + * member. + */ +#define FSTAB_ENTRY_DT_MOUNT_FLAGS(node_id) \ + ((DT_PROP(node_id, automount) ? FS_MOUNT_FLAG_AUTOMOUNT : 0) \ + | (DT_PROP(node_id, read_only) ? FS_MOUNT_FLAG_READ_ONLY : 0) \ + | (DT_PROP(node_id, no_format) ? FS_MOUNT_FLAG_NO_FORMAT : 0)) + +/** + * @brief The name under which a zephyr,fstab entry mount structure is + * defined. + */ +#define FS_FSTAB_ENTRY(node_id) _CONCAT(z_fsmp_, node_id) + +/** + * @brief Generate a declaration for the externally defined fstab + * entry. + * + * This will evaluate to the name of a struct fs_mount_t object. + */ +#define FS_FSTAB_DECLARE_ENTRY(node_id) \ + extern struct fs_mount_t FS_FSTAB_ENTRY(node_id) + /** * @brief Open or create file *