summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-11 19:08:51 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-11 19:08:51 +0000
commit049b66a75a6f7795b5e80ce70122479f2ef31586 (patch)
tree2af089980e448cc2cf6ae01d884acb23f26f6d88 /apps
parent7272d1e7473fc1ce1d0a29c7287260402ca2420e (diff)
downloadnuttx-049b66a75a6f7795b5e80ce70122479f2ef31586.tar.gz
nuttx-049b66a75a6f7795b5e80ce70122479f2ef31586.tar.bz2
nuttx-049b66a75a6f7795b5e80ce70122479f2ef31586.zip
Fix an error handling bug in the fread logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5511 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps')
-rw-r--r--apps/examples/posix_spawn/Makefile27
-rw-r--r--apps/examples/posix_spawn/filesystem/Makefile16
-rw-r--r--apps/examples/posix_spawn/spawn_main.c16
3 files changed, 44 insertions, 15 deletions
diff --git a/apps/examples/posix_spawn/Makefile b/apps/examples/posix_spawn/Makefile
index bda3376d2..0bfa36e55 100644
--- a/apps/examples/posix_spawn/Makefile
+++ b/apps/examples/posix_spawn/Makefile
@@ -105,7 +105,26 @@ distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-# There are no dependencies in this directory. We should are code some of
-# more important dependencies here:
-
--include Make.dep
+# There are no dependencies in this directory. Some of more important
+# and more obvious dependencies are hard-coded here:
+
+spawn_main.o: spawn_main.c \
+ $(TOPDIR)/include/nuttx/config.h \
+ $(TOPDIR)/include/nuttx/compiler.h \
+ $(TOPDIR)/include/sys/mount.h \
+ $(TOPDIR)/include/stdio.h \
+ $(TOPDIR)/include/stdlib.h \
+ $(TOPDIR)/include/unistd.h \
+ $(TOPDIR)/include/string.h \
+ $(TOPDIR)/include/fcntl.h \
+ $(TOPDIR)/include/spawn.h \
+ $(TOPDIR)/include/debug.h \
+ $(TOPDIR)/include/errno.h \
+ $(TOPDIR)/include/nuttx/ramdisk.h \
+ $(TOPDIR)/include/nuttx/binfmt/elf.h \
+ $(TOPDIR)/include/nuttx/binfmt/symtab.h \
+ filesystem/romfs.h
+
+symtab.o: filesystem/symtab.c \
+ $(TOPDIR)/include/nuttx/compiler.h \
+ $(TOPDIR)/include/nuttx/binfmt/symtab.h
diff --git a/apps/examples/posix_spawn/filesystem/Makefile b/apps/examples/posix_spawn/filesystem/Makefile
index 2005d060f..26897426c 100644
--- a/apps/examples/posix_spawn/filesystem/Makefile
+++ b/apps/examples/posix_spawn/filesystem/Makefile
@@ -44,7 +44,7 @@ ROMFS_HDR = $(FILESYSTEM_DIR)$(DELIM)romfs.h
SYMTAB_SRC = $(FILESYSTEM_DIR)$(DELIM)symtab.c
all: $(ROMFS_HDR) $(SYMTAB_SRC)
-.PHONY: all hello redirect clean install populate
+.PHONY: all hello/hello redirect/redirect clean populate
# Create the romfs directory
@@ -53,24 +53,20 @@ $(ROMFS_DIR):
# Build the hello test program
-hello: $(ROMFS_DIR)
+hello/hello:
$(Q) $(MAKE) -C hello hello TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
# Build the redirection test program
-redirect: $(ROMFS_DIR)
+redirect/redirect:
$(Q) $(MAKE) -C redirect redirect TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
-# Install the test programs in the romfs directory
+# Create the romfs.img file from the romfs directory
-install: hello redirect testdata.txt
+$(ROMFS_IMG): hello/hello redirect/redirect testdata.txt $(ROMFS_DIR)
$(Q) $(MAKE) -C hello install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
$(Q) $(MAKE) -C redirect install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
$(Q) install --mode=0644 testdata.txt $(ROMFS_DIR)/testdata.txt
-
-# Create the romfs.img file from the romfs directory
-
-$(ROMFS_IMG): install
$(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "POSIXSPAWN"
# Create the romfs.h header file from the romfs.img file
@@ -80,7 +76,7 @@ $(ROMFS_HDR) : $(ROMFS_IMG)
# Create the exported symbol table
-$(SYMTAB_SRC): hello/hello redirect/redirect testdata.txt
+$(SYMTAB_SRC): $(ROMFS_DIR)/hello $(ROMFS_DIR)/redirect $(ROMFS_DIR)/testdata.txt
$(Q) $(FILESYSTEM_DIR)$(DELIM)mksymtab.sh $(ROMFS_DIR) >$@
# Clean each subdirectory
diff --git a/apps/examples/posix_spawn/spawn_main.c b/apps/examples/posix_spawn/spawn_main.c
index 6f8859516..1506fe499 100644
--- a/apps/examples/posix_spawn/spawn_main.c
+++ b/apps/examples/posix_spawn/spawn_main.c
@@ -89,6 +89,15 @@
# error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file"
#endif
+/* The redirection test does not work. This is because it tries to redirect
+ * file as stdin. That won't work now because (1) the file descriptors must
+ * be dup'ed when the new task is created, and (2) there is no support in
+ * place for dup'ing file descriptors for anything other than sockets and
+ * character drivers. This is a bug!
+ */
+
+#define FILE_DUP_BUG 1
+
/* Describe the ROMFS file system */
#define SECTORSIZE 512
@@ -138,7 +147,9 @@ static unsigned int g_mmstep; /* Memory Usage at beginning of test step */
static const char delimiter[] =
"****************************************************************************";
+#ifndef FILE_DUP_BUG
static const char g_redirect[] = "redirect";
+#endif
static const char g_hello[] = "hello";
static const char g_data[] = "testdata.txt";
@@ -361,9 +372,11 @@ int spawn_main(int argc, char *argv[])
mm_update(&g_mmstep, "after file_action/attr destruction");
/*************************************************************************
- * Case 2: Simple program with redirection of stdin
+ * Case 2: Simple program with redirection of stdin to a file input
*************************************************************************/
+#ifndef FILE_DUP_BUG
+
/* Output a seperated so that we can clearly discriminate the output of
* this program from the others.
*/
@@ -450,6 +463,7 @@ int spawn_main(int argc, char *argv[])
posix_spawnattr_dump(&attr);
mm_update(&g_mmstep, "after file_action/attr destruction");
+#endif
/* Clean-up */