2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
21 #include <sys/strlog.h>
23 #include <smbsrv/smbinfo.h>
24 #include <smbsrv/smb_ioctl.h>
27 #include <libfakekernel/fakekernel.h>
29 static const char *pri_name
[LOG_DEBUG
+1] = {
30 "emerg", "alert", "crit", "err", "warning", "notice", "info", "debug"
35 * Provide a replacement for libsmb:smb_vsyslog() that just
36 * prints the messages to stdout for "fksmbd" debugging.
39 smb_vsyslog(int pri
, const char *fmt
, va_list ap
)
41 int save_errno
= errno
;
42 char buf
[SMBD_LOG_MSGSIZE
];
47 if (smbd
.s_debug
== 0 && pri
> LOG_INFO
)
50 newfmt
= smb_syslog_fmt_m(buf
, sizeof (buf
), fmt
, save_errno
);
53 (void) fprintf(stdout
, "fksmbd.%s: ", pri_name
[pri
]);
54 /* LINTED E_SEC_PRINTF_VAR_FMT */
55 (void) vfprintf(stdout
, newfmt
, ap
);
56 (void) fprintf(stdout
, "\n");
59 (void) fflush(stdout
);
63 * Provide a real function (one that prints something) to replace
64 * the stub in libfakekernel. This prints cmn_err() messages.
67 fakekernel_putlog(char *msg
, size_t len
, int flags
)
71 * [CE_CONT, CE_NOTE, CE_WARN, CE_PANIC] maps to
72 * [SL_NOTE, SL_NOTE, SL_WARN, SL_FATAL]
74 if (smbd
.s_debug
== 0 && (flags
& SL_NOTE
))
76 (void) fwrite(msg
, 1, len
, stdout
);
77 (void) fflush(stdout
);
81 * Initialization function called at the start of fksmbd:main().
82 * Call an empty function in both of libfksmbsrv, libfakekernel,
83 * just to force them to load so we can set breakpoints in them
84 * without debugger forceload tricks. This also avoids elfchk
85 * complaints from libfakekernel, which we don't call directly