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
This commit is contained in:
parent
b236e229c9
commit
fc822d98e5
@ -105,7 +105,26 @@ distclean: clean
|
|||||||
$(call DELFILE, Make.dep)
|
$(call DELFILE, Make.dep)
|
||||||
$(call DELFILE, .depend)
|
$(call DELFILE, .depend)
|
||||||
|
|
||||||
# There are no dependencies in this directory. We should are code some of
|
# There are no dependencies in this directory. Some of more important
|
||||||
# more important dependencies here:
|
# and more obvious dependencies are hard-coded here:
|
||||||
|
|
||||||
-include Make.dep
|
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
|
||||||
|
@ -44,7 +44,7 @@ ROMFS_HDR = $(FILESYSTEM_DIR)$(DELIM)romfs.h
|
|||||||
SYMTAB_SRC = $(FILESYSTEM_DIR)$(DELIM)symtab.c
|
SYMTAB_SRC = $(FILESYSTEM_DIR)$(DELIM)symtab.c
|
||||||
|
|
||||||
all: $(ROMFS_HDR) $(SYMTAB_SRC)
|
all: $(ROMFS_HDR) $(SYMTAB_SRC)
|
||||||
.PHONY: all hello redirect clean install populate
|
.PHONY: all hello/hello redirect/redirect clean populate
|
||||||
|
|
||||||
# Create the romfs directory
|
# Create the romfs directory
|
||||||
|
|
||||||
@ -53,24 +53,20 @@ $(ROMFS_DIR):
|
|||||||
|
|
||||||
# Build the hello test program
|
# Build the hello test program
|
||||||
|
|
||||||
hello: $(ROMFS_DIR)
|
hello/hello:
|
||||||
$(Q) $(MAKE) -C hello hello TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
|
$(Q) $(MAKE) -C hello hello TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
|
||||||
|
|
||||||
# Build the redirection test program
|
# Build the redirection test program
|
||||||
|
|
||||||
redirect: $(ROMFS_DIR)
|
redirect/redirect:
|
||||||
$(Q) $(MAKE) -C redirect redirect TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
|
$(Q) $(MAKE) -C redirect redirect TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
|
||||||
|
|
||||||
# Install the test programs in the romfs directory
|
|
||||||
|
|
||||||
install: hello redirect testdata.txt
|
|
||||||
$(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
|
# Create the romfs.img file from the romfs directory
|
||||||
|
|
||||||
$(ROMFS_IMG): install
|
$(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
|
||||||
$(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "POSIXSPAWN"
|
$(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "POSIXSPAWN"
|
||||||
|
|
||||||
# Create the romfs.h header file from the romfs.img file
|
# Create the romfs.h header file from the romfs.img file
|
||||||
@ -80,7 +76,7 @@ $(ROMFS_HDR) : $(ROMFS_IMG)
|
|||||||
|
|
||||||
# Create the exported symbol table
|
# 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) >$@
|
$(Q) $(FILESYSTEM_DIR)$(DELIM)mksymtab.sh $(ROMFS_DIR) >$@
|
||||||
|
|
||||||
# Clean each subdirectory
|
# Clean each subdirectory
|
||||||
|
@ -89,6 +89,15 @@
|
|||||||
# error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file"
|
# error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file"
|
||||||
#endif
|
#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 */
|
/* Describe the ROMFS file system */
|
||||||
|
|
||||||
#define SECTORSIZE 512
|
#define SECTORSIZE 512
|
||||||
@ -138,7 +147,9 @@ static unsigned int g_mmstep; /* Memory Usage at beginning of test step */
|
|||||||
|
|
||||||
static const char delimiter[] =
|
static const char delimiter[] =
|
||||||
"****************************************************************************";
|
"****************************************************************************";
|
||||||
|
#ifndef FILE_DUP_BUG
|
||||||
static const char g_redirect[] = "redirect";
|
static const char g_redirect[] = "redirect";
|
||||||
|
#endif
|
||||||
static const char g_hello[] = "hello";
|
static const char g_hello[] = "hello";
|
||||||
static const char g_data[] = "testdata.txt";
|
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");
|
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
|
/* Output a seperated so that we can clearly discriminate the output of
|
||||||
* this program from the others.
|
* this program from the others.
|
||||||
*/
|
*/
|
||||||
@ -450,6 +463,7 @@ int spawn_main(int argc, char *argv[])
|
|||||||
posix_spawnattr_dump(&attr);
|
posix_spawnattr_dump(&attr);
|
||||||
|
|
||||||
mm_update(&g_mmstep, "after file_action/attr destruction");
|
mm_update(&g_mmstep, "after file_action/attr destruction");
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Clean-up */
|
/* Clean-up */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user