[PATCH 2/9] tftpfs: Always build TFTP client
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Apr 30 09:48:10 UTC 2018
Move TFTP client filesystem to separate library libtftpfs.a.
Conditionally use legacy network stack features, e.g. BOOTP support.
Update #3419.
---
cpukit/headers.am | 1 +
cpukit/{libnetworking => include}/rtems/tftp.h | 0
cpukit/libnetworking/Makefile.am | 10 +++++++++-
cpukit/libnetworking/headers.am | 1 -
cpukit/libnetworking/lib/tftpDriver.c | 18 ++++++++++++++----
5 files changed, 24 insertions(+), 6 deletions(-)
rename cpukit/{libnetworking => include}/rtems/tftp.h (100%)
diff --git a/cpukit/headers.am b/cpukit/headers.am
index dbd1273095..048cef6d83 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -190,6 +190,7 @@ include_rtems_HEADERS += include/rtems/termios_printk.h
include_rtems_HEADERS += include/rtems/termios_printk_cnf.h
include_rtems_HEADERS += include/rtems/termiostypes.h
include_rtems_HEADERS += include/rtems/test.h
+include_rtems_HEADERS += include/rtems/tftp.h
include_rtems_HEADERS += include/rtems/thread.h
include_rtems_HEADERS += include/rtems/timecounter.h
include_rtems_HEADERS += include/rtems/timespec.h
diff --git a/cpukit/libnetworking/rtems/tftp.h b/cpukit/include/rtems/tftp.h
similarity index 100%
rename from cpukit/libnetworking/rtems/tftp.h
rename to cpukit/include/rtems/tftp.h
diff --git a/cpukit/libnetworking/Makefile.am b/cpukit/libnetworking/Makefile.am
index 3ab9a274e6..1f6be15312 100644
--- a/cpukit/libnetworking/Makefile.am
+++ b/cpukit/libnetworking/Makefile.am
@@ -1,6 +1,14 @@
include $(top_srcdir)/automake/multilib.am
include $(top_srcdir)/automake/compile.am
+project_lib_LIBRARIES =
+TMPINSTALL_FILES =
+
+project_lib_LIBRARIES += libtftpfs.a
+libtftpfs_a_SOURCES = lib/tftpDriver.c
+$(PROJECT_LIB)/libtftpfs.a: libtftpfs.a
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/libtftpfs.a
+TMPINSTALL_FILES += $(PROJECT_LIB)/libtftpfs.a
# poll is not supported
UNUSED_FILES = poll.h
@@ -127,7 +135,7 @@ noinst_LIBRARIES += lib.a
lib_a_CPPFLAGS = $(AM_CPPFLAGS) $(lib_CPPFLAGS) -D__BSD_VISIBLE
lib_a_SOURCES = lib/getprotoby.c lib/rtems_bsdnet_ntp.c lib/ftpfs.c \
- lib/syslog.c lib/tftpDriver.c
+ lib/syslog.c
lib_a_SOURCES += rtems/rtems_syscall_api.c
endif
diff --git a/cpukit/libnetworking/headers.am b/cpukit/libnetworking/headers.am
index b4532e4089..ce4c7c77e0 100644
--- a/cpukit/libnetworking/headers.am
+++ b/cpukit/libnetworking/headers.am
@@ -115,7 +115,6 @@ include_rtems_HEADERS += rtems/rtems_mii_ioctl.h
include_rtems_HEADERS += rtems/rtems_netdb.h
include_rtems_HEADERS += rtems/rtems_netinet_in.h
include_rtems_HEADERS += rtems/rtems_syscall.h
-include_rtems_HEADERS += rtems/tftp.h
include_rtems_bsdnetdir = $(includedir)/rtems/bsdnet
include_rtems_bsdnet_HEADERS =
diff --git a/cpukit/libnetworking/lib/tftpDriver.c b/cpukit/libnetworking/lib/tftpDriver.c
index 97c9998aec..514f931b13 100644
--- a/cpukit/libnetworking/lib/tftpDriver.c
+++ b/cpukit/libnetworking/lib/tftpDriver.c
@@ -28,7 +28,6 @@
#include <rtems.h>
#include <rtems/libio_.h>
#include <rtems/seterr.h>
-#include <rtems/rtems_bsdnet.h>
#include <rtems/tftp.h>
#include <rtems/thread.h>
#include <sys/types.h>
@@ -37,6 +36,10 @@
#include <arpa/inet.h>
#include <netdb.h>
+#ifdef RTEMS_NETWORKING
+#include <rtems/rtems_bsdnet.h>
+#endif
+
#ifdef RTEMS_TFTP_DRIVER_DEBUG
int rtems_tftp_driver_debug = 1;
#endif
@@ -537,9 +540,11 @@ static int rtems_tftp_open_worker(
*/
hostname = full_path_name;
cp1 = strchr (full_path_name, ':');
- if (!cp1)
+ if (!cp1) {
+#ifdef RTEMS_NETWORKING
hostname = "BOOTP_HOST";
- else {
+#endif
+ } else {
*cp1 = '\0';
++cp1;
}
@@ -547,9 +552,12 @@ static int rtems_tftp_open_worker(
/*
* Convert hostname to Internet address
*/
+#ifdef RTEMS_NETWORKING
if (strcmp (hostname, "BOOTP_HOST") == 0)
farAddress = rtems_bsdnet_bootp_server_address;
- else if (inet_aton (hostname, &farAddress) == 0) {
+ else
+#endif
+ if (inet_aton (hostname, &farAddress) == 0) {
struct hostent *he = gethostbyname(hostname);
if (he == NULL)
return ENOENT;
@@ -559,9 +567,11 @@ static int rtems_tftp_open_worker(
/*
* Extract file pathname component
*/
+#ifdef RTEMS_NETWORKING
if (strcmp (cp1, "BOOTP_FILE") == 0) {
cp1 = rtems_bsdnet_bootp_boot_file_name;
}
+#endif
if (*cp1 == '\0')
return ENOENT;
remoteFilename = cp1;
--
2.12.3
More information about the devel
mailing list