CVS commit: src/usr.bin/fstat

2019-09-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep  6 17:08:22 UTC 2019

Modified Files:
src/usr.bin/fstat: fstat.1 fstat.c fstat.h misc.c

Log Message:
Add -O to print offsets; align columns properly.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/fstat/fstat.1
cvs rdiff -u -r1.112 -r1.113 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/fstat/fstat.h
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/fstat/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/fstat

2019-09-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep  6 17:08:22 UTC 2019

Modified Files:
src/usr.bin/fstat: fstat.1 fstat.c fstat.h misc.c

Log Message:
Add -O to print offsets; align columns properly.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/fstat/fstat.1
cvs rdiff -u -r1.112 -r1.113 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/fstat/fstat.h
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/fstat/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/fstat/fstat.1
diff -u src/usr.bin/fstat/fstat.1:1.34 src/usr.bin/fstat/fstat.1:1.35
--- src/usr.bin/fstat/fstat.1:1.34	Mon Jul  3 17:34:57 2017
+++ src/usr.bin/fstat/fstat.1	Fri Sep  6 13:08:22 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: fstat.1,v 1.34 2017/07/03 21:34:57 wiz Exp $
+.\"	$NetBSD: fstat.1,v 1.35 2019/09/06 17:08:22 christos Exp $
 .\"
 .\" Copyright (c) 1987, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" from: @(#)fstat.1	8.3 (Berkeley) 2/25/94
 .\"
-.Dd December 15, 2013
+.Dd September 6, 2019
 .Dt FSTAT 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd display status of open files
 .Sh SYNOPSIS
 .Nm
-.Op Fl Afnv
+.Op Fl AfnOv
 .Op Fl M Ar core
 .Op Fl N Ar system
 .Op Fl p Ar pid
@@ -54,7 +54,7 @@ If no options are specified,
 reports on all open files in the system.
 .Pp
 Options:
-.Bl -tag -width Ds
+.Bl -tag -width XX
 .It Fl A
 Add an output column with the address of the kernel object (vnode or file),
 that can be matched with
@@ -72,12 +72,15 @@ resides, type
 Please see the
 .Sx BUGS
 section for issues with this option.
-.It Fl M
-Extract values associated with the name list from the specified core
+.It Fl M Ar core
+Extract values associated with the name list from the specified
+.Ar core
 instead of the default
 .Pa /dev/kmem .
-.It Fl N
-Extract the name list from the specified system instead of the default
+.It Fl N Ar system
+Extract the name list from the specified
+.Ar system
+instead of the default
 .Pa /netbsd .
 .It Fl n
 Numerical format.
@@ -88,10 +91,14 @@ device number that the special device re
 in
 .Pa /dev ;
 and print the mode of the file in octal instead of symbolic form.
-.It Fl p
-Report all files open by the specified process.
-.It Fl u
-Report all files open by the specified user.
+.It Fl O
+Report file offsets instead of sizes.
+.It Fl p Ar process
+Report all files open by the specified
+.Ar process .
+.It Fl u Ar user
+Report all files open by the specified
+.Ar user .
 .It Fl v
 Verbose mode.
 Print error messages upon failures to locate particular
@@ -161,9 +168,11 @@ using a symbolic format (see
 .Xr strmode 3 ) ;
 otherwise, the mode is printed
 as an octal number.
-.It Li SZ\&|DV
+.It Li SZ\&|DV or OFFS
 If the file is not a character or block special file, prints the size of
-the file in bytes.
+the file in bytes (or the offset if the
+.Fl O
+is specified).
 Otherwise, if the
 .Fl n
 flag is not specified, prints

Index: src/usr.bin/fstat/fstat.c
diff -u src/usr.bin/fstat/fstat.c:1.112 src/usr.bin/fstat/fstat.c:1.113
--- src/usr.bin/fstat/fstat.c:1.112	Sat Feb  2 22:19:29 2019
+++ src/usr.bin/fstat/fstat.c	Fri Sep  6 13:08:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fstat.c,v 1.112 2019/02/03 03:19:29 mrg Exp $	*/
+/*	$NetBSD: fstat.c,v 1.113 2019/09/06 17:08:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)fstat.c	8.3 (Berkeley) 5/2/95";
 #else
-__RCSID("$NetBSD: fstat.c,v 1.112 2019/02/03 03:19:29 mrg Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.113 2019/09/06 17:08:22 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -134,6 +134,7 @@ static int 	fsflg,	/* show files on same
 static int 	checkfile; /* true if restricting to particular files or filesystems */
 static int	nflg;	/* (numerical) display f.s. and rdev as dev_t */
 static int	Aflg;	/* prefix with address of file structure */
+static int	Oflg;	/* print offset instead of size */
 int	vflg;	/* display errors in locating kernel data objects etc... */
 
 static fdfile_t **ofiles; /* buffer of pointers to file structures */
@@ -171,12 +172,12 @@ static const char *inet6_addrstr(char *,
 uint16_t, bool);
 #endif
 static const char *at_addrstr(char *, size_t, const struct sockaddr_at *);
-static void	socktrans(struct socket *, int);
+static void	socktrans(struct file *, struct socket *, int);
 static void	misctrans(struct file *, int);
 static int	ufs_filestat(struct vnode *, struct filestat *);
 static void	usage(void) __dead;
 static const char   *vfilestat(struct vnode *, struct filestat *);
-static void	vtrans(struct vnode *, int, int, long);
+static void	vtrans(struct file *, struct vnode *, int, int, long);
 static void	ftrans(fdfile_t *, int);
 static void	ptrans(struct file *, struct pipe *, int);
 static void	kdriver_in

CVS commit: src/usr.bin/fstat

2019-09-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Sep  6 19:05:05 UTC 2019

Modified Files:
src/usr.bin/fstat: fstat.1

Log Message:
Use \(em.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/fstat/fstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/fstat

2019-09-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Sep  6 19:05:05 UTC 2019

Modified Files:
src/usr.bin/fstat: fstat.1

Log Message:
Use \(em.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/fstat/fstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/fstat/fstat.1
diff -u src/usr.bin/fstat/fstat.1:1.35 src/usr.bin/fstat/fstat.1:1.36
--- src/usr.bin/fstat/fstat.1:1.35	Fri Sep  6 17:08:22 2019
+++ src/usr.bin/fstat/fstat.1	Fri Sep  6 19:05:04 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: fstat.1,v 1.35 2019/09/06 17:08:22 christos Exp $
+.\"	$NetBSD: fstat.1,v 1.36 2019/09/06 19:05:04 wiz Exp $
 .\"
 .\" Copyright (c) 1987, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -144,7 +144,7 @@ the file is not an inode, but rather a s
 .Tn FIFO ,
 or there is an error.
 In this case the remainder of the line doesn't
-correspond to the remaining headers -- the format of the line
+correspond to the remaining headers \(em the format of the line
 is described later under
 .Sx SOCKETS .
 .It Li MOUNT



CVS commit: src/usr.bin/fstat

2022-06-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Jun 19 11:31:19 UTC 2022

Modified Files:
src/usr.bin/fstat: Makefile fstat.c fstat.h
Added Files:
src/usr.bin/fstat: zfs.c zfs_znode.h

Log Message:
Add basic ZFS support to fstat(1).
XXX: Use a local zfs_znode.h for a znode_t definition because the ZFS
kernel code makes it too hard to include headers from userland.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/fstat/Makefile
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/fstat/fstat.h
cvs rdiff -u -r0 -r1.1 src/usr.bin/fstat/zfs.c src/usr.bin/fstat/zfs_znode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/fstat/Makefile
diff -u src/usr.bin/fstat/Makefile:1.26 src/usr.bin/fstat/Makefile:1.27
--- src/usr.bin/fstat/Makefile:1.26	Sun Oct 13 07:28:15 2019
+++ src/usr.bin/fstat/Makefile	Sun Jun 19 11:31:19 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.26 2019/10/13 07:28:15 mrg Exp $
+#	$NetBSD: Makefile,v 1.27 2022/06/19 11:31:19 simonb Exp $
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 
 .include 
@@ -6,6 +6,9 @@
 USE_FORT?= yes	# setuid
 PROG=	fstat
 SRCS=	fstat.c isofs.c ntfs.c ptyfs.c tmpfs.c misc.c
+.if (${MKZFS} != "no")
+SRCS+=	zfs.c
+.endif
 DPADD=	${LIBKVM}
 LDADD=	-lkvm
 BINGRP=	kmem
@@ -16,6 +19,9 @@ CPPFLAGS+= -I${NETBSDSRCDIR}/sys
 .if (${USE_INET6} != "no")
 CPPFLAGS+=-DINET6
 .endif
+.if (${MKZFS} != "no")
+CPPFLAGS+=-DHAVE_ZFS
+.endif
 CPPFLAGS+=-D_KMEMUSER
 
 LDADD+=-lutil

Index: src/usr.bin/fstat/fstat.c
diff -u src/usr.bin/fstat/fstat.c:1.114 src/usr.bin/fstat/fstat.c:1.115
--- src/usr.bin/fstat/fstat.c:1.114	Wed Aug 26 23:08:29 2020
+++ src/usr.bin/fstat/fstat.c	Sun Jun 19 11:31:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fstat.c,v 1.114 2020/08/26 23:08:29 christos Exp $	*/
+/*	$NetBSD: fstat.c,v 1.115 2022/06/19 11:31:19 simonb Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)fstat.c	8.3 (Berkeley) 5/2/95";
 #else
-__RCSID("$NetBSD: fstat.c,v 1.114 2020/08/26 23:08:29 christos Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.115 2022/06/19 11:31:19 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -611,6 +611,12 @@ vfilestat(struct vnode *vp, struct files
 			if (!tmpfs_filestat(vp, fsp))
 badtype = "error";
 			break;
+#ifdef HAVE_ZFS
+		case VT_ZFS:
+			if (!zfs_filestat(vp, fsp))
+badtype = "error";
+			break;
+#endif
 		case VT_NULL:
 		case VT_OVERLAY:
 		case VT_UMAP:

Index: src/usr.bin/fstat/fstat.h
diff -u src/usr.bin/fstat/fstat.h:1.10 src/usr.bin/fstat/fstat.h:1.11
--- src/usr.bin/fstat/fstat.h:1.10	Fri Sep  6 17:08:22 2019
+++ src/usr.bin/fstat/fstat.h	Sun Jun 19 11:31:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fstat.h,v 1.10 2019/09/06 17:08:22 christos Exp $	*/
+/*	$NetBSD: fstat.h,v 1.11 2022/06/19 11:31:19 simonb Exp $	*/
 /*-
  * Copyright (c) 1988, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -60,4 +60,5 @@ int	isofs_filestat(struct vnode *, struc
 int	ntfs_filestat(struct vnode *, struct filestat *);
 int	ptyfs_filestat(struct vnode *, struct filestat *);
 int	tmpfs_filestat(struct vnode *, struct filestat *);
+int	zfs_filestat(struct vnode *, struct filestat *);
 void	oprint(struct file *, const char *);

Added files:

Index: src/usr.bin/fstat/zfs.c
diff -u /dev/null src/usr.bin/fstat/zfs.c:1.1
--- /dev/null	Sun Jun 19 11:31:19 2022
+++ src/usr.bin/fstat/zfs.c	Sun Jun 19 11:31:19 2022
@@ -0,0 +1,75 @@
+/*	$NetBSD: zfs.c,v 1.1 2022/06/19 11:31:19 simonb Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Simon Burge.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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, WH

CVS commit: src/usr.bin/fstat

2022-06-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Jun 19 11:31:19 UTC 2022

Modified Files:
src/usr.bin/fstat: Makefile fstat.c fstat.h
Added Files:
src/usr.bin/fstat: zfs.c zfs_znode.h

Log Message:
Add basic ZFS support to fstat(1).
XXX: Use a local zfs_znode.h for a znode_t definition because the ZFS
kernel code makes it too hard to include headers from userland.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/fstat/Makefile
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/fstat/fstat.h
cvs rdiff -u -r0 -r1.1 src/usr.bin/fstat/zfs.c src/usr.bin/fstat/zfs_znode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



re: CVS commit: src/usr.bin/fstat

2011-09-06 Thread matthew green

> Module Name:  src
> Committed By: christos
> Date: Sat Sep  3 13:22:56 UTC 2011
> 
> Modified Files:
>   src/usr.bin/fstat: fstat.1
> 
> Log Message:
> Mention that fstat -f will not list open unix sockets on that filesystem.

shouldn't this be a .Sh BUGS entry?  it sure isn't a feature.


.mrg.