From 5d3d123272d820fa60548bb1880db188833b4738 Mon Sep 17 00:00:00 2001 From: Shoukui Zhang Date: Mon, 11 Dec 2023 11:27:40 +0800 Subject: [PATCH] BCH: Add readonly configuration for BCH devices Signed-off-by: Shoukui Zhang --- drivers/bch/Kconfig | 6 ++++++ fs/vfs/fs_open.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/drivers/bch/Kconfig b/drivers/bch/Kconfig index cdf70d59ae..a8152e63b5 100644 --- a/drivers/bch/Kconfig +++ b/drivers/bch/Kconfig @@ -28,4 +28,10 @@ config BCH_BUFFER_ALIGNMENT int "Buffer aligned bytes" default 0 +config BCH_DEVICE_READONLY + bool "Set BCH device readonly" + default n + ---help--- + Set bch devices read-only + endif # BCH diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index 200571e34e..fe36e6d7e3 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -198,7 +198,11 @@ static int file_vopen(FAR struct file *filep, FAR const char *path, /* Get the file structure of the opened character driver proxy */ +#ifdef CONFIG_BCH_DEVICE_READONLY + ret = block_proxy(filep, path, O_RDOK); +#else ret = block_proxy(filep, path, oflags); +#endif #ifdef CONFIG_FS_NOTIFY if (ret >= 0) {