回退 'Pull Request !938 : 修复文件系统不合理的锁操作'
This commit is contained in:
parent
4bd0e73512
commit
fa142daffb
|
@ -60,6 +60,7 @@
|
||||||
#endif /* FS_LOCK_TIMEOUT_SEC */
|
#endif /* FS_LOCK_TIMEOUT_SEC */
|
||||||
|
|
||||||
static UINT8 g_workBuffer[FF_MAX_SS];
|
static UINT8 g_workBuffer[FF_MAX_SS];
|
||||||
|
static pthread_mutex_t g_fatfsMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static char *g_volPath[FF_VOLUMES] = {FF_VOLUME_STRS};
|
static char *g_volPath[FF_VOLUMES] = {FF_VOLUME_STRS};
|
||||||
|
|
||||||
PARTITION VolToPart[] = {
|
PARTITION VolToPart[] = {
|
||||||
|
@ -69,6 +70,31 @@ PARTITION VolToPart[] = {
|
||||||
{ 0, 0, 4, 0, 0 }
|
{ 0, 0, 4, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int FsLock(void)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
struct timespec absTimeout = {0};
|
||||||
|
if (!OsCheckKernelRunning()) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = clock_gettime(CLOCK_REALTIME, &absTimeout);
|
||||||
|
if (ret != 0) {
|
||||||
|
PRINT_ERR("clock gettime err 0x%x!\r\n", errno);
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
absTimeout.tv_sec += FS_LOCK_TIMEOUT_SEC;
|
||||||
|
ret = pthread_mutex_timedlock(&g_fatfsMutex, &absTimeout);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FsUnlock(void)
|
||||||
|
{
|
||||||
|
if (!OsCheckKernelRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(void)pthread_mutex_unlock(&g_fatfsMutex);
|
||||||
|
}
|
||||||
|
|
||||||
static int FsChangeDrive(const char *path)
|
static int FsChangeDrive(const char *path)
|
||||||
{
|
{
|
||||||
INT32 res;
|
INT32 res;
|
||||||
|
@ -249,69 +275,95 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
|
||||||
{
|
{
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
FATFS *fs = NULL;
|
FATFS *fs = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if (mountflags & MS_REMOUNT) {
|
if (mountflags & MS_REMOUNT) {
|
||||||
return Remount(mp, mountflags);
|
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;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs = (FATFS *)LOSCFG_FS_MALLOC_HOOK(sizeof(FATFS));
|
fs = (FATFS *)LOSCFG_FS_MALLOC_HOOK(sizeof(FATFS));
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
PutLdPath(ldPath);
|
ret = (int)LOS_NOK;
|
||||||
return (int)LOS_NOK;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
(void)memset_s(fs, sizeof(FATFS), 0, sizeof(FATFS));
|
(void)memset_s(fs, sizeof(FATFS), 0, sizeof(FATFS));
|
||||||
|
|
||||||
res = f_mount(fs, ldPath, 1);
|
|
||||||
if (res != FR_OK) {
|
|
||||||
LOSCFG_FS_FREE_HOOK(fs);
|
|
||||||
PutLdPath(ldPath);
|
|
||||||
errno = FatfsErrno(res);
|
|
||||||
return (int)LOS_NOK;
|
|
||||||
}
|
|
||||||
mp->mData = (void *)fs;
|
mp->mData = (void *)fs;
|
||||||
|
|
||||||
|
res = f_mount((FATFS *)mp->mData, ldPath, 1);
|
||||||
|
if (res != FR_OK) {
|
||||||
|
errno = FatfsErrno(res);
|
||||||
|
ret = (int)LOS_NOK;
|
||||||
|
goto ERROUT;
|
||||||
|
}
|
||||||
|
|
||||||
PutLdPath(ldPath);
|
PutLdPath(ldPath);
|
||||||
|
FsUnlock();
|
||||||
return (int)LOS_OK;
|
return (int)LOS_OK;
|
||||||
|
|
||||||
|
ERROUT:
|
||||||
|
LOSCFG_FS_FREE_HOOK(fs);
|
||||||
|
mp->mData = NULL;
|
||||||
|
PutLdPath(ldPath);
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsUmount(struct MountPoint *mp)
|
int FatfsUmount(struct MountPoint *mp)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
int volId;
|
int volId;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
char *ldPath;
|
|
||||||
FATFS *fatfs = (FATFS *)mp->mData;
|
FATFS *fatfs = (FATFS *)mp->mData;
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *ldPath = GetLdPath(mp->mDev);
|
||||||
|
if (ldPath == NULL) {
|
||||||
|
errno = EFAULT;
|
||||||
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
|
}
|
||||||
|
|
||||||
/* The volume is not mounted */
|
/* The volume is not mounted */
|
||||||
if (fatfs->fs_type == 0) {
|
if (fatfs->fs_type == 0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
volId = GetPartIdByPartName(mp->mDev);
|
volId = GetPartIdByPartName(mp->mDev);
|
||||||
/* umount is not allowed when a file or directory is opened. */
|
/* umount is not allowed when a file or directory is opened. */
|
||||||
if (f_checkopenlock(volId) != FR_OK) {
|
if (f_checkopenlock(volId) != FR_OK) {
|
||||||
errno = EBUSY;
|
errno = EBUSY;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
}
|
goto OUT;
|
||||||
|
|
||||||
ldPath = GetLdPath(mp->mDev);
|
|
||||||
if (ldPath == NULL) {
|
|
||||||
errno = EFAULT;
|
|
||||||
return (int)LOS_NOK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_mount((FATFS *)NULL, ldPath, 0);
|
res = f_mount((FATFS *)NULL, ldPath, 0);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
PutLdPath(ldPath);
|
ret = (int)LOS_NOK;
|
||||||
return (int)LOS_NOK;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fatfs->win != NULL) {
|
if (fatfs->win != NULL) {
|
||||||
|
@ -321,15 +373,19 @@ int FatfsUmount(struct MountPoint *mp)
|
||||||
LOSCFG_FS_FREE_HOOK(mp->mData);
|
LOSCFG_FS_FREE_HOOK(mp->mData);
|
||||||
mp->mData = NULL;
|
mp->mData = NULL;
|
||||||
|
|
||||||
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
|
OUT:
|
||||||
PutLdPath(ldPath);
|
PutLdPath(ldPath);
|
||||||
return (int)LOS_OK;
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsUmount2(struct MountPoint *mp, int flag)
|
int FatfsUmount2(struct MountPoint *mp, int flag)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
UINT32 flags;
|
UINT32 flags;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
char *ldPath;
|
|
||||||
FATFS *fatfs = (FATFS *)mp->mData;
|
FATFS *fatfs = (FATFS *)mp->mData;
|
||||||
|
|
||||||
flags = MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW;
|
flags = MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW;
|
||||||
|
@ -338,23 +394,31 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The volume is not mounted */
|
ret = FsLock();
|
||||||
if (fatfs->fs_type == 0) {
|
if (ret != 0) {
|
||||||
errno = EINVAL;
|
errno = ret;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ldPath = GetLdPath(mp->mDev);
|
char *ldPath = GetLdPath(mp->mDev);
|
||||||
if (ldPath == NULL) {
|
if (ldPath == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The volume is not mounted */
|
||||||
|
if (fatfs->fs_type == 0) {
|
||||||
|
errno = EINVAL;
|
||||||
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_mount((FATFS *)NULL, ldPath, 0);
|
res = f_mount((FATFS *)NULL, ldPath, 0);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PutLdPath(ldPath);
|
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fatfs->win != NULL) {
|
if (fatfs->win != NULL) {
|
||||||
|
@ -364,8 +428,12 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
|
||||||
LOSCFG_FS_FREE_HOOK(mp->mData);
|
LOSCFG_FS_FREE_HOOK(mp->mData);
|
||||||
mp->mData = NULL;
|
mp->mData = NULL;
|
||||||
|
|
||||||
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
|
OUT:
|
||||||
PutLdPath(ldPath);
|
PutLdPath(ldPath);
|
||||||
return (int)LOS_OK;
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsOpen(struct File *file, const char *path, int oflag)
|
int FatfsOpen(struct File *file, const char *path, int oflag)
|
||||||
|
@ -388,12 +456,20 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
LOSCFG_FS_FREE_HOOK(fp);
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
ret = FsChangeDrive(path);
|
ret = FsChangeDrive(path);
|
||||||
if (ret != (int)LOS_OK) {
|
if (ret != (int)LOS_OK) {
|
||||||
PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret);
|
PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
|
ret = (int)LOS_NOK;
|
||||||
LOSCFG_FS_FREE_HOOK(fp);
|
LOSCFG_FS_FREE_HOOK(fp);
|
||||||
return (int)LOS_NOK;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_open(fp, path, fmode);
|
res = f_open(fp, path, fmode);
|
||||||
|
@ -401,20 +477,31 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
|
||||||
PRINT_ERR("FAT open err 0x%x!\r\n", res);
|
PRINT_ERR("FAT open err 0x%x!\r\n", res);
|
||||||
LOSCFG_FS_FREE_HOOK(fp);
|
LOSCFG_FS_FREE_HOOK(fp);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->fData = (void *)fp;
|
file->fData = (void *)fp;
|
||||||
|
|
||||||
return (int)LOS_OK;
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsClose(struct File *file)
|
int FatfsClose(struct File *file)
|
||||||
{
|
{
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
FIL *fp = (FIL *)file->fData;
|
FIL *fp = (FIL *)file->fData;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if ((fp == NULL) || (fp->obj.fs == NULL)) {
|
if ((fp == NULL) || (fp->obj.fs == NULL)) {
|
||||||
|
FsUnlock();
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
@ -422,6 +509,7 @@ int FatfsClose(struct File *file)
|
||||||
res = f_close(fp);
|
res = f_close(fp);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT close err 0x%x!\r\n", res);
|
PRINT_ERR("FAT close err 0x%x!\r\n", res);
|
||||||
|
FsUnlock();
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
@ -433,6 +521,7 @@ int FatfsClose(struct File *file)
|
||||||
#endif
|
#endif
|
||||||
LOSCFG_FS_FREE_HOOK(file->fData);
|
LOSCFG_FS_FREE_HOOK(file->fData);
|
||||||
file->fData = NULL;
|
file->fData = NULL;
|
||||||
|
FsUnlock();
|
||||||
|
|
||||||
return (int)LOS_OK;
|
return (int)LOS_OK;
|
||||||
}
|
}
|
||||||
|
@ -442,22 +531,31 @@ ssize_t FatfsRead(struct File *file, char *buf, size_t nbyte)
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
UINT32 lenRead;
|
UINT32 lenRead;
|
||||||
FIL *fp = (FIL *)file->fData;
|
FIL *fp = (FIL *)file->fData;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (ssize_t)LOS_NOK;
|
||||||
|
}
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
|
FsUnlock();
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_read(fp, buf, nbyte, &lenRead);
|
res = f_read(fp, buf, nbyte, &lenRead);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
|
FsUnlock();
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
FsUnlock();
|
||||||
|
|
||||||
return (ssize_t)lenRead;
|
return (ssize_t)lenRead;
|
||||||
}
|
}
|
||||||
|
@ -468,15 +566,22 @@ ssize_t FatfsWrite(struct File *file, const char *buf, size_t nbyte)
|
||||||
UINT32 lenWrite;
|
UINT32 lenWrite;
|
||||||
static BOOL overFlow = FALSE;
|
static BOOL overFlow = FALSE;
|
||||||
FIL *fp = (FIL *)file->fData;
|
FIL *fp = (FIL *)file->fData;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (ssize_t)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if ((fp ==NULL) || (fp->obj.fs == NULL)) {
|
if ((fp ==NULL) || (fp->obj.fs == NULL)) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (ssize_t)LOS_NOK;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_write(fp, buf, nbyte, &lenWrite);
|
res = f_write(fp, buf, nbyte, &lenWrite);
|
||||||
|
@ -487,10 +592,15 @@ ssize_t FatfsWrite(struct File *file, const char *buf, size_t nbyte)
|
||||||
|
|
||||||
if ((res != FR_OK) || (nbyte != lenWrite)) {
|
if ((res != FR_OK) || (nbyte != lenWrite)) {
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (ssize_t)LOS_NOK;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FsUnlock();
|
||||||
return (ssize_t)lenWrite;
|
return (ssize_t)lenWrite;
|
||||||
|
|
||||||
|
ERROUT:
|
||||||
|
FsUnlock();
|
||||||
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t FatfsLseek(struct File *file, off_t offset, int whence)
|
off_t FatfsLseek(struct File *file, off_t offset, int whence)
|
||||||
|
@ -498,10 +608,17 @@ off_t FatfsLseek(struct File *file, off_t offset, int whence)
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
off_t pos;
|
off_t pos;
|
||||||
FIL *fp = (FIL *)file->fData;
|
FIL *fp = (FIL *)file->fData;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (off_t)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if ((fp == NULL) || (fp->obj.fs == NULL)) {
|
if ((fp == NULL) || (fp->obj.fs == NULL)) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (off_t)LOS_NOK;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whence == SEEK_SET) {
|
if (whence == SEEK_SET) {
|
||||||
|
@ -512,17 +629,22 @@ off_t FatfsLseek(struct File *file, off_t offset, int whence)
|
||||||
pos = f_size(fp);
|
pos = f_size(fp);
|
||||||
} else {
|
} else {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return (off_t)LOS_NOK;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_lseek(fp, offset + pos);
|
res = f_lseek(fp, offset + pos);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (off_t)LOS_NOK;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = f_tell(fp);
|
pos = f_tell(fp);
|
||||||
|
FsUnlock();
|
||||||
return pos;
|
return pos;
|
||||||
|
|
||||||
|
ERROUT:
|
||||||
|
FsUnlock();
|
||||||
|
return (off_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the specified FILE */
|
/* Remove the specified FILE */
|
||||||
|
@ -536,26 +658,39 @@ int FatfsUnlink(struct MountPoint *mp, const char *path)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mp->mWriteEnable) {
|
if (!mp->mWriteEnable) {
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = FsChangeDrive(path);
|
ret = FsChangeDrive(path);
|
||||||
if (ret != (int)LOS_OK) {
|
if (ret != (int)LOS_OK) {
|
||||||
PRINT_ERR("FAT unlink ChangeDrive err 0x%x!\r\n", ret);
|
PRINT_ERR("FAT unlink ChangeDrive err 0x%x!\r\n", ret);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_unlink(path);
|
res = f_unlink(path);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT unlink err 0x%x!\r\n", res);
|
PRINT_ERR("FAT unlink err 0x%x!\r\n", res);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)LOS_OK;
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
|
int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
|
||||||
|
@ -569,18 +704,26 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
ret = FsChangeDrive(path);
|
ret = FsChangeDrive(path);
|
||||||
if (ret != (int)LOS_OK) {
|
if (ret != (int)LOS_OK) {
|
||||||
PRINT_ERR("FAT stat ChangeDrive err 0x%x!\r\n", ret);
|
PRINT_ERR("FAT stat ChangeDrive err 0x%x!\r\n", ret);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_stat(path, &fileInfo);
|
res = f_stat(path, &fileInfo);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT stat err 0x%x!\r\n", res);
|
PRINT_ERR("FAT stat err 0x%x!\r\n", res);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->st_size = fileInfo.fsize;
|
buf->st_size = fileInfo.fsize;
|
||||||
|
@ -597,27 +740,43 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
|
||||||
buf->st_mode |= S_IFDIR;
|
buf->st_mode |= S_IFDIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)LOS_OK;
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Synchronize all changes to Flash */
|
/* Synchronize all changes to Flash */
|
||||||
int FatfsSync(struct File *file)
|
int FatfsSync(struct File *file)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
FIL *fp = (FIL *)file->fData;
|
FIL *fp = (FIL *)file->fData;
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if ((fp == NULL) || (fp->obj.fs == NULL)) {
|
if ((fp == NULL) || (fp->obj.fs == NULL)) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_sync(fp);
|
res = f_sync(fp);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
return (int)LOS_OK;
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsMkdir(struct MountPoint *mp, const char *path)
|
int FatfsMkdir(struct MountPoint *mp, const char *path)
|
||||||
|
@ -630,26 +789,38 @@ int FatfsMkdir(struct MountPoint *mp, const char *path)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mp->mWriteEnable) {
|
if (!mp->mWriteEnable) {
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = FsChangeDrive(path);
|
ret = FsChangeDrive(path);
|
||||||
if (ret != (int)LOS_OK) {
|
if (ret != (int)LOS_OK) {
|
||||||
PRINT_ERR("FAT mkdir ChangeDrive err 0x%x!\r\n", ret);
|
PRINT_ERR("FAT mkdir ChangeDrive err 0x%x!\r\n", ret);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_mkdir(path);
|
res = f_mkdir(path);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT mkdir err 0x%x!\r\n", res);
|
PRINT_ERR("FAT mkdir err 0x%x!\r\n", res);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
return (int)LOS_OK;
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsOpendir(struct Dir *dir, const char *dirName)
|
int FatfsOpendir(struct Dir *dir, const char *dirName)
|
||||||
|
@ -660,34 +831,47 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
|
||||||
|
|
||||||
if (dirName == NULL) {
|
if (dirName == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return (int)LOS_NOK;
|
goto ERROUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
dp = (DIR *)LOSCFG_FS_MALLOC_HOOK(sizeof(DIR));
|
||||||
|
if (dp == NULL) {
|
||||||
|
errno = ENOENT;
|
||||||
|
goto ERROUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = FsChangeDrive(dirName);
|
ret = FsChangeDrive(dirName);
|
||||||
if (ret != (int)LOS_OK) {
|
if (ret != (int)LOS_OK) {
|
||||||
PRINT_ERR("FAT opendir ChangeDrive err 0x%x!\r\n", ret);
|
PRINT_ERR("FAT opendir ChangeDrive err 0x%x!\r\n", ret);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
goto ERROUT;
|
||||||
}
|
|
||||||
|
|
||||||
dp = (DIR *)LOSCFG_FS_MALLOC_HOOK(sizeof(DIR));
|
|
||||||
if (dp == NULL) {
|
|
||||||
errno = ENOENT;
|
|
||||||
return (int)LOS_NOK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_opendir(dp, dirName);
|
res = f_opendir(dp, dirName);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT opendir err 0x%x!\r\n", res);
|
PRINT_ERR("FAT opendir err 0x%x!\r\n", res);
|
||||||
LOSCFG_FS_FREE_HOOK(dp);
|
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir->dData = dp;
|
dir->dData = dp;
|
||||||
dir->dOffset = 0;
|
dir->dOffset = 0;
|
||||||
|
|
||||||
|
FsUnlock();
|
||||||
return (int)LOS_OK;
|
return (int)LOS_OK;
|
||||||
|
|
||||||
|
ERROUT:
|
||||||
|
if (dp != NULL) {
|
||||||
|
LOSCFG_FS_FREE_HOOK(dp);
|
||||||
|
}
|
||||||
|
FsUnlock();
|
||||||
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsReaddir(struct Dir *dir, struct dirent *dent)
|
int FatfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||||
|
@ -695,6 +879,7 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
FILINFO fileInfo = {0};
|
FILINFO fileInfo = {0};
|
||||||
DIR *dp = NULL;
|
DIR *dp = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if ((dir == NULL) || (dir->dData == NULL)) {
|
if ((dir == NULL) || (dir->dData == NULL)) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
|
@ -702,11 +887,18 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||||
}
|
}
|
||||||
|
|
||||||
dp = (DIR *)dir->dData;
|
dp = (DIR *)dir->dData;
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
res = f_readdir(dp, &fileInfo);
|
res = f_readdir(dp, &fileInfo);
|
||||||
/* if res not ok or fname is NULL , return NULL */
|
/* if res not ok or fname is NULL , return NULL */
|
||||||
if ((res != FR_OK) || (fileInfo.fname[0] == 0x0)) {
|
if ((res != FR_OK) || (fileInfo.fname[0] == 0x0)) {
|
||||||
PRINT_ERR("FAT readdir err 0x%x!\r\n", res);
|
PRINT_ERR("FAT readdir err 0x%x!\r\n", res);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
|
FsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,6 +909,7 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||||
} else {
|
} else {
|
||||||
dent->d_type = DT_REG;
|
dent->d_type = DT_REG;
|
||||||
}
|
}
|
||||||
|
FsUnlock();
|
||||||
|
|
||||||
return (int)LOS_OK;
|
return (int)LOS_OK;
|
||||||
}
|
}
|
||||||
|
@ -725,6 +918,7 @@ int FatfsClosedir(struct Dir *dir)
|
||||||
{
|
{
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
DIR *dp = NULL;
|
DIR *dp = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if ((dir == NULL) || (dir->dData == NULL)) {
|
if ((dir == NULL) || (dir->dData == NULL)) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
|
@ -732,15 +926,23 @@ int FatfsClosedir(struct Dir *dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
dp = dir->dData;
|
dp = dir->dData;
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
res = f_closedir(dp);
|
res = f_closedir(dp);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT closedir err 0x%x!\r\n", res);
|
PRINT_ERR("FAT closedir err 0x%x!\r\n", res);
|
||||||
|
FsUnlock();
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOSCFG_FS_FREE_HOOK(dir->dData);
|
LOSCFG_FS_FREE_HOOK(dir->dData);
|
||||||
dir->dData = NULL;
|
dir->dData = NULL;
|
||||||
|
FsUnlock();
|
||||||
|
|
||||||
return (int)LOS_OK;
|
return (int)LOS_OK;
|
||||||
}
|
}
|
||||||
|
@ -755,26 +957,38 @@ int FatfsRmdir(struct MountPoint *mp, const char *path)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mp->mWriteEnable) {
|
if (!mp->mWriteEnable) {
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = FsChangeDrive(path);
|
ret = FsChangeDrive(path);
|
||||||
if (ret != (int)LOS_OK) {
|
if (ret != (int)LOS_OK) {
|
||||||
PRINT_ERR("FAT rmdir ChangeDrive err 0x%x!\r\n", ret);
|
PRINT_ERR("FAT rmdir ChangeDrive err 0x%x!\r\n", ret);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_rmdir(path);
|
res = f_rmdir(path);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT rmdir err 0x%x!\r\n", res);
|
PRINT_ERR("FAT rmdir err 0x%x!\r\n", res);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
return (int)LOS_OK;
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
|
int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
|
||||||
|
@ -787,26 +1001,38 @@ int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mp->mWriteEnable) {
|
if (!mp->mWriteEnable) {
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = FsChangeDrive(oldName);
|
ret = FsChangeDrive(oldName);
|
||||||
if (ret != (int)LOS_OK) {
|
if (ret != (int)LOS_OK) {
|
||||||
PRINT_ERR("FAT f_getfree ChangeDrive err 0x%x!\r\n", ret);
|
PRINT_ERR("FAT f_getfree ChangeDrive err 0x%x!\r\n", ret);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_rename(oldName, newName);
|
res = f_rename(oldName, newName);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT frename err 0x%x!\r\n", res);
|
PRINT_ERR("FAT frename err 0x%x!\r\n", res);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
return (int)LOS_OK;
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsStatfs(const char *path, struct statfs *buf)
|
int FatfsStatfs(const char *path, struct statfs *buf)
|
||||||
|
@ -821,18 +1047,26 @@ int FatfsStatfs(const char *path, struct statfs *buf)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
ret = FsChangeDrive(path);
|
ret = FsChangeDrive(path);
|
||||||
if (ret != FR_OK) {
|
if (ret != FR_OK) {
|
||||||
PRINT_ERR("FAT f_getfree ChangeDrive err %d.", ret);
|
PRINT_ERR("FAT f_getfree ChangeDrive err %d.", ret);
|
||||||
errno = FatfsErrno(FR_INVALID_PARAMETER);
|
errno = FatfsErrno(FR_INVALID_PARAMETER);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_getfree(path, &freeClust, &fs);
|
res = f_getfree(path, &freeClust, &fs);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT f_getfree err 0x%x.", res);
|
PRINT_ERR("FAT f_getfree err 0x%x.", res);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
buf->f_bfree = freeClust;
|
buf->f_bfree = freeClust;
|
||||||
buf->f_bavail = freeClust;
|
buf->f_bavail = freeClust;
|
||||||
|
@ -844,7 +1078,11 @@ int FatfsStatfs(const char *path, struct statfs *buf)
|
||||||
buf->f_bsize = FF_MIN_SS * fs->csize;
|
buf->f_bsize = FF_MIN_SS * fs->csize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (int)LOS_OK;
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DoTruncate(struct File *file, off_t length, UINT32 count)
|
static int DoTruncate(struct File *file, off_t length, UINT32 count)
|
||||||
|
@ -852,6 +1090,7 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
|
||||||
FRESULT res = FR_OK;
|
FRESULT res = FR_OK;
|
||||||
DWORD csz;
|
DWORD csz;
|
||||||
FIL *fp = (FIL *)file->fData;
|
FIL *fp = (FIL *)file->fData;
|
||||||
|
int ret = (int)LOS_OK;
|
||||||
|
|
||||||
csz = (DWORD)(fp->obj.fs)->csize * SS(fp->obj.fs); /* Cluster size */
|
csz = (DWORD)(fp->obj.fs)->csize * SS(fp->obj.fs); /* Cluster size */
|
||||||
if (length > csz * count) {
|
if (length > csz * count) {
|
||||||
|
@ -859,7 +1098,8 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
|
||||||
res = f_expand(fp, 0, (FSIZE_t)(length), FALLOC_FL_KEEP_SIZE);
|
res = f_expand(fp, 0, (FSIZE_t)(length), FALLOC_FL_KEEP_SIZE);
|
||||||
#else
|
#else
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
} else if (length < csz * count) {
|
} else if (length < csz * count) {
|
||||||
res = f_truncate(fp, (FSIZE_t)length);
|
res = f_truncate(fp, (FSIZE_t)length);
|
||||||
|
@ -867,13 +1107,14 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
|
||||||
|
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp->obj.objsize = length; /* Set file size to length */
|
fp->obj.objsize = length; /* Set file size to length */
|
||||||
fp->flag |= 0x40; /* Set modified flag */
|
fp->flag |= 0x40; /* Set modified flag */
|
||||||
|
|
||||||
return (int)LOS_OK;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsTruncate(struct File *file, off_t length)
|
int FatfsTruncate(struct File *file, off_t length)
|
||||||
|
@ -882,30 +1123,49 @@ int FatfsTruncate(struct File *file, off_t length)
|
||||||
UINT count;
|
UINT count;
|
||||||
DWORD fclust;
|
DWORD fclust;
|
||||||
FIL *fp = (FIL *)file->fData;
|
FIL *fp = (FIL *)file->fData;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if ((length < 0) || (length > UINT_MAX)) {
|
if ((length < 0) || (length > UINT_MAX)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
if ((fp == NULL) || (fp->obj.fs == NULL)) {
|
if ((fp == NULL) || (fp->obj.fs == NULL)) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_getclustinfo(fp, &fclust, &count);
|
res = f_getclustinfo(fp, &fclust, &count);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DoTruncate(file, length, count);
|
ret = DoTruncate(file, length, count);
|
||||||
|
if (ret != FR_OK) {
|
||||||
|
goto OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsFdisk(const char *dev, int *partTbl, int arrayNum)
|
int FatfsFdisk(const char *dev, int *partTbl, int arrayNum)
|
||||||
{
|
{
|
||||||
int pdrv;
|
int pdrv;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if ((dev == NULL) || (partTbl == NULL)) {
|
if ((dev == NULL) || (partTbl == NULL)) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
|
@ -918,13 +1178,25 @@ int FatfsFdisk(const char *dev, int *partTbl, int arrayNum)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
|
}
|
||||||
|
|
||||||
res = f_fdisk(pdrv, (DWORD const *)partTbl, g_workBuffer);
|
res = f_fdisk(pdrv, (DWORD const *)partTbl, g_workBuffer);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
return (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)LOS_OK;
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
|
OUT:
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FatfsFormat(const char *partName, void *privData)
|
int FatfsFormat(const char *partName, void *privData)
|
||||||
|
@ -933,6 +1205,7 @@ int FatfsFormat(const char *partName, void *privData)
|
||||||
MKFS_PARM opt = {0};
|
MKFS_PARM opt = {0};
|
||||||
int option = *(int *)privData;
|
int option = *(int *)privData;
|
||||||
char *dev = NULL; /* logical driver */
|
char *dev = NULL; /* logical driver */
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (partName == NULL) {
|
if (partName == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
|
@ -945,17 +1218,29 @@ int FatfsFormat(const char *partName, void *privData)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = FsLock();
|
||||||
|
if (ret != 0) {
|
||||||
|
errno = ret;
|
||||||
|
PutLdPath(dev);
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
opt.fmt = option;
|
opt.fmt = option;
|
||||||
opt.n_sect = 0; /* use default allocation unit size depends on the volume
|
opt.n_sect = 0; /* use default allocation unit size depends on the volume
|
||||||
size. */
|
size. */
|
||||||
res = f_mkfs(dev, &opt, g_workBuffer, FF_MAX_SS);
|
res = f_mkfs(dev, &opt, g_workBuffer, FF_MAX_SS);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
PutLdPath(dev);
|
ret = (int)LOS_NOK;
|
||||||
return (int)LOS_NOK;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)LOS_OK;
|
ret = (int)LOS_OK;
|
||||||
|
|
||||||
|
OUT:
|
||||||
|
PutLdPath(dev);
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct MountOps g_fatfsMnt = {
|
static struct MountOps g_fatfsMnt = {
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_fs.h"
|
#include "los_fs.h"
|
||||||
|
|
||||||
|
static pthread_mutex_t g_fsLocalMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
static struct PartitionCfg g_partitionCfg;
|
static struct PartitionCfg g_partitionCfg;
|
||||||
static struct DeviceDesc *g_lfsDevice = NULL;
|
static struct DeviceDesc *g_lfsDevice = NULL;
|
||||||
|
|
||||||
|
@ -376,6 +378,7 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||||
|
|
||||||
ret = lfs_dir_read(lfs, dirInfo, &lfsInfo);
|
ret = lfs_dir_read(lfs, dirInfo, &lfsInfo);
|
||||||
if (ret == TRUE) {
|
if (ret == TRUE) {
|
||||||
|
pthread_mutex_lock(&g_fsLocalMutex);
|
||||||
(void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
|
(void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
|
||||||
if (lfsInfo.type == LFS_TYPE_DIR) {
|
if (lfsInfo.type == LFS_TYPE_DIR) {
|
||||||
dent->d_type = DT_DIR;
|
dent->d_type = DT_DIR;
|
||||||
|
@ -384,6 +387,7 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||||
}
|
}
|
||||||
|
|
||||||
dent->d_reclen = lfsInfo.size;
|
dent->d_reclen = lfsInfo.size;
|
||||||
|
pthread_mutex_unlock(&g_fsLocalMutex);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
@ -563,7 +567,9 @@ int LfsClose(struct File *file)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&g_fsLocalMutex);
|
||||||
ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle);
|
ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle);
|
||||||
|
pthread_mutex_unlock(&g_fsLocalMutex);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
errno = LittlefsErrno(ret);
|
errno = LittlefsErrno(ret);
|
||||||
|
|
|
@ -34,11 +34,3 @@ config FS_VFS
|
||||||
|
|
||||||
help
|
help
|
||||||
Answer Y to enable LiteOS support VFS.
|
Answer Y to enable LiteOS support VFS.
|
||||||
|
|
||||||
if FS_VFS
|
|
||||||
config FS_LOCK_TIMEOUT
|
|
||||||
int "Filesystem global lock timeout value in tick. -1 for waiting forever"
|
|
||||||
default -1
|
|
||||||
help
|
|
||||||
The timeout value of getting filesystem lock in tick. -1 for waiting forever
|
|
||||||
endif
|
|
||||||
|
|
|
@ -139,17 +139,6 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data);
|
||||||
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
|
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
|
||||||
const struct FileOps *fsFops, const struct FsManagement *fsMgt);
|
const struct FileOps *fsFops, const struct FsManagement *fsMgt);
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Lock the whole filesystem to forbid filesystem access.
|
|
||||||
*
|
|
||||||
* @return Return LOS_NOK if error. Return LOS_OK if seccess.
|
|
||||||
*/
|
|
||||||
int LOS_FsLock(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Unlock the whole filesystem to allow filesystem access.
|
|
||||||
*/
|
|
||||||
void LOS_FsUnlock(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|
|
@ -100,20 +100,20 @@ int PollQueryFd(int fd, struct PollTable *table)
|
||||||
UINT32 g_fsMutex;
|
UINT32 g_fsMutex;
|
||||||
static UINT32 g_dirNum = 0;
|
static UINT32 g_dirNum = 0;
|
||||||
|
|
||||||
int LOS_FsLock(void)
|
int VfsLock(void)
|
||||||
{
|
{
|
||||||
if (!OsCheckKernelRunning()) {
|
if (!OsCheckKernelRunning()) {
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
if (LOS_MuxPend(g_fsMutex, (UINT32)LOSCFG_FS_LOCK_TIMEOUT) != LOS_OK) {
|
if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
|
||||||
PRINT_ERR("LOS_FsLock failed!");
|
PRINT_ERR("VfsLock failed!");
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOS_FsUnlock(void)
|
void VfsUnlock(void)
|
||||||
{
|
{
|
||||||
if (!OsCheckKernelRunning()) {
|
if (!OsCheckKernelRunning()) {
|
||||||
return;
|
return;
|
||||||
|
@ -224,7 +224,7 @@ static int VfsOpen(const char *path, int flags)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ static int VfsOpen(const char *path, int flags)
|
||||||
(mp->mFs->fsFops == NULL) || (mp->mFs->fsFops->open == NULL)) {
|
(mp->mFs->fsFops == NULL) || (mp->mFs->fsFops->open == NULL)) {
|
||||||
/* path is not in any mountpoint */
|
/* path is not in any mountpoint */
|
||||||
VFS_ERRNO_SET(ENOENT);
|
VFS_ERRNO_SET(ENOENT);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,14 +242,14 @@ static int VfsOpen(const char *path, int flags)
|
||||||
(flags & (O_CREAT | O_WRONLY | O_RDWR))) {
|
(flags & (O_CREAT | O_WRONLY | O_RDWR))) {
|
||||||
/* can't create file in read only mp */
|
/* can't create file in read only mp */
|
||||||
VFS_ERRNO_SET(EACCES);
|
VFS_ERRNO_SET(EACCES);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = VfsFileGet();
|
file = VfsFileGet();
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
VFS_ERRNO_SET(ENFILE);
|
VFS_ERRNO_SET(ENFILE);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ static int VfsOpen(const char *path, int flags)
|
||||||
if (file->fullPath == NULL) {
|
if (file->fullPath == NULL) {
|
||||||
VFS_ERRNO_SET(ENOMEM);
|
VFS_ERRNO_SET(ENOMEM);
|
||||||
VfsFilePut(file);
|
VfsFilePut(file);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
(void)strcpy_s((char *)file->fullPath, len, path);
|
(void)strcpy_s((char *)file->fullPath, len, path);
|
||||||
|
@ -279,7 +279,7 @@ static int VfsOpen(const char *path, int flags)
|
||||||
VfsFilePut(file);
|
VfsFilePut(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ static struct File *VfsAttachFile(int fd, UINT32 status)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EFAULT);
|
VFS_ERRNO_SET(EFAULT);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -302,13 +302,13 @@ static struct File *VfsAttachFile(int fd, UINT32 status)
|
||||||
file = FdToFile(fd);
|
file = FdToFile(fd);
|
||||||
if ((file == NULL) || (file->fMp == NULL)) {
|
if ((file == NULL) || (file->fMp == NULL)) {
|
||||||
VFS_ERRNO_SET(EBADF);
|
VFS_ERRNO_SET(EBADF);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->fStatus != FILE_STATUS_READY) {
|
if (file->fStatus != FILE_STATUS_READY) {
|
||||||
VFS_ERRNO_SET(EBADF);
|
VFS_ERRNO_SET(EBADF);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ static struct File *VfsAttachFileWithStatus(int fd, int status)
|
||||||
static void VfsDetachFile(const struct File *file)
|
static void VfsDetachFile(const struct File *file)
|
||||||
{
|
{
|
||||||
(void)file;
|
(void)file;
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int VfsClose(int fd)
|
static int VfsClose(int fd)
|
||||||
|
@ -674,7 +674,7 @@ int stat(const char *path, struct stat *stat)
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
@ -682,7 +682,7 @@ int stat(const char *path, struct stat *stat)
|
||||||
mp = VfsMpFind(path, &pathInMp);
|
mp = VfsMpFind(path, &pathInMp);
|
||||||
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
|
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
|
||||||
VFS_ERRNO_SET(ENOENT);
|
VFS_ERRNO_SET(ENOENT);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ int stat(const char *path, struct stat *stat)
|
||||||
VFS_ERRNO_SET(ENOTSUP);
|
VFS_ERRNO_SET(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
FUNC_ALIAS(stat, _stat, (const char *path, struct stat *stat), int);
|
FUNC_ALIAS(stat, _stat, (const char *path, struct stat *stat), int);
|
||||||
|
@ -708,7 +708,7 @@ int statfs(const char *path, struct statfs *buf)
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
@ -716,7 +716,7 @@ int statfs(const char *path, struct statfs *buf)
|
||||||
mp = VfsMpFind(path, &pathInMp);
|
mp = VfsMpFind(path, &pathInMp);
|
||||||
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
|
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
|
||||||
VFS_ERRNO_SET(ENOENT);
|
VFS_ERRNO_SET(ENOENT);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ int statfs(const char *path, struct statfs *buf)
|
||||||
VFS_ERRNO_SET(ENOTSUP);
|
VFS_ERRNO_SET(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ int unlink(const char *path)
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
@ -750,13 +750,13 @@ int unlink(const char *path)
|
||||||
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0') ||
|
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0') ||
|
||||||
(mp->mFs->fsFops->unlink == NULL)) {
|
(mp->mFs->fsFops->unlink == NULL)) {
|
||||||
VFS_ERRNO_SET(ENOENT);
|
VFS_ERRNO_SET(ENOENT);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mp->mFs->fsFops->unlink(mp, pathInMp);
|
ret = mp->mFs->fsFops->unlink(mp, pathInMp);
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
FUNC_ALIAS(unlink, _unlink, (const char *path), int);
|
FUNC_ALIAS(unlink, _unlink, (const char *path), int);
|
||||||
|
@ -774,7 +774,7 @@ int rename(const char *oldpath, const char *newpath)
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
@ -783,27 +783,27 @@ int rename(const char *oldpath, const char *newpath)
|
||||||
|
|
||||||
if (pathInMpOld == NULL) {
|
if (pathInMpOld == NULL) {
|
||||||
VFS_ERRNO_SET(EINVAL);
|
VFS_ERRNO_SET(EINVAL);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mpOld == NULL) || (*pathInMpOld == '\0') ||
|
if ((mpOld == NULL) || (*pathInMpOld == '\0') ||
|
||||||
(mpOld->mFs->fsFops->unlink == NULL)) {
|
(mpOld->mFs->fsFops->unlink == NULL)) {
|
||||||
VFS_ERRNO_SET(EINVAL);
|
VFS_ERRNO_SET(EINVAL);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpNew = VfsMpFind(newpath, &pathInMpNew);
|
mpNew = VfsMpFind(newpath, &pathInMpNew);
|
||||||
if ((mpNew == NULL) || (pathInMpNew == NULL) || (*pathInMpNew == '\0') || (mpNew->mFs->fsFops->unlink == NULL)) {
|
if ((mpNew == NULL) || (pathInMpNew == NULL) || (*pathInMpNew == '\0') || (mpNew->mFs->fsFops->unlink == NULL)) {
|
||||||
VFS_ERRNO_SET(EINVAL);
|
VFS_ERRNO_SET(EINVAL);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mpOld != mpNew) {
|
if (mpOld != mpNew) {
|
||||||
VFS_ERRNO_SET(EXDEV);
|
VFS_ERRNO_SET(EXDEV);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,7 +813,7 @@ int rename(const char *oldpath, const char *newpath)
|
||||||
VFS_ERRNO_SET(ENOTSUP);
|
VFS_ERRNO_SET(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,7 +861,7 @@ DIR *opendir(const char *path)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
LOSCFG_FS_FREE_HOOK(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -869,7 +869,7 @@ DIR *opendir(const char *path)
|
||||||
|
|
||||||
if (g_dirNum >= LOSCFG_MAX_OPEN_DIRS) {
|
if (g_dirNum >= LOSCFG_MAX_OPEN_DIRS) {
|
||||||
VFS_ERRNO_SET(ENFILE);
|
VFS_ERRNO_SET(ENFILE);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
LOSCFG_FS_FREE_HOOK(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -877,14 +877,14 @@ DIR *opendir(const char *path)
|
||||||
mp = VfsMpFind(path, &pathInMp);
|
mp = VfsMpFind(path, &pathInMp);
|
||||||
if ((mp == NULL) || (pathInMp == NULL)) {
|
if ((mp == NULL) || (pathInMp == NULL)) {
|
||||||
VFS_ERRNO_SET(ENOENT);
|
VFS_ERRNO_SET(ENOENT);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
LOSCFG_FS_FREE_HOOK(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mp->mFs->fsFops->opendir == NULL) {
|
if (mp->mFs->fsFops->opendir == NULL) {
|
||||||
VFS_ERRNO_SET(ENOTSUP);
|
VFS_ERRNO_SET(ENOTSUP);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
LOSCFG_FS_FREE_HOOK(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -901,7 +901,7 @@ DIR *opendir(const char *path)
|
||||||
dir = NULL;
|
dir = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return (DIR *)dir;
|
return (DIR *)dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,7 +915,7 @@ struct dirent *readdir(DIR *dir)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -929,7 +929,7 @@ struct dirent *readdir(DIR *dir)
|
||||||
VFS_ERRNO_SET(ENOTSUP);
|
VFS_ERRNO_SET(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -947,7 +947,7 @@ int closedir(DIR *dir)
|
||||||
|
|
||||||
mp = d->dMp;
|
mp = d->dMp;
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
@ -966,7 +966,7 @@ int closedir(DIR *dir)
|
||||||
VFS_ERRNO_SET(EBADF);
|
VFS_ERRNO_SET(EBADF);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
LOSCFG_FS_FREE_HOOK(d);
|
LOSCFG_FS_FREE_HOOK(d);
|
||||||
d = NULL;
|
d = NULL;
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
|
@ -984,7 +984,7 @@ int mkdir(const char *path, mode_t mode)
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
@ -992,7 +992,7 @@ int mkdir(const char *path, mode_t mode)
|
||||||
mp = VfsMpFind(path, &pathInMp);
|
mp = VfsMpFind(path, &pathInMp);
|
||||||
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
|
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
|
||||||
VFS_ERRNO_SET(ENOENT);
|
VFS_ERRNO_SET(ENOENT);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1002,7 +1002,7 @@ int mkdir(const char *path, mode_t mode)
|
||||||
VFS_ERRNO_SET(ENOTSUP);
|
VFS_ERRNO_SET(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,7 +1017,7 @@ int rmdir(const char *path)
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
@ -1026,13 +1026,13 @@ int rmdir(const char *path)
|
||||||
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0') ||
|
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0') ||
|
||||||
(mp->mFs->fsFops->rmdir == NULL)) {
|
(mp->mFs->fsFops->rmdir == NULL)) {
|
||||||
VFS_ERRNO_SET(ENOENT);
|
VFS_ERRNO_SET(ENOENT);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mp->mFs->fsFops->rmdir(mp, pathInMp);
|
ret = mp->mFs->fsFops->rmdir(mp, pathInMp);
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet(ret);
|
return MapToPosixRet(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,31 +1312,31 @@ ssize_t pread(int fd, void *buff, size_t bytes, off_t off)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet((int)ret);
|
return MapToPosixRet((int)ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
savepos = lseek(fd, 0, SEEK_CUR);
|
savepos = lseek(fd, 0, SEEK_CUR);
|
||||||
if (savepos == (off_t)-1) {
|
if (savepos == (off_t)-1) {
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet((int)ret);
|
return MapToPosixRet((int)ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = lseek(fd, off, SEEK_SET);
|
pos = lseek(fd, off, SEEK_SET);
|
||||||
if (pos == (off_t)-1) {
|
if (pos == (off_t)-1) {
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet((int)ret);
|
return MapToPosixRet((int)ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = read(fd, buff, bytes);
|
ret = read(fd, buff, bytes);
|
||||||
pos = lseek(fd, savepos, SEEK_SET);
|
pos = lseek(fd, savepos, SEEK_SET);
|
||||||
if ((pos == (off_t)-1) && (ret >= 0)) {
|
if ((pos == (off_t)-1) && (ret >= 0)) {
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet((int)LOS_NOK);
|
return MapToPosixRet((int)LOS_NOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
|
|
||||||
return MapToPosixRet((int)ret);
|
return MapToPosixRet((int)ret);
|
||||||
}
|
}
|
||||||
|
@ -1359,31 +1359,31 @@ ssize_t pwrite(int fd, const void *buff, size_t bytes, off_t off)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOS_FsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
return MapToPosixRet((int)ret);
|
return MapToPosixRet((int)ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
savepos = lseek(fd, 0, SEEK_CUR);
|
savepos = lseek(fd, 0, SEEK_CUR);
|
||||||
if (savepos == (off_t)-1) {
|
if (savepos == (off_t)-1) {
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet((int)ret);
|
return MapToPosixRet((int)ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = lseek(fd, off, SEEK_SET);
|
pos = lseek(fd, off, SEEK_SET);
|
||||||
if (pos == (off_t)-1) {
|
if (pos == (off_t)-1) {
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet((int)ret);
|
return MapToPosixRet((int)ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = write(fd, buff, bytes);
|
ret = write(fd, buff, bytes);
|
||||||
pos = lseek(fd, savepos, SEEK_SET);
|
pos = lseek(fd, savepos, SEEK_SET);
|
||||||
if ((pos == (off_t)-1) && (ret >= 0)) {
|
if ((pos == (off_t)-1) && (ret >= 0)) {
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return MapToPosixRet((int)LOS_NOK);
|
return MapToPosixRet((int)LOS_NOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
|
|
||||||
return MapToPosixRet((int)ret);
|
return MapToPosixRet((int)ret);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,17 +41,17 @@ struct FsMap *VfsFsMapGet(const char *fsType)
|
||||||
{
|
{
|
||||||
struct FsMap *curr = g_fsMap;
|
struct FsMap *curr = g_fsMap;
|
||||||
|
|
||||||
(void)LOS_FsLock();
|
(void)VfsLock();
|
||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
if ((curr->fsType != NULL) && (fsType != NULL) &&
|
if ((curr->fsType != NULL) && (fsType != NULL) &&
|
||||||
(strcmp(curr->fsType, fsType) == 0)) {
|
(strcmp(curr->fsType, fsType) == 0)) {
|
||||||
LOS_FsUnlock();
|
(void)VfsUnlock();
|
||||||
return curr;
|
return curr;
|
||||||
}
|
}
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,11 +86,11 @@ int OsFsRegister(const char *fsType, const struct MountOps *fsMops,
|
||||||
newfs->fsMgt = fsMgt;
|
newfs->fsMgt = fsMgt;
|
||||||
newfs->fsRefs = 0;
|
newfs->fsRefs = 0;
|
||||||
|
|
||||||
(void)LOS_FsLock();
|
(void)VfsLock();
|
||||||
newfs->next = g_fsMap;
|
newfs->next = g_fsMap;
|
||||||
g_fsMap = newfs;
|
g_fsMap = newfs;
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,17 +191,17 @@ int mount(const char *source, const char *target,
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)LOS_FsLock();
|
(void)VfsLock();
|
||||||
|
|
||||||
if (mountflags & MS_REMOUNT) {
|
if (mountflags & MS_REMOUNT) {
|
||||||
ret = VfsRemount(source, target, fsType, mountflags, data);
|
ret = VfsRemount(source, target, fsType, mountflags, data);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp = VfsMountPointInit(target, fsType, mountflags);
|
mp = VfsMountPointInit(target, fsType, mountflags);
|
||||||
if (mp == NULL) {
|
if (mp == NULL) {
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ int mount(const char *source, const char *target,
|
||||||
mp->mDev = LOSCFG_FS_MALLOC_HOOK(len);
|
mp->mDev = LOSCFG_FS_MALLOC_HOOK(len);
|
||||||
if (mp->mDev == NULL) {
|
if (mp->mDev == NULL) {
|
||||||
LOSCFG_FS_FREE_HOOK(mp);
|
LOSCFG_FS_FREE_HOOK(mp);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
(void)strcpy_s((char *)mp->mDev, len, source);
|
(void)strcpy_s((char *)mp->mDev, len, source);
|
||||||
|
@ -231,14 +231,14 @@ int mount(const char *source, const char *target,
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mountPoints = mp;
|
g_mountPoints = mp;
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
|
||||||
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
||||||
LOSCFG_FS_FREE_HOOK(mp);
|
LOSCFG_FS_FREE_HOOK(mp);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ int umount(const char *target)
|
||||||
const char *pathInMp = NULL;
|
const char *pathInMp = NULL;
|
||||||
int ret = (int)LOS_NOK;
|
int ret = (int)LOS_NOK;
|
||||||
|
|
||||||
(void)LOS_FsLock();
|
(void)VfsLock();
|
||||||
if (target == NULL) {
|
if (target == NULL) {
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
@ -276,12 +276,12 @@ int umount(const char *target)
|
||||||
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
||||||
LOSCFG_FS_FREE_HOOK(mp);
|
LOSCFG_FS_FREE_HOOK(mp);
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
PRINT_ERR("umount2 failed, target %s.\n", target);
|
PRINT_ERR("umount2 failed, target %s.\n", target);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ int umount2(const char *target, int flag)
|
||||||
const char *pathInMp = NULL;
|
const char *pathInMp = NULL;
|
||||||
int ret = (int)LOS_NOK;
|
int ret = (int)LOS_NOK;
|
||||||
|
|
||||||
(void)LOS_FsLock();
|
(void)VfsLock();
|
||||||
if (target == NULL) {
|
if (target == NULL) {
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
@ -336,11 +336,11 @@ int umount2(const char *target, int flag)
|
||||||
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
||||||
LOSCFG_FS_FREE_HOOK(mp);
|
LOSCFG_FS_FREE_HOOK(mp);
|
||||||
|
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
PRINT_ERR("umount2 failed, target %s.\n", target);
|
PRINT_ERR("umount2 failed, target %s.\n", target);
|
||||||
LOS_FsUnlock();
|
VfsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ extern "C" {
|
||||||
extern UINT32 g_fsMutex;
|
extern UINT32 g_fsMutex;
|
||||||
|
|
||||||
int OsVfsInit(void);
|
int OsVfsInit(void);
|
||||||
|
int VfsLock(void);
|
||||||
|
void VfsUnlock(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue