1*10652SHyon.Kim@Sun.COM /* 2*10652SHyon.Kim@Sun.COM * CDDL HEADER START 3*10652SHyon.Kim@Sun.COM * 4*10652SHyon.Kim@Sun.COM * The contents of this file are subject to the terms of the 5*10652SHyon.Kim@Sun.COM * Common Development and Distribution License (the "License"). 6*10652SHyon.Kim@Sun.COM * You may not use this file except in compliance with the License. 7*10652SHyon.Kim@Sun.COM * 8*10652SHyon.Kim@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*10652SHyon.Kim@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*10652SHyon.Kim@Sun.COM * See the License for the specific language governing permissions 11*10652SHyon.Kim@Sun.COM * and limitations under the License. 12*10652SHyon.Kim@Sun.COM * 13*10652SHyon.Kim@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*10652SHyon.Kim@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*10652SHyon.Kim@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*10652SHyon.Kim@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*10652SHyon.Kim@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*10652SHyon.Kim@Sun.COM * 19*10652SHyon.Kim@Sun.COM * CDDL HEADER END 20*10652SHyon.Kim@Sun.COM */ 21*10652SHyon.Kim@Sun.COM 22*10652SHyon.Kim@Sun.COM /* 23*10652SHyon.Kim@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24*10652SHyon.Kim@Sun.COM * Use is subject to license terms. 25*10652SHyon.Kim@Sun.COM */ 26*10652SHyon.Kim@Sun.COM 27*10652SHyon.Kim@Sun.COM #include <stdio.h> 28*10652SHyon.Kim@Sun.COM #include <sys/types.h> 29*10652SHyon.Kim@Sun.COM #include <sys/varargs.h> 30*10652SHyon.Kim@Sun.COM #include <errno.h> 31*10652SHyon.Kim@Sun.COM #include <string.h> 32*10652SHyon.Kim@Sun.COM 33*10652SHyon.Kim@Sun.COM #include <sun_sas.h> 34*10652SHyon.Kim@Sun.COM 35*10652SHyon.Kim@Sun.COM #define MAX_LOG_LEN 2048 36*10652SHyon.Kim@Sun.COM 37*10652SHyon.Kim@Sun.COM void 38*10652SHyon.Kim@Sun.COM log( 39*10652SHyon.Kim@Sun.COM int level, 40*10652SHyon.Kim@Sun.COM const char *routine, 41*10652SHyon.Kim@Sun.COM char *msg, 42*10652SHyon.Kim@Sun.COM ... 43*10652SHyon.Kim@Sun.COM ) 44*10652SHyon.Kim@Sun.COM { 45*10652SHyon.Kim@Sun.COM char header[MAX_LOG_LEN+1]; 46*10652SHyon.Kim@Sun.COM char message[MAX_LOG_LEN+1]; 47*10652SHyon.Kim@Sun.COM int oldErrno = 0; 48*10652SHyon.Kim@Sun.COM va_list ap; 49*10652SHyon.Kim@Sun.COM 50*10652SHyon.Kim@Sun.COM oldErrno = errno; 51*10652SHyon.Kim@Sun.COM 52*10652SHyon.Kim@Sun.COM (void) memset(&header, 0, MAX_LOG_LEN+1); 53*10652SHyon.Kim@Sun.COM (void) memset(&message, 0, MAX_LOG_LEN+1); 54*10652SHyon.Kim@Sun.COM 55*10652SHyon.Kim@Sun.COM va_start(ap, msg); 56*10652SHyon.Kim@Sun.COM (void) snprintf(header, MAX_LOG_LEN, "%s: %s: %s", 57*10652SHyon.Kim@Sun.COM "SM-HBA Sun SAS VSL", routine, msg); 58*10652SHyon.Kim@Sun.COM 59*10652SHyon.Kim@Sun.COM /* LINTED E_SEC_PRINTF_VAR_FMT */ 60*10652SHyon.Kim@Sun.COM (void) vsnprintf(message, MAX_LOG_LEN, header, ap); 61*10652SHyon.Kim@Sun.COM 62*10652SHyon.Kim@Sun.COM /* LINTED E_SEC_PRINTF_VAR_FMT */ 63*10652SHyon.Kim@Sun.COM syslog(level, message); 64*10652SHyon.Kim@Sun.COM 65*10652SHyon.Kim@Sun.COM va_end(ap); 66*10652SHyon.Kim@Sun.COM 67*10652SHyon.Kim@Sun.COM errno = oldErrno; 68*10652SHyon.Kim@Sun.COM } 69