summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-30 17:29:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-30 17:29:40 +0000
commit4be9e73e52fadd5cfcf726bfe09cb844eb2b6152 (patch)
treeaa597c7ef62dd3f42ecd6412d38d1831dd2d63e1 /apps
parent2272d60c0c7045ffdcfdb3d2c37ed8849a129783 (diff)
downloadpx4-nuttx-4be9e73e52fadd5cfcf726bfe09cb844eb2b6152.tar.gz
px4-nuttx-4be9e73e52fadd5cfcf726bfe09cb844eb2b6152.tar.bz2
px4-nuttx-4be9e73e52fadd5cfcf726bfe09cb844eb2b6152.zip
Add file creation logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3542 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps')
-rw-r--r--apps/examples/nxffs/nxffs_main.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/examples/nxffs/nxffs_main.c b/apps/examples/nxffs/nxffs_main.c
index f4000b6ea..9a3532e2c 100644
--- a/apps/examples/nxffs/nxffs_main.c
+++ b/apps/examples/nxffs/nxffs_main.c
@@ -79,12 +79,17 @@
# define CONFIG_EXAMPLES_NXFFS_MAXNAME 128
#endif
+#if CONFIG_EXAMPLES_NXFFS_MAXNAME > 255
+# undef CONFIG_EXAMPLES_NXFFS_MAXNAME
+# define CONFIG_EXAMPLES_NXFFS_MAXNAME 255
+#endif
+
#ifndef CONFIG_EXAMPLES_NXFFS_MAXFILE
# define CONFIG_EXAMPLES_NXFFS_MAXFILE 8192
#endif
-#ifndef CONFIG_EXAMPLES_NXFFS_GULP
-# define CONFIG_EXAMPLES_NXFFS_GULP 347
+#ifndef CONFIG_EXAMPLES_NXFFS_MAXIO
+# define CONFIG_EXAMPLES_NXFFS_MAXIO 347
#endif
#ifndef CONFIG_EXAMPLES_NXFFS_MAXOPEN
@@ -248,12 +253,13 @@ static inline int nxffs_wrfile(void)
for (offset = 0; offset < file->len; )
{
+ size_t maxio = (rand() % CONFIG_EXAMPLES_NXFFS_MAXIO) + 1;
size_t nbytestowrite = file->len - offset;
ssize_t nbyteswritten;
- if (nbytestowrite > CONFIG_EXAMPLES_NXFFS_GULP)
+ if (nbytestowrite > maxio)
{
- nbytestowrite = CONFIG_EXAMPLES_NXFFS_GULP;
+ nbytestowrite = maxio;
}
nbyteswritten = write(fd, &g_fileimage[offset], nbytestowrite);
@@ -270,7 +276,7 @@ static inline int nxffs_wrfile(void)
}
else if (nbyteswritten != nbytestowrite)
{
- fprintf(stderr, "Partial write: %d\n");
+ fprintf(stderr, "Partial write:\n");
fprintf(stderr, " File name: %s\n", file->name);
fprintf(stderr, " File size: %d\n", file->len);
fprintf(stderr, " Write offset: %d\n", offset);