Print this page
4211 Some syslog facility names and symbols are missing
1762 Syslogd man page: missing reference.


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*

  23  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include <sys/types.h>
  27 #include <sys/param.h>
  28 #include <sys/varargs.h>
  29 #include <sys/systm.h>
  30 #include <sys/cmn_err.h>
  31 #include <sys/stream.h>
  32 #include <sys/strsubr.h>
  33 #include <sys/strsun.h>
  34 #include <sys/sysmacros.h>
  35 #include <sys/kmem.h>
  36 #include <sys/log.h>
  37 #include <sys/spl.h>
  38 #include <sys/syslog.h>
  39 #include <sys/console.h>
  40 #include <sys/debug.h>
  41 #include <sys/utsname.h>
  42 #include <sys/id_space.h>


  56 static stdata_t log_fakestr;
  57 static id_space_t *log_minorspace;
  58 static log_t log_backlog;
  59 static struct kmem_cache *log_cons_cache;       /* log_t cache */
  60 
  61 static queue_t *log_recentq;
  62 static queue_t *log_freeq;
  63 
  64 static zone_key_t log_zone_key;
  65 
  66 static char log_overflow_msg[] = "message overflow on /dev/log minor #%d%s\n";
  67 
  68 static char log_pri[LOG_PRIMASK + 1][LOG_PRISIZE] = {
  69         "emerg",        "alert",        "crit",         "error",
  70         "warning",      "notice",       "info",         "debug"
  71 };
  72 
  73 static char log_fac[LOG_NFACILITIES + 1][LOG_FACSIZE] = {
  74         "kern",         "user",         "mail",         "daemon",
  75         "auth",         "syslog",       "lpr",          "news",
  76         "uucp",         "resv9",        "resv10",       "resv11",
  77         "resv12",       "audit",        "resv14",       "cron",
  78         "local0",       "local1",       "local2",       "local3",
  79         "local4",       "local5",       "local6",       "local7",
  80         "unknown"
  81 };
  82 static int log_cons_constructor(void *, void *, int);
  83 static void log_cons_destructor(void *, void *);
  84 
  85 /*
  86  * Get exclusive access to the logging system; this includes all minor
  87  * devices.  We use an rwlock rather than a mutex because hold times
  88  * are potentially long, so we don't want to waste cycles in adaptive mutex
  89  * spin (rwlocks always block when contended).  Note that we explicitly
  90  * support recursive calls (e.g. printf() calls foo() calls printf()).
  91  *
  92  * Clients may use log_enter() / log_exit() to guarantee that a group
  93  * of messages is treated atomically (i.e. they appear in order and are
  94  * not interspersed with any other messages), e.g. for multiline printf().
  95  *
  96  * This could probably be changed to a per-zone lock if contention becomes
  97  * an issue.




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2013 Gary Mills
  24  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
  25  */
  26 
  27 #include <sys/types.h>
  28 #include <sys/param.h>
  29 #include <sys/varargs.h>
  30 #include <sys/systm.h>
  31 #include <sys/cmn_err.h>
  32 #include <sys/stream.h>
  33 #include <sys/strsubr.h>
  34 #include <sys/strsun.h>
  35 #include <sys/sysmacros.h>
  36 #include <sys/kmem.h>
  37 #include <sys/log.h>
  38 #include <sys/spl.h>
  39 #include <sys/syslog.h>
  40 #include <sys/console.h>
  41 #include <sys/debug.h>
  42 #include <sys/utsname.h>
  43 #include <sys/id_space.h>


  57 static stdata_t log_fakestr;
  58 static id_space_t *log_minorspace;
  59 static log_t log_backlog;
  60 static struct kmem_cache *log_cons_cache;       /* log_t cache */
  61 
  62 static queue_t *log_recentq;
  63 static queue_t *log_freeq;
  64 
  65 static zone_key_t log_zone_key;
  66 
  67 static char log_overflow_msg[] = "message overflow on /dev/log minor #%d%s\n";
  68 
  69 static char log_pri[LOG_PRIMASK + 1][LOG_PRISIZE] = {
  70         "emerg",        "alert",        "crit",         "error",
  71         "warning",      "notice",       "info",         "debug"
  72 };
  73 
  74 static char log_fac[LOG_NFACILITIES + 1][LOG_FACSIZE] = {
  75         "kern",         "user",         "mail",         "daemon",
  76         "auth",         "syslog",       "lpr",          "news",
  77         "uucp",         "bsdcron",      "authpriv",     "ftp",
  78         "ntp",          "audit",        "console",      "cron",
  79         "local0",       "local1",       "local2",       "local3",
  80         "local4",       "local5",       "local6",       "local7",
  81         "unknown"
  82 };
  83 static int log_cons_constructor(void *, void *, int);
  84 static void log_cons_destructor(void *, void *);
  85 
  86 /*
  87  * Get exclusive access to the logging system; this includes all minor
  88  * devices.  We use an rwlock rather than a mutex because hold times
  89  * are potentially long, so we don't want to waste cycles in adaptive mutex
  90  * spin (rwlocks always block when contended).  Note that we explicitly
  91  * support recursive calls (e.g. printf() calls foo() calls printf()).
  92  *
  93  * Clients may use log_enter() / log_exit() to guarantee that a group
  94  * of messages is treated atomically (i.e. they appear in order and are
  95  * not interspersed with any other messages), e.g. for multiline printf().
  96  *
  97  * This could probably be changed to a per-zone lock if contention becomes
  98  * an issue.