From bbc658930a78887fe751b3c67aa1146f30b8250c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 8 Oct 2014 20:12:52 -0600 Subject: [PATCH] Passing va_list in syscall does not work. Temporarily moved syslog and lowsyslog into kernel code and access via a system call. Need to revisit. Will probably need to move all of syslog back from fs/syslog to libc/syslog --- fs/syslog/Make.defs | 4 +- fs/syslog/{fs_syslog.c => fs_devsyslog.c} | 2 +- fs/syslog/{fs_lowvsyslog.c => fs_lowsyslog.c} | 18 +++ fs/syslog/fs_vsyslog.c | 18 +++ include/sys/syscall.h | 4 +- include/syslog.h | 30 ++++- libc/Makefile | 1 - libc/libc.csv | 2 - libc/syslog/Make.defs | 43 ------- libc/syslog/lib_lowsyslog.c | 105 ------------------ libc/syslog/lib_syslog.c | 101 ----------------- syscall/syscall.csv | 4 +- syscall/syscall_lookup.h | 4 +- syscall/syscall_stublookup.c | 10 +- 14 files changed, 78 insertions(+), 268 deletions(-) rename fs/syslog/{fs_syslog.c => fs_devsyslog.c} (99%) rename fs/syslog/{fs_lowvsyslog.c => fs_lowsyslog.c} (92%) delete mode 100644 libc/syslog/Make.defs delete mode 100644 libc/syslog/lib_lowsyslog.c delete mode 100644 libc/syslog/lib_syslog.c diff --git a/fs/syslog/Make.defs b/fs/syslog/Make.defs index 21e04e9e62..a6e92b8bf6 100644 --- a/fs/syslog/Make.defs +++ b/fs/syslog/Make.defs @@ -35,7 +35,7 @@ # Add the internal C files to the build -CSRCS += fs_vsyslog.c fs_lowvsyslog.c fs_setlogmask.c +CSRCS += fs_vsyslog.c fs_lowsyslog.c fs_setlogmask.c ifeq ($(CONFIG_SYSLOG),y) CSRCS += fs_syslogstream.c @@ -49,7 +49,7 @@ endif ifeq ($(CONFIG_SYSLOG),y) ifeq ($(CONFIG_SYSLOG_CHAR),y) -CSRCS += fs_syslog.c +CSRCS += fs_devsyslog.c endif endif diff --git a/fs/syslog/fs_syslog.c b/fs/syslog/fs_devsyslog.c similarity index 99% rename from fs/syslog/fs_syslog.c rename to fs/syslog/fs_devsyslog.c index 151f1cab9f..930c89be4c 100644 --- a/fs/syslog/fs_syslog.c +++ b/fs/syslog/fs_devsyslog.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/syslog/syslog.c + * fs/syslog/fs_devsyslog.c * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/fs/syslog/fs_lowvsyslog.c b/fs/syslog/fs_lowsyslog.c similarity index 92% rename from fs/syslog/fs_lowvsyslog.c rename to fs/syslog/fs_lowsyslog.c index 52d493a73e..3caa81d8ae 100644 --- a/fs/syslog/fs_lowvsyslog.c +++ b/fs/syslog/fs_lowsyslog.c @@ -126,4 +126,22 @@ int lowvsyslog(int priority, FAR const char *fmt, va_list ap) return ret; } +/**************************************************************************** + * Name: lowsyslog + ****************************************************************************/ + +int lowsyslog(int priority, FAR const char *fmt, ...) +{ + va_list ap; + int ret; + + /* Let lowvsyslog do the work */ + + va_start(ap, fmt); + ret = lowvsyslog(priority, fmt, ap); + va_end(ap); + + return ret; +} + #endif /* CONFIG_ARCH_LOWPUTC || CONFIG_SYSLOG */ diff --git a/fs/syslog/fs_vsyslog.c b/fs/syslog/fs_vsyslog.c index 8d49570ecf..0f4d1844ee 100644 --- a/fs/syslog/fs_vsyslog.c +++ b/fs/syslog/fs_vsyslog.c @@ -149,3 +149,21 @@ int vsyslog(int priority, FAR const char *fmt, va_list ap) return ret; } + +/**************************************************************************** + * Name: lowsyslog + ****************************************************************************/ + +int lowsyslog(int priority, FAR const char *fmt, ...) +{ + va_list ap; + int ret; + + /* Let lowvsyslog do the work */ + + va_start(ap, fmt); + ret = lowvsyslog(priority, fmt, ap); + va_end(ap); + + return ret; +} diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 503044665d..636c918e38 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -84,8 +84,8 @@ /* SYSLOG */ -#define SYS_vsyslog (CONFIG_SYS_RESERVED+14) -#define SYS_lowvsyslog (CONFIG_SYS_RESERVED+15) +#define SYS_syslog (CONFIG_SYS_RESERVED+14) +#define SYS_lowsyslog (CONFIG_SYS_RESERVED+15) #define SYS_setlogmask (CONFIG_SYS_RESERVED+16) /* Semaphores */ diff --git a/include/syslog.h b/include/syslog.h index 3922320e47..3264d3d586 100644 --- a/include/syslog.h +++ b/include/syslog.h @@ -51,9 +51,15 @@ ****************************************************************************/ /* Configuration ************************************************************/ /* Some interfaces in this file are currently only available within the - * kernel. They could are available to applicaions in the flat build and + * kernel. They could are available to applications in the flat build and * could be made available in the protected and kernel builds IF system * calls were added. + * + * REVISIT: For example, I don't yet know how to pass a va_list in a system + * call so none of those interfaces. + * + * NOTE: In protected and kernel builds, there may also be a limit to the + * number of parameters that are supported in the variable parameter list. */ #if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL) @@ -144,10 +150,15 @@ void closelog(void); * C pre-processor supports a variable number of macro arguments, then those * macros below will map all debug statements to one or the other of the * following. + * + * NOTE: In protected and kernel builds, there may be a limit to the number + * of parameter that are supported in the variable parameter list. */ int syslog(int priority, FAR const char *format, ...); +#ifdef __KERNEL__ int vsyslog(int priority, FAR const char *src, va_list ap); +#endif #ifdef CONFIG_ARCH_LOWPUTC /* These are non-standard, low-level system logging interface. The @@ -155,10 +166,16 @@ int vsyslog(int priority, FAR const char *src, va_list ap); * interface writes to the syslog device (usually fd=1, stdout) whereas * lowsyslog() uses a lower level interface that works even from interrupt * handlers. + * + * NOTE: In protected and kernel builds, there may be a limit to the number + * of parameters that are supported in the variable parameter list. */ int lowsyslog(int priority, FAR const char *format, ...); +# ifdef __KERNEL__ int lowvsyslog(int priority, FAR const char *format, va_list ap); +# endif + #else /* If the platform cannot support lowsyslog, then we will substitute the * standard syslogging functions. These will, however, probably cause @@ -171,11 +188,20 @@ int lowvsyslog(int priority, FAR const char *format, va_list ap); # else # define lowsyslog (void) # endif -# define lowvsyslog(p,f,a) vsyslog(p,f,a) +# ifdef __KERNEL__ +# define lowvsyslog(p,f,a) vsyslog(p,f,a) +# endif #endif /* The setlogmask() function sets the logmask and returns the previous * mask. If the mask argument is 0, the current logmask is not modified. + * + * REVISIT: In the current implementation, the syslog interfaces are not + * part of libc, but are part of the kernel logic. Per POSIX the syslog + * mask should be a per-process value but in this implementation it is + * a single, kernel value. This could easily fixed (at least in the + * kernel build) by simply moving all of the syslog logic back into libc + * (where it once was). */ int setlogmask(int mask); diff --git a/libc/Makefile b/libc/Makefile index b1082dd514..8412f8d884 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -65,7 +65,6 @@ include stdio/Make.defs include stdlib/Make.defs include unistd/Make.defs include sched/Make.defs -include syslog/Make.defs include string/Make.defs include aio/Make.defs include pthread/Make.defs diff --git a/libc/libc.csv b/libc/libc.csv index 054cf3a74c..4d05a2af65 100644 --- a/libc/libc.csv +++ b/libc/libc.csv @@ -65,7 +65,6 @@ "llabs","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long int","long long int" "lldbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..." "llvdbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..." -"lowsyslog","syslog.h","","int","int","FAR const char *","..." "match","nuttx/regex.h","","int","const char *","const char *" "memccpy","string.h","","FAR void","FAR void *","FAR const void *","int c","size_t" "memchr","string.h","","FAR void","FAR const void *","int c","size_t" @@ -155,7 +154,6 @@ "strtoll","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long","const char *nptr","char **endptr","int base" "strtoul","stdlib.h","","unsigned long","const char *","char **","int" "strtoull","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","unsigned long long","const char *","char **","int" -"syslog","syslog.h","","int","int","FAR const char *","..." "tcflush","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","int" "tcgetattr","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","FAR struct termios *" "tcsetattr","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","int","FAR const struct termios *" diff --git a/libc/syslog/Make.defs b/libc/syslog/Make.defs deleted file mode 100644 index 9df5c32288..0000000000 --- a/libc/syslog/Make.defs +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################ -# libc/syslog/Make.defs -# -# Copyright (C) 2014 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# 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. -# -############################################################################ - -# Add the internal C files to the build - -CSRCS += lib_syslog.c lib_lowsyslog.c - -# Add the syslog directory to the build - -DEPPATH += --dep-path syslog -VPATH += :syslog diff --git a/libc/syslog/lib_lowsyslog.c b/libc/syslog/lib_lowsyslog.c deleted file mode 100644 index 53de47aba4..0000000000 --- a/libc/syslog/lib_lowsyslog.c +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** - * libc/syslog/lib_lowsyslog.c - * - * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_SYSLOG) - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Global Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Global Constant Data - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Constant Data - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: lowsyslog - ****************************************************************************/ - -int lowsyslog(int priority, FAR const char *fmt, ...) -{ - va_list ap; - int ret; - - /* Let lowvsyslog do the work */ - - va_start(ap, fmt); - ret = lowvsyslog(priority, fmt, ap); - va_end(ap); - - return ret; -} - -#endif /* CONFIG_ARCH_LOWPUTC || CONFIG_SYSLOG */ diff --git a/libc/syslog/lib_syslog.c b/libc/syslog/lib_syslog.c deleted file mode 100644 index 16655a28c9..0000000000 --- a/libc/syslog/lib_syslog.c +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** - * libc/syslog/lib_syslog.c - * - * Copyright (C) 2007-2009, 2011-2014 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Global Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Global Constant Data - ****************************************************************************/ - -/**************************************************************************** - * Global Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Constant Data - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: syslog - ****************************************************************************/ - -int syslog(int priority, FAR const char *fmt, ...) -{ - va_list ap; - int ret; - - /* Let vsyslog do the work */ - - va_start(ap, fmt); - ret = vsyslog(priority, fmt, ap); - va_end(ap); - - return ret; -} diff --git a/syscall/syscall.csv b/syscall/syscall.csv index 58c3320fc3..dd002aa99e 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -29,7 +29,7 @@ "ioctl","sys/ioctl.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","int","int","int","unsigned long" "kill","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","pid_t","int" "listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int" -"lowvsyslog","syslog.h","","int","int","FAR const char *","va_list" +"lowsyslog","syslog.h","","int","int","FAR const char *","..." "lseek","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","off_t","int","off_t","int" "mkdir","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","mode_t" "mkfifo","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR const char*","mode_t" @@ -136,6 +136,7 @@ "stat","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","FAR struct stat*" #"statfs","stdio.h","","int","FAR const char*","FAR struct statfs*" "statfs","sys/statfs.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","struct statfs*" +"syslog","syslog.h","","int","int","FAR const char *","..." "task_create","sched.h","!defined(CONFIG_BUILD_KERNEL)", "int","FAR const char*","int","int","main_t","FAR char * const []|FAR char * const *" #"task_create","sched.h","","int","const char*","int","main_t","FAR char * const []|FAR char * const *" "task_delete","sched.h","","int","pid_t" @@ -152,7 +153,6 @@ "up_assert","assert.h","","void","FAR const uint8_t*","int" #"up_assert","assert.h","","void" "vfork","unistd.h","defined(CONFIG_ARCH_HAVE_VFORK)","pid_t" -"vsyslog","syslog.h","","int","int","FAR const char *","va_list" "wait","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","pid_t","int*" "waitid","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","int","idtype_t","id_t"," FAR siginfo_t *","int" "waitpid","sys/wait.h","defined(CONFIG_SCHED_WAITPID)","pid_t","pid_t","int*","int" diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index c8735f14b5..5a5e1a95b3 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -60,8 +60,8 @@ SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno) /* SYSLOG */ -SYSCALL_LOOKUP(vsyslog, 3, SYS_vsyslog) -SYSCALL_LOOKUP(lowvsyslog, 3, SYS_lowvsyslog) +SYSCALL_LOOKUP(syslog, 6, SYS_syslog) +SYSCALL_LOOKUP(lowsyslog, 6, SYS_lowsyslog) SYSCALL_LOOKUP(setlogmask, 1, SYS_setlogmask) /* Semaphores */ diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index 5e289e5e7f..24471c4e86 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -78,11 +78,11 @@ uintptr_t STUB_sched_yield(int nbr); /* SYSLOG */ -uintptr_t STUB_vsyslog(int nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm2); -uintptr_t STUB_lowvsyslog(int nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm2); -uintptr_t STUB_setlogmask(iint nbr, uintptr_t parm1); +uintptr_t STUB_syslog(int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); +uintptr_t STUB_lowsyslog(int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); +uintptr_t STUB_setlogmask(int nbr, uintptr_t parm1); /* Semaphores */