svn commit: r195479 - projects/libprocstat/usr.bin/fstat
Stanislav Sedov
stas at FreeBSD.org
Wed Jul 8 23:09:04 UTC 2009
Author: stas
Date: Wed Jul 8 23:09:04 2009
New Revision: 195479
URL: http://svn.freebsd.org/changeset/base/195479
Log:
- Add preliminary fuser support.
Obtained from: fuser
Added:
projects/libprocstat/usr.bin/fstat/functions.h
projects/libprocstat/usr.bin/fstat/main.c
Deleted:
projects/libprocstat/usr.bin/fstat/fstat.h
Modified:
projects/libprocstat/usr.bin/fstat/Makefile
projects/libprocstat/usr.bin/fstat/cd9660.c
projects/libprocstat/usr.bin/fstat/fstat.c
projects/libprocstat/usr.bin/fstat/msdosfs.c
projects/libprocstat/usr.bin/fstat/zfs.c
Modified: projects/libprocstat/usr.bin/fstat/Makefile
==============================================================================
--- projects/libprocstat/usr.bin/fstat/Makefile Wed Jul 8 22:28:36 2009 (r195478)
+++ projects/libprocstat/usr.bin/fstat/Makefile Wed Jul 8 23:09:04 2009 (r195479)
@@ -4,13 +4,16 @@
.include <bsd.own.mk>
PROG= fstat
-SRCS= cd9660.c common.c fstat.c msdosfs.c
+SRCS= cd9660.c common.c fstat.c main.c msdosfs.c fuser.c
+LINKS= ${BINDIR}/fstat ${BINDIR}/fuser
DPADD= ${LIBKVM}
LDADD= -lkvm
BINGRP= kmem
BINMODE=2555
WARNS?= 6
+MAN1= fuser.1 fstat.1
+
CFLAGS+=-D_KVM_VNODE
# XXX This is a hack.
Modified: projects/libprocstat/usr.bin/fstat/cd9660.c
==============================================================================
--- projects/libprocstat/usr.bin/fstat/cd9660.c Wed Jul 8 22:28:36 2009 (r195478)
+++ projects/libprocstat/usr.bin/fstat/cd9660.c Wed Jul 8 23:09:04 2009 (r195479)
@@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include "common.h"
-#include "fstat.h"
int
isofs_filestat(kvm_t *kd, struct vnode *vp, struct filestat *fsp)
Modified: projects/libprocstat/usr.bin/fstat/fstat.c
==============================================================================
--- projects/libprocstat/usr.bin/fstat/fstat.c Wed Jul 8 22:28:36 2009 (r195478)
+++ projects/libprocstat/usr.bin/fstat/fstat.c Wed Jul 8 23:09:04 2009 (r195479)
@@ -103,7 +103,7 @@ __FBSDID("$FreeBSD$");
#include <netdb.h>
#include "common.h"
-#include "fstat.h"
+#include "functions.h"
#define TEXT -1
#define CDIR -2
@@ -112,8 +112,6 @@ __FBSDID("$FreeBSD$");
#define MMAP -5
#define JDIR -6
-DEVS *devs;
-
#ifdef notdef
struct nlist nl[] = {
{ "" },
@@ -140,6 +138,14 @@ int maxfiles;
maxfiles = (d); \
}
+typedef struct devs {
+ struct devs *next;
+ long fsid;
+ long ino;
+ const char *name;
+} DEVS;
+
+DEVS *devs;
char *memf, *nlistf;
kvm_t *kd;
@@ -157,7 +163,7 @@ int getfname(const char *filename);
void usage(void);
int
-main(int argc, char **argv)
+do_fstat(int argc, char **argv)
{
struct passwd *passwd;
int arg, ch, what;
Added: projects/libprocstat/usr.bin/fstat/functions.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/libprocstat/usr.bin/fstat/functions.h Wed Jul 8 23:09:04 2009 (r195479)
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2009 The FreeBSD Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef __FUNCTIONS_H__
+#define __FUNCTIONS_H__
+
+int do_fstat(int argc, char *argv[]);
+int do_fuser(int argc, char *argv[]);
+
+#endif /* !__FUNCTIONS_H__ */
Added: projects/libprocstat/usr.bin/fstat/main.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/libprocstat/usr.bin/fstat/main.c Wed Jul 8 23:09:04 2009 (r195479)
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2009 Stanislav Sedov <stas at FreeBSD.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <err.h>
+#include <libgen.h>
+#include <stdlib.h>
+#include <string.h>
+
+int do_fstat(int argc, char *argv[]);
+int do_fuser(int argc, char *argv[]);
+
+int
+main(int argc, char *argv[])
+{
+ char *p;
+
+ p = basename(argv[0]);
+ if (p == NULL)
+ err(1, "basename(%s)", argv[0]);
+ if (!strcmp(p, "fuser"))
+ return (do_fuser(argc, argv));
+ else
+ return (do_fstat(argc, argv));
+}
Modified: projects/libprocstat/usr.bin/fstat/msdosfs.c
==============================================================================
--- projects/libprocstat/usr.bin/fstat/msdosfs.c Wed Jul 8 22:28:36 2009 (r195478)
+++ projects/libprocstat/usr.bin/fstat/msdosfs.c Wed Jul 8 23:09:04 2009 (r195479)
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#define VTODE(vp) ((struct denode *)(vp)->v_data)
#include "common.h"
-#include "fstat.h"
struct dosmount {
struct dosmount *next;
Modified: projects/libprocstat/usr.bin/fstat/zfs.c
==============================================================================
--- projects/libprocstat/usr.bin/fstat/zfs.c Wed Jul 8 22:28:36 2009 (r195478)
+++ projects/libprocstat/usr.bin/fstat/zfs.c Wed Jul 8 23:09:04 2009 (r195479)
@@ -52,7 +52,6 @@
#define ZFS
#undef dprintf
#include "common.h"
-#include "fstat.h"
/*
* Offset calculations that are used to get data from znode without having the
More information about the svn-src-projects
mailing list