From 323084f32fba6d6fb7039cad923119e532463909 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 8 Oct 2014 19:37:10 -0600 Subject: [PATCH] Add syslog system calls --- ChangeLog | 7 ++++--- include/sys/syscall.h | 26 ++++++++++++++++---------- include/syslog.h | 19 ++++++++++++++++--- libc/libc.csv | 1 - syscall/syscall.csv | 3 +++ syscall/syscall_lookup.h | 6 ++++++ syscall/syscall_stublookup.c | 11 +++++++++++ 7 files changed, 56 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71a512192b..c9c5d8a2ee 100755 --- a/ChangeLog +++ b/ChangeLog @@ -8802,6 +8802,7 @@ * drivers/: Correct everything under nuttx/drivers, nuttx/arch, nuttx/net, nuttx/binfmt, and nuttx/configs to use the corrected syslog interfaces (2014-10-8). - * libc/syslog: Move syslog logic from libc/misc and libc/stdio to - libc/syslog (2014-10-8). - + * libc/syslog and fs/syslog: Move syslog logic from libc/misc and + libc/stdio to libc/syslog and fs/syslog. Also move some syslog logic + from fs/driver to fs/syslog (2014-10-8). + * fs/syslog/fs_syslogmask.c: Implement syslogmask() (2014-10-8). diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 755162a744..503044665d 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -82,23 +82,29 @@ #define SYS_sched_yield (CONFIG_SYS_RESERVED+12) #define SYS_set_errno (CONFIG_SYS_RESERVED+13) +/* SYSLOG */ + +#define SYS_vsyslog (CONFIG_SYS_RESERVED+14) +#define SYS_lowvsyslog (CONFIG_SYS_RESERVED+15) +#define SYS_setlogmask (CONFIG_SYS_RESERVED+16) + /* Semaphores */ -#define SYS_sem_destroy (CONFIG_SYS_RESERVED+14) -#define SYS_sem_post (CONFIG_SYS_RESERVED+15) -#define SYS_sem_timedwait (CONFIG_SYS_RESERVED+16) -#define SYS_sem_trywait (CONFIG_SYS_RESERVED+17) -#define SYS_sem_wait (CONFIG_SYS_RESERVED+18) +#define SYS_sem_destroy (CONFIG_SYS_RESERVED+17) +#define SYS_sem_post (CONFIG_SYS_RESERVED+18) +#define SYS_sem_timedwait (CONFIG_SYS_RESERVED+19) +#define SYS_sem_trywait (CONFIG_SYS_RESERVED+20) +#define SYS_sem_wait (CONFIG_SYS_RESERVED+21) /* Named semaphores */ #ifdef CONFIG_FS_NAMED_SEMAPHORES -# define SYS_sem_open (CONFIG_SYS_RESERVED+19) -# define SYS_sem_close (CONFIG_SYS_RESERVED+20) -# define SYS_sem_unlink (CONFIG_SYS_RESERVED+21) -# define __SYS_task_create (CONFIG_SYS_RESERVED+22) +# define SYS_sem_open (CONFIG_SYS_RESERVED+22) +# define SYS_sem_close (CONFIG_SYS_RESERVED+23) +# define SYS_sem_unlink (CONFIG_SYS_RESERVED+24) +# define __SYS_task_create (CONFIG_SYS_RESERVED+25) #else -# define __SYS_task_create (CONFIG_SYS_RESERVED+19) +# define __SYS_task_create (CONFIG_SYS_RESERVED+22) #endif /* Task creation APIs based on global entry points cannot be use with diff --git a/include/syslog.h b/include/syslog.h index e57595fe1b..3922320e47 100644 --- a/include/syslog.h +++ b/include/syslog.h @@ -49,6 +49,19 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +/* Configuration ************************************************************/ +/* Some interfaces in this file are currently only available within the + * kernel. They could are available to applicaions in the flat build and + * could be made available in the protected and kernel builds IF system + * calls were added. + */ + +#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL) +# undef __KERNEL__ +# define __KERNEL__ 1 +#endif + +/* syslog interface *********************************************************/ /* The option argument to openlog() is an OR of any of these: * * LOG_CONS - Write directly to system console if there is an error @@ -136,7 +149,7 @@ void closelog(void); int syslog(int priority, FAR const char *format, ...); int vsyslog(int priority, FAR const char *src, va_list ap); -#ifdef CONFIG_ARCH_LOWPUTC /* Non-standard */ +#ifdef CONFIG_ARCH_LOWPUTC /* These are non-standard, low-level system logging interface. The * difference between syslog() and lowsyslog() is that the syslog() * interface writes to the syslog device (usually fd=1, stdout) whereas @@ -167,9 +180,9 @@ int lowvsyslog(int priority, FAR const char *format, va_list ap); int setlogmask(int mask); -/* Enable or disable syslog output */ +#if defined(CONFIG_SYSLOG_ENABLE) && defined(__KERNEL__) +/* Non-standard interface to enable or disable syslog output */ -#ifdef CONFIG_SYSLOG_ENABLE /* Non-standard */ void syslog_enable(bool enable); #endif diff --git a/libc/libc.csv b/libc/libc.csv index e384e69f3a..054cf3a74c 100644 --- a/libc/libc.csv +++ b/libc/libc.csv @@ -156,7 +156,6 @@ "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 *","..." -"syslog_enable","syslog.h","defined(CONFIG_SYSLOG_ENABLE)","void","bool" "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/syscall/syscall.csv b/syscall/syscall.csv index 1831c652cd..58c3320fc3 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -29,6 +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" "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" @@ -118,6 +119,7 @@ "sendto","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR const void*","size_t","int","FAR const struct sockaddr*","socklen_t" "set_errno","errno.h","","void","int" "setenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int","const char*","const char*","int" +"setlogmask","syslog.h","","int","int" "setsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR const void*","socklen_t" "shmat", "sys/shm.h", "defined(CONFIG_MM_SHM)", "FAR void *", "int", "FAR const void *", "int" "shmctl", "sys/shm.h", "defined(CONFIG_MM_SHM)", "int", "int", "int", "FAR struct shmid_ds *" @@ -150,6 +152,7 @@ "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 1c640d0b39..c8735f14b5 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -58,6 +58,12 @@ SYSCALL_LOOKUP(sched_unlock, 0, STUB_sched_unlock) SYSCALL_LOOKUP(sched_yield, 0, STUB_sched_yield) SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno) +/* SYSLOG */ + +SYSCALL_LOOKUP(vsyslog, 3, SYS_vsyslog) +SYSCALL_LOOKUP(lowvsyslog, 3, SYS_lowvsyslog) +SYSCALL_LOOKUP(setlogmask, 1, SYS_setlogmask) + /* Semaphores */ SYSCALL_LOOKUP(sem_destroy, 2, STUB_sem_destroy) diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index d0805ee66c..5e289e5e7f 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -75,6 +75,17 @@ uintptr_t STUB_sched_setscheduler(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); uintptr_t STUB_sched_unlock(int nbr); 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); + +/* Semaphores */ + uintptr_t STUB_sem_close(int nbr, uintptr_t parm1); uintptr_t STUB_sem_destroy(int nbr, uintptr_t parm1); uintptr_t STUB_sem_open(int nbr, uintptr_t parm1, uintptr_t parm2,