All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit
Date: Wed, 07 May 2014 16:15:27 +0100	[thread overview]
Message-ID: <536A4E0F.8030408@redhat.com> (raw)
In-Reply-To: <536A458A.2080507@redhat.com>

On 07/05/14 15:39, Steven Whitehouse wrote:
> Hi,
>
> On 07/05/14 15:33, Andrew Price wrote:
>> In order to piece together the order in which fsck.gfs2 runs and
>> gfs2_edit savemeta were done it's useful to keep a log of the command
>> line options used and the fsck.gfs2 start and end times. Log these to
>> syslog.
>>
>> Signed-off-by: Andrew Price <anprice@redhat.com>
>> ---
>>   gfs2/fsck/main.c     | 35 +++++++++++++++++++++++++++++++++++
>>   gfs2/man/fsck.gfs2.8 |  2 ++
>>   2 files changed, 37 insertions(+)
>>
>> diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
>> index 346e580..0031ec0 100644
>> --- a/gfs2/fsck/main.c
>> +++ b/gfs2/fsck/main.c
>> @@ -12,6 +12,7 @@
>>   #include <libintl.h>
>>   #include <locale.h>
>>   #define _(String) gettext(String)
>> +#include <syslog.h>
>>   #include "copyright.cf"
>>   #include "libgfs2.h"
>> @@ -261,6 +262,36 @@ static int fsck_pass(const struct fsck_pass *p,
>> struct gfs2_sbd *sdp)
>>       return 0;
>>   }
>> +static void exitlog(void)
>> +{
>> +    syslog(LOG_INFO, "exiting.");
>> +}
>> +
> Would be nice if it was possible to log the exit status too here...

Agreed. It's a shame the exit handlers don't take a status argument 
really. We're going to have to do something like

   extern int fsck_status;
   #define fsck_exit(s) exit(fsck_status = (s))

and then change all the exit() callers to make it work. There might be a 
lot of churn but it should be fairly mechanical so I'll whip up a patch 
for that shortly.

>> +static void startlog(int argc, char **argv)
>> +{
>> +    int i;
>> +    char *cmd, *p;
>> +    size_t len;
>> +
>> +    for (len = i = 0; i < argc; i++)
>> +        len += strlen(argv[i]);
>> +    len += argc; /* Add spaces and '\0' */
>> +
>> +    cmd = malloc(len);
>> +    if (cmd == NULL) {
>> +        perror(argv[0]);
>> +        exit(FSCK_ERROR);
>> +    }
>> +    p = cmd;
>> +    for (i = 0; i < argc; i++, p++) {
>> +        p = stpcpy(p, argv[i]);
>> +        *p = ' ';
>> +    }
>> +    *(--p) = '\0';
>> +    syslog(LOG_INFO, "started: %s", cmd);
> If you use vsyslog rather than syslog I wonder if its possible to make
> this a bit neater?

I've looked into it but I can't see an obvious way to do this. vsyslog 
would be useful if we knew how many format specifiers to use beforehand 
but in this case I think we're stuck with "%s".

Andy



      reply	other threads:[~2014-05-07 15:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07 14:33 [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Andrew Price
2014-05-07 14:33 ` [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode' Andrew Price
2014-05-07 14:48   ` Bob Peterson
2014-05-07 15:01     ` Andrew Price
2014-05-07 14:33 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove UI fields from struct gfs2_sbd Andrew Price
2014-05-07 14:33 ` [Cluster-devel] [PATCH 4/5] libgfs2: Remove debug field from gfs2_sbd Andrew Price
2014-05-07 14:33 ` [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API Andrew Price
2014-05-07 14:48   ` Steven Whitehouse
2014-05-07 14:55   ` Bob Peterson
2014-05-07 15:07     ` Andrew Price
2014-05-07 15:17       ` Andrew Price
2014-05-07 14:39 ` [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Steven Whitehouse
2014-05-07 15:15   ` Andrew Price [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=536A4E0F.8030408@redhat.com \
    --to=anprice@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.