fix: fix the MS_REMOUNT support

The mount interface can't deal with MS_REMOUNT flag now, fix it.

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Id0960c8d92ce767b8d8ef98b3ba2e1d1ab7db15d
This commit is contained in:
Far 2022-11-14 15:56:01 +08:00
parent 527cec6e27
commit 64d15df9ea
3 changed files with 42 additions and 7 deletions

View File

@ -282,6 +282,12 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
return (int)LOS_NOK; return (int)LOS_NOK;
} }
if (mountflags & MS_REMOUNT) {
ret = Remount(mp, mountflags);
FsUnlock();
return ret;
}
char *ldPath = GetLdPath(mp->mDev); char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) { if (ldPath == NULL) {
errno = EFAULT; errno = EFAULT;
@ -289,11 +295,6 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
goto ERROUT; goto ERROUT;
} }
if (mountflags & MS_REMOUNT) {
ret = Remount(mp, mountflags);
goto ERROUT;
}
fs = (FATFS *)malloc(sizeof(FATFS)); fs = (FATFS *)malloc(sizeof(FATFS));
if (fs == NULL) { if (fs == NULL) {
errno = ENOMEM; errno = ENOMEM;

View File

@ -184,6 +184,12 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
goto errout; goto errout;
} }
if (mountflags & MS_REMOUNT) {
errno = ENOSYS;
ret = (int)LOS_NOK;
goto errout;
}
mountHdl = (lfs_t *)malloc(sizeof(lfs_t) + sizeof(struct lfs_config)); mountHdl = (lfs_t *)malloc(sizeof(lfs_t) + sizeof(struct lfs_config));
if (mountHdl == NULL) { if (mountHdl == NULL) {
errno = ENODEV; errno = ENODEV;

View File

@ -33,6 +33,7 @@
#include "vfs_config.h" #include "vfs_config.h"
#include "stdlib.h" #include "stdlib.h"
#include "string.h" #include "string.h"
#include "errno.h"
#include "vfs_operations.h" #include "vfs_operations.h"
#include "los_compiler.h" #include "los_compiler.h"
#include "los_debug.h" #include "los_debug.h"
@ -122,7 +123,7 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
return bestMp; return bestMp;
} }
STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType, unsigned long mountflags) STATIC struct MountPoint *VfsMountPointInit(const char *target, const char *fsType, unsigned long mountflags)
{ {
struct MountPoint *mp = NULL; struct MountPoint *mp = NULL;
const char *pathInMp = NULL; const char *pathInMp = NULL;
@ -155,6 +156,27 @@ STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType,
return mp; return mp;
} }
STATIC int VfsRemount(const char *source ,const char *target,
const char *fsType, unsigned long mountflags,
const void *data)
{
(VOID)source;
(VOID)fsType;
struct MountPoint *mp;
mp = VfsMpFind(target, NULL);
if (mp == NULL) {
errno = EINVAL;
return (int)LOS_NOK;
}
LOS_ASSERT(mp->mFs != NULL);
LOS_ASSERT(mp->mFs->fsMops != NULL);
LOS_ASSERT(mp->mFs->fsMops->mount != NULL);
return mp->mFs->fsMops->mount(mp, mountflags, data);
}
int LOS_FsMount(const char *source, const char *target, int LOS_FsMount(const char *source, const char *target,
const char *fsType, unsigned long mountflags, const char *fsType, unsigned long mountflags,
const void *data) const void *data)
@ -169,7 +191,13 @@ int LOS_FsMount(const char *source, const char *target,
(void)VfsLock(); (void)VfsLock();
mp = MountPointInit(target, fsType, mountflags); if (mountflags & MS_REMOUNT) {
ret = VfsRemount(source, target, fsType, mountflags, data);
VfsUnlock();
return ret;
}
mp = VfsMountPointInit(target, fsType, mountflags);
if (mp == NULL) { if (mp == NULL) {
VfsUnlock(); VfsUnlock();
return (int)LOS_NOK; return (int)LOS_NOK;