summaryrefslogtreecommitdiff
path: root/apps/examples/posix_spawn/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'apps/examples/posix_spawn/filesystem')
-rw-r--r--apps/examples/posix_spawn/filesystem/Makefile25
-rw-r--r--apps/examples/posix_spawn/filesystem/hello/Makefile59
-rw-r--r--apps/examples/posix_spawn/filesystem/hello/hello.c78
-rw-r--r--apps/examples/posix_spawn/filesystem/redirect/Makefile (renamed from apps/examples/posix_spawn/filesystem/program/Makefile)4
-rw-r--r--apps/examples/posix_spawn/filesystem/redirect/redirect.c (renamed from apps/examples/posix_spawn/filesystem/program/program.c)5
5 files changed, 159 insertions, 12 deletions
diff --git a/apps/examples/posix_spawn/filesystem/Makefile b/apps/examples/posix_spawn/filesystem/Makefile
index 19a02bb80..2005d060f 100644
--- a/apps/examples/posix_spawn/filesystem/Makefile
+++ b/apps/examples/posix_spawn/filesystem/Makefile
@@ -44,22 +44,28 @@ ROMFS_HDR = $(FILESYSTEM_DIR)$(DELIM)romfs.h
SYMTAB_SRC = $(FILESYSTEM_DIR)$(DELIM)symtab.c
all: $(ROMFS_HDR) $(SYMTAB_SRC)
-.PHONY: all program clean install populate
+.PHONY: all hello redirect clean install populate
# Create the romfs directory
$(ROMFS_DIR):
$(Q) mkdir $(ROMFS_DIR)
-# Build the test program
+# Build the hello test program
-program: $(ROMFS_DIR)
- $(Q) $(MAKE) -C program program TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
+hello: $(ROMFS_DIR)
+ $(Q) $(MAKE) -C hello hello TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
-# Install the test program in the romfs directory
+# Build the redirection test program
-install: program testdata.txt
- $(Q) $(MAKE) -C program install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
+redirect: $(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
@@ -74,12 +80,13 @@ $(ROMFS_HDR) : $(ROMFS_IMG)
# Create the exported symbol table
-$(SYMTAB_SRC): program
+$(SYMTAB_SRC): hello/hello redirect/redirect testdata.txt
$(Q) $(FILESYSTEM_DIR)$(DELIM)mksymtab.sh $(ROMFS_DIR) >$@
# Clean each subdirectory
clean:
- $(Q) $(MAKE) -C program clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
+ $(Q) $(MAKE) -C hello clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
+ $(Q) $(MAKE) -C redirect clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"
$(Q) rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB_SRC)
$(Q) rm -rf $(ROMFS_DIR)
diff --git a/apps/examples/posix_spawn/filesystem/hello/Makefile b/apps/examples/posix_spawn/filesystem/hello/Makefile
new file mode 100644
index 000000000..5cd80411b
--- /dev/null
+++ b/apps/examples/posix_spawn/filesystem/hello/Makefile
@@ -0,0 +1,59 @@
+############################################################################
+# examples/elf/tests/hello/Makefile
+#
+# Copyright (C) 2012 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <gnutt@nuttx.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+-include $(TOPDIR)/Make.defs
+
+BIN = hello
+
+SRCS = $(BIN).c
+OBJS = $(SRCS:.c=.o)
+
+all: $(BIN)
+
+$(OBJS): %.o: %.c
+ @echo "CC: $<"
+ $(Q) $(CC) -c $(CELFFLAGS) $< -o $@
+
+$(BIN): $(OBJS)
+ @echo "LD: $<"
+ $(Q) $(LD) $(LDELFFLAGS) -o $@ $^
+
+clean:
+ $(call DELFILE, $(BIN))
+ $(call CLEAN)
+
+install:
+ $(Q) mkdir -p $(ROMFS_DIR)
+ $(Q) install $(BIN) $(ROMFS_DIR)/$(BIN)
diff --git a/apps/examples/posix_spawn/filesystem/hello/hello.c b/apps/examples/posix_spawn/filesystem/hello/hello.c
new file mode 100644
index 000000000..1b269d85f
--- /dev/null
+++ b/apps/examples/posix_spawn/filesystem/hello/hello.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * examples/posix_spawn/filesystem/hello/hello.c
+ *
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, char **argv)
+{
+ int i;
+
+ /* Mandatory "Hello, world!" */
+
+ puts("Getting ready to say \"Hello, world\"\n");
+ printf("Hello, world!\n");
+ puts("It has been said.\n");
+
+ /* Print arguments */
+
+ printf("argc\t= %d\n", argc);
+ printf("argv\t= 0x%p\n", argv);
+
+ for (i = 0; i < argc; i++)
+ {
+ printf("argv[%d]\t= ", i);
+ if (argv[i])
+ {
+ printf("(0x%p) \"%s\"\n", argv[i], argv[i]);
+ }
+ else
+ {
+ printf("NULL?\n");
+ }
+ }
+
+ printf("argv[%d]\t= 0x%p\n", argc, argv[argc]);
+ printf("Goodbye, world!\n");
+ return 0;
+}
diff --git a/apps/examples/posix_spawn/filesystem/program/Makefile b/apps/examples/posix_spawn/filesystem/redirect/Makefile
index cf55797b2..421ff014a 100644
--- a/apps/examples/posix_spawn/filesystem/program/Makefile
+++ b/apps/examples/posix_spawn/filesystem/redirect/Makefile
@@ -1,5 +1,5 @@
############################################################################
-# examples/posix_spawn/filesystem/program/Makefile
+# examples/posix_spawn/filesystem/redirect/Makefile
#
# Copyright (C) 2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
@@ -35,7 +35,7 @@
-include $(TOPDIR)/Make.defs
-BIN = program
+BIN = redirect
SRCS = $(BIN).c
OBJS = $(SRCS:.c=.o)
diff --git a/apps/examples/posix_spawn/filesystem/program/program.c b/apps/examples/posix_spawn/filesystem/redirect/redirect.c
index f63b559c8..61638df79 100644
--- a/apps/examples/posix_spawn/filesystem/program/program.c
+++ b/apps/examples/posix_spawn/filesystem/redirect/redirect.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * examples/posix_spawn/filesystem/program/program.c
+ * examples/posix_spawn/filesystem/redirect/redirect.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -47,6 +47,8 @@ int main(int argc, char **argv)
{
int ch;
+ printf("Entering the stdin redirection test\n");
+
/* stdin should have been redirected to testdata.txt. Read and print until
* we hit the end of file.
*/
@@ -56,5 +58,6 @@ int main(int argc, char **argv)
putchar(ch);
}
+ printf("Exit-ing the stdin redirection test\n");
return 0;
}