From: Jeff Layton <jlayton@redhat.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: steved@redhat.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2/3] nfs-utils: add statdb_dump utility
Date: Tue, 5 Jan 2010 14:17:32 -0500 [thread overview]
Message-ID: <20100105141732.4590bcce@tlielax.poochiereds.net> (raw)
In-Reply-To: <248F9B15-E200-419D-96A0-6D64008D8750@oracle.com>
On Tue, 5 Jan 2010 11:09:20 -0500
Chuck Lever <chuck.lever@oracle.com> wrote:
>
> On Jan 5, 2010, at 10:40 AM, Jeff Layton wrote:
>
> > To dump contents of statd's monitor DB.
> >
> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > ---
> > tests/Makefile.am | 6 ++++
> > tests/statdb_dump.c | 75 ++++++++++++++++++++++++++++++++++++++++++
> > +++++++++
> > 2 files changed, 81 insertions(+), 0 deletions(-)
> > create mode 100644 tests/statdb_dump.c
> >
> > diff --git a/tests/Makefile.am b/tests/Makefile.am
> > index 375af80..a20b42b 100644
> > --- a/tests/Makefile.am
> > +++ b/tests/Makefile.am
> > @@ -1,5 +1,11 @@
> > ## Process this file with automake to produce Makefile.in
> >
> > +check_PROGRAMS = statdb_dump
> > +statdb_dump_SOURCES = statdb_dump.c
> > +
> > +statdb_dump_LDADD = ../support/nfs/libnfs.a \
> > + ../support/nsm/libnsm.a $(LIBCAP)
> > +
> > SUBDIRS = nsm_client
> >
> > MAINTAINERCLEANFILES = Makefile.in
> > diff --git a/tests/statdb_dump.c b/tests/statdb_dump.c
> > new file mode 100644
> > index 0000000..655213a
> > --- /dev/null
> > +++ b/tests/statdb_dump.c
> > @@ -0,0 +1,75 @@
> > +/*
> > + * statdb_dump.c -- dump contents of statd's monitor DB
> > + *
> > + * Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License
> > + * as published by the Free Software Foundation; either version 2
> > + * of the License, or (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
> > + * Boston, MA 02110-1301, USA.
> > + *
> > + * Output format is:
> > + *
> > + * <hostname> <cookie> <mon_name>
>
> my_name might also be interesting when we get local multi-homed
> support going. Perhaps some command line switches could control what
> is displayed.
>
Ok, I can add my_name. I'm not crazy about adding options though. My
thinking at this point is to keep the program really simple and let the
caller parse out what it needs.
> > + *
> > + */
> > +
> > +#ifdef HAVE_CONFIG_H
> > +#include "config.h"
> > +#endif
> > +
> > +#include <stdio.h>
> > +
> > +#include "nsm.h"
> > +#include "xlog.h"
> > +
> > +static char cookiebuf[(SM_PRIV_SIZE * 2) + 1];
> > +
> > +static _Bool
> > +error_check(const int len, const size_t buflen)
> > +{
> > + return (len < 0) || ((size_t)len >= buflen);
> > +}
> > +
> > +static unsigned int
> > +dump_host(const char *hostname, const struct sockaddr *sa, const
> > struct mon *m,
> > + const time_t timestamp)
> > +{
> > + int i, len;
> > + char *buf = cookiebuf;
> > + size_t remaining = sizeof(cookiebuf);
> > +
> > + /* convert cookie to text string */
> > + for (i = 0; i < SM_PRIV_SIZE; i++) {
> > + len = snprintf(buf, remaining, "%02x",
> > + (unsigned int)(0xff & m->priv[i]));
> > + if (error_check(len, remaining))
> > + return 0;
> > + buf += len;
> > + remaining -= (size_t)len;
> > + }
>
> I wonder if having a shared helper in support/nsm/file.c for
> converting a priv cookie to a string would be generally useful.
>
I thought about that too but didn't because I only saw one other place
that did this. Still though, it's probably the right thing to do. I'll
have a look at that.
> > +
> > + printf("%s %s %s\n", hostname, cookiebuf, m->mon_id.mon_name);
> > + return 1;
> > +}
> > +
> > +int
> > +main(int argc, char **argv)
> > +{
> > + xlog_syslog(0);
> > + xlog_stderr(1);
> > + xlog_open(argv[0]);
> > +
> > + nsm_load_monitor_list(dump_host);
> > + return 0;
> > +}
> > --
> > 1.6.5.2
> >
>
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2010-01-05 19:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-05 15:40 [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) Jeff Layton
2010-01-05 15:40 ` [PATCH 1/3] nfs-utils: introduce new statd testing simulator Jeff Layton
2010-01-05 15:40 ` [PATCH 2/3] nfs-utils: add statdb_dump utility Jeff Layton
2010-01-05 16:09 ` Chuck Lever
2010-01-05 19:17 ` Jeff Layton [this message]
[not found] ` <20100105141732.4590bcce-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-01-05 19:25 ` Chuck Lever
2010-01-05 15:40 ` [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check" Jeff Layton
2010-01-05 16:37 ` Steve Dickson
[not found] ` <4B436AD3.2080107-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-01-05 18:25 ` Jeff Layton
[not found] ` <20100105132519.02c3c76d-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-01-05 21:29 ` Jeff Layton
2010-01-06 19:17 ` [PATCH 0/3] nfs-utils: add testing infrastructure to nfs-utils (try #3) J. Bruce Fields
2010-01-06 19:42 ` Jeff Layton
[not found] ` <20100106144247.18dc10de-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-01-06 19:58 ` J. Bruce Fields
2010-01-06 20:10 ` Jeff Layton
2010-01-06 20:22 ` Chuck Lever
2010-01-06 20:33 ` J. Bruce Fields
2010-01-07 14:18 ` Jeff Layton
[not found] ` <20100107091832.687cb7eb-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2010-01-08 5:05 ` J. Bruce Fields
2010-01-08 12:03 ` Jeff Layton
2010-01-08 14:51 ` Jeff Layton
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=20100105141732.4590bcce@tlielax.poochiereds.net \
--to=jlayton@redhat.com \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox