diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-05-04 18:49:53 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-05-04 18:49:53 +0000 |
commit | 29bc6e24ce51bb7b97591f5d354bc3b9b3b05602 (patch) | |
tree | b812c7578cc5369898dc14d49913d490cd75d0de /apps | |
parent | 90b3f2e71415c4cb55bd40ac25b863fa4ed63818 (diff) | |
download | px4-nuttx-29bc6e24ce51bb7b97591f5d354bc3b9b3b05602.tar.gz px4-nuttx-29bc6e24ce51bb7b97591f5d354bc3b9b3b05602.tar.bz2 px4-nuttx-29bc6e24ce51bb7b97591f5d354bc3b9b3b05602.zip |
More NXFFS bugfixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3560 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps')
-rw-r--r-- | apps/examples/nxffs/nxffs_main.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/apps/examples/nxffs/nxffs_main.c b/apps/examples/nxffs/nxffs_main.c index 19e93138d..779375629 100644 --- a/apps/examples/nxffs/nxffs_main.c +++ b/apps/examples/nxffs/nxffs_main.c @@ -223,6 +223,7 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file) { size_t offset; int fd; + int ret; /* Create a random file */ @@ -259,8 +260,21 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file) fprintf(stderr, " File size: %d\n", file->len); fprintf(stderr, " Write offset: %d\n", offset); fprintf(stderr, " Write size: %d\n", nbytestowrite); - nxffs_freefile(file); close(fd); + + /* Remove any garbage file that might have been left behind */ + + ret = unlink(file->name); + if (ret < 0) + { + fprintf(stderr, " Failed to remove corrupted file\n"); + } + else + { + fprintf(stderr, " Successfully removed corrupted file\n"); + } + + nxffs_freefile(file); return ERROR; } else if (nbyteswritten != nbytestowrite) @@ -510,13 +524,8 @@ static int nxffs_delfiles(void) /* And delete the next undeleted file after that random index */ - for (j = ndx + 1; j != ndx; j++) + for (j = ndx + 1; j != ndx;) { - if (j >= CONFIG_EXAMPLES_NXFFS_MAXOPEN) - { - j = 0; - } - file = &g_files[j]; if (file->name && !file->deleted) { @@ -535,6 +544,14 @@ static int nxffs_delfiles(void) break; } } + + /* Increment the index and test for wrap-around */ + + if (++j >= CONFIG_EXAMPLES_NXFFS_MAXOPEN) + { + j = 0; + } + } } |