libs/unistd and other affected files: Hostname support no longer depends on CONFIG_NET since the host name is also useful in the non-network environment. CONFIG_NET_HOSTNAME changed to CONFIG_LIB_HOSTNAME.

This commit is contained in:
Xiang Xiao
2019-01-27 06:56:16 -06:00
committed by Gregory Nutt
parent c40daffb5b
commit 16850297f3
45 changed files with 67 additions and 92 deletions
+1 -1
View File
@@ -47,7 +47,7 @@
"ftell","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","long","FAR FILE *"
"fwrite","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","size_t","FAR const void *","size_t","size_t","FAR FILE *"
"getcwd","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON)","FAR char","FAR char *","size_t"
"gethostname","unistd.h","defined(CONFIG_LIBC_NETDB)","int","FAR char*","size_t"
"gethostname","unistd.h","","int","FAR char*","size_t"
"getopt","unistd.h","","int","int","FAR char *const[]","FAR const char *"
"getoptargp","unistd.h","","FAR char *"
"getoptindp","unistd.h","","int"
1 _inet_ntoa arpa/inet.h defined(CONFIG_NET_IPv4) && !defined(CONFIG_CAN_PASS_STRUCTS) FAR char in_addr_t
47 ftell stdio.h CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 long FAR FILE *
48 fwrite stdio.h CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 size_t FAR const void *
49 getcwd unistd.h CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON) FAR char FAR char *
50 gethostname unistd.h defined(CONFIG_LIBC_NETDB) int FAR char*
51 getopt unistd.h int int
52 getoptargp unistd.h FAR char *
53 getoptindp unistd.h int
-5
View File
@@ -99,7 +99,6 @@ int uname(FAR struct utsname *name)
strncpy(name->sysname, "NuttX", SYS_NAMELEN);
#ifdef CONFIG_LIBC_NETDB
/* Get the hostname */
if (-1 == gethostname(name->nodename, HOST_NAME_MAX))
@@ -109,10 +108,6 @@ int uname(FAR struct utsname *name)
name->nodename[HOST_NAME_MAX-1] = '\0';
#else
strncpy(name->nodename, "", HOST_NAME_MAX);
#endif
strncpy(name->release, CONFIG_VERSION_STRING, SYS_NAMELEN);
name->release[SYS_NAMELEN-1] = '\0';
+6
View File
@@ -99,3 +99,9 @@ config TASK_SPAWN_DEFAULT_STACKSIZE
Default: 2048.
endmenu # Program Execution Options
config LIB_HOSTNAME
string "Host name for this device"
default ""
---help---
A unique name to identify device on the network
-2
View File
@@ -60,9 +60,7 @@ ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CSRCS += lib_sleep.c lib_usleep.c
endif
ifeq ($(CONFIG_NET),y)
CSRCS += lib_gethostname.c lib_sethostname.c
endif
# Add the unistd directory to the build
+3 -9
View File
@@ -47,10 +47,6 @@
#include <nuttx/irq.h>
/* This file is only compiled if network support is enabled */
#ifdef CONFIG_NET
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -59,8 +55,8 @@
* changed via sethostname(), however.
*/
#ifndef CONFIG_NET_HOSTNAME
# define CONFIG_NET_HOSTNAME ""
#ifndef CONFIG_LIB_HOSTNAME
# define CONFIG_LIB_HOSTNAME ""
#endif
/****************************************************************************
@@ -69,7 +65,7 @@
/* This is the system hostname */
char g_hostname[HOST_NAME_MAX + 1] = CONFIG_NET_HOSTNAME;
char g_hostname[HOST_NAME_MAX + 1] = CONFIG_LIB_HOSTNAME;
/****************************************************************************
* Public Functions
@@ -145,5 +141,3 @@ int gethostname(FAR char *name, size_t namelen)
#endif
}
#endif /* CONFIG_NET */
-5
View File
@@ -46,10 +46,6 @@
#include <nuttx/irq.h>
/* This file is only compiled if network support is enabled */
#ifdef CONFIG_NET
/* Further, in the protected and kernel build modes where kernel and
* application code are separated, the hostname is a common system property
* and must reside only in the kernel. In that case, this accessor
@@ -128,5 +124,4 @@ int sethostname(FAR const char *name, size_t size)
return 0;
}
#endif /* CONFIG_NET */
#endif /* (!CONFIG_BUILD_PROTECTED && !CONFIG_BUILD_KERNEL) || __KERNEL__ */