vold_err.c revision ace1a5f11236a072fca1b5e0ea1416a083a9f2aa
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <time.h>
#include <syslog.h>
#include <errno.h>
#include <string.h>
#include <thread.h>
#include <synch.h>
#include "vold.h"
/* flags to errmsg() */
#define ER_STDERR 0x1
#define ER_SYSLOG 0x2
#define ER_NOSTAMP 0x4
#define FATALMSG "fatal: "
#define QUITMSG "exiting: "
#define WARNMSG "warning: "
#define INFOMSG "info: "
#define DEBUGMSG "debug[%d]: "
#define NFSTRMSG "unfs: "
#define DEBUGMSG_LEN 128
void
{
#ifdef NEED_ALL_LOG_INFO
int fflags;
#endif
/* let's init our mutex here (since there's no better place) */
/* open the logfile */
}
/* set logfile mode to "rw-r--r--" */
perror("vold failed to chmod logfile");
}
#ifdef NEED_ALL_LOG_INFO
/* for debugging, set the "FLUSH" bit using fcntl */
} else {
} else {
"DEBUG: just set O_SYNC flag for \"%s\"\n",
path);
}
}
#endif /* NEED_ALL_LOG_INFO */
}
void
flushlog()
{
/* keep this REALLY simple because it's called on SEGV, et. al */
}
void
{
(void) mutex_lock(&err_mutex);
(void) mutex_unlock(&err_mutex);
exit(-1);
}
void
{
(void) mutex_lock(&err_mutex);
(void) mutex_unlock(&err_mutex);
exit(0);
}
void
{
(void) mutex_lock(&err_mutex);
(void) mutex_unlock(&err_mutex);
}
void
{
extern int verbose;
int flag = 0;
if (verbose) {
}
(void) mutex_lock(&err_mutex);
(void) mutex_unlock(&err_mutex);
}
void
{
extern int verbose;
if (verbose == 0) {
return;
}
(void) mutex_lock(&err_mutex);
(void) mutex_unlock(&err_mutex);
}
void
{
extern int debug_level;
char dbgmsg[DEBUGMSG_LEN];
if (level > debug_level) {
return;
}
(void) mutex_lock(&err_mutex);
(void) mutex_unlock(&err_mutex);
}
void
{
extern int trace;
if (trace == 0) {
return;
}
(void) mutex_lock(&err_mutex);
(void) mutex_unlock(&err_mutex);
}
/*ARGSUSED*/
void
dbxtrap(const char *s)
{
#ifndef lint
int a = 0;
#endif
}
/*
* this routine must *NOT* be void, since the ASSERT() macro in vold.h
* doesn't like that
*/
int
failass(char *a, char *f, int l)
{
int do_fatal = 1;
dbxtrap("assertion failed");
if (do_fatal) {
fatal("assertion failed: %s, file: %s, line: %d\n", a, f, l);
}
return (0);
}
static void
{
const char *p;
char *errmsg;
char *s;
time_t t;
#ifdef DEBUG
#else
#endif
}
if ((flags & ER_NOSTAMP) == 0) {
/* stick the time into the msg */
(void) time(&t);
#ifdef DEBUG
(void) localtime_r(&t, &tm);
#else
s[24] = ' ';
#endif
/* stick our tag into the msg */
}
/* scan for %m and replace with errno msg */
p = fmt;
while (*p != NULLC) {
if ((*p == '%') && (*(p+1) == 'm')) {
p += 2;
continue;
}
*s++ = *p++;
}
*s = '\0'; /* don't forget the null byte */
/* write off to log file */
/* write to stderr */
}
/* write to syslog (already opened in main()) */
}
}