feat: 增加mount的MS_RDONLY标志的支持

增加mount的MS_RDONLY标志的支持,并修改vfs主要接口相关支持。
1. fatfs lseek接口在分区以MS_RDONLY方式和文件以只读打开时不再能够扩大文件的大小。
2. 直接在镜像中创建storage目录,而不是在挂载根文件系统时创建storage目录。
3. 增加了MS_RDONLY的测试用例。

Close #I3Z1W6

Signed-off-by: Far <yesiyuan2@huawei.com>
This commit is contained in:
Far
2021-07-20 15:12:58 +08:00
parent 9d3e872454
commit 8729f6ee57
11 changed files with 333 additions and 8 deletions
+7
View File
@@ -41,6 +41,8 @@
#include "stdlib.h"
#include "sys/stat.h"
#include "vnode.h"
#include "fs/mount.h"
#include <fcntl.h>
/****************************************************************************
* Static Functions
@@ -69,6 +71,11 @@ int chattr(const char *pathname, struct IATTR *attr)
goto errout_with_lock;
}
if ((vnode->originMount) && (vnode->originMount->mountFlags & MS_RDONLY)) {
ret = -EROFS;
goto errout_with_lock;
}
/* The way we handle the stat depends on the type of vnode that we
* are dealing with.
*/
+8
View File
@@ -37,9 +37,11 @@
#include "vfs_config.h"
#include "sys/stat.h"
#include "vnode.h"
#include "fs/mount.h"
#include "string.h"
#include "stdlib.h"
#include "utime.h"
#include <fcntl.h>
/****************************************************************************
* Global Functions
@@ -79,6 +81,12 @@ int utime(const char *path, const struct utimbuf *ptimes)
goto errout_with_path;
}
if ((vnode->originMount) && (vnode->originMount->mountFlags & MS_RDONLY)) {
VnodeDrop();
ret = -EROFS;
goto errout_with_path;
}
if (vnode->vop && vnode->vop->Chattr) {
if (ptimes == NULL) {
/* get current seconds */