From 8929c98e42e81dce0b00d03a1c7b2f45ee85fe87 Mon Sep 17 00:00:00 2001 From: ngkaho1234 Date: Sat, 30 Jan 2016 23:26:22 +0800 Subject: ext4: add read_only parameter to ext4_mount routine. Now users can mount a filesystem as read-only mode explicitly. --- include/ext4.h | 5 ++++- include/ext4_fs.h | 4 +++- include/ext4_types.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ext4.h b/include/ext4.h index 4bf31ac..bf6e101 100644 --- a/include/ext4.h +++ b/include/ext4.h @@ -122,9 +122,12 @@ int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc, * - / * - /my_partition/ * - /my_second_partition/ + * @param read_only mount as read-only mode. * * @return standard error code */ -int ext4_mount(const char *dev_name, const char *mount_point); +int ext4_mount(const char *dev_name, + const char *mount_point, + bool read_only); /**@brief Umount operation. * @param mount_point mount name diff --git a/include/ext4_fs.h b/include/ext4_fs.h index 97e1d1d..473929d 100644 --- a/include/ext4_fs.h +++ b/include/ext4_fs.h @@ -93,9 +93,11 @@ static inline ext4_fsblk_t ext4_fs_first_bg_block_no(struct ext4_sblock *s, /**@brief Initialize filesystem and read all needed data. * @param fs Filesystem instance to be initialized * @param bdev Identifier if device with the filesystem + * @param read_only Mark the filesystem as read-only. * @return Error code */ -int ext4_fs_init(struct ext4_fs *fs, struct ext4_blockdev *bdev); +int ext4_fs_init(struct ext4_fs *fs, struct ext4_blockdev *bdev, + bool read_only); /**@brief Destroy filesystem instance (used by unmount operation). * @param fs Filesystem to be destroyed diff --git a/include/ext4_types.h b/include/ext4_types.h index 41cb33f..ca3a8c2 100644 --- a/include/ext4_types.h +++ b/include/ext4_types.h @@ -303,6 +303,8 @@ struct ext4_sblock { #endif struct ext4_fs { + bool read_only; + struct ext4_blockdev *bdev; struct ext4_sblock sb; -- cgit v1.2.3