Mirror of git://git.busybox.net/busybox with our patches on top
Source
/* vi: set sw=4 ts=4: */
/*
* circular buffer syslog implementation for busybox
*
* Copyright (C) 2000 by Gennady Feldman <gfeldman@gena01.com>
*
* Maintainer: Gennady Feldman <gfeldman@gena01.com> as of Mar 12, 2001
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config LOGREAD
//config: bool "logread"
//config: default y
//WRONG: it should be compilable without SYSLOG=y:
//WRONG: depends on FEATURE_IPC_SYSLOG
//config: help
//config: If you enabled Circular Buffer support, you almost
//config: certainly want to enable this feature as well. This
//config: utility will allow you to read the messages that are
//config: stored in the syslogd circular buffer.
//config:
//config:config FEATURE_LOGREAD_REDUCED_LOCKING
//config: bool "Double buffering"
//config: default y
//config: depends on LOGREAD
//config: help
//config: 'logread' ouput to slow serial terminals can have
//config: side effects on syslog because of the semaphore.
//config: This option make logread to double buffer copy
//config: from circular buffer, minimizing semaphore
//config: contention at some minor memory expense.
//config:
//applet:IF_LOGREAD(APPLET(logread, BB_DIR_SBIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_LOGREAD) += logread.o
//usage:#define logread_trivial_usage
//usage: "[-fF]"
//usage:#define logread_full_usage "\n\n"
//usage: "Show messages in syslogd's circular buffer\n"
//usage: "\n -f Output data as log grows"
//usage: "\n -F Same as -f, but dump buffer first"
/* our shared key (syslogd.c and logread.c must be in sync) */
enum { KEY_ID = 0x414e4547 }; /* "GENA" */
struct shbuf_ds {
int32_t size; // size of data - 1
int32_t tail; // end of message list
char data[1]; // messages
};
static const struct sembuf init_sem[3] = {
{0, -1, IPC_NOWAIT | SEM_UNDO},