!909 修复mount接口对MS_REMOUNT的支持

Merge pull request !909 from Far/master
This commit is contained in:
openharmony_ci 2022-11-15 14:17:19 +00:00 committed by Gitee
commit aee957bb1f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
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;
}
if (mountflags & MS_REMOUNT) {
ret = Remount(mp, mountflags);
FsUnlock();
return ret;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
@ -289,11 +295,6 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
goto ERROUT;
}
if (mountflags & MS_REMOUNT) {
ret = Remount(mp, mountflags);
goto ERROUT;
}
fs = (FATFS *)malloc(sizeof(FATFS));
if (fs == NULL) {
errno = ENOMEM;

View File

@ -184,6 +184,12 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
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));
if (mountHdl == NULL) {
errno = ENODEV;

View File

@ -33,6 +33,7 @@
#include "vfs_config.h"
#include "stdlib.h"
#include "string.h"
#include "errno.h"
#include "vfs_operations.h"
#include "los_compiler.h"
#include "los_debug.h"
@ -122,7 +123,7 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
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;
const char *pathInMp = NULL;
@ -155,6 +156,27 @@ STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType,
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,
const char *fsType, unsigned long mountflags,
const void *data)
@ -169,7 +191,13 @@ int LOS_FsMount(const char *source, const char *target,
(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) {
VfsUnlock();
return (int)LOS_NOK;