Subject: Re: pkg/36680
To: None <atatat@NetBSD.org, gnats-admin@netbsd.org,>
From: Bernd Ernesti <veego@NetBSD.org>
List: pkgsrc-bugs
Date: 08/11/2007 19:00:06
The following reply was made to PR pkg/36680; it has been noted by GNATS.
From: Bernd Ernesti <veego@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/36680
Date: Sat, 11 Aug 2007 20:58:32 +0200
IMHO the original patch in the pr has some room for improvements.
Here is a different one:
- Don't hardcode the MFSNAMELEN length, inspired by commits from
Christos (patch-ae and patch-af)
- Define NETBSD_SYS in the pkgsrc Makefile so it works if NETBSDSRCDIR is
not pointing to a default location and thus some featues, like ptyfs
support was disabled
- Update the line numbers in patch-aa
- Add tmpfs support (patch-ad, patch-af and in the new patch-ag)
- Update the NetBSD versions in Configure otherwise NETBSDV would fall
back to 1006000 and so at least one feature was not found, the PFSfd
procfs support (in the new patch-ag)
- Bump pkg revision for new features (normaly I wouldn't have bumped the
version if it were only to fix a -current compile, because the version
also includes the kernel version)
00PORTING was not modified. It has to be adapted for the HASTMPFS changes
when the changes are send back to the author:
HASTMPFS indicates the *BSD dialect has a tmpfs file system.
I used 499002500 for the MFSNAMELEN changes because it was changed in the
middle of the 4.99.24 source code.
You can also find the patch file on ftp.NetBSD.org:/pub/NetBSD/misc/veego/36680.patch
in the case gnats changes the format.
Bernd
--- Makefile 6 May 2007 21:41:30 -0000 1.92
+++ Makefile 11 Aug 2007 15:26:37 -0000
@@ -3,6 +3,7 @@
DISTNAME= lsof_4.78
PKGNAME= ${DISTNAME:S/_/-/}.${OS_VERSION}
+PKGREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ \
ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/NEW/ \
@@ -34,6 +35,7 @@
.if ${OPSYS} == "NetBSD"
REAL_GROUP= -g kmem
+CONFIGURE_ENV+= NETBSD_SYS="${NETBSDSRCDIR}/sys"
.elif ${OPSYS} == "SunOS"
MAKE_ENV+= CPPFLAGS=
.endif
--- distinfo 6 May 2007 21:42:02 -0000 1.66
+++ distinfo 11 Aug 2007 17:49:01 -0000
@@ -3,8 +3,9 @@
SHA1 (lsof_4.78.tar.bz2) = 0379fc9f38a931ce19e8386e662314d96fc2a099
RMD160 (lsof_4.78.tar.bz2) = 50d71e500f1109cda717b73ce209c0e100a6dbe9
Size (lsof_4.78.tar.bz2) = 756729 bytes
-SHA1 (patch-aa) = 332eb1ac95d86023dde66d1b99b9335c8f54b81f
+SHA1 (patch-aa) = 051015025297ab131c30ceb62e926750c365d14a
SHA1 (patch-ab) = 1501d8b0e6fd2c61949ba0d447c7b726655725c4
-SHA1 (patch-ad) = bbdd2c4c997233f7743a0c99ffcc6ce29679a8a9
-SHA1 (patch-ae) = ba3804e89101fb504edd33983f35904559a63dbf
-SHA1 (patch-af) = 0ceeb8e4a704d89aba5b9271d17afe038d877e8f
+SHA1 (patch-ad) = ac9ade0dce7299704d60daa15fb95a436938f456
+SHA1 (patch-ae) = 1d8c1c3baf9575631c23d3ced7b12fab1df95cd6
+SHA1 (patch-af) = 7110b279ca99bd399d1654683b6fc8367d2fee8d
+SHA1 (patch-ag) = b992cc4a80563f143e72fe3f27557a460af38121
diff -b -u -r1.25 patch-aa
--- patches/patch-aa 17 Jan 2005 14:54:01 -0000 1.25
+++ patches/patch-aa 11 Aug 2007 16:21:46 -0000
@@ -5,9 +5,9 @@
Set LSOF_LESS_SECURE_SOCKETS to non-zero in order to allow non-root
users to see open sockets, even when LSOF_MORE_SECURE is set.
---- dialects/n+obsd/machine.h.orig 2004-10-17 17:55:27.000000000 -0400
-+++ dialects/n+obsd/machine.h
-@@ -383,7 +383,9 @@
+--- dialects/n+obsd/machine.h.orig 2006-03-28 23:54:17.000000000 +0200
++++ dialects/n+obsd/machine.h 2007-08-11 18:01:56.000000000 +0200
+@@ -410,7 +410,9 @@
* (the one that its user logged on with) of the lsof process.
*/
@@ -18,7 +18,7 @@
/*
-@@ -392,7 +394,9 @@
+@@ -419,7 +421,9 @@
* listing is selected by the "-i" option.
*/
--- patches/patch-ad 6 May 2007 21:41:30 -0000 1.12
+++ patches/patch-ad 11 Aug 2007 17:48:59 -0000
@@ -1,7 +1,7 @@
$NetBSD: patch-ad,v 1.12 2007/05/06 21:41:30 christos Exp $
---- dialects/n+obsd/dnode.c.orig 2007-04-24 12:22:06.000000000 -0400
-+++ dialects/n+obsd/dnode.c 2007-05-06 16:43:51.000000000 -0400
+--- dialects/n+obsd/dnode.c.orig 2007-04-24 18:22:06.000000000 +0200
++++ dialects/n+obsd/dnode.c 2007-08-11 19:46:43.000000000 +0200
@@ -38,6 +38,9 @@
#include "lsof.h"
@@ -12,7 +12,7 @@
#if defined(HAS_DINODE_U)
#define DINODE_U dinode_u
-@@ -194,7 +197,9 @@
+@@ -194,12 +197,17 @@
unsigned char ns;
unsigned char rdevs;
char *ep, *ty;
@@ -21,8 +21,37 @@
+#endif
struct inode i;
struct mfsnode m;
++#if defined(HASTMPFS)
++ struct tmpfs_node tmp;
++#endif /* defined(HASTMPFS) */
struct nfsnode n;
-@@ -619,6 +624,7 @@
+ enum nodetype {NONODE, CDFSNODE, DOSNODE, EXT2NODE, FDESCNODE, INODE,
+- KERNFSNODE, MFSNODE, NFSNODE, PFSNODE, PTYFSNODE} nty;
++ KERNFSNODE, MFSNODE, NFSNODE, PFSNODE, PTYFSNODE, TMPFSNODE} nty;
+ enum vtype type;
+ struct vnode *v, vb;
+ struct l_vfs *vfs;
+@@ -471,6 +479,19 @@
+ nty = MFSNODE;
+ break;
+
++#if defined(HASTMPFS)
++ case VT_TMPFS:
++ if (!v->v_data
++ || kread((KA_T)v->v_data, (char *)&tmp, sizeof(tmp))) {
++ (void) snpf(Namech, Namechl, "can't read tmpfs_node at: %s",
++ print_kptr((KA_T)v->v_data, (char *)NULL, 0));
++ enter_nm(Namech);
++ return;
++ }
++ nty = TMPFSNODE;
++ break;
++#endif /* defined(HASTMPFS) */
++
+ #if defined(HASMSDOSFS)
+ case VT_MSDOSFS:
+ if (!v->v_data
+@@ -619,6 +640,7 @@
}
@@ -30,7 +59,7 @@
if ((lff = i.i_lockf)) {
/*
-@@ -667,6 +673,7 @@
+@@ -667,6 +689,7 @@
break;
} while ((lfp = lf.lf_next) && lfp != lff);
}
@@ -38,3 +67,41 @@
break;
default:
if (v->v_type == VBAD || v->v_type == VNON)
+@@ -900,6 +923,13 @@
+ break;
+ #endif /* defined(HASPTYFS) */
+
++#if defined(HASTMPFS)
++ case TMPFSNODE:
++ Lf->inode = (INODETYPE)tmp.tn_id;
++ Lf->inp_ty = 1;
++ break;
++#endif /* defined(HASTMPFS) */
++
+ }
+
+ /*
+@@ -1019,6 +1049,13 @@
+ Lf->sz_def = 1;
+ break;
+
++#if defined(HASTMPFS)
++ case TMPFSNODE:
++ Lf->sz = (SZOFFTYPE)tmp.tn_size;
++ Lf->sz_def = 1;
++ break;
++#endif /* defined(HASTMPFS) */
++
+ #if defined(HASEXT2FS)
+ case EXT2NODE:
+ # if defined(HASI_E2FS_PTR)
+@@ -1221,6 +1258,9 @@
+ Lf->dev_def = Lf->rdev_def = 0;
+ (void) snpf(Namech, Namechl, "%#x", m.mfs_baseoff);
+ enter_dev_ch("memory");
++ } else if (nty == TMPFSNODE) {
++ Lf->dev_def = Lf->rdev_def = 0;
++ enter_dev_ch("memory");
+ }
+
+ #if defined(HASPROCFS)
--- patches/patch-ae 1 Aug 2006 12:29:59 -0000 1.10
+++ patches/patch-ae 11 Aug 2007 12:48:50 -0000
@@ -1,7 +1,7 @@
$NetBSD: patch-ae,v 1.10 2006/08/01 12:29:59 tron Exp $
---- dialects/n+obsd/dmnt.c.orig 2005-08-08 20:53:31.000000000 +0100
-+++ dialects/n+obsd/dmnt.c 2006-08-01 13:25:57.000000000 +0100
+--- dialects/n+obsd/dmnt.c.orig 2005-08-08 21:53:31.000000000 +0200
++++ dialects/n+obsd/dmnt.c 2007-08-11 14:43:05.000000000 +0200
@@ -45,6 +45,15 @@
#include <sys/statvfs.h>
#endif /* defined(NETBSDV) && defined(HASSTATVFS) */
@@ -18,3 +18,16 @@
#include "lsof.h"
+@@ -94,7 +103,12 @@
+ for (; n; n--, mb++) {
+ if (mb->f_fstypename[0] == '\0')
+ continue;
++#if defined(NETBSDV) && __NetBSD_Version__ >= 499002500
++ /* MFSNAMELEN was removed from the kernel source after 4.99.24 */
++ mb->f_fstypename[sizeof(mb->f_fstypename) - 1] = '\0';
++#else
+ mb->f_fstypename[MFSNAMELEN - 1] = '\0';
++#endif
+ /*
+ * Interpolate a possible symbolic directory link.
+ */
diff -b -u -r1.7 patch-af
--- patches/patch-af 6 May 2007 21:41:30 -0000 1.7
+++ patches/patch-af 11 Aug 2007 16:20:52 -0000
@@ -1,7 +1,7 @@
$NetBSD: patch-af,v 1.7 2007/05/06 21:41:30 christos Exp $
---- dialects/n+obsd/dlsof.h.orig 2006-03-28 16:54:15.000000000 -0500
-+++ dialects/n+obsd/dlsof.h 2007-05-06 17:37:00.000000000 -0400
+--- dialects/n+obsd/dlsof.h.orig 2006-03-28 23:54:15.000000000 +0200
++++ dialects/n+obsd/dlsof.h 2007-08-11 18:16:59.000000000 +0200
@@ -161,6 +161,7 @@
#include <sys/socketvar.h>
#include <sys/un.h>
@@ -18,3 +18,26 @@
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
+@@ -264,6 +264,9 @@
+
+ #undef KERNEL
+ #include <ufs/mfs/mfsnode.h>
++# if defined(HASTMPFS)
++#include <fs/tmpfs/tmpfs.h>
++# endif /* defined(HASTMPFS) */
+
+ # if defined(HASNFSPROTO)
+ #include <nfs/rpcv2.h>
+@@ -489,7 +492,12 @@
+ struct l_vfs {
+ KA_T addr; /* kernel address */
+ fsid_t fsid; /* file system ID */
++#if defined(NETBSDV) && __NetBSD_Version__ >= 499002500
++ /* MFSNAMELEN was removed from the kernel source after 4.99.24 */
++ char type[sizeof(((struct statvfs *)NULL)->f_fstypename)]; /* type of file system */
++#else
+ char type[MFSNAMELEN]; /* type of file system */
++#endif
+ char *dir; /* mounted directory */
+ char *fsname; /* file system name */
+ struct l_vfs *next; /* forward link */
diff -N patches/patch-ag
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-ag 11 Aug 2007 16:01:31 -0000
@@ -0,0 +1,103 @@
+$NetBSD$
+
+--- Configure.orig 2007-04-24 21:00:22.000000000 +0200
++++ Configure 2007-08-11 18:00:38.000000000 +0200
+@@ -86,6 +86,7 @@
+ # $LSOF_LOCALSUFFIX local suffix for Makefile
+ # $LSOF_NBSD_BUFQH NetBSD <sys/bufq.h> copy status
+ # $LSOF_NBSD_PTYFS NetBSD ${NETBSD_SYS}/sys/fs/ptyfs/ copy status
++# $LSOF_NBSD_TMPFS NetBSD ${NETBSD_SYS}/sys/fs/tmpfs/ copy status
+ # $LSOF_N_UNIXV *BSD system's kernel file
+ # $LSOF_PL patch level
+ # $LSOF_RANLIB randomizing command for the lsof library
+@@ -2447,6 +2448,19 @@
+ echo "!!!WARNING!!! Unsupported NetBSD version: $LSOF_VSTR"
+ echo "!!!WARNING!!! Configuring for NetBSD 3.0"
+ ;;
++ 4.0*)
++ LSOF_TSTBIGF=" "
++ LSOF_VERS="4000000"
++ ;;
++ 4.99.*)
++ LSOF_TSTBIGF=" "
++ LSOF_VERS="4099000"
++ ;;
++ 4*)
++ LSOF_VERS="4000000"
++ echo "!!!WARNING!!! Unsupported NetBSD version: $LSOF_VSTR"
++ echo "!!!WARNING!!! Configuring for NetBSD 4.0"
++ ;;
+ *)
+ echo "Unknown NetBSD release: $LSOF_VSTR"
+ echo Assuming NetBSD 1.6
+@@ -2464,6 +2478,8 @@
+ ;;
+ 3000000|3099000)
+ ;;
++ 4000000|4099000)
++ ;;
+ *)
+ echo "Unknown NetBSD version: $LSOF_VERS"
+ rm -f $LSOF_HLP
+@@ -2871,6 +2887,7 @@
+ fi # }
+ LSOF_TMP2="sys/vnode.h"
+ LSOF_NBSD_PTYFS=0
++ LSOF_NBSD_TMPFS=0
+ if test -r ${LSOF_INCLUDE}/$LSOF_TMP2 # {
+ then
+ LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
+@@ -2948,6 +2965,24 @@
+ fi # }
+ fi # }
+ fi # }
++ grep -q VT_TMPFS $LSOF_TMP3
++ if test $? -eq 0 # {
++ then
++ LSOF_TMP2="fs/tmpfs/tmpfs.h"
++ if test -r ${LSOF_INCLUDE}/$LSOF_TMP2 # {
++ then
++ LSOF_CFGF="$LSOF_CFGF -DHASTMPFS"
++ else
++ if test -r ${NETBSD_SYS}/$LSOF_TMP2 # {
++ then
++ if test $NETBSD_SYS != $LSOF_INCLUDE # {
++ then
++ LSOF_CFGF="$LSOF_CFGF -DHASTMPFS"
++ LSOF_NBSD_TMPFS=1
++ fi # }
++ fi # }
++ fi # }
++ fi # }
+ if test "X$NETBSD_UVM" = "X" # {
+ then
+ grep -q UVM $LSOF_TMP3
+@@ -3233,6 +3268,28 @@
+ LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/n+obsd/include"
+ fi # }
+ fi # }
++ if test $LSOF_NBSD_TMPFS -eq 1 # {
++ then
++
++ # Make a local copy of $NETBSD_SYS/sys/fs/tmpfs/tmpfs.h.
++
++ if test ! -d dialects/n+obsd/include # {
++ then
++ mkdir dialects/n+obsd/include
++ fi # }
++ if test ! -d dialects/n+obsd/include/fs # {
++ then
++ mkdir dialects/n+obsd/include/fs
++ fi # }
++ rm -rf dialects/n+obsd/include/fs/tmpfs
++ mkdir dialects/n+obsd/include/fs/tmpfs
++ cp $NETBSD_SYS/fs/tmpfs/tmpfs.h dialects/n+obsd/include/fs/tmpfs
++ echo $LSOF_CFGF | grep /dialects/n+obsd/include > /dev/null 2>&1
++ if test $? -ne 0 # {
++ then
++ LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/n+obsd/include"
++ fi # }
++ fi # }
+ LSOF_CFGL="$LSOF_CFGL -lkvm"
+ LSOF_DIALECT_DIR=n+obsd
+ ;;