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

This commit is contained in:
Gregory Nutt 2014-10-08 20:12:52 -06:00
parent 2673651446
commit bbc658930a
14 changed files with 78 additions and 268 deletions

View File

@ -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

View File

@ -1,5 +1,5 @@
/****************************************************************************
* fs/syslog/syslog.c
* fs/syslog/fs_devsyslog.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -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 */

View File

@ -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;
}

View File

@ -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 */

View File

@ -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);

View File

@ -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

View File

@ -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 *"

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -1,43 +0,0 @@
############################################################################
# libc/syslog/Make.defs
#
# Copyright (C) 2014 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.
#
############################################################################
# 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

View File

@ -1,105 +0,0 @@
/****************************************************************************
* libc/syslog/lib_lowsyslog.c
*
* Copyright (C) 2007-2009, 2011-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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdarg.h>
#include <syslog.h>
#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 */

View File

@ -1,101 +0,0 @@
/****************************************************************************
* libc/syslog/lib_syslog.c
*
* Copyright (C) 2007-2009, 2011-2014 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 <nuttx/config.h>
#include <stdarg.h>
#include <syslog.h>
/****************************************************************************
* 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;
}

View File

@ -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"

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -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 */

View File

@ -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 */