* Makefile.in (DLL_OFILES): Add fhandler_mailslot.o.

* devices.h (FH_KMSG): Define new device.
	* devices.in: Add "/dev/kmsg" entry.
	* devices.cc: Regenerate.
	* dtable.cc (build_fh_pc): Handle case FH_KMSG.
	* fhandler.h (class fhandler_mailslot): New class.
	(class select_stuff): Add device_specific_mailslot pointer.
	* fhandler_mailslot.cc: New file.
	* select.cc (peek_mailslot): New function.
	(verify_mailslot): Ditto.
	(struct mailslotinf): New stuct to handle select on mailslots.
	(thread_mailslot): New function.
	(start_thread_mailslot): Ditto.
	(mailslot_cleanup): Ditto.
	(fhandler_mailslot::select_read): New method.
	* syslog.cc (klog_guard): New muto.
	(dev_kmsg): Local mailslot for kernel message device.
	(vklog): New function.
	(klog): Ditto.
	* winsup.h (vklog): Declare.
	(klog): Ditto.
	* include/sys/syslog.h: Define _PATH_KLOG.
This commit is contained in:
Corinna Vinschen
2005-05-10 20:56:07 +00:00
parent a586e5b6ae
commit 13505ca8fc
12 changed files with 1179 additions and 803 deletions

View File

@ -461,6 +461,38 @@ syslog (int priority, const char *message, ...)
va_end (ap);
}
static NO_COPY muto klog_guard;
fhandler_mailslot *dev_kmsg;
extern "C" void
vklog (int priority, const char *message, va_list ap)
{
/* TODO: kernel messages are under our control entirely and they should
be quick. No playing with /dev/null, but a fixed upper size for now. */
char buf[2060]; /* 2048 + a prority */
__small_sprintf (buf, "<%d>", priority);
__small_vsprintf (buf + strlen (buf), message, ap);
klog_guard.init ("klog_guard")->acquire ();
if (!dev_kmsg)
dev_kmsg = (fhandler_mailslot *) build_fh_name ("/dev/kmsg");
if (dev_kmsg && !dev_kmsg->get_handle ())
dev_kmsg->open (O_WRONLY, 0);
if (dev_kmsg && dev_kmsg->get_handle ())
dev_kmsg->write (buf, strlen (buf) + 1);
else
vsyslog (priority, message, ap);
klog_guard.release ();
}
extern "C" void
klog (int priority, const char *message, ...)
{
va_list ap;
va_start (ap, message);
vklog (priority, message, ap);
va_end (ap);
}
extern "C" void
closelog (void)
{