bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [task #5490] syslog


From: Constantine Kousoulos
Subject: Re: [task #5490] syslog
Date: Mon, 29 Jan 2007 21:09:52 +0200
User-agent: Icedove 1.5.0.9 (X11/20061220)

Here is my simple translator named logrelay.

A first attempt to syslog the proc server could be the following:
--- hurd/proc/mgt.c     2003-08-17 01:19:37.000000000 +0300
+++ mymgt1.c            2007-01-29 21:04:45.000000000 +0200
@@ -18,7 +18,7 @@
        the Free Software Foundation, 675 Mass Ave, Cambridge, MA
02139,
USA.  */

        /* Written by Michael I. Bushnell.  */
-
+#include "logrelay.h"
        #include <mach.h>
        #include <sys/types.h>
        #include <sys/mman.h>
@@ -418,6 +418,8 @@
        {
          error_t err;
          struct proc *p;
+  mach_port_t dest_port;
+
          struct exc *e = ports_lookup_port (proc_bucket, excport,
exc_class);
          if (!e)
            return EOPNOTSUPP;
@@ -453,6 +455,10 @@
            default:
              /* Some unexpected error in forwarding the message.  */
              /* FALLTHROUGH */
+    dest_port=file_name_lookup("/tmp/logrelay",0,0);
+    if (dest_port!=NULL)
+       S_send_log(dest_port,"proc server",
+               "unable to forward exception message", 3, (1<<3));

            case MACH_SEND_NOTIFY_IN_PROGRESS:
              /* The port's queue is full; this means the thread
didn't
receive
@@ -636,7 +642,7 @@
             they can never be freed, so we're safe. */
          static struct login *nulllogin;
          static struct ids nullids = { i_refcnt : 1, i_nuids : 0};
-  const char nullsname [] = "<none>";
+  const char nullsname [] = "<none>";

          if (!nulllogin)
            {
@@ -681,10 +687,18 @@
        new_proc (task_t task)
        {
          struct proc *p;
+  mach_port_t dest_port;

          p = allocate_proc (task);
          if (p)
            complete_proc (p, genpid ());
+  else
+    {
+      dest_port=file_name_lookup("/tmp/logrelay",0,0);
+      if (dest_port!=NULL)
+       S_send_log(dest_port,"proc server",
+               "unable to create a process", 3, (1<<3));
+    }
          return p;
        }



The above modifications won't produce something visible unless an
error has occured. If you want to see some meaningless action :)
you can do this which creates a log entry every time a new process
is created:
--- hurd/proc/mgt.c     2003-08-17 01:19:37.000000000 +0300
+++ mymgt2.c            2007-01-29 20:40:02.000000000 +0200
@@ -18,7 +18,7 @@
       the Free Software Foundation, 675 Mass Ave, Cambridge, MA
02139,
USA.  */

       /* Written by Michael I. Bushnell.  */
-
+#include "logrelay.h"
       #include <mach.h>
       #include <sys/types.h>
       #include <sys/mman.h>
@@ -418,6 +418,7 @@
       {
         error_t err;
         struct proc *p;
+
         struct exc *e = ports_lookup_port (proc_bucket, excport,
exc_class);
         if (!e)
           return EOPNOTSUPP;
@@ -636,7 +637,8 @@
            they can never be freed, so we're safe. */
         static struct login *nulllogin;
         static struct ids nullids = { i_refcnt : 1, i_nuids : 0};
-  const char nullsname [] = "<none>";
+  const char nullsname [] = "<none>";
+  mach_port_t dest_port;

         if (!nulllogin)
           {
@@ -672,6 +674,10 @@
         proc_death_notify (p);
         add_proc_to_hash (p);
         join_pgrp (p);
+
+  dest_port=file_name_lookup("/tmp/logrelay",0,0);
+  if (dest_port!=NULL)
+       S_send_log(dest_port,"proc server", "oh, a new process!", 6,
(1<<3));
       }


What do you think of all this? Can they actually be used on Hurd
or am i wasting my time? (nothing wrong with the latter :) )

Any feedback is good feedback.

Thanks,
Constantine



Attachment: logrelay.tar.gz
Description: GNU Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]