From 4779429ab06895bb1a248c8dcbb69feed34cd722 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Fri, 15 Dec 2017 16:41:20 +0800 Subject: [PATCH 1/3] [dfs]:fix bug in nfs caused by struct dfs_fd --- components/dfs/filesystems/nfs/dfs_nfs.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/components/dfs/filesystems/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c index 5d7aa0db61..e7bccd9b2b 100644 --- a/components/dfs/filesystems/nfs/dfs_nfs.c +++ b/components/dfs/filesystems/nfs/dfs_nfs.c @@ -578,7 +578,8 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count) RT_ASSERT(file->data != NULL); - nfs = (nfs_filesystem *)((struct dfs_filesystem*)(file->data)); + struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); fd = (nfs_file *)(nfs->data); RT_ASSERT(fd != NULL); @@ -644,7 +645,8 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count) return -EISDIR; RT_ASSERT(file->data != NULL); - nfs = (nfs_filesystem *)((struct dfs_filesystem*)(file->data)); + struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); fd = (nfs_file *)(nfs->data); RT_ASSERT(fd != NULL); @@ -704,7 +706,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset) return -EISDIR; RT_ASSERT(file->data != NULL); - nfs = (nfs_filesystem *)((struct dfs_filesystem*)(file->data)); + struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); fd = (nfs_file *)(nfs->data); RT_ASSERT(fd != NULL); @@ -722,7 +725,8 @@ int nfs_close(struct dfs_fd *file) { nfs_filesystem *nfs; RT_ASSERT(file->data != NULL); - nfs = (nfs_filesystem *)((struct dfs_filesystem*)(file->data)); + struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); if (file->type == FT_DIRECTORY) { @@ -751,7 +755,8 @@ int nfs_open(struct dfs_fd *file) { nfs_filesystem *nfs; RT_ASSERT(file->data != NULL); - nfs = (nfs_filesystem *)((struct dfs_filesystem*)(file->data)); + struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); if (file->flags & O_DIRECTORY) @@ -1093,7 +1098,8 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count) RT_ASSERT(file->data != NULL); - nfs = (nfs_filesystem *)((struct dfs_filesystem*)(file->data)); + struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); dir = (nfs_dir *)(nfs->data); RT_ASSERT(dir != NULL); From 4d0e205406c8c149e4de727df2e68b84f21d1e79 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Fri, 15 Dec 2017 17:15:13 +0800 Subject: [PATCH 2/3] [nfs]:Format Optimize --- components/dfs/filesystems/nfs/dfs_nfs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/components/dfs/filesystems/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c index e7bccd9b2b..72ea80d48f 100644 --- a/components/dfs/filesystems/nfs/dfs_nfs.c +++ b/components/dfs/filesystems/nfs/dfs_nfs.c @@ -579,7 +579,7 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count) RT_ASSERT(file->data != NULL); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); - nfs = (struct nfs_filesystem *)(dfs_nfs->data); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); fd = (nfs_file *)(nfs->data); RT_ASSERT(fd != NULL); @@ -646,7 +646,7 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count) RT_ASSERT(file->data != NULL); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); - nfs = (struct nfs_filesystem *)(dfs_nfs->data); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); fd = (nfs_file *)(nfs->data); RT_ASSERT(fd != NULL); @@ -686,8 +686,8 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count) /* update current position */ file->pos = fd->offset; /* update file size */ - if (fd->size < fd->offset) fd->size = fd->offset; - file->size = fd->size; + if (fd->size < fd->offset) fd->size = fd->offset; + file->size = fd->size; } xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res); } while (count > 0); @@ -707,7 +707,7 @@ int nfs_lseek(struct dfs_fd *file, off_t offset) RT_ASSERT(file->data != NULL); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); - nfs = (struct nfs_filesystem *)(dfs_nfs->data); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); fd = (nfs_file *)(nfs->data); RT_ASSERT(fd != NULL); @@ -726,7 +726,7 @@ int nfs_close(struct dfs_fd *file) nfs_filesystem *nfs; RT_ASSERT(file->data != NULL); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); - nfs = (struct nfs_filesystem *)(dfs_nfs->data); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); if (file->type == FT_DIRECTORY) { @@ -756,7 +756,7 @@ int nfs_open(struct dfs_fd *file) nfs_filesystem *nfs; RT_ASSERT(file->data != NULL); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); - nfs = (struct nfs_filesystem *)(dfs_nfs->data); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); if (file->flags & O_DIRECTORY) @@ -888,7 +888,7 @@ nfs_dir *nfs_opendir(nfs_filesystem *nfs, const char *path) if (handle == NULL) { rt_free(dir); - + return NULL; } @@ -1099,7 +1099,7 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count) RT_ASSERT(file->data != NULL); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem*)(file->data)); - nfs = (struct nfs_filesystem *)(dfs_nfs->data); + nfs = (struct nfs_filesystem *)(dfs_nfs->data); dir = (nfs_dir *)(nfs->data); RT_ASSERT(dir != NULL); From d051c6dec06fe444061b0f89dffa0135568cbdfb Mon Sep 17 00:00:00 2001 From: SummerGift Date: Fri, 15 Dec 2017 17:23:29 +0800 Subject: [PATCH 3/3] [nfs]:Format Optimize --- components/dfs/filesystems/nfs/dfs_nfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/components/dfs/filesystems/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c index 72ea80d48f..1324210007 100644 --- a/components/dfs/filesystems/nfs/dfs_nfs.c +++ b/components/dfs/filesystems/nfs/dfs_nfs.c @@ -888,7 +888,6 @@ nfs_dir *nfs_opendir(nfs_filesystem *nfs, const char *path) if (handle == NULL) { rt_free(dir); - return NULL; }