CVS commit: src/sys/ufs/ufs

2020-12-25 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Dec 25 10:00:40 UTC 2020

Modified Files:
src/sys/ufs/ufs: ufs_quota1.c

Log Message:
Avoid potentially accessing an array with an index out of range.

Reported-by: syzbot+8832f540234b996bc...@syzkaller.appspotmail.com
Reported-by: syzbot+0b785dd10d987350e...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ufs/ufs_quota1.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.22 src/sys/ufs/ufs/ufs_quota1.c:1.23
--- src/sys/ufs/ufs/ufs_quota1.c:1.22	Mon Jun 20 00:52:04 2016
+++ src/sys/ufs/ufs/ufs_quota1.c	Fri Dec 25 10:00:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.23 2020/12/25 10:00:40 nia Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.23 2020/12/25 10:00:40 nia Exp $");
 
 #include 
 #include 
@@ -311,6 +311,9 @@ quota1_handle_cmd_quotaon(struct lwp *l,
 	struct pathbuf *pb;
 	struct nameidata nd;
 
+	if (type < 0 || type >= MAXQUOTAS)
+		return EINVAL;
+
 	if (ump->um_flags & UFS_QUOTA2) {
 		uprintf("%s: quotas v2 already enabled\n",
 		mp->mnt_stat.f_mntonname);
@@ -421,6 +424,9 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 	kauth_cred_t cred;
 	int i, error;
 
+	if (type < 0 || type >= MAXQUOTAS)
+		return EINVAL;
+
 	mutex_enter();
 	while ((ump->umq1_qflags[type] & (QTF_CLOSING | QTF_OPENING)) != 0)
 		cv_wait(, );



CVS commit: src/sys/ufs/ufs

2020-05-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri May  1 08:43:37 UTC 2020

Modified Files:
src/sys/ufs/ufs: ufs_vfsops.c

Log Message:
There is no difference between a zero-sized and not yet
reclaimed directory vnode and a non-existent vnode.

Teach ufs_fhtovp() to treat zero-sized directories as stale.

PR kern/55211 (fs/vfs/t_vnops:nfs_dir_rmdirdotdot test fails)


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/ufs/ufs/ufs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vfsops.c
diff -u src/sys/ufs/ufs/ufs_vfsops.c:1.59 src/sys/ufs/ufs/ufs_vfsops.c:1.60
--- src/sys/ufs/ufs/ufs_vfsops.c:1.59	Fri Jan 17 20:08:10 2020
+++ src/sys/ufs/ufs/ufs_vfsops.c	Fri May  1 08:43:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vfsops.c,v 1.59 2020/01/17 20:08:10 ad Exp $	*/
+/*	$NetBSD: ufs_vfsops.c,v 1.60 2020/05/01 08:43:37 hannken Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.59 2020/01/17 20:08:10 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.60 2020/05/01 08:43:37 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -247,7 +247,8 @@ ufs_fhtovp(struct mount *mp, struct ufid
 	}
 	ip = VTOI(nvp);
 	KASSERT(ip != NULL);
-	if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen) {
+	if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen ||
+	((ip->i_mode & IFMT) == IFDIR && ip->i_size == 0)) {
 		vput(nvp);
 		*vpp = NULLVP;
 		return (ESTALE);



CVS commit: src/sys/ufs/ufs

2020-04-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr 20 03:57:02 UTC 2020

Modified Files:
src/sys/ufs/ufs: ufs_bmap.c

Log Message:
handle negative small block numbers for extattr


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ufs/ufs_bmap.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_bmap.c
diff -u src/sys/ufs/ufs/ufs_bmap.c:1.52 src/sys/ufs/ufs/ufs_bmap.c:1.53
--- src/sys/ufs/ufs/ufs_bmap.c:1.52	Sat Mar 18 01:33:06 2017
+++ src/sys/ufs/ufs/ufs_bmap.c	Sun Apr 19 23:57:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $	*/
+/*	$NetBSD: ufs_bmap.c,v 1.53 2020/04/20 03:57:02 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.53 2020/04/20 03:57:02 christos Exp $");
 
 #include 
 #include 
@@ -190,6 +190,13 @@ ufs_bmaparray(struct vnode *vp, daddr_t 
 			}
 		}
 		return (0);
+	} else if (bn < 0 && bn >= -UFS_NXADDR) {
+		KASSERT(ump->um_fstype == UFS2);
+		daddr = ufs_rw64(ip->i_ffs2_extb[-1 - bn], UFS_MPNEEDSWAP(ump));
+		*bnp = blkptrtodb(ump, daddr);
+		if (*bnp == 0)
+			*bnp = -1;
+		return 0;
 	}
 
 	xap = ap == NULL ? a : ap;



CVS commit: src/sys/ufs/ufs

2020-03-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Mar  8 00:23:59 UTC 2020

Modified Files:
src/sys/ufs/ufs: ufs_dirhash.c

Log Message:
in ufsdirhash_free(), only examine dh->dh_onlist after taking the
dirhashlist lock.  if we skip the lock then we might see that
dh_onlist is zero while ufsdirhash_recycle() is still working on
the dirhash.  the symptom I saw was that ufsdirhash_free() would
try to destroy the dh_lock mutex while it was still held.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/ufs/ufs_dirhash.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_dirhash.c
diff -u src/sys/ufs/ufs/ufs_dirhash.c:1.37 src/sys/ufs/ufs/ufs_dirhash.c:1.38
--- src/sys/ufs/ufs/ufs_dirhash.c:1.37	Sat Dec 20 00:28:05 2014
+++ src/sys/ufs/ufs/ufs_dirhash.c	Sun Mar  8 00:23:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp $	*/
+/*	$NetBSD: ufs_dirhash.c,v 1.38 2020/03/08 00:23:59 chs Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002 Ian Dowse.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.38 2020/03/08 00:23:59 chs Exp $");
 
 /*
  * This implements a hash-based lookup scheme for UFS directories.
@@ -285,12 +285,10 @@ ufsdirhash_free(struct inode *ip)
 
 	ip->i_dirhash = NULL;
 
-	if (dh->dh_onlist) {
-		DIRHASHLIST_LOCK();
-		if (dh->dh_onlist)
-			TAILQ_REMOVE(_list, dh, dh_list);
-		DIRHASHLIST_UNLOCK();
-	}
+	DIRHASHLIST_LOCK();
+	if (dh->dh_onlist)
+		TAILQ_REMOVE(_list, dh, dh_list);
+	DIRHASHLIST_UNLOCK();
 
 	/* The dirhash pointed to by 'dh' is exclusively ours now. */
 	mem = sizeof(*dh);



CVS commit: src/sys/ufs/ufs

2020-02-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Feb 26 18:00:12 UTC 2020

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
Zero out the padding in 'd_namlen', to prevent info leaks. Same logic as
ufs_makedirentry().

Found by kMSan: the unzeroed bytes of the pool_cache were getting copied
to the disk via a DMA write operation, and there kMSan was noticing
uninitialized memory leaving the system.

Reported-by: syzbot+382c9dffc06a9683a...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.248 src/sys/ufs/ufs/ufs_vnops.c:1.249
--- src/sys/ufs/ufs/ufs_vnops.c:1.248	Wed Sep 18 17:59:15 2019
+++ src/sys/ufs/ufs/ufs_vnops.c	Wed Feb 26 18:00:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.248 2019/09/18 17:59:15 christos Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.249 2020/02/26 18:00:12 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.248 2019/09/18 17:59:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.249 2020/02/26 18:00:12 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -873,7 +873,11 @@ ufs_whiteout(void *v)
 		newdir->d_namlen = cnp->cn_namelen;
 		memcpy(newdir->d_name, cnp->cn_nameptr,
 		(size_t)cnp->cn_namelen);
-		newdir->d_name[cnp->cn_namelen] = '\0';
+
+		/* NUL terminate and zero out padding */
+		memset(>d_name[cnp->cn_namelen], 0,
+		UFS_NAMEPAD(cnp->cn_namelen));
+
 		newdir->d_type = DT_WHT;
 		error = ufs_direnter(dvp, ulr, NULL, newdir, cnp, NULL);
 		pool_cache_put(ufs_direct_cache, newdir);



CVS commit: src/sys/ufs/ufs

2019-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  5 15:07:12 UTC 2019

Modified Files:
src/sys/ufs/ufs: dir.h ufs_lookup.c

Log Message:
Add more comments to explain what we are doing.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/ufs/dir.h
cvs rdiff -u -r1.149 -r1.150 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/dir.h
diff -u src/sys/ufs/ufs/dir.h:1.26 src/sys/ufs/ufs/dir.h:1.27
--- src/sys/ufs/ufs/dir.h:1.26	Sat May  4 21:48:53 2019
+++ src/sys/ufs/ufs/dir.h	Sun May  5 11:07:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.26 2019/05/05 01:48:53 christos Exp $	*/
+/*	$NetBSD: dir.h,v 1.27 2019/05/05 15:07:12 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -109,7 +109,9 @@ struct	direct {
  * The UFS_DIRSIZ macro gives the minimum record length which will hold
  * the directory entry.  This requires the amount of space in struct direct
  * without the d_name field, plus enough space for the name with a terminating
- * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
+ * NUL byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
+ * The UFS_NAMEPAD macro gives the number bytes of padding needed including
+ * the NUL terminating byte.
  */
 #define DIR_ROUNDUP	4
 #define UFS_NAMEROUNDUP(namlen)	(((namlen) + DIR_ROUNDUP) & ~(DIR_ROUNDUP - 1))

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.149 src/sys/ufs/ufs/ufs_lookup.c:1.150
--- src/sys/ufs/ufs/ufs_lookup.c:1.149	Sat May  4 21:48:53 2019
+++ src/sys/ufs/ufs/ufs_lookup.c	Sun May  5 11:07:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.149 2019/05/05 01:48:53 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.150 2019/05/05 15:07:12 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.149 2019/05/05 01:48:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.150 2019/05/05 15:07:12 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -799,7 +799,7 @@ ufs_makedirentry(struct inode *ip, struc
 	newdirp->d_namlen = namelen;
 	memcpy(newdirp->d_name, cnp->cn_nameptr, namelen);
 
-	/* Zero out padding */
+	/* NUL terminate and zero out padding */
 	memset(>d_name[namelen], 0, UFS_NAMEPAD(namelen));
 
 	if (FSFMT(ITOV(ip)))



CVS commit: src/sys/ufs/ufs

2019-05-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  5 01:48:53 UTC 2019

Modified Files:
src/sys/ufs/ufs: dir.h ufs_lookup.c

Log Message:
Zero out all the dirent padding not just one byte, to avoid kernel memory
disclosure (from https://svnweb.freebsd.org/base?view=revision=347066)


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ufs/dir.h
cvs rdiff -u -r1.148 -r1.149 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/dir.h
diff -u src/sys/ufs/ufs/dir.h:1.25 src/sys/ufs/ufs/dir.h:1.26
--- src/sys/ufs/ufs/dir.h:1.25	Tue Sep  1 02:16:03 2015
+++ src/sys/ufs/ufs/dir.h	Sat May  4 21:48:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp $	*/
+/*	$NetBSD: dir.h,v 1.26 2019/05/05 01:48:53 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -111,8 +111,11 @@ struct	direct {
  * without the d_name field, plus enough space for the name with a terminating
  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  */
+#define DIR_ROUNDUP	4
+#define UFS_NAMEROUNDUP(namlen)	(((namlen) + DIR_ROUNDUP) & ~(DIR_ROUNDUP - 1))
+#define UFS_NAMEPAD(namlen)	(DIR_ROUNDUP - ((namlen) & (DIR_ROUNDUP - 1)))
 #define	UFS_DIRECTSIZ(namlen) \
-	((sizeof(struct direct) - (FFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3))
+	((sizeof(struct direct) - (FFS_MAXNAMLEN+1)) + UFS_NAMEROUNDUP(namlen))
 
 #if (BYTE_ORDER == LITTLE_ENDIAN)
 #define UFS_DIRSIZ(oldfmt, dp, needswap)	\

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.148 src/sys/ufs/ufs/ufs_lookup.c:1.149
--- src/sys/ufs/ufs/ufs_lookup.c:1.148	Fri Oct 27 08:25:15 2017
+++ src/sys/ufs/ufs/ufs_lookup.c	Sat May  4 21:48:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.148 2017/10/27 12:25:15 joerg Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.149 2019/05/05 01:48:53 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.148 2017/10/27 12:25:15 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.149 2019/05/05 01:48:53 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -793,10 +793,15 @@ void
 ufs_makedirentry(struct inode *ip, struct componentname *cnp,
 struct direct *newdirp)
 {
+	size_t namelen = cnp->cn_namelen;
+
 	newdirp->d_ino = ip->i_number;
-	newdirp->d_namlen = cnp->cn_namelen;
-	memcpy(newdirp->d_name, cnp->cn_nameptr, (size_t)cnp->cn_namelen);
-	newdirp->d_name[cnp->cn_namelen] = '\0';
+	newdirp->d_namlen = namelen;
+	memcpy(newdirp->d_name, cnp->cn_nameptr, namelen);
+
+	/* Zero out padding */
+	memset(>d_name[namelen], 0, UFS_NAMEPAD(namelen));
+
 	if (FSFMT(ITOV(ip)))
 		newdirp->d_type = 0;
 	else



CVS commit: src/sys/ufs/ufs

2019-02-24 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Feb 25 06:00:40 UTC 2019

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
Revert -r1.244-245 of ufs_vnops.c; they are wrong.
Fix the mistake in -r1.243 that made them look like reasonable changes.

(this does not affect whether the -r1.243 change works with the union
mount path in libc, but fixes an immediate hazard)


To generate a diff of this commit:
cvs rdiff -u -r1.245 -r1.246 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.245 src/sys/ufs/ufs/ufs_vnops.c:1.246
--- src/sys/ufs/ufs/ufs_vnops.c:1.245	Mon Feb 25 00:51:24 2019
+++ src/sys/ufs/ufs/ufs_vnops.c	Mon Feb 25 06:00:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.245 2019/02/25 00:51:24 christos Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.246 2019/02/25 06:00:40 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.245 2019/02/25 00:51:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.246 2019/02/25 06:00:40 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1246,7 +1246,7 @@ ufs_readdir(void *v)
 	size_t		numcookies, maxcookies;
 	/* disk buffer */
 	off_t		physstart, physend;
-	size_t		skipstart;
+	size_t		skipstart, dropend;
 	char		*rawbuf;
 	size_t		rawbufmax, rawbytes;
 	struct uio	rawuio;
@@ -1277,11 +1277,13 @@ ufs_readdir(void *v)
 	}
 
 	skipstart = startoffset - physstart;
+	dropend = endoffset - physend;
 
 	/* how much to actually read */
 	rawbufmax = callerbytes + skipstart;
 	if (rawbufmax < callerbytes)
 		return EINVAL;
+	rawbufmax -= dropend;
 
 	if (rawbufmax < _DIRENT_MINSIZE(rawdp)) {
 		/* no room for even one struct direct */



CVS commit: src/sys/ufs/ufs

2019-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 25 00:51:24 UTC 2019

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
drop unused


To generate a diff of this commit:
cvs rdiff -u -r1.244 -r1.245 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.244 src/sys/ufs/ufs/ufs_vnops.c:1.245
--- src/sys/ufs/ufs/ufs_vnops.c:1.244	Sun Feb 24 19:11:13 2019
+++ src/sys/ufs/ufs/ufs_vnops.c	Sun Feb 24 19:51:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.244 2019/02/25 00:11:13 christos Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.245 2019/02/25 00:51:24 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.244 2019/02/25 00:11:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.245 2019/02/25 00:51:24 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1246,7 +1246,7 @@ ufs_readdir(void *v)
 	size_t		numcookies, maxcookies;
 	/* disk buffer */
 	off_t		physstart, physend;
-	size_t		skipstart, dropend;
+	size_t		skipstart;
 	char		*rawbuf;
 	size_t		rawbufmax, rawbytes;
 	struct uio	rawuio;
@@ -1277,7 +1277,6 @@ ufs_readdir(void *v)
 	}
 
 	skipstart = startoffset - physstart;
-	dropend = endoffset - physend;
 
 	/* how much to actually read */
 	rawbufmax = callerbytes + skipstart;



CVS commit: src/sys/ufs/ufs

2019-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 25 00:11:13 UTC 2019

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
remove junk assignment.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.243 src/sys/ufs/ufs/ufs_vnops.c:1.244
--- src/sys/ufs/ufs/ufs_vnops.c:1.243	Sun Feb 24 14:06:40 2019
+++ src/sys/ufs/ufs/ufs_vnops.c	Sun Feb 24 19:11:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.243 2019/02/24 19:06:40 mlelstv Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.244 2019/02/25 00:11:13 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.243 2019/02/24 19:06:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.244 2019/02/25 00:11:13 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1283,7 +1283,6 @@ ufs_readdir(void *v)
 	rawbufmax = callerbytes + skipstart;
 	if (rawbufmax < callerbytes)
 		return EINVAL;
-	rawbuf -= dropend;
 
 	if (rawbufmax < _DIRENT_MINSIZE(rawdp)) {
 		/* no room for even one struct direct */



CVS commit: src/sys/ufs/ufs

2019-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Feb 24 19:06:40 UTC 2019

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
Reading a directory may trigger a panic when the buffer is too small.
Adjust necessary checks.

While here, also check for arithmetic overflow.

Reported-by: syzbot+88ecace8bff241690...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.242 src/sys/ufs/ufs/ufs_vnops.c:1.243
--- src/sys/ufs/ufs/ufs_vnops.c:1.242	Tue Jan  1 10:06:55 2019
+++ src/sys/ufs/ufs/ufs_vnops.c	Sun Feb 24 19:06:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.242 2019/01/01 10:06:55 hannken Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.243 2019/02/24 19:06:40 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.242 2019/01/01 10:06:55 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.243 2019/02/24 19:06:40 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1268,19 +1268,28 @@ ufs_readdir(void *v)
 	}
 
 	/* round start and end down to block boundaries */
-	physstart = startoffset & ~(off_t)(ump->um_dirblksiz - 1);
-	physend = endoffset & ~(off_t)(ump->um_dirblksiz - 1);
+	physstart = rounddown2(startoffset, ump->um_dirblksiz);
+	physend = rounddown2(endoffset, ump->um_dirblksiz);
+
+	if (physstart >= physend) {
+		/* Need at least one block */
+		return EINVAL;
+	}
+
 	skipstart = startoffset - physstart;
 	dropend = endoffset - physend;
 
-	if (callerbytes - dropend < _DIRENT_MINSIZE(rawdp)) {
+	/* how much to actually read */
+	rawbufmax = callerbytes + skipstart;
+	if (rawbufmax < callerbytes)
+		return EINVAL;
+	rawbuf -= dropend;
+
+	if (rawbufmax < _DIRENT_MINSIZE(rawdp)) {
 		/* no room for even one struct direct */
 		return EINVAL;
 	}
 
-	/* how much to actually read */
-	rawbufmax = callerbytes + skipstart - dropend;
-
 	/* read it */
 	rawbuf = kmem_alloc(rawbufmax, KM_SLEEP);
 	rawiov.iov_base = rawbuf;



CVS commit: src/sys/ufs/ufs

2018-01-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Jan 28 10:01:18 UTC 2018

Modified Files:
src/sys/ufs/ufs: ufs_inode.c

Log Message:
Make sure inode blocks and size are zero when VOP_INACTIVE()
finalises a now unlinked inode.
Counterpart of the check in ffs_newvnode().


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/ufs/ufs/ufs_inode.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.102 src/sys/ufs/ufs/ufs_inode.c:1.103
--- src/sys/ufs/ufs/ufs_inode.c:1.102	Sat Oct 28 00:37:13 2017
+++ src/sys/ufs/ufs/ufs_inode.c	Sun Jan 28 10:01:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.102 2017/10/28 00:37:13 pgoyette Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.103 2018/01/28 10:01:18 hannken Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.102 2017/10/28 00:37:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.103 2018/01/28 10:01:18 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -149,6 +149,15 @@ out:
 	 */
 	*ap->a_recycle = (ip->i_mode == 0);
 
+	if (ip->i_mode == 0 && (DIP(ip, size) != 0 || DIP(ip, blocks) != 0)) {
+		printf("%s: unlinked ino %" PRId64 " on \"%s\" has"
+		" non zero size %" PRIx64 " or blocks %" PRIx64
+		" with allerror %d\n",
+		__func__, ip->i_number, mp->mnt_stat.f_mntonname,
+		DIP(ip, size), DIP(ip, blocks), allerror);
+		panic("%s: dirty filesystem?", __func__);
+	}
+
 	return (allerror);
 }
 



CVS commit: src/sys/ufs/ufs

2017-10-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Oct 25 18:06:01 UTC 2017

Modified Files:
src/sys/ufs/ufs: quota2.h

Log Message:
fix tyop, PR kern/52653 by Edgar Fuss


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ufs/quota2.h

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

Modified files:

Index: src/sys/ufs/ufs/quota2.h
diff -u src/sys/ufs/ufs/quota2.h:1.9 src/sys/ufs/ufs/quota2.h:1.10
--- src/sys/ufs/ufs/quota2.h:1.9	Sun Feb  5 14:19:04 2012
+++ src/sys/ufs/ufs/quota2.h	Wed Oct 25 18:06:01 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: quota2.h,v 1.9 2012/02/05 14:19:04 dholland Exp $ */
+/* $NetBSD: quota2.h,v 1.10 2017/10/25 18:06:01 jdolecek Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -56,7 +56,7 @@ struct quota2_val {
 
 /*
  * On-disk description of a user or group quota
- * These entries are keept as linked list, either in one of the hash HEAD,
+ * These entries are kept as linked list, either in one of the hash HEAD,
  * or in the free list.
  */
 



CVS commit: src/sys/ufs/ufs

2017-08-20 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun Aug 20 12:09:06 UTC 2017

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
update the comment to the current IFMT/permissions location


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/ufs/ufs/inode.h

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

Modified files:

Index: src/sys/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.75 src/sys/ufs/ufs/inode.h:1.76
--- src/sys/ufs/ufs/inode.h:1.75	Sun Aug 14 11:31:41 2016
+++ src/sys/ufs/ufs/inode.h	Sun Aug 20 12:09:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.75 2016/08/14 11:31:41 jdolecek Exp $	*/
+/*	$NetBSD: inode.h,v 1.76 2017/08/20 12:09:06 maya Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -144,7 +144,7 @@ struct inode {
 	 * These fields are currently only used by FFS and LFS,
 	 * do NOT use them with ext2fs.
 	 */
-	u_int16_t i_mode;	/* IFMT, permissions; see below. */
+	u_int16_t i_mode;	/* IFMT, permissions; see dinode.h. */
 	int16_t   i_nlink;	/* File link count. */
 	u_int64_t i_size;	/* File byte count. */
 	u_int32_t i_flags;	/* Status flags (chflags). */



CVS commit: src/sys/ufs/ufs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:11:45 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.145 src/sys/ufs/ufs/ufs_lookup.c:1.146
--- src/sys/ufs/ufs/ufs_lookup.c:1.145	Fri Apr 29 02:38:19 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Thu Mar 30 09:11:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -376,8 +375,6 @@ ufs_lookup(void *v)
 		cnp->cn_flags |= ISWHITEOUT;
 	}
 
-	fstrans_start(vdp->v_mount, FSTRANS_SHARED);
-
 	/*
 	 * Suppress search for slots unless creating
 	 * file and at end of pathname, in which case
@@ -695,7 +692,6 @@ found:
 	error = 0;
 
 out:
-	fstrans_done(vdp->v_mount);
 	return error;
 }
 



CVS commit: src/sys/ufs/ufs

2017-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 18 05:39:06 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.235 src/sys/ufs/ufs/ufs_vnops.c:1.236
--- src/sys/ufs/ufs/ufs_vnops.c:1.235	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ufs/ufs_vnops.c	Sat Mar 18 05:39:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.235 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.236 2017/03/18 05:39:06 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.235 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.236 2017/03/18 05:39:06 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -865,10 +865,9 @@ ufs_whiteout(void *v)
 		error = UFS_WAPBL_BEGIN(dvp->v_mount);
 		if (error)
 			break;
-#ifdef DIAGNOSTIC
-		if (ump->um_maxsymlinklen <= 0)
-			panic("ufs_whiteout: old format filesystem");
-#endif
+
+		KASSERTMSG((ump->um_maxsymlinklen > 0),
+		"ufs_whiteout: old format filesystem");
 
 		newdir = pool_cache_get(ufs_direct_cache, PR_WAITOK);
 		newdir->d_ino = UFS_WINO;
@@ -886,10 +885,9 @@ ufs_whiteout(void *v)
 		error = UFS_WAPBL_BEGIN(dvp->v_mount);
 		if (error)
 			break;
-#ifdef DIAGNOSTIC
-		if (ump->um_maxsymlinklen <= 0)
-			panic("ufs_whiteout: old format filesystem");
-#endif
+
+		KASSERTMSG((ump->um_maxsymlinklen > 0),
+		"ufs_whiteout: old format filesystem");
 
 		cnp->cn_flags &= ~DOWHITEOUT;
 		error = ufs_dirremove(dvp, ulr, NULL, cnp->cn_flags, 0);



CVS commit: src/sys/ufs/ufs

2017-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 18 05:33:07 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_bmap.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ufs/ufs_bmap.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_bmap.c
diff -u src/sys/ufs/ufs/ufs_bmap.c:1.51 src/sys/ufs/ufs/ufs_bmap.c:1.52
--- src/sys/ufs/ufs/ufs_bmap.c:1.51	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ufs/ufs_bmap.c	Sat Mar 18 05:33:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_bmap.c,v 1.51 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.51 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $");
 
 #include 
 #include 
@@ -127,10 +127,8 @@ ufs_bmaparray(struct vnode *vp, daddr_t 
 	ip = VTOI(vp);
 	mp = vp->v_mount;
 	ump = ip->i_ump;
-#ifdef DIAGNOSTIC
-	if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL))
-		panic("ufs_bmaparray: invalid arguments");
-#endif
+	KASSERTMSG(((ap == NULL) == (nump == NULL)),
+	"ufs_bmaparray: invalid arguments: ap = %p, nump = %p", ap, nump);
 
 	if (runp) {
 		/*
@@ -249,12 +247,9 @@ ufs_bmaparray(struct vnode *vp, daddr_t 
 		}
 		if (bp->b_oflags & (BO_DONE | BO_DELWRI)) {
 			trace(TR_BREADHIT, pack(vp, size), metalbn);
-		}
-#ifdef DIAGNOSTIC
-		else if (!daddr)
-			panic("ufs_bmaparray: indirect block not in cache");
-#endif
-		else {
+		} else {
+			KASSERTMSG((daddr != 0),
+			"ufs_bmaparray: indirect block not in cache");
 			trace(TR_BREADMISS, pack(vp, size), metalbn);
 			bp->b_blkno = blkptrtodb(ump, daddr);
 			bp->b_flags |= B_READ;



CVS commit: src/sys/ufs/ufs

2017-01-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan  4 10:04:17 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_inode.c

Log Message:
Change ufs_truncate_retry() to call UFS_TRUNCATE() at least once.
Even with "newsize == ip->i_size" it must set mtime etc.

Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)"


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/ufs/ufs/ufs_inode.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.97 src/sys/ufs/ufs/ufs_inode.c:1.98
--- src/sys/ufs/ufs/ufs_inode.c:1.97	Fri Oct 28 20:38:12 2016
+++ src/sys/ufs/ufs/ufs_inode.c	Wed Jan  4 10:04:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.97 2016/10/28 20:38:12 jdolecek Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.98 2017/01/04 10:04:17 hannken Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.97 2016/10/28 20:38:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.98 2017/01/04 10:04:17 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -303,7 +303,7 @@ ufs_truncate_retry(struct vnode *vp, uin
 	/*
 	 * Truncate might temporarily fail, loop until done.
 	 */
-	while (ip->i_size != newsize) {
+	do {
 		error = UFS_WAPBL_BEGIN(mp);
 		if (error)
 			goto out;
@@ -313,7 +313,7 @@ ufs_truncate_retry(struct vnode *vp, uin
 
 		if (error != 0 && error != EAGAIN)
 			goto out;
-	}
+	} while (ip->i_size != newsize);
 
   out:
 	return error;



CVS commit: src/sys/ufs/ufs

2016-11-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Nov 20 21:21:26 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_quota2.c

Log Message:
KASSERT(mutex_owner(...)) ---> KASSERT(mutex_owned(...))

Fixes part of PR kern/47114.  Tested by code inspection.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ufs/ufs_quota2.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota2.c
diff -u src/sys/ufs/ufs/ufs_quota2.c:1.40 src/sys/ufs/ufs/ufs_quota2.c:1.41
--- src/sys/ufs/ufs/ufs_quota2.c:1.40	Sat Mar 28 19:24:05 2015
+++ src/sys/ufs/ufs/ufs_quota2.c	Sun Nov 20 21:21:26 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.40 2015/03/28 19:24:05 maxv Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.41 2016/11/20 21:21:26 riastradh Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.40 2015/03/28 19:24:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.41 2016/11/20 21:21:26 riastradh Exp $");
 
 #include 
 #include 
@@ -200,7 +200,7 @@ quota2_walk_list(struct ufsmount *ump, s
 	struct quota2_entry *q2e;
 	daddr_t lblkno, blkoff, olblkno = 0;
 
-	KASSERT(mutex_owner());
+	KASSERT(mutex_owned());
 
 	while (off != 0) {
 		lblkno = (off >> ump->um_mountp->mnt_fs_bshift);



CVS commit: src/sys/ufs/ufs

2016-11-11 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Nov 11 22:59:26 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_wapbl.h

Log Message:
fix !WAPBL variant of UFS_WAPBL_REGISTER_DEALLOCATION()


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/ufs/ufs_wapbl.h

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

Modified files:

Index: src/sys/ufs/ufs/ufs_wapbl.h
diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.13 src/sys/ufs/ufs/ufs_wapbl.h:1.14
--- src/sys/ufs/ufs/ufs_wapbl.h:1.13	Thu Nov 10 20:56:32 2016
+++ src/sys/ufs/ufs/ufs_wapbl.h	Fri Nov 11 22:59:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_wapbl.h,v 1.13 2016/11/10 20:56:32 jdolecek Exp $	*/
+/*	$NetBSD: ufs_wapbl.h,v 1.14 2016/11/11 22:59:26 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -171,8 +171,8 @@ ufs_wapbl_end(struct mount *mp)
 #define	UFS_WAPBL_JUNLOCK_ASSERT(mp)
 #define	UFS_WAPBL_REGISTER_INODE(mp, ino, mode)		do { } while (0)
 #define	UFS_WAPBL_UNREGISTER_INODE(mp, ino, mode)	do { } while (0)
-#define	UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len)		0
-#define	UFS_WAPBL_REGISTER_DEALLOCATION_FORCE(mp, blk, len)	0
+#define	UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len, cookiep)		0
+#define	UFS_WAPBL_REGISTER_DEALLOCATION_FORCE(mp, blk, len)		0
 #define	UFS_WAPBL_UNREGISTER_DEALLOCATION(mp, cookie)	do { } while (0)
 #endif
 



CVS commit: src/sys/ufs/ufs

2016-11-08 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Nov  9 05:08:35 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_extattr.c

Log Message:
Explain why the lock in here needs to be recursive. Related to PR 46997.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ufs/ufs_extattr.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extattr.c
diff -u src/sys/ufs/ufs/ufs_extattr.c:1.47 src/sys/ufs/ufs/ufs_extattr.c:1.48
--- src/sys/ufs/ufs/ufs_extattr.c:1.47	Thu Jul  7 06:55:44 2016
+++ src/sys/ufs/ufs/ufs_extattr.c	Wed Nov  9 05:08:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extattr.c,v 1.47 2016/07/07 06:55:44 msaitoh Exp $	*/
+/*	$NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.47 2016/07/07 06:55:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -168,7 +168,13 @@ static void
 ufs_extattr_uepm_lock(struct ufsmount *ump)
 {
 
-	/* XXX Why does this need to be recursive? */
+	/*
+	 * XXX This needs to be recursive for the following reasons:
+	 *   - it is taken in ufs_extattr_vnode_inactive
+	 *   - which is called from VOP_INACTIVE
+	 *   - which can be triggered by any vrele, vput, or vn_close
+	 *   - several of these can happen while it's held
+	 */
 	if (mutex_owned(>um_extattr.uepm_lock)) {
 		ump->um_extattr.uepm_lockcnt++;
 		return;



CVS commit: src/sys/ufs/ufs

2016-11-08 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Nov  9 04:12:55 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
ufs_makeinode is declared file-static at the top of the file; mark it
at its definition too, for consistency and to avoid misleading casual
passersby.


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.233 src/sys/ufs/ufs/ufs_vnops.c:1.234
--- src/sys/ufs/ufs/ufs_vnops.c:1.233	Fri Oct 28 20:38:12 2016
+++ src/sys/ufs/ufs/ufs_vnops.c	Wed Nov  9 04:12:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.233 2016/10/28 20:38:12 jdolecek Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.234 2016/11/09 04:12:55 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.233 2016/10/28 20:38:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.234 2016/11/09 04:12:55 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1764,7 +1764,7 @@ ufs_vinit(struct mount *mntp, int (**spe
 /*
  * Allocate a new inode.
  */
-int
+static int
 ufs_makeinode(struct vattr *vap, struct vnode *dvp,
 	const struct ufs_lookup_results *ulr,
 	struct vnode **vpp, struct componentname *cnp)



CVS commit: src/sys/ufs/ufs

2016-08-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 14 11:31:41 UTC 2016

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
again remove IN_E4EXTENTS; it's not used anywhere any more, and it's better to 
keep fs-specific flags out of generic headers anyway


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/ufs/ufs/inode.h

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

Modified files:

Index: src/sys/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.74 src/sys/ufs/ufs/inode.h:1.75
--- src/sys/ufs/ufs/inode.h:1.74	Thu Aug  4 17:47:47 2016
+++ src/sys/ufs/ufs/inode.h	Sun Aug 14 11:31:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.74 2016/08/04 17:47:47 jdolecek Exp $	*/
+/*	$NetBSD: inode.h,v 1.75 2016/08/14 11:31:41 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -226,7 +226,6 @@ struct inode {
 /*	   unused   0x1000 */	/* was LFS-only IN_PAGING */
 #define	IN_MODIFY	0x2000		/* Modification time update request. */
 /*	   unused	0x4000 */	/* was LFS-only IN_CDIROP */
-#define	IN_E4EXTENTS0x8000		/* ext4 extents */
 
 #if defined(_KERNEL)
 



CVS commit: src/sys/ufs/ufs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 00:52:04 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_quota1.c

Log Message:
Widen before multiplying. Like -r1.21, but in the other similar case.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/ufs/ufs_quota1.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.21 src/sys/ufs/ufs/ufs_quota1.c:1.22
--- src/sys/ufs/ufs/ufs_quota1.c:1.21	Tue Nov 25 19:48:24 2014
+++ src/sys/ufs/ufs/ufs_quota1.c	Mon Jun 20 00:52:04 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.21 2014/11/25 19:48:24 christos Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.21 2014/11/25 19:48:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $");
 
 #include 
 #include 
@@ -806,7 +806,7 @@ dq1get(struct vnode *dqvp, u_long id, st
 	aiov.iov_base = (void *)>dq_un.dq1_dqb;
 	aiov.iov_len = sizeof (struct dqblk);
 	auio.uio_resid = sizeof (struct dqblk);
-	auio.uio_offset = (off_t)(id * sizeof (struct dqblk));
+	auio.uio_offset = (off_t)id * sizeof (struct dqblk);
 	auio.uio_rw = UIO_READ;
 	UIO_SETUP_SYSSPACE();
 	error = VOP_READ(dqvp, , 0, ump->um_cred[type]);



CVS commit: src/sys/ufs/ufs

2016-06-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun  3 15:36:03 UTC 2016

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
ext4 extents glue


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/ufs/ufs/inode.h

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

Modified files:

Index: src/sys/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.71 src/sys/ufs/ufs/inode.h:1.72
--- src/sys/ufs/ufs/inode.h:1.71	Mon May 26 15:16:39 2014
+++ src/sys/ufs/ufs/inode.h	Fri Jun  3 11:36:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.71 2014/05/26 19:16:39 dholland Exp $	*/
+/*	$NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /*
@@ -78,6 +79,7 @@ struct ffs_inode_ext {
 struct ext2fs_inode_ext {
 	daddr_t ext2fs_last_lblk;	/* last logical block allocated */
 	daddr_t ext2fs_last_blk;	/* last block allocated on disk */
+	struct ext4_extent_cache i_ext_cache; /* cache for ext4 extent */
 };
 
 struct lfs_inode_ext;
@@ -234,8 +236,7 @@ struct inode {
 /* These flags are kept in i_flag. */
 #define	IN_ACCESS	0x0001		/* Access time update request. */
 #define	IN_CHANGE	0x0002		/* Inode change time update request. */
-#define	IN_UPDATE	0x0004		/* Inode was written to; update mtime. */
-#define	IN_MODIFY	0x2000		/* Modification time update request. */
+#define	IN_UPDATE	0x0004		/* Inode written to; update mtime. */
 #define	IN_MODIFIED	0x0008		/* Inode has been modified. */
 #define	IN_ACCESSED	0x0010		/* Inode has been accessed. */
 /* 	   unused	0x0020 */	/* was IN_RENAME */
@@ -244,8 +245,12 @@ struct inode {
 /*	   unused	0x0100 */	/* was LFS-only IN_CLEANING */
 /*	   unused	0x0200 */	/* was LFS-only IN_ADIROP */
 #define	IN_SPACECOUNTED	0x0400		/* Blocks to be freed in free count. */
+/*	   unused	0x0800 */	/* what was that? */
 /*	   unused   0x1000 */	/* was LFS-only IN_PAGING */
+#define	IN_MODIFY	0x2000		/* Modification time update request. */
 /*	   unused	0x4000 */	/* was LFS-only IN_CDIROP */
+#define	IN_E4EXTENTS0x8000		/* ext4 extents */
+
 #if defined(_KERNEL)
 
 /*



CVS commit: src/sys/ufs/ufs

2016-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 19 18:32:03 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c ufs_wapbl.h

Log Message:
Get rid of UFS_WAPBL_BEGIN1/END1

ufs makeinode no longer releases dvp, so incrementing the
usecount for wapbl is unnecessary.

>From coypu.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/ufs/ufs/ufs_vnops.c
cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ufs/ufs_wapbl.h

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.231 src/sys/ufs/ufs/ufs_vnops.c:1.232
--- src/sys/ufs/ufs/ufs_vnops.c:1.231	Tue Sep  1 06:09:23 2015
+++ src/sys/ufs/ufs/ufs_vnops.c	Thu May 19 18:32:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.231 2015/09/01 06:09:23 dholland Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.232 2016/05/19 18:32:03 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.231 2015/09/01 06:09:23 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.232 2016/05/19 18:32:03 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -151,7 +151,7 @@ ufs_create(void *v)
 	UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
 
 	/*
-	 * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
+	 * UFS_WAPBL_BEGIN(dvp->v_mount) performed by successful
 	 * ufs_makeinode
 	 */
 	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
@@ -160,7 +160,7 @@ ufs_create(void *v)
 		fstrans_done(dvp->v_mount);
 		return (error);
 	}
-	UFS_WAPBL_END1(dvp->v_mount, dvp);
+	UFS_WAPBL_END(dvp->v_mount);
 	fstrans_done(dvp->v_mount);
 	VN_KNOTE(dvp, NOTE_WRITE);
 	VOP_UNLOCK(*ap->a_vpp);
@@ -194,7 +194,7 @@ ufs_mknod(void *v)
 	UFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp));
 
 	/*
-	 * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
+	 * UFS_WAPBL_BEGIN(dvp->v_mount) performed by successful
 	 * ufs_makeinode
 	 */
 	fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
@@ -204,7 +204,7 @@ ufs_mknod(void *v)
 	ip = VTOI(*vpp);
 	ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
 	UFS_WAPBL_UPDATE(*vpp, NULL, NULL, 0);
-	UFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp);
+	UFS_WAPBL_END(ap->a_dvp->v_mount);
 	VOP_UNLOCK(*vpp);
 out:
 	fstrans_done(ap->a_dvp->v_mount);
@@ -1200,7 +1200,7 @@ ufs_symlink(void *v)
 	UFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp));
 
 	/*
-	 * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
+	 * UFS_WAPBL_BEGIN(dvp->v_mount) performed by successful
 	 * ufs_makeinode
 	 */
 	fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
@@ -1232,7 +1232,7 @@ ufs_symlink(void *v)
 		error = ufs_bufio(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
 		IO_NODELOCKED | IO_JOURNALLOCKED, ap->a_cnp->cn_cred, NULL,
 		NULL);
-	UFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp);
+	UFS_WAPBL_END(ap->a_dvp->v_mount);
 	VOP_UNLOCK(vp);
 	if (error)
 		vrele(vp);
@@ -1784,7 +1784,7 @@ ufs_makeinode(struct vattr *vap, struct 
 	}
 	*vpp = tvp;
 	ip = VTOI(tvp);
-	error = UFS_WAPBL_BEGIN1(dvp->v_mount, dvp);
+	error = UFS_WAPBL_BEGIN(dvp->v_mount);
 	if (error) {
 		vput(tvp);
 		return (error);
@@ -1832,7 +1832,7 @@ ufs_makeinode(struct vattr *vap, struct 
 	DIP_ASSIGN(ip, nlink, 0);
 	ip->i_flag |= IN_CHANGE;
 	UFS_WAPBL_UPDATE(tvp, NULL, NULL, 0);
-	UFS_WAPBL_END1(dvp->v_mount, dvp);
+	UFS_WAPBL_END(dvp->v_mount);
 	vput(tvp);
 	return (error);
 }

Index: src/sys/ufs/ufs/ufs_wapbl.h
diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.8 src/sys/ufs/ufs/ufs_wapbl.h:1.9
--- src/sys/ufs/ufs/ufs_wapbl.h:1.8	Sun Nov 10 18:28:08 2013
+++ src/sys/ufs/ufs/ufs_wapbl.h	Thu May 19 18:32:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_wapbl.h,v 1.8 2013/11/10 18:28:08 christos Exp $	*/
+/*	$NetBSD: ufs_wapbl.h,v 1.9 2016/05/19 18:32:03 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -134,10 +134,7 @@ ufs_wapbl_end2(struct mount *mp, struct 
 
 #define	UFS_WAPBL_BEGIN(mp)		\
 	ufs_wapbl_begin2(mp, NULL, NULL, __FUNCTION__, __LINE__)
-#define	UFS_WAPBL_BEGIN1(mp, v1)	\
-	ufs_wapbl_begin2(mp, v1, NULL, __FUNCTION__, __LINE__)
 #define	UFS_WAPBL_END(mp)	ufs_wapbl_end2(mp, NULL, NULL)
-#define	UFS_WAPBL_END1(mp, v1)	ufs_wapbl_end2(mp, v1, NULL)
 
 #define	UFS_WAPBL_UPDATE(vp, access, modify, flags)			\
 	if ((vp)->v_mount->mnt_wapbl) {	\
@@ -164,9 +161,7 @@ ufs_wapbl_end2(struct mount *mp, struct 
 
 #else /* ! WAPBL */
 #define	UFS_WAPBL_BEGIN(mp) (__USE(mp), 0)
-#define	UFS_WAPBL_BEGIN1(mp, v1) 0
 #define	UFS_WAPBL_END(mp)	do { } while (0)
-#define	UFS_WAPBL_END1(mp, v1)
 #define	UFS_WAPBL_UPDATE(vp, access, modify, flags)	do { } while (0)
 #define	UFS_WAPBL_JLOCK_ASSERT(mp)
 #define	UFS_WAPBL_JUNLOCK_ASSERT(mp)



CVS commit: src/sys/ufs/ufs

2016-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 19 18:32:20 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_wapbl.h

Log Message:
While here, replace GCC __FUNCTION__ by C99 __func__

>From coypu.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/ufs_wapbl.h

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

Modified files:

Index: src/sys/ufs/ufs/ufs_wapbl.h
diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.10 src/sys/ufs/ufs/ufs_wapbl.h:1.11
--- src/sys/ufs/ufs/ufs_wapbl.h:1.10	Thu May 19 18:32:11 2016
+++ src/sys/ufs/ufs/ufs_wapbl.h	Thu May 19 18:32:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_wapbl.h,v 1.10 2016/05/19 18:32:11 riastradh Exp $	*/
+/*	$NetBSD: ufs_wapbl.h,v 1.11 2016/05/19 18:32:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@ ufs_wapbl_end(struct mount *mp)
 }
 
 #define	UFS_WAPBL_BEGIN(mp)		\
-	ufs_wapbl_begin(mp, __FUNCTION__, __LINE__)
+	ufs_wapbl_begin(mp, __func__, __LINE__)
 #define	UFS_WAPBL_END(mp) ufs_wapbl_end(mp)
 
 #define	UFS_WAPBL_UPDATE(vp, access, modify, flags)			\



CVS commit: src/sys/ufs/ufs

2016-05-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 19 18:32:11 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_wapbl.h

Log Message:
Simplify ufs_wapbl_begin2/end2, drop 2 suffix

We are no longer calling UFS_WAPBL_BEGIN/END with vnodes (we are giving
NULL as a parameter in all cases), so we can get rid of this input
parameter and the relevant check.

>From coypu.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ufs/ufs_wapbl.h

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

Modified files:

Index: src/sys/ufs/ufs/ufs_wapbl.h
diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.9 src/sys/ufs/ufs/ufs_wapbl.h:1.10
--- src/sys/ufs/ufs/ufs_wapbl.h:1.9	Thu May 19 18:32:03 2016
+++ src/sys/ufs/ufs/ufs_wapbl.h	Thu May 19 18:32:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_wapbl.h,v 1.9 2016/05/19 18:32:03 riastradh Exp $	*/
+/*	$NetBSD: ufs_wapbl.h,v 1.10 2016/05/19 18:32:11 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -95,16 +95,10 @@ void	ufs_wapbl_verify_inodes(struct moun
 #endif
 
 static __inline int
-ufs_wapbl_begin2(struct mount *mp, struct vnode *vp1, struct vnode *vp2,
-		 const char *file, int line)
+ufs_wapbl_begin(struct mount *mp, const char *file, int line)
 {
 	if (mp->mnt_wapbl) {
 		int error;
-
-		if (vp1)
-			vref(vp1);
-		if (vp2)
-			vref(vp2);
 		error = wapbl_begin(mp->mnt_wapbl, file, line);
 		if (error)
 			return error;
@@ -117,7 +111,7 @@ ufs_wapbl_begin2(struct mount *mp, struc
 }
 
 static __inline void
-ufs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2)
+ufs_wapbl_end(struct mount *mp)
 {
 	if (mp->mnt_wapbl) {
 #ifdef WAPBL_DEBUG_INODES
@@ -125,16 +119,12 @@ ufs_wapbl_end2(struct mount *mp, struct 
 			ufs_wapbl_verify_inodes(mp, "wapbl_end");
 #endif
 		wapbl_end(mp->mnt_wapbl);
-		if (vp2)
-			vrele(vp2);
-		if (vp1)
-			vrele(vp1);
 	}
 }
 
 #define	UFS_WAPBL_BEGIN(mp)		\
-	ufs_wapbl_begin2(mp, NULL, NULL, __FUNCTION__, __LINE__)
-#define	UFS_WAPBL_END(mp)	ufs_wapbl_end2(mp, NULL, NULL)
+	ufs_wapbl_begin(mp, __FUNCTION__, __LINE__)
+#define	UFS_WAPBL_END(mp) ufs_wapbl_end(mp)
 
 #define	UFS_WAPBL_UPDATE(vp, access, modify, flags)			\
 	if ((vp)->v_mount->mnt_wapbl) {	\



CVS commit: src/sys/ufs/ufs

2016-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 29 03:05:05 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_bswap.h

Log Message:
use variables that could be unused.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/ufs/ufs_bswap.h

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

Modified files:

Index: src/sys/ufs/ufs/ufs_bswap.h
diff -u src/sys/ufs/ufs/ufs_bswap.h:1.20 src/sys/ufs/ufs/ufs_bswap.h:1.21
--- src/sys/ufs/ufs/ufs_bswap.h:1.20	Sat Oct 19 16:12:18 2013
+++ src/sys/ufs/ufs/ufs_bswap.h	Thu Apr 28 23:05:04 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_bswap.h,v 1.20 2013/10/19 20:12:18 mrg Exp $	*/
+/*	$NetBSD: ufs_bswap.h,v 1.21 2016/04/29 03:05:04 christos Exp $	*/
 
 /*
  * Copyright (c) 1998 Manuel Bouyer.
@@ -40,9 +40,9 @@
 #define UFS_FSNEEDSWAP(fs)	((fs)->fs_flags & FS_SWAPPED)
 #define	UFS_IPNEEDSWAP(ip)	UFS_MPNEEDSWAP((ip)->i_ump)
 #else
-#define	UFS_MPNEEDSWAP(ump)	(0)
-#define UFS_FSNEEDSWAP(fs)	(0)
-#define	UFS_IPNEEDSWAP(ip)	(0)
+#define	UFS_MPNEEDSWAP(ump)	((void)(ump), 0)
+#define UFS_FSNEEDSWAP(fs)	((void)(fs), 0)
+#define	UFS_IPNEEDSWAP(ip)	((void)(ip), 0)
 #endif
 
 #if !defined(_KERNEL) || defined(FFS_EI)



CVS commit: src/sys/ufs/ufs

2016-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 29 02:38:19 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
mention the PR


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.144 src/sys/ufs/ufs/ufs_lookup.c:1.145
--- src/sys/ufs/ufs/ufs_lookup.c:1.144	Thu Apr 28 22:16:53 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Thu Apr 28 22:38:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.144 2016/04/29 02:16:53 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.144 2016/04/29 02:16:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -865,7 +865,7 @@ ufs_dirgrow(struct vnode *dvp, const str
 
 static int
 #if __GNUC_PREREQ__(5, 3)
-/* This gets miscompiled by gcc 5.3 */
+/* This gets miscompiled by gcc 5.3 PR/51094 */
 __attribute__((__optimize__("no-tree-vrp")))
 #endif
 ufs_dircompact(struct vnode *dvp, const struct ufs_lookup_results *ulr,



CVS commit: src/sys/ufs/ufs

2016-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 29 02:16:53 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Split ufs_direnter futher and turn off tree-vrp for the broken function.


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.143 src/sys/ufs/ufs/ufs_lookup.c:1.144
--- src/sys/ufs/ufs/ufs_lookup.c:1.143	Wed Apr 13 23:25:28 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Thu Apr 28 22:16:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.143 2016/04/14 03:25:28 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.144 2016/04/29 02:16:53 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.143 2016/04/14 03:25:28 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.144 2016/04/29 02:16:53 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -807,102 +807,85 @@ ufs_makedirentry(struct inode *ip, struc
 		newdirp->d_type = IFTODT(ip->i_mode);
 }
 
-/*
- * Write a directory entry after a call to namei, using the parameters
- * that ufs_lookup left in nameidata and in the ufs_lookup_results.
- *
- * DVP is the directory to be updated. It must be locked.
- * ULR is the ufs_lookup_results structure from the final lookup step.
- * TVP is not used. (XXX: why is it here? remove it)
- * DIRP is the new directory entry contents.
- * CNP is the componentname from the final lookup step.
- * NEWDIRBP is not used and (XXX) should be removed. The previous
- * comment here said it was used by the now-removed softupdates code.
- *
- * The link count of the target inode is *not* incremented; the
- * caller does that.
- *
- * If ulr->ulr_count is 0, ufs_lookup did not find space to insert the
- * directory entry. ulr_offset, which is the place to put the entry,
- * should be on a block boundary (and should be at the end of the
- * directory AFAIK) and a fresh block is allocated to put the new
- * directory entry in.
- *
- * If ulr->ulr_count is not zero, ufs_lookup found a slot to insert
- * the entry into. This slot ranges from ulr_offset to ulr_offset +
- * ulr_count. However, this slot may already be partially populated
- * requiring compaction. See notes below.
- *
- * Furthermore, if ulr_count is not zero and ulr_endoff is not the
- * same as i_size, the directory is truncated to size ulr_endoff.
- */
-int
-ufs_direnter(struct vnode *dvp, const struct ufs_lookup_results *ulr,
+
+static int
+ufs_dirgrow(struct vnode *dvp, const struct ufs_lookup_results *ulr,
 struct vnode *tvp, struct direct *dirp,
 struct componentname *cnp, struct buf *newdirbp)
 {
-	kauth_cred_t cr;
-	int newentrysize;
-	struct inode *dp;
+	const kauth_cred_t cr = cnp->cn_cred;
+	const struct ufsmount *ump = VFSTOUFS(dvp->v_mount);
+	const int needswap = UFS_MPNEEDSWAP(ump);
+	const int dirblksiz = ump->um_dirblksiz;
+	const int fsfmt = FSFMT(dvp);
+	const u_int newentrysize = UFS_DIRSIZ(0, dirp, 0);
+	struct inode *dp = VTOI(dvp);
+	int error, ret, blkoff;
+	struct timespec ts;
+	struct buf *bp;
+
+	/*
+	 * If ulr_count is 0, then namei could find no
+	 * space in the directory. Here, ulr_offset will
+	 * be on a directory block boundary and we will write the
+	 * new entry into a fresh block.
+	 */
+	if (ulr->ulr_offset & (dirblksiz - 1))
+		panic("%s: newblk", __func__);
+	if ((error = UFS_BALLOC(dvp, (off_t)ulr->ulr_offset, dirblksiz,
+	cr, B_CLRBUF | B_SYNC, )) != 0) {
+		return error;
+	}
+
+	dp->i_size = ulr->ulr_offset + dirblksiz;
+	DIP_ASSIGN(dp, size, dp->i_size);
+	dp->i_flag |= IN_CHANGE | IN_UPDATE;
+	uvm_vnp_setsize(dvp, dp->i_size);
+	dirp->d_reclen = ufs_rw16(dirblksiz, needswap);
+	dirp->d_ino = ufs_rw32(dirp->d_ino, needswap);
+	if (fsfmt && ENDIANSWAP(needswap))
+		ufs_dirswap(dirp);
+	blkoff = ulr->ulr_offset & (ump->um_mountp->mnt_stat.f_iosize - 1);
+	memcpy((char *)bp->b_data + blkoff, dirp, newentrysize);
+#ifdef UFS_DIRHASH
+	if (dp->i_dirhash != NULL) {
+		ufsdirhash_newblk(dp, ulr->ulr_offset);
+		ufsdirhash_add(dp, dirp, ulr->ulr_offset);
+		ufsdirhash_checkblock(dp, (char *)bp->b_data + blkoff,
+		ulr->ulr_offset);
+	}
+#endif
+	error = VOP_BWRITE(bp->b_vp, bp);
+	vfs_timestamp();
+	ret = UFS_UPDATE(dvp, , , UPDATE_DIROP);
+	if (error == 0)
+		return ret;
+	return error;
+}
+
+static int
+#if __GNUC_PREREQ__(5, 3)
+/* This gets miscompiled by gcc 5.3 */
+__attribute__((__optimize__("no-tree-vrp")))
+#endif
+ufs_dircompact(struct vnode *dvp, const struct ufs_lookup_results *ulr,
+struct vnode *tvp, struct direct *dirp,
+struct componentname *cnp, struct buf *newdirbp)
+{
+	const struct ufsmount *ump = VFSTOUFS(dvp->v_mount);
+	const int needswap = UFS_MPNEEDSWAP(ump);
+	const int fsfmt = FSFMT(dvp);
+	const 

CVS commit: src/sys/ufs/ufs

2016-04-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 14 03:25:28 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
missing ,


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.142 src/sys/ufs/ufs/ufs_lookup.c:1.143
--- src/sys/ufs/ufs/ufs_lookup.c:1.142	Wed Apr 13 23:23:22 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Wed Apr 13 23:25:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.142 2016/04/14 03:23:22 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.143 2016/04/14 03:25:28 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.142 2016/04/14 03:23:22 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.143 2016/04/14 03:25:28 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -769,7 +769,7 @@ ufs_dirbadentry(const struct vnode *dp, 
 		if (name[i] == '\0') {
 			str = "NUL in name";
 #ifdef DIAGNOSTIC
-			snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d"
+			snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d",
 			str, name, i, namlen);
 			str = buf;
 #endif



CVS commit: src/sys/ufs/ufs

2016-04-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 14 03:23:22 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
- match endianness logic more to the original code
- fix namlen type
- use bool more
- eat \n's from panic strings


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.141 src/sys/ufs/ufs/ufs_lookup.c:1.142
--- src/sys/ufs/ufs/ufs_lookup.c:1.141	Tue Apr 12 20:09:26 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Wed Apr 13 23:23:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.141 2016/04/13 00:09:26 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.142 2016/04/14 03:23:22 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.141 2016/04/13 00:09:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.142 2016/04/14 03:23:22 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -77,18 +77,18 @@ int	dirchk = 0;
 #endif
 
 #if BYTE_ORDER == LITTLE_ENDIAN
-#define ENDIANSWAP 0
+# define ENDIANSWAP(needswap) ((needswap) == 0)
 #else
-#define ENDIANSWAP UFS_NEEDSWAP
+# define ENDIANSWAP(needswap) ((needswap) != 0)
 #endif
 
 #define NAMLEN(fsfmt, needswap, dp) \
-((fsfmt) && (needswap) == ENDIANSWAP ? (dp)->d_type : dp->d_namlen)
+((fsfmt) && ENDIANSWAP(needswap) ? (dp)->d_type : (dp)->d_namlen)
 
 static void
 ufs_dirswap(struct direct *dirp)
 {
-	u_char tmp = dirp->d_namlen;
+	uint8_t tmp = dirp->d_namlen;
 	dirp->d_namlen = dirp->d_type;
 	dirp->d_type = tmp;
 }
@@ -242,7 +242,7 @@ out:
 
 static int
 ufs_getino(struct vnode *vdp, struct inode *ip, ino_t foundino,
-struct vnode **tdp, int same)
+struct vnode **tdp, bool same)
 {
 	if (ip->i_number == foundino) {
 		if (same)
@@ -655,7 +655,7 @@ found:
 		 */
 		calc_count(results, dirblksiz, prevoff);
 
-		if ((error = ufs_getino(vdp, dp, foundino, , FALSE)) != 0)
+		if ((error = ufs_getino(vdp, dp, foundino, , false)) != 0)
 			goto out;
 
 		if ((error = ufs_can_delete(tdp, vdp, dp, cred)) != 0)
@@ -678,13 +678,13 @@ found:
 		 * Careful about locking second inode.
 		 * This can only occur if the target is ".".
 		 */
-		if ((error = ufs_getino(vdp, dp, foundino, , TRUE)) != 0)
+		if ((error = ufs_getino(vdp, dp, foundino, , true)) != 0)
 			goto out;
 		*vpp = tdp;
 		goto out;
 	}
 
-	if ((error = ufs_getino(vdp, dp, foundino, , FALSE)) != 0)
+	if ((error = ufs_getino(vdp, dp, foundino, , false)) != 0)
 		goto out;
 
 	*vpp = tdp;
@@ -728,7 +728,7 @@ ufs_dirbadentry(const struct vnode *dp, 
 	const int dirblksiz = ump->um_dirblksiz;
 	const int maxsize = dirblksiz - (entryoffsetinblock & (dirblksiz - 1));
 	const int fsfmt = FSFMT(dp);
-	const uint16_t namlen = NAMLEN(fsfmt, needswap, ep);
+	const uint8_t namlen = NAMLEN(fsfmt, needswap, ep);
 	const uint16_t reclen = ufs_rw16(ep->d_reclen, needswap);
 	const int dirsiz = (int)UFS_DIRSIZ(fsfmt, ep, needswap);
 	const char *name = ep->d_name;
@@ -743,8 +743,10 @@ ufs_dirbadentry(const struct vnode *dp, 
 		str = "too big";
 	else if (reclen < dirsiz)
 		str = "too small";
+#if FFS_MAXNAMLEN < 255
 	else if (namlen > FFS_MAXNAMLEN)
 		str = "long name";
+#endif
 	else
 		str = NULL;
 
@@ -752,7 +754,7 @@ ufs_dirbadentry(const struct vnode *dp, 
 #ifdef DIAGNOSTIC
 		snprintf(buf, sizeof(buf), "Bad dir (%s), reclen=%#x, "
 		"namlen=%d, dirsiz=%d <= reclen=%d <= maxsize=%d, "
-		"flags=%#x, entryoffsetinblock=%d, dirblksiz=%d\n",
+		"flags=%#x, entryoffsetinblock=%d, dirblksiz=%d",
 		str, reclen, namlen, dirsiz, reclen, maxsize,
 		dp->v_mount->mnt_flag, entryoffsetinblock, dirblksiz);
 		str = buf;
@@ -763,11 +765,11 @@ ufs_dirbadentry(const struct vnode *dp, 
 	if (ep->d_ino == 0)
 		return NULL;
 
-	for (int i = 0; i < namlen; i++)
+	for (uint8_t i = 0; i < namlen; i++)
 		if (name[i] == '\0') {
 			str = "NUL in name";
 #ifdef DIAGNOSTIC
-			snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d\n",
+			snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d"
 			str, name, i, namlen);
 			str = buf;
 #endif
@@ -777,7 +779,7 @@ ufs_dirbadentry(const struct vnode *dp, 
 	if (name[namlen]) {
 		str = "missing NUL in name";
 #ifdef DIAGNOSTIC
-		snprintf(buf, sizeof(buf), "%s [%*.*s] namlen=%d\n", str, 
+		snprintf(buf, sizeof(buf), "%s [%*.*s] namlen=%d", str, 
 		namlen, namlen, name, namlen);
 		str = buf;
 #endif
@@ -881,7 +883,7 @@ ufs_direnter(struct vnode *dvp, const st
 		uvm_vnp_setsize(dvp, dp->i_size);
 		dirp->d_reclen = ufs_rw16(dirblksiz, needswap);
 		dirp->d_ino = ufs_rw32(dirp->d_ino, needswap);
-		if (fsfmt && needswap == ENDIANSWAP)
+		if (fsfmt && ENDIANSWAP(needswap))
 			ufs_dirswap(dirp);
 		blkoff = ulr->ulr_offset & (ump->um_mountp->mnt_stat.f_iosize 

CVS commit: src/sys/ufs/ufs

2016-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 13 00:09:26 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
more deduplication.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.140 src/sys/ufs/ufs/ufs_lookup.c:1.141
--- src/sys/ufs/ufs/ufs_lookup.c:1.140	Tue Apr 12 12:12:22 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Tue Apr 12 20:09:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.140 2016/04/12 16:12:22 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.141 2016/04/13 00:09:26 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.140 2016/04/12 16:12:22 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.141 2016/04/13 00:09:26 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -109,6 +109,15 @@ struct slotinfo {
 };
 
 static void
+calc_count(struct ufs_lookup_results *results, int dirblksiz, doff_t prevoff)
+{
+	if ((results->ulr_offset & (dirblksiz - 1)) == 0)
+		results->ulr_count = 0;
+	else
+		results->ulr_count = results->ulr_offset - prevoff;
+}
+
+static void
 slot_init(struct slotinfo *slot)
 {
 	slot->status = FOUND;
@@ -181,10 +190,7 @@ slot_estimate(const struct slotinfo *slo
 		enduseful = results->ulr_offset;
 	} else if (nameiop == DELETE) {
 		results->ulr_offset = slot->offset;
-		if ((results->ulr_offset & (dirblksiz - 1)) == 0)
-			results->ulr_count = 0;
-		else
-			results->ulr_count = results->ulr_offset - prevoff;
+		calc_count(results, dirblksiz, prevoff);
 	} else {
 		results->ulr_offset = slot->offset;
 		results->ulr_count = slot->size;
@@ -199,6 +205,57 @@ slot_estimate(const struct slotinfo *slo
 }
 
 /*
+ * Check if we can delete inode tdp in directory vdp with inode ip and creds.
+ */
+static int
+ufs_can_delete(struct vnode *tdp, struct vnode *vdp, struct inode *ip,
+kauth_cred_t cred)
+{
+	int error;
+	/*
+	 * Write access to directory required to delete files.
+	 */
+	error = VOP_ACCESS(vdp, VWRITE, cred);
+	if (error)
+		goto out;
+
+	if (!(ip->i_mode & ISVTX)) 
+		return 0;
+
+	/*
+	 * If directory is "sticky", then user must own
+	 * the directory, or the file in it, else she
+	 * may not delete it (unless she's root). This
+	 * implements append-only directories.
+	 */
+	error = kauth_authorize_vnode(cred, KAUTH_VNODE_DELETE, tdp, vdp,
+	genfs_can_sticky(cred, ip->i_uid, VTOI(tdp)->i_uid));
+	if (error) {
+		error = EPERM;	// Why override?
+		goto out;
+	}
+	return 0;
+out:
+	vrele(tdp);
+	return error;
+}
+
+static int
+ufs_getino(struct vnode *vdp, struct inode *ip, ino_t foundino,
+struct vnode **tdp, int same)
+{
+	if (ip->i_number == foundino) {
+		if (same)
+			return EISDIR;
+		vref(vdp);
+		*tdp = vdp;
+		return 0;
+	}
+	return vcache_get(vdp->v_mount, , sizeof(foundino), tdp);
+}
+
+
+/*
  * Convert a component of a pathname into a pointer to a locked inode.
  * This is a very central and rather complicated routine.
  * If the file system is not maintained in a strict tree hierarchy,
@@ -299,7 +356,7 @@ ufs_lookup(void *v)
 	 * we are looking for is known already.
 	 */
 	if (cache_lookup(vdp, cnp->cn_nameptr, cnp->cn_namelen,
-			 cnp->cn_nameiop, cnp->cn_flags, , vpp)) {
+	cnp->cn_nameiop, cnp->cn_flags, , vpp)) {
 		if (iswhiteout) {
 			cnp->cn_flags |= ISWHITEOUT;
 		}
@@ -464,8 +521,7 @@ searchloop:
 		 */
 		const uint16_t namlen = NAMLEN(fsfmt, needswap, ep);
 		if (namlen != cnp->cn_namelen ||
-		memcmp(cnp->cn_nameptr, ep->d_name,
-		(unsigned)namlen))
+		memcmp(cnp->cn_nameptr, ep->d_name, (size_t)namlen))
 			goto next;
 
 #ifdef UFS_DIRHASH
@@ -597,45 +653,15 @@ found:
 		 * is a previous entry in this block) in results->ulr_count.
 		 * Save directory inode pointer in ndp->ni_dvp for dirremove().
 		 */
-		if ((results->ulr_offset & (dirblksiz - 1)) == 0)
-			results->ulr_count = 0;
-		else
-			results->ulr_count = results->ulr_offset - prevoff;
-		if (dp->i_number == foundino) {
-			vref(vdp);
-			tdp = vdp;
-		} else {
-			error = vcache_get(vdp->v_mount,
-			, sizeof(foundino), );
-			if (error)
-goto out;
-		}
-		/*
-		 * Write access to directory required to delete files.
-		 */
-		error = VOP_ACCESS(vdp, VWRITE, cred);
-		if (error) {
-			vrele(tdp);
+		calc_count(results, dirblksiz, prevoff);
+
+		if ((error = ufs_getino(vdp, dp, foundino, , FALSE)) != 0)
 			goto out;
-		}
-		/*
-		 * If directory is "sticky", then user must own
-		 * the directory, or the file in it, else she
-		 * may not delete it (unless she's root). This
-		 * implements append-only directories.
-		 */
-		if (dp->i_mode & ISVTX) {
-			error = kauth_authorize_vnode(cred, KAUTH_VNODE_DELETE,
-			tdp, vdp, genfs_can_sticky(cred, 

CVS commit: src/sys/ufs/ufs

2016-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 12 16:12:22 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_extern.h ufs_lookup.c

Log Message:
Remove gcc hack, it does not help.
Add more const.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/ufs/ufs/ufs_extern.h
cvs rdiff -u -r1.139 -r1.140 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extern.h
diff -u src/sys/ufs/ufs/ufs_extern.h:1.81 src/sys/ufs/ufs/ufs_extern.h:1.82
--- src/sys/ufs/ufs/ufs_extern.h:1.81	Mon Apr 11 20:36:29 2016
+++ src/sys/ufs/ufs/ufs_extern.h	Tue Apr 12 12:12:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extern.h,v 1.81 2016/04/12 00:36:29 christos Exp $	*/
+/*	$NetBSD: ufs_extern.h,v 1.82 2016/04/12 16:12:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -115,7 +115,7 @@ int	ufs_truncate(struct vnode *, uint64_
 
 /* ufs_lookup.c */
 void	ufs_dirbad(struct inode *, doff_t, const char *);
-const char *ufs_dirbadentry(struct vnode *, struct direct *, int);
+const char *ufs_dirbadentry(const struct vnode *, const struct direct *, int);
 void	ufs_makedirentry(struct inode *, struct componentname *,
 			 struct direct *);
 int	ufs_direnter(struct vnode *, const struct ufs_lookup_results *,

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.139 src/sys/ufs/ufs/ufs_lookup.c:1.140
--- src/sys/ufs/ufs/ufs_lookup.c:1.139	Tue Apr 12 11:56:05 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Tue Apr 12 12:12:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.139 2016/04/12 15:56:05 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.140 2016/04/12 16:12:22 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.139 2016/04/12 15:56:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.140 2016/04/12 16:12:22 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -384,14 +384,12 @@ ufs_lookup(void *v)
 		results->ulr_offset = 0;
 		numdirpasses = 1;
 	} else {
-		struct buf *vbp = bp;	// XXX: gcc
 		results->ulr_offset = results->ulr_diroff;
 		entryoffsetinblock = results->ulr_offset & bmask;
 		if (entryoffsetinblock != 0 &&
 		(error = ufs_blkatoff(vdp, (off_t)results->ulr_offset,
-		NULL, , false)))
+		NULL, , false)))
 			goto out;
-		bp = vbp;
 		numdirpasses = 2;
 		namecache_count_2passes();
 	}



CVS commit: src/sys/ufs/ufs

2016-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 12 15:56:05 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
- fix build with UFS_DIRHASH
- hide extra diagnostic info
- try to elide gcc bug


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.138 src/sys/ufs/ufs/ufs_lookup.c:1.139
--- src/sys/ufs/ufs/ufs_lookup.c:1.138	Tue Apr 12 10:40:16 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Tue Apr 12 11:56:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.138 2016/04/12 14:40:16 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.139 2016/04/12 15:56:05 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.138 2016/04/12 14:40:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.139 2016/04/12 15:56:05 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -356,7 +356,7 @@ ufs_lookup(void *v)
 	 */
 	if (ufsdirhash_build(dp) == 0) {
 		/* Look for a free slot if needed. */
-		enduseful = slot_findfree(, dp->i_size);
+		enduseful = slot_findfree(, dp);
 		/* Look up the component. */
 		numdirpasses = 1;
 		entryoffsetinblock = 0; /* silence compiler warning */
@@ -366,6 +366,7 @@ ufs_lookup(void *v)
 		case 0:
 			ep = (void *)((char *)bp->b_data +
 			(results->ulr_offset & bmask));
+			reclen = ufs_rw16(ep->d_reclen, needswap);
 			goto foundentry;
 		case ENOENT:
 			results->ulr_offset = roundup(dp->i_size, dirblksiz);
@@ -383,11 +384,14 @@ ufs_lookup(void *v)
 		results->ulr_offset = 0;
 		numdirpasses = 1;
 	} else {
+		struct buf *vbp = bp;	// XXX: gcc
 		results->ulr_offset = results->ulr_diroff;
-		if ((entryoffsetinblock = results->ulr_offset & bmask) &&
+		entryoffsetinblock = results->ulr_offset & bmask;
+		if (entryoffsetinblock != 0 &&
 		(error = ufs_blkatoff(vdp, (off_t)results->ulr_offset,
-		NULL, , false)))
+		NULL, , false)))
 			goto out;
+		bp = vbp;
 		numdirpasses = 2;
 		namecache_count_2passes();
 	}
@@ -707,7 +711,8 @@ ufs_dirbad(struct inode *ip, doff_t offs
  *	name must be as long as advertised, and null terminated
  */
 const char *
-ufs_dirbadentry(struct vnode *dp, struct direct *ep, int entryoffsetinblock)
+ufs_dirbadentry(const struct vnode *dp, const struct direct *ep,
+int entryoffsetinblock)
 {
 	const struct ufsmount *ump = VFSTOUFS(dp->v_mount);
 	const int needswap = UFS_MPNEEDSWAP(ump);
@@ -717,8 +722,12 @@ ufs_dirbadentry(struct vnode *dp, struct
 	const uint16_t namlen = NAMLEN(fsfmt, needswap, ep);
 	const uint16_t reclen = ufs_rw16(ep->d_reclen, needswap);
 	const int dirsiz = (int)UFS_DIRSIZ(fsfmt, ep, needswap);
-
+	const char *name = ep->d_name;
 	const char *str;
+#ifdef DIAGNOSTIC
+	static char buf[512];
+#endif
+
 	if ((reclen & 0x3) != 0)
 		str = "not rounded";
 	else if (reclen > maxsize)
@@ -731,11 +740,14 @@ ufs_dirbadentry(struct vnode *dp, struct
 		str = NULL;
 
 	if (str) {
-		printf("%s: Bad dir (%s), reclen=%#x, namlen=%d, "
-		"dirsiz=%d <= reclen=%d <= maxsize=%d, "
+#ifdef DIAGNOSTIC
+		snprintf(buf, sizeof(buf), "Bad dir (%s), reclen=%#x, "
+		"namlen=%d, dirsiz=%d <= reclen=%d <= maxsize=%d, "
 		"flags=%#x, entryoffsetinblock=%d, dirblksiz=%d\n",
-		__func__, str, reclen, namlen, dirsiz, reclen, maxsize,
+		str, reclen, namlen, dirsiz, reclen, maxsize,
 		dp->v_mount->mnt_flag, entryoffsetinblock, dirblksiz);
+		str = buf;
+#endif
 		return str;
 	}
 
@@ -743,16 +755,23 @@ ufs_dirbadentry(struct vnode *dp, struct
 		return NULL;
 
 	for (int i = 0; i < namlen; i++)
-		if (ep->d_name[i] == '\0') {
+		if (name[i] == '\0') {
 			str = "NUL in name";
-			printf("%s: %s i=%d, namlen=%d\n", __func__, str, i,
-			namlen);
+#ifdef DIAGNOSTIC
+			snprintf(buf, sizeof(buf), "%s [%s] i=%d, namlen=%d\n",
+			str, name, i, namlen);
+			str = buf;
+#endif
 			return str;
 		}
 
-	if (ep->d_name[namlen]) {
+	if (name[namlen]) {
 		str = "missing NUL in name";
-		printf("%s: %s namlen=%d\n", __func__, str, namlen);
+#ifdef DIAGNOSTIC
+		snprintf(buf, sizeof(buf), "%s [%*.*s] namlen=%d\n", str, 
+		namlen, namlen, name, namlen);
+		str = buf;
+#endif
 		return str;
 	}
 	return NULL;
@@ -915,7 +934,7 @@ ufs_direnter(struct vnode *dvp, const st
 	ep = (void *)dirbuf;
 	dsize = (ep->d_ino != 0) ? UFS_DIRSIZ(fsfmt, ep, needswap) : 0;
 	reclen = ufs_rw16(ep->d_reclen, needswap);
-	spacefree =  reclen - dsize;
+	spacefree = reclen - dsize;
 	for (loc = reclen; loc < ulr->ulr_count; ) {
 		nep = (void *)(dirbuf + loc);
 



CVS commit: src/sys/ufs/ufs

2016-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 12 14:40:16 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
- Collect the slot-related variables in their own structure and extract
  some of the slot finding and updating code into their own function.
- Add a new label "next" in the main search loop to avoid nesting and
  code duplication.
- Cache some reclen and ino variables for better readability and efficiency.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.137 src/sys/ufs/ufs/ufs_lookup.c:1.138
--- src/sys/ufs/ufs/ufs_lookup.c:1.137	Mon Apr 11 20:36:29 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Tue Apr 12 10:40:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.137 2016/04/12 00:36:29 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.138 2016/04/12 14:40:16 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.137 2016/04/12 00:36:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.138 2016/04/12 14:40:16 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -93,6 +93,111 @@ ufs_dirswap(struct direct *dirp)
 	dirp->d_type = tmp;
 }
 
+struct slotinfo {
+	enum {
+		NONE,		/* need to search a slot for our new entry */
+		COMPACT,	/* a compaction can make a slot in the current
+   DIRBLKSIZ block */
+		FOUND,		/* found a slot (or no need to search) */
+	} status;
+	doff_t offset;		/* offset of area with free space.
+   a special value -1 for invalid */
+	int size;		/* size of area at slotoffset */
+	int freespace;		/* accumulated amount of space free in
+   the current DIRBLKSIZ block */
+	int needed;		/* size of the entry we're seeking */
+};
+
+static void
+slot_init(struct slotinfo *slot)
+{
+	slot->status = FOUND;
+	slot->offset = -1;
+	slot->freespace = slot->size = slot->needed = 0;
+}
+
+#ifdef UFS_DIRHASH
+static doff_t
+slot_findfree(struct slotinfo *slot, struct inode *dp)
+{
+	if (slot->status == FOUND)
+		return dp->i_size;
+
+	slot->offset = ufsdirhash_findfree(dp, slot->needed, >size);
+	if (slot->offset < 0)
+		return dp->i_size;
+
+	slot->status = COMPACT;
+	doff_t enduseful = ufsdirhash_enduseful(dp);
+	if (enduseful < 0)
+		return dp->i_size;
+	return enduseful;
+}
+#endif
+
+static void
+slot_white(struct slotinfo *slot, uint16_t reclen,
+struct ufs_lookup_results *results)
+{
+	slot->status = FOUND;
+	slot->offset = results->ulr_offset;
+	slot->size = reclen;
+	results->ulr_reclen = slot->size;
+}
+
+static void
+slot_update(struct slotinfo *slot, int size, uint16_t reclen, doff_t offset)
+{
+	if (size >= slot->needed) {
+		slot->status = FOUND;
+		slot->offset = offset;
+		slot->size = reclen;
+	} else if (slot->status == NONE) {
+		slot->freespace += size;
+		if (slot->offset == -1)
+			slot->offset = offset;
+		if (slot->freespace >= slot->needed) {
+			slot->status = COMPACT;
+			slot->size = offset + reclen - slot->offset;
+		}
+	}
+}
+
+/*
+ * Return an indication of where the new directory entry should be put.
+ * If we didn't find a slot, then set results->ulr_count to 0 indicating
+ * that the new slot belongs at the end of the directory. If we found a slot,
+ * then the new entry can be put in the range from results->ulr_offset to
+ * results->ulr_offset + results->ulr_count.
+ */
+static int
+slot_estimate(const struct slotinfo *slot, int dirblksiz, int nameiop,
+doff_t prevoff, doff_t enduseful, const struct inode *ip,
+struct ufs_lookup_results *results)
+{
+	if (slot->status == NONE) {
+		results->ulr_offset = roundup(ip->i_size, dirblksiz);
+		results->ulr_count = 0;
+		enduseful = results->ulr_offset;
+	} else if (nameiop == DELETE) {
+		results->ulr_offset = slot->offset;
+		if ((results->ulr_offset & (dirblksiz - 1)) == 0)
+			results->ulr_count = 0;
+		else
+			results->ulr_count = results->ulr_offset - prevoff;
+	} else {
+		results->ulr_offset = slot->offset;
+		results->ulr_count = slot->size;
+		if (enduseful < slot->offset + slot->size)
+			enduseful = slot->offset + slot->size;
+	}
+	results->ulr_endoff = roundup(enduseful, dirblksiz);
+#if 0 /* commented out by dbj. none of the on disk fields changed */
+	ip->i_flag |= IN_CHANGE | IN_UPDATE;
+#endif
+	return EJUSTRETURN;
+}
+
 /*
  * Convert a component of a pathname into a pointer to a locked inode.
  * This is a very central and rather complicated routine.
@@ -139,18 +244,7 @@ ufs_lookup(void *v)
 	struct buf *bp;			/* a buffer of directory entries */
 	struct direct *ep;		/* the current directory entry */
 	int entryoffsetinblock;		/* offset of ep in bp's buffer */
-	enum {
-		NONE,		/* need to search a slot for our new entry */
-		COMPACT,	/* a compaction can make a slot in the 

CVS commit: src/sys/ufs/ufs

2016-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 12 00:36:29 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_extern.h ufs_lookup.c

Log Message:
Provide reason to be printed in panic string.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/ufs/ufs/ufs_extern.h
cvs rdiff -u -r1.136 -r1.137 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extern.h
diff -u src/sys/ufs/ufs/ufs_extern.h:1.80 src/sys/ufs/ufs/ufs_extern.h:1.81
--- src/sys/ufs/ufs/ufs_extern.h:1.80	Mon Apr 11 19:41:15 2016
+++ src/sys/ufs/ufs/ufs_extern.h	Mon Apr 11 20:36:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extern.h,v 1.80 2016/04/11 23:41:15 christos Exp $	*/
+/*	$NetBSD: ufs_extern.h,v 1.81 2016/04/12 00:36:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -115,7 +115,7 @@ int	ufs_truncate(struct vnode *, uint64_
 
 /* ufs_lookup.c */
 void	ufs_dirbad(struct inode *, doff_t, const char *);
-int	ufs_dirbadentry(struct vnode *, struct direct *, int);
+const char *ufs_dirbadentry(struct vnode *, struct direct *, int);
 void	ufs_makedirentry(struct inode *, struct componentname *,
 			 struct direct *);
 int	ufs_direnter(struct vnode *, const struct ufs_lookup_results *,

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.136 src/sys/ufs/ufs/ufs_lookup.c:1.137
--- src/sys/ufs/ufs/ufs_lookup.c:1.136	Mon Apr 11 19:41:15 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Mon Apr 11 20:36:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.136 2016/04/11 23:41:15 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.137 2016/04/12 00:36:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.136 2016/04/11 23:41:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.137 2016/04/12 00:36:29 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -344,12 +344,12 @@ searchloop:
 		 */
 		KASSERT(bp != NULL);
 		ep = (void *)((char *)bp->b_data + entryoffsetinblock);
-		if (ep->d_reclen == 0 ||
-		(dirchk && ufs_dirbadentry(vdp, ep, entryoffsetinblock))) {
+		const char *msg;
+		if ((ep->d_reclen == 0 && (msg = "null entry")) || (dirchk &&
+		(msg = ufs_dirbadentry(vdp, ep, entryoffsetinblock {
 			int i;
 
-			ufs_dirbad(dp, results->ulr_offset, ep->d_reclen == 0 ? 
-			"null entry" : "mangled entry");
+			ufs_dirbad(dp, results->ulr_offset, msg);
 			i = dirblksiz - (entryoffsetinblock & (dirblksiz - 1));
 			results->ulr_offset += i;
 			entryoffsetinblock += i;
@@ -659,14 +659,13 @@ out:
 void
 ufs_dirbad(struct inode *ip, doff_t offset, const char *how)
 {
-	struct mount *mp;
+	struct mount *mp = ITOV(ip)->v_mount;
+	void (*p)(const char  *, ...)  =
+	(mp->mnt_flag & MNT_RDONLY) == 0 ? panic : printf;
 
-	mp = ITOV(ip)->v_mount;
-	printf("%s: bad dir ino %llu at offset %d: %s\n",
+	(*p)("%s: bad dir ino %llu at offset %d: %s\n",
 	mp->mnt_stat.f_mntonname, (unsigned long long)ip->i_number,
 	offset, how);
-	if ((mp->mnt_flag & MNT_RDONLY) == 0)
-		panic("bad dir");
 }
 
 /*
@@ -677,7 +676,7 @@ ufs_dirbad(struct inode *ip, doff_t offs
  *	name is not longer than FFS_MAXNAMLEN
  *	name must be as long as advertised, and null terminated
  */
-int
+const char *
 ufs_dirbadentry(struct vnode *dp, struct direct *ep, int entryoffsetinblock)
 {
 	const struct ufsmount *ump = VFSTOUFS(dp->v_mount);
@@ -707,26 +706,26 @@ ufs_dirbadentry(struct vnode *dp, struct
 		"flags=%#x, entryoffsetinblock=%d, dirblksiz=%d\n",
 		__func__, str, reclen, namlen, dirsiz, reclen, maxsize,
 		dp->v_mount->mnt_flag, entryoffsetinblock, dirblksiz);
-		goto bad;
+		return str;
 	}
 
 	if (ep->d_ino == 0)
-		return 0;
+		return NULL;
 
-	int i;
-	for (i = 0; i < namlen; i++)
+	for (int i = 0; i < namlen; i++)
 		if (ep->d_name[i] == '\0') {
-			printf("%s: NUL in name i=%d, namlen=%d\n", __func__,
-			i, namlen);
-			goto bad;
-	}
-	if (ep->d_name[i]) {
-		printf("%s: missing NUL in name namlen=%d\n", __func__, i);
-		goto bad;
-	}
-	return 0;
-bad:
-	return 1;
+			str = "NUL in name";
+			printf("%s: %s i=%d, namlen=%d\n", __func__, str, i,
+			namlen);
+			return str;
+		}
+
+	if (ep->d_name[namlen]) {
+		str = "missing NUL in name";
+		printf("%s: %s namlen=%d\n", __func__, str, namlen);
+		return str;
+	}
+	return NULL;
 }
 
 /*



CVS commit: src/sys/ufs/ufs

2016-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr 11 23:41:15 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_extern.h ufs_lookup.c

Log Message:
misc cleanups, no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/ufs/ufs/ufs_extern.h
cvs rdiff -u -r1.135 -r1.136 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extern.h
diff -u src/sys/ufs/ufs/ufs_extern.h:1.79 src/sys/ufs/ufs/ufs_extern.h:1.80
--- src/sys/ufs/ufs/ufs_extern.h:1.79	Fri Mar 27 13:27:56 2015
+++ src/sys/ufs/ufs/ufs_extern.h	Mon Apr 11 19:41:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extern.h,v 1.79 2015/03/27 17:27:56 riastradh Exp $	*/
+/*	$NetBSD: ufs_extern.h,v 1.80 2016/04/11 23:41:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -126,7 +126,7 @@ int	ufs_dirremove(struct vnode *, const 
 int	ufs_dirrewrite(struct inode *, off_t,
 		   struct inode *, ino_t, int, int, int);
 int	ufs_dirempty(struct inode *, ino_t, kauth_cred_t);
-int	ufs_blkatoff(struct vnode *, off_t, char **, struct buf **, bool);
+int	ufs_blkatoff(struct vnode *, off_t, void *, struct buf **, bool);
 
 /* ufs_rename.c -- for lfs */
 bool	ufs_gro_directory_empty_p(struct mount *, kauth_cred_t,

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.135 src/sys/ufs/ufs/ufs_lookup.c:1.136
--- src/sys/ufs/ufs/ufs_lookup.c:1.135	Sat Jul 11 07:04:48 2015
+++ src/sys/ufs/ufs/ufs_lookup.c	Mon Apr 11 19:41:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.135 2015/07/11 11:04:48 mlelstv Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.136 2016/04/11 23:41:15 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.135 2015/07/11 11:04:48 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.136 2016/04/11 23:41:15 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -76,6 +76,23 @@ int	dirchk = 1;
 int	dirchk = 0;
 #endif
 
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define ENDIANSWAP 0
+#else
+#define ENDIANSWAP UFS_NEEDSWAP
+#endif
+
+#define NAMLEN(fsfmt, needswap, dp) \
+((fsfmt) && (needswap) == ENDIANSWAP ? (dp)->d_type : dp->d_namlen)
+
+static void
+ufs_dirswap(struct direct *dirp)
+{
+	u_char tmp = dirp->d_namlen;
+	dirp->d_namlen = dirp->d_type;
+	dirp->d_type = tmp;
+}
+
 /*
  * Convert a component of a pathname into a pointer to a locked inode.
  * This is a very central and rather complicated routine.
@@ -153,6 +170,7 @@ ufs_lookup(void *v)
 	ino_t foundino;
 	struct ufs_lookup_results *results;
 	int iswhiteout;			/* temp result from cache_lookup() */
+	const int fsfmt = FSFMT(vdp);
 
 	flags = cnp->cn_flags;
 
@@ -261,7 +279,7 @@ ufs_lookup(void *v)
 		switch (ufsdirhash_lookup(dp, cnp->cn_nameptr, cnp->cn_namelen,
 		>ulr_offset, , nameiop == DELETE ?  : NULL)) {
 		case 0:
-			ep = (struct direct *)((char *)bp->b_data +
+			ep = (void *)((char *)bp->b_data +
 			(results->ulr_offset & bmask));
 			goto foundentry;
 		case ENOENT:
@@ -325,12 +343,13 @@ searchloop:
 		 * "dirchk" to be true.
 		 */
 		KASSERT(bp != NULL);
-		ep = (struct direct *)((char *)bp->b_data + entryoffsetinblock);
+		ep = (void *)((char *)bp->b_data + entryoffsetinblock);
 		if (ep->d_reclen == 0 ||
 		(dirchk && ufs_dirbadentry(vdp, ep, entryoffsetinblock))) {
 			int i;
 
-			ufs_dirbad(dp, results->ulr_offset, "mangled entry");
+			ufs_dirbad(dp, results->ulr_offset, ep->d_reclen == 0 ? 
+			"null entry" : "mangled entry");
 			i = dirblksiz - (entryoffsetinblock & (dirblksiz - 1));
 			results->ulr_offset += i;
 			entryoffsetinblock += i;
@@ -347,7 +366,7 @@ searchloop:
 			int size = ufs_rw16(ep->d_reclen, needswap);
 
 			if (ep->d_ino != 0)
-size -= UFS_DIRSIZ(FSFMT(vdp), ep, needswap);
+size -= UFS_DIRSIZ(fsfmt, ep, needswap);
 			if (size > 0) {
 if (size >= slotneeded) {
 	slotstatus = FOUND;
@@ -373,19 +392,7 @@ searchloop:
 		 * Check for a name match.
 		 */
 		if (ep->d_ino) {
-			int namlen;
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-			if (FSFMT(vdp) && needswap == 0)
-namlen = ep->d_type;
-			else
-namlen = ep->d_namlen;
-#else
-			if (FSFMT(vdp) && needswap != 0)
-namlen = ep->d_type;
-			else
-namlen = ep->d_namlen;
-#endif
+			const int namlen = NAMLEN(fsfmt, needswap, ep);
 			if (namlen == cnp->cn_namelen &&
 			!memcmp(cnp->cn_nameptr, ep->d_name,
 			(unsigned)namlen)) {
@@ -396,7 +403,7 @@ foundentry:
  * Save directory entry's inode number and
  * reclen, and release directory buffer.
  */
-if (!FSFMT(vdp) && ep->d_type == DT_WHT) {
+if (!fsfmt && ep->d_type == DT_WHT) {
 	slotstatus = FOUND;
 	slotoffset = results->ulr_offset;
 	slotsize = ufs_rw16(ep->d_reclen,
@@ -527,10 +534,11 @@ found:
 	 * Check that directory length properly reflects presence
 	 * 

CVS commit: src/sys/ufs/ufs

2016-01-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan 22 23:06:10 UTC 2016

Modified Files:
src/sys/ufs/ufs: dinode.h

Log Message:
u_int{16,32,64}_t -> uint{16,32,64}_t, for the benefit of userland.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ufs/dinode.h

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

Modified files:

Index: src/sys/ufs/ufs/dinode.h
diff -u src/sys/ufs/ufs/dinode.h:1.24 src/sys/ufs/ufs/dinode.h:1.25
--- src/sys/ufs/ufs/dinode.h:1.24	Sun Jun  9 17:55:46 2013
+++ src/sys/ufs/ufs/dinode.h	Fri Jan 22 23:06:10 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dinode.h,v 1.24 2013/06/09 17:55:46 dholland Exp $	*/
+/*	$NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -80,10 +80,10 @@
 #define	UFS_NIADDR	3		/* Indirect addresses in inode. */
 
 struct ufs1_dinode {
-	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
+	uint16_t	di_mode;	/*   0: IFMT, permissions; see below. */
 	int16_t		di_nlink;	/*   2: File link count. */
-	u_int16_t	di_oldids[2];	/*   4: Ffs: old user and group ids. */
-	u_int64_t	di_size;	/*   8: File byte count. */
+	uint16_t	di_oldids[2];	/*   4: Ffs: old user and group ids. */
+	uint64_t	di_size;	/*   8: File byte count. */
 	int32_t		di_atime;	/*  16: Last access time. */
 	int32_t		di_atimensec;	/*  20: Last access time. */
 	int32_t		di_mtime;	/*  24: Last modified time. */
@@ -92,22 +92,22 @@ struct ufs1_dinode {
 	int32_t		di_ctimensec;	/*  36: Last inode change time. */
 	int32_t		di_db[UFS_NDADDR]; /*  40: Direct disk blocks. */
 	int32_t		di_ib[UFS_NIADDR]; /*  88: Indirect disk blocks. */
-	u_int32_t	di_flags;	/* 100: Status flags (chflags). */
-	u_int32_t	di_blocks;	/* 104: Blocks actually held. */
+	uint32_t	di_flags;	/* 100: Status flags (chflags). */
+	uint32_t	di_blocks;	/* 104: Blocks actually held. */
 	int32_t		di_gen;		/* 108: Generation number. */
-	u_int32_t	di_uid;		/* 112: File owner. */
-	u_int32_t	di_gid;		/* 116: File group. */
-	u_int64_t	di_modrev;	/* 120: i_modrev for NFSv4 */
+	uint32_t	di_uid;		/* 112: File owner. */
+	uint32_t	di_gid;		/* 116: File group. */
+	uint64_t	di_modrev;	/* 120: i_modrev for NFSv4 */
 };
 
 struct ufs2_dinode {
-	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
+	uint16_t	di_mode;	/*   0: IFMT, permissions; see below. */
 	int16_t		di_nlink;	/*   2: File link count. */
-	u_int32_t	di_uid;		/*   4: File owner. */
-	u_int32_t	di_gid;		/*   8: File group. */
-	u_int32_t	di_blksize;	/*  12: Inode blocksize. */
-	u_int64_t	di_size;	/*  16: File byte count. */
-	u_int64_t	di_blocks;	/*  24: Bytes actually held. */
+	uint32_t	di_uid;		/*   4: File owner. */
+	uint32_t	di_gid;		/*   8: File group. */
+	uint32_t	di_blksize;	/*  12: Inode blocksize. */
+	uint64_t	di_size;	/*  16: File byte count. */
+	uint64_t	di_blocks;	/*  24: Bytes actually held. */
 	int64_t		di_atime;	/*  32: Last access time. */
 	int64_t		di_mtime;	/*  40: Last modified time. */
 	int64_t		di_ctime;	/*  48: Last inode change time. */
@@ -117,13 +117,13 @@ struct ufs2_dinode {
 	int32_t		di_ctimensec;	/*  72: Last inode change time. */
 	int32_t		di_birthnsec;	/*  76: Inode creation time. */
 	int32_t		di_gen;		/*  80: Generation number. */
-	u_int32_t	di_kernflags;	/*  84: Kernel flags. */
-	u_int32_t	di_flags;	/*  88: Status flags (chflags). */
+	uint32_t	di_kernflags;	/*  84: Kernel flags. */
+	uint32_t	di_flags;	/*  88: Status flags (chflags). */
 	int32_t		di_extsize;	/*  92: External attributes block. */
 	int64_t		di_extb[UFS_NXADDR];/* 96: External attributes block. */
 	int64_t		di_db[UFS_NDADDR]; /* 112: Direct disk blocks. */
 	int64_t		di_ib[UFS_NIADDR]; /* 208: Indirect disk blocks. */
-	u_int64_t	di_modrev;	/* 232: i_modrev for NFSv4 */
+	uint64_t	di_modrev;	/* 232: i_modrev for NFSv4 */
 	int64_t		di_spare[2];	/* 240: Reserved; currently unused */
 };
 



CVS commit: src/sys/ufs/ufs

2015-09-01 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Sep  1 06:09:23 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
Propagate fix from lfs:
For non-devices, have getattr (and thus stat) produce NODEV in the
rdev field, instead of leaking the address of the first direct block.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.230 src/sys/ufs/ufs/ufs_vnops.c:1.231
--- src/sys/ufs/ufs/ufs_vnops.c:1.230	Mon Apr 20 23:03:09 2015
+++ src/sys/ufs/ufs/ufs_vnops.c	Tue Sep  1 06:09:23 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.230 2015/04/20 23:03:09 riastradh Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.231 2015/09/01 06:09:23 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.230 2015/04/20 23:03:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.231 2015/09/01 06:09:23 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -378,8 +378,16 @@ ufs_getattr(void *v)
 	vap->va_gid = ip->i_gid;
 	vap->va_size = vp->v_size;
 	if (ip->i_ump->um_fstype == UFS1) {
-		vap->va_rdev = (dev_t)ufs_rw32(ip->i_ffs1_rdev,
-		UFS_MPNEEDSWAP(ip->i_ump));
+		switch (vp->v_type) {
+		case VBLK:
+		case VCHR:
+			vap->va_rdev = (dev_t)ufs_rw32(ip->i_ffs1_rdev,
+			UFS_MPNEEDSWAP(ip->i_ump));
+			break;
+		default:
+			vap->va_rdev = NODEV;
+			break;
+		}
 		vap->va_atime.tv_sec = ip->i_ffs1_atime;
 		vap->va_atime.tv_nsec = ip->i_ffs1_atimensec;
 		vap->va_mtime.tv_sec = ip->i_ffs1_mtime;
@@ -390,8 +398,16 @@ ufs_getattr(void *v)
 		vap->va_birthtime.tv_nsec = 0;
 		vap->va_bytes = dbtob((u_quad_t)ip->i_ffs1_blocks);
 	} else {
-		vap->va_rdev = (dev_t)ufs_rw64(ip->i_ffs2_rdev,
-		UFS_MPNEEDSWAP(ip->i_ump));
+		switch (vp->v_type) {
+		case VBLK:
+		case VCHR:
+			vap->va_rdev = (dev_t)ufs_rw64(ip->i_ffs2_rdev,
+			UFS_MPNEEDSWAP(ip->i_ump));
+			break;
+		default:
+			vap->va_rdev = NODEV;
+			break;
+		}
 		vap->va_atime.tv_sec = ip->i_ffs2_atime;
 		vap->va_atime.tv_nsec = ip->i_ffs2_atimensec;
 		vap->va_mtime.tv_sec = ip->i_ffs2_mtime;



CVS commit: src/sys/ufs/ufs

2015-09-01 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Sep  1 06:16:03 UTC 2015

Modified Files:
src/sys/ufs/ufs: dir.h

Log Message:
Pull over comments on struct direct's type/reclen byte swapping from LFS.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ufs/dir.h

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

Modified files:

Index: src/sys/ufs/ufs/dir.h
diff -u src/sys/ufs/ufs/dir.h:1.24 src/sys/ufs/ufs/dir.h:1.25
--- src/sys/ufs/ufs/dir.h:1.24	Wed Jun 19 17:51:26 2013
+++ src/sys/ufs/ufs/dir.h	Tue Sep  1 06:16:03 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.24 2013/06/19 17:51:26 dholland Exp $	*/
+/*	$NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -124,6 +124,50 @@ struct	direct {
 UFS_DIRECTSIZ((dp)->d_type) : UFS_DIRECTSIZ((dp)->d_namlen))
 #endif
 
+/*
+ * UFS_OLDDIRFMT and UFS_NEWDIRFMT are code numbers for a directory
+ * format change that happened in ffs a long time ago. (Back in the
+ * 80s, if I'm not mistaken.)
+ *
+ * These code numbers do not appear on disk. They're generated from
+ * runtime logic that is cued by other things, which is why
+ * UFS_OLDDIRFMT is confusingly 1 and UFS_NEWDIRFMT is confusingly 0.
+ *
+ * Relatedly, the FFS_EI byte swapping logic for directories is a
+ * horrible mess. For example, to access the namlen field, one
+ * currently does the following:
+ *
+ * #if (BYTE_ORDER == LITTLE_ENDIAN)
+ * swap = (UFS_IPNEEDSWAP(VTOI(vp)) == 0);
+ * #else
+ * swap = (UFS_IPNEEDSWAP(VTOI(vp)) != 0);
+ * #endif
+ * return ((FSFMT(vp) && swap) ? dp->d_type : dp->d_namlen);
+ *
+ * UFS_IPNEEDSWAP() returns true if the volume is opposite-endian. This
+ * horrible "swap" logic is cutpasted all over everywhere but amounts
+ * to the following:
+ *
+ *running code  volume  lfs_dobyteswap  "swap"
+ *--
+ *LITTLE_ENDIAN LITTLE_ENDIAN   false   true
+ *LITTLE_ENDIAN BIG_ENDIAN  truefalse
+ *BIG_ENDIANLITTLE_ENDIAN   truetrue
+ *BIG_ENDIANBIG_ENDIAN  false   false
+ *
+ * which you'll note boils down to "volume is little-endian".
+ *
+ * Meanwhile, FSFMT(vp) yields UFS_OLDDIRFMT or UFS_NEWDIRFMT via
+ * perverted logic of its own. Since UFS_OLDDIRFMT is 1 (contrary to
+ * what one might expect approaching this cold) what this mess means
+ * is: on OLDDIRFMT volumes that are little-endian, we read the
+ * namlen value out of the type field. This is because on OLDDIRFMT
+ * volumes there is no d_type field, just a 16-bit d_namlen; so if
+ * the 16-bit d_namlen is little-endian, the useful part of it is
+ * in the first byte, which in the NEWDIRFMT structure is the d_type
+ * field.
+ */
+
 #define UFS_OLDDIRFMT	1
 #define UFS_NEWDIRFMT	0
 



CVS commit: src/sys/ufs/ufs

2015-06-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 13 14:56:45 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_inode.c

Log Message:
ufs_inactive: stop overwriting error status and return the last error seen.

Should resolve CID 1306276 (UNUSED_VALUE)


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/ufs/ufs/ufs_inode.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.94 src/sys/ufs/ufs/ufs_inode.c:1.95
--- src/sys/ufs/ufs/ufs_inode.c:1.94	Wed Jun 10 15:28:27 2015
+++ src/sys/ufs/ufs/ufs_inode.c	Sat Jun 13 14:56:45 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.94 2015/06/10 15:28:27 hannken Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.95 2015/06/13 14:56:45 hannken Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.94 2015/06/10 15:28:27 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.95 2015/06/13 14:56:45 hannken Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -86,7 +86,7 @@ ufs_inactive(void *v)
 	struct inode *ip = VTOI(vp);
 	struct mount *mp = vp-v_mount;
 	mode_t mode;
-	int error = 0;
+	int allerror = 0, error;
 	bool wapbl_locked = false;
 
 	UFS_WAPBL_JUNLOCK_ASSERT(mp);
@@ -102,10 +102,12 @@ ufs_inactive(void *v)
 		ufs_extattr_vnode_inactive(vp, curlwp);
 #endif
 		if (ip-i_size != 0)
-			error = ufs_truncate(vp, 0, NOCRED);
+			allerror = ufs_truncate(vp, 0, NOCRED);
 #if defined(QUOTA) || defined(QUOTA2)
 		error = UFS_WAPBL_BEGIN(mp);
-		if (error == 0) {
+		if (error) {
+			allerror = error;
+		} else {
 			wapbl_locked = true;
 			(void)chkiq(ip, -1, NOCRED, 0);
 		}
@@ -124,8 +126,10 @@ ufs_inactive(void *v)
 	if (ip-i_flag  (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) {
 		if (! wapbl_locked) {
 			error = UFS_WAPBL_BEGIN(mp);
-			if (error)
+			if (error) {
+allerror = error;
 goto out;
+			}
 			wapbl_locked = true;
 		}
 		UFS_UPDATE(vp, NULL, NULL, 0);
@@ -140,7 +144,7 @@ out:
 	*ap-a_recycle = (ip-i_mode == 0);
 	VOP_UNLOCK(vp);
 	fstrans_done(mp);
-	return (error);
+	return (allerror);
 }
 
 /*



CVS commit: src/sys/ufs/ufs

2015-06-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jun 10 15:28:27 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_inode.c

Log Message:
ufs_inactive: take UFS_WAPBL_BEGIN() before calling chkiq().

Should fix PR kern/49948 (quota panic)


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/ufs/ufs/ufs_inode.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.93 src/sys/ufs/ufs/ufs_inode.c:1.94
--- src/sys/ufs/ufs/ufs_inode.c:1.93	Wed Apr 15 14:39:24 2015
+++ src/sys/ufs/ufs/ufs_inode.c	Wed Jun 10 15:28:27 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.93 2015/04/15 14:39:24 riastradh Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.94 2015/06/10 15:28:27 hannken Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.93 2015/04/15 14:39:24 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.94 2015/06/10 15:28:27 hannken Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -84,27 +84,31 @@ ufs_inactive(void *v)
 	} */ *ap = v;
 	struct vnode *vp = ap-a_vp;
 	struct inode *ip = VTOI(vp);
-	struct mount *transmp;
+	struct mount *mp = vp-v_mount;
 	mode_t mode;
 	int error = 0;
+	bool wapbl_locked = false;
 
-	UFS_WAPBL_JUNLOCK_ASSERT(vp-v_mount);
+	UFS_WAPBL_JUNLOCK_ASSERT(mp);
 
-	transmp = vp-v_mount;
-	fstrans_start(transmp, FSTRANS_LAZY);
+	fstrans_start(mp, FSTRANS_LAZY);
 	/*
 	 * Ignore inodes related to stale file handles.
 	 */
 	if (ip-i_mode == 0)
 		goto out;
-	if (ip-i_nlink = 0  (vp-v_mount-mnt_flag  MNT_RDONLY) == 0) {
+	if (ip-i_nlink = 0  (mp-mnt_flag  MNT_RDONLY) == 0) {
 #ifdef UFS_EXTATTR
 		ufs_extattr_vnode_inactive(vp, curlwp);
 #endif
 		if (ip-i_size != 0)
 			error = ufs_truncate(vp, 0, NOCRED);
 #if defined(QUOTA) || defined(QUOTA2)
-		(void)chkiq(ip, -1, NOCRED, 0);
+		error = UFS_WAPBL_BEGIN(mp);
+		if (error == 0) {
+			wapbl_locked = true;
+			(void)chkiq(ip, -1, NOCRED, 0);
+		}
 #endif
 		DIP_ASSIGN(ip, rdev, 0);
 		mode = ip-i_mode;
@@ -118,20 +122,24 @@ ufs_inactive(void *v)
 	}
 
 	if (ip-i_flag  (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) {
-		error = UFS_WAPBL_BEGIN(vp-v_mount);
-		if (error)
-			goto out;
+		if (! wapbl_locked) {
+			error = UFS_WAPBL_BEGIN(mp);
+			if (error)
+goto out;
+			wapbl_locked = true;
+		}
 		UFS_UPDATE(vp, NULL, NULL, 0);
-		UFS_WAPBL_END(vp-v_mount);
 	}
 out:
+	if (wapbl_locked)
+		UFS_WAPBL_END(mp);
 	/*
 	 * If we are done with the inode, reclaim it
 	 * so that it can be reused immediately.
 	 */
 	*ap-a_recycle = (ip-i_mode == 0);
 	VOP_UNLOCK(vp);
-	fstrans_done(transmp);
+	fstrans_done(mp);
 	return (error);
 }
 



CVS commit: src/sys/ufs/ufs

2015-04-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr 15 14:39:24 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_inode.c

Log Message:
Release the glock on VOP_GETPAGES failure.

Tripped over by nick@'s failing disk, missing unlock in error branch
discovered by jmcneill@.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/ufs/ufs/ufs_inode.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.92 src/sys/ufs/ufs/ufs_inode.c:1.93
--- src/sys/ufs/ufs/ufs_inode.c:1.92	Wed Oct 29 01:13:28 2014
+++ src/sys/ufs/ufs/ufs_inode.c	Wed Apr 15 14:39:24 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.92 2014/10/29 01:13:28 christos Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.93 2015/04/15 14:39:24 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.92 2014/10/29 01:13:28 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.93 2015/04/15 14:39:24 riastradh Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -229,6 +229,7 @@ ufs_balloc_range(struct vnode *vp, off_t
 	VM_PROT_WRITE, 0, PGO_SYNCIO | PGO_PASTEOF | PGO_NOBLOCKALLOC |
 	PGO_NOTIMESTAMP | PGO_GLOCKHELD);
 	if (error) {
+		genfs_node_unlock(vp);
 		goto out;
 	}
 



CVS commit: src/sys/ufs/ufs

2015-04-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 12 22:41:28 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_readwrite.c

Log Message:
Don't putpages in ufs buffercached writes: kassert there are none.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/ufs/ufs/ufs_readwrite.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_readwrite.c
diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.118 src/sys/ufs/ufs/ufs_readwrite.c:1.119
--- src/sys/ufs/ufs/ufs_readwrite.c:1.118	Tue Mar 31 11:43:05 2015
+++ src/sys/ufs/ufs/ufs_readwrite.c	Sun Apr 12 22:41:28 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_readwrite.c,v 1.118 2015/03/31 11:43:05 riastradh Exp $	*/
+/*	$NetBSD: ufs_readwrite.c,v 1.119 2015/04/12 22:41:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.118 2015/03/31 11:43:05 riastradh Exp $);
+__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.119 2015/04/12 22:41:28 riastradh Exp $);
 
 #ifdef LFS_READWRITE
 #define	FS			struct lfs
@@ -567,9 +567,7 @@ BUFWR(struct vnode *vp, struct uio *uio,
 #endif /* !LFS_READWRITE */
 
 	/* XXX Should never have pages cached here.  */
-	mutex_enter(vp-v_interlock);
-	VOP_PUTPAGES(vp, trunc_page(origoff), round_page(origoff + resid),
-	PGO_CLEANIT | PGO_FREE | PGO_SYNCIO | PGO_JOURNALLOCKED);
+	KASSERT(vp-v_uobj.uo_npages == 0);
 	while (uio-uio_resid  0) {
 		lbn = ufs_lblkno(fs, uio-uio_offset);
 		blkoffset = ufs_blkoff(fs, uio-uio_offset);



CVS commit: src/sys/ufs/ufs

2015-04-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 12 22:48:38 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_readwrite.c

Log Message:
Omit now-unused variable.  rump build didn't catch this...


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/ufs/ufs/ufs_readwrite.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_readwrite.c
diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.119 src/sys/ufs/ufs/ufs_readwrite.c:1.120
--- src/sys/ufs/ufs/ufs_readwrite.c:1.119	Sun Apr 12 22:41:28 2015
+++ src/sys/ufs/ufs/ufs_readwrite.c	Sun Apr 12 22:48:38 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_readwrite.c,v 1.119 2015/04/12 22:41:28 riastradh Exp $	*/
+/*	$NetBSD: ufs_readwrite.c,v 1.120 2015/04/12 22:48:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.119 2015/04/12 22:41:28 riastradh Exp $);
+__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.120 2015/04/12 22:48:38 riastradh Exp $);
 
 #ifdef LFS_READWRITE
 #define	FS			struct lfs
@@ -518,7 +518,7 @@ BUFWR(struct vnode *vp, struct uio *uio,
 	FS *fs;
 	int flags;
 	struct buf *bp;
-	off_t osize, origoff;
+	off_t osize;
 	int resid, xfersize, size, blkoffset;
 	daddr_t lbn;
 	int extended=0;
@@ -554,7 +554,6 @@ BUFWR(struct vnode *vp, struct uio *uio,
 	fstrans_start(vp-v_mount, FSTRANS_SHARED);
 
 	flags = ioflag  IO_SYNC ? B_SYNC : 0;
-	origoff = uio-uio_offset;
 	resid = uio-uio_resid;
 	osize = ip-i_size;
 	error = 0;



CVS commit: src/sys/ufs/ufs

2015-04-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  1 20:03:11 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
Don't use dvp after vput(dvp).

Still don't understand why the fstrans_done must happen after the
vput, and that will cause trouble once we move responsibility for the
vrele and unlock outside the vop as it seems obvious we ought to do
-- it's the caller's reference, not the vop's.


To generate a diff of this commit:
cvs rdiff -u -r1.227 -r1.228 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.227 src/sys/ufs/ufs/ufs_vnops.c:1.228
--- src/sys/ufs/ufs/ufs_vnops.c:1.227	Fri Mar 27 19:47:14 2015
+++ src/sys/ufs/ufs/ufs_vnops.c	Wed Apr  1 20:03:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.227 2015/03/27 19:47:14 riastradh Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.228 2015/04/01 20:03:11 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.227 2015/03/27 19:47:14 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.228 2015/04/01 20:03:11 riastradh Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -723,27 +723,30 @@ ufs_remove(void *v)
 	} */ *ap = v;
 	struct vnode	*vp, *dvp;
 	struct inode	*ip;
+	struct mount	*mp;
 	int		error;
 	struct ufs_lookup_results *ulr;
 
 	vp = ap-a_vp;
 	dvp = ap-a_dvp;
 	ip = VTOI(vp);
+	mp = dvp-v_mount;
+	KASSERT(mp == vp-v_mount);
 
 	/* XXX should handle this material another way */
 	ulr = VTOI(dvp)-i_crap;
 	UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
 
-	fstrans_start(dvp-v_mount, FSTRANS_SHARED);
+	fstrans_start(mp, FSTRANS_SHARED);
 	if (vp-v_type == VDIR || (ip-i_flags  (IMMUTABLE | APPEND)) ||
 	(VTOI(dvp)-i_flags  APPEND))
 		error = EPERM;
 	else {
-		error = UFS_WAPBL_BEGIN(dvp-v_mount);
+		error = UFS_WAPBL_BEGIN(mp);
 		if (error == 0) {
 			error = ufs_dirremove(dvp, ulr,
 	  ip, ap-a_cnp-cn_flags, 0);
-			UFS_WAPBL_END(dvp-v_mount);
+			UFS_WAPBL_END(mp);
 		}
 	}
 	VN_KNOTE(vp, NOTE_DELETE);
@@ -753,7 +756,7 @@ ufs_remove(void *v)
 	else
 		vput(vp);
 	vput(dvp);
-	fstrans_done(dvp-v_mount);
+	fstrans_done(mp);
 	return (error);
 }
 



CVS commit: src/sys/ufs/ufs

2015-03-31 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 31 11:43:05 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_readwrite.c

Log Message:
Amplify that even if we fixed it now the tentacles are still stuck.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/ufs/ufs/ufs_readwrite.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_readwrite.c
diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.117 src/sys/ufs/ufs/ufs_readwrite.c:1.118
--- src/sys/ufs/ufs/ufs_readwrite.c:1.117	Tue Mar 31 00:22:50 2015
+++ src/sys/ufs/ufs/ufs_readwrite.c	Tue Mar 31 11:43:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_readwrite.c,v 1.117 2015/03/31 00:22:50 riastradh Exp $	*/
+/*	$NetBSD: ufs_readwrite.c,v 1.118 2015/03/31 11:43:05 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.117 2015/03/31 00:22:50 riastradh Exp $);
+__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.118 2015/03/31 11:43:05 riastradh Exp $);
 
 #ifdef LFS_READWRITE
 #define	FS			struct lfs
@@ -349,6 +349,11 @@ WRITE(void *v)
 	 * genfs_getpages/putpages to cope with the possibility that
 	 * the transaction may or may not be locked on entry to the
 	 * page cache.
+	 *
+	 * And even if we added that notion to WAPBL, it wouldn't help
+	 * us get rid of the tentacles in genfs_getpages/putpages
+	 * because we'd have to interoperate with old implementations
+	 * that assume they can replay the log without fsck.
 	 */
 	error = UFS_WAPBL_BEGIN(vp-v_mount);
 	if (error) {



CVS commit: src/sys/ufs/ufs

2015-03-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 31 00:22:50 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_readwrite.c

Log Message:
Write an essay explaining why ffs_write is one huge WAPBL transaction.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/ufs/ufs/ufs_readwrite.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_readwrite.c
diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.116 src/sys/ufs/ufs/ufs_readwrite.c:1.117
--- src/sys/ufs/ufs/ufs_readwrite.c:1.116	Sun Mar 29 14:39:41 2015
+++ src/sys/ufs/ufs/ufs_readwrite.c	Tue Mar 31 00:22:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_readwrite.c,v 1.116 2015/03/29 14:39:41 riastradh Exp $	*/
+/*	$NetBSD: ufs_readwrite.c,v 1.117 2015/03/31 00:22:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.116 2015/03/29 14:39:41 riastradh Exp $);
+__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.117 2015/03/31 00:22:50 riastradh Exp $);
 
 #ifdef LFS_READWRITE
 #define	FS			struct lfs
@@ -328,6 +328,28 @@ WRITE(void *v)
 
 	KASSERT(vp-v_type == VREG);
 
+	/*
+	 * XXX The entire write operation must occur in a single WAPBL
+	 * transaction because it may allocate disk blocks, if
+	 * appending or filling holes, which is allowed to happen only
+	 * if the write fully succeeds.
+	 *
+	 * If ubc_uiomove fails in the middle with EFAULT, we can clean
+	 * up at the end with UFS_TRUNCATE.  But if the power fails in
+	 * the middle, there would be nobody to deallocate the blocks,
+	 * without an fsck to globally analyze the file system.
+	 *
+	 * If the increasingly inaccurately named WAPBL were augmented
+	 * with rollback records for block allocations, then we could
+	 * split this into multiple transactions and commit the
+	 * allocations in the last one.
+	 *
+	 * But WAPBL doesn't have that notion now, so we'll have to
+	 * live with gigantic transactions and WAPBL tentacles in
+	 * genfs_getpages/putpages to cope with the possibility that
+	 * the transaction may or may not be locked on entry to the
+	 * page cache.
+	 */
 	error = UFS_WAPBL_BEGIN(vp-v_mount);
 	if (error) {
 		fstrans_done(vp-v_mount);



CVS commit: src/sys/ufs/ufs

2015-03-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 29 14:39:41 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_readwrite.c

Log Message:
WAPBL tx is always locked by ufs_bufrd caller, so never unlock it.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/ufs/ufs/ufs_readwrite.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_readwrite.c
diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.115 src/sys/ufs/ufs/ufs_readwrite.c:1.116
--- src/sys/ufs/ufs/ufs_readwrite.c:1.115	Sat Mar 28 19:24:05 2015
+++ src/sys/ufs/ufs/ufs_readwrite.c	Sun Mar 29 14:39:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_readwrite.c,v 1.115 2015/03/28 19:24:05 maxv Exp $	*/
+/*	$NetBSD: ufs_readwrite.c,v 1.116 2015/03/29 14:39:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.115 2015/03/28 19:24:05 maxv Exp $);
+__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.116 2015/03/29 14:39:41 riastradh Exp $);
 
 #ifdef LFS_READWRITE
 #define	FS			struct lfs
@@ -610,8 +610,6 @@ BUFWR(struct vnode *vp, struct uio *uio,
 
 	error = ufs_post_write_update(vp, uio, ioflag, cred, osize, resid,
 	extended, error);
-	if ((ioflag  IO_JOURNALLOCKED) == 0)
-		UFS_WAPBL_END(vp-v_mount);
 	fstrans_done(vp-v_mount);
 
 	return (error);



CVS commit: src/sys/ufs/ufs

2015-03-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 28 04:13:26 UTC 2015

Modified Files:
src/sys/ufs/ufs: ufs_readwrite.c

Log Message:
VOP_WRITE never has IO_JOURNALLOCKED.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/ufs/ufs/ufs_readwrite.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_readwrite.c
diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.110 src/sys/ufs/ufs/ufs_readwrite.c:1.111
--- src/sys/ufs/ufs/ufs_readwrite.c:1.110	Sat Mar 28 03:53:36 2015
+++ src/sys/ufs/ufs/ufs_readwrite.c	Sat Mar 28 04:13:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_readwrite.c,v 1.110 2015/03/28 03:53:36 riastradh Exp $	*/
+/*	$NetBSD: ufs_readwrite.c,v 1.111 2015/03/28 04:13:25 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.110 2015/03/28 03:53:36 riastradh Exp $);
+__KERNEL_RCSID(1, $NetBSD: ufs_readwrite.c,v 1.111 2015/03/28 04:13:25 riastradh Exp $);
 
 #ifdef LFS_READWRITE
 #define	FS			struct lfs
@@ -292,6 +292,8 @@ WRITE(void *v)
 	KASSERT(vp-v_size == ip-i_size);
 	KASSERT(uio-uio_rw == UIO_WRITE);
 	KASSERT(vp-v_type == VREG);
+	KASSERT(!ISSET(ioflag, IO_JOURNALLOCKED));
+	UFS_WAPBL_JUNLOCK_ASSERT(vp-v_mount);
 
 	if (ioflag  IO_APPEND)
 		uio-uio_offset = ip-i_size;
@@ -322,12 +324,10 @@ WRITE(void *v)
 
 	KASSERT(vp-v_type == VREG);
 
-	if ((ioflag  IO_JOURNALLOCKED) == 0) {
-		error = UFS_WAPBL_BEGIN(vp-v_mount);
-		if (error) {
-			fstrans_done(vp-v_mount);
-			return error;
-		}
+	error = UFS_WAPBL_BEGIN(vp-v_mount);
+	if (error) {
+		fstrans_done(vp-v_mount);
+		return error;
 	}
 
 #ifdef LFS_READWRITE
@@ -504,8 +504,7 @@ out:
 	else
 		UFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
 	KASSERT(vp-v_size == ip-i_size);
-	if ((ioflag  IO_JOURNALLOCKED) == 0)
-		UFS_WAPBL_END(vp-v_mount);
+	UFS_WAPBL_END(vp-v_mount);
 	fstrans_done(vp-v_mount);
 
 	return (error);



CVS commit: src/sys/ufs/ufs

2014-12-19 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Dec 19 10:59:21 UTC 2014

Modified Files:
src/sys/ufs/ufs: extattr.h

Log Message:
Bump UFS1 extended attribute max name length to 256

For extended attribute name max length, kernel filesystem-independant
code use either EXTATTR_MAXNAMELEN (BSD API) or XATTR_NAME_MAX (Linux API),
which are both defined as KERNEL_NAME_MAX and fits Linux limit of 255
without training \0.

UFS1 code had a lower limit that broke Linux compatibility. We can bump
the limit without sacrifying backward compatibility, because:

1) There is no API exposing this limit outside the kernel. Upper kernel
layers have a larger limit handle the increase without a hitch

2) Each attribute has its own backing store in the fileystem, the name
of the backing store matching the attribute name. A newer kernel can
create/read/write backing store for longer attribute names and will
have no problem with existing shorter names.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/extattr.h

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

Modified files:

Index: src/sys/ufs/ufs/extattr.h
diff -u src/sys/ufs/ufs/extattr.h:1.10 src/sys/ufs/ufs/extattr.h:1.11
--- src/sys/ufs/ufs/extattr.h:1.10	Sun Oct  9 21:15:34 2011
+++ src/sys/ufs/ufs/extattr.h	Fri Dec 19 10:59:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: extattr.h,v 1.10 2011/10/09 21:15:34 chs Exp $	*/
+/*	$NetBSD: extattr.h,v 1.11 2014/12/19 10:59:21 manu Exp $	*/
 
 /*-
  * Copyright (c) 1999-2001 Robert N. M. Watson
@@ -43,7 +43,7 @@
 #define	UFS_EXTATTR_FSROOTSUBDIR	.attribute
 #define	UFS_EXTATTR_SUBDIR_SYSTEM	system
 #define	UFS_EXTATTR_SUBDIR_USER		user
-#define	UFS_EXTATTR_MAXEXTATTRNAME	65	/* including null */
+#define	UFS_EXTATTR_MAXEXTATTRNAME	256	/* including null */
 
 #define	UFS_EXTATTR_ATTR_FLAG_INUSE	0x0001	/* attr has been set */
 #define	UFS_EXTATTR_PERM_KERNEL		0x



CVS commit: src/sys/ufs/ufs

2014-12-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 20 00:28:05 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_dirhash.c

Log Message:
clear i_dirhash sooner, but what lock protects it?


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/ufs/ufs/ufs_dirhash.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_dirhash.c
diff -u src/sys/ufs/ufs/ufs_dirhash.c:1.36 src/sys/ufs/ufs/ufs_dirhash.c:1.37
--- src/sys/ufs/ufs/ufs_dirhash.c:1.36	Tue Feb 25 13:30:13 2014
+++ src/sys/ufs/ufs/ufs_dirhash.c	Fri Dec 19 19:28:05 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_dirhash.c,v 1.36 2014/02/25 18:30:13 pooka Exp $	*/
+/*	$NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002 Ian Dowse.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_dirhash.c,v 1.36 2014/02/25 18:30:13 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp $);
 
 /*
  * This implements a hash-based lookup scheme for UFS directories.
@@ -255,6 +255,7 @@ ufsdirhash_build(struct inode *ip)
 	return (0);
 
 fail:
+	ip-i_dirhash = NULL;
 	DIRHASH_UNLOCK(dh);
 	if (dh-dh_hash != NULL) {
 		for (i = 0; i  narrays; i++)
@@ -266,7 +267,6 @@ fail:
 		kmem_free(dh-dh_blkfree, dh-dh_blkfreesz);
 	mutex_destroy(dh-dh_lock);
 	pool_cache_put(ufsdirhash_cache, dh);
-	ip-i_dirhash = NULL;
 	atomic_add_int(ufs_dirhashmem, -memreqd);
 	return (-1);
 }
@@ -283,6 +283,8 @@ ufsdirhash_free(struct inode *ip)
 	if ((dh = ip-i_dirhash) == NULL)
 		return;
 
+	ip-i_dirhash = NULL;
+
 	if (dh-dh_onlist) {
 		DIRHASHLIST_LOCK();
 		if (dh-dh_onlist)
@@ -303,7 +305,6 @@ ufsdirhash_free(struct inode *ip)
 	}
 	mutex_destroy(dh-dh_lock);
 	pool_cache_put(ufsdirhash_cache, dh);
-	ip-i_dirhash = NULL;
 
 	atomic_add_int(ufs_dirhashmem, -mem);
 }



CVS commit: src/sys/ufs/ufs

2014-11-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 25 19:48:24 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_quota1.c

Log Message:
CID 977076: Widen before multiply.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/ufs/ufs_quota1.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.20 src/sys/ufs/ufs/ufs_quota1.c:1.21
--- src/sys/ufs/ufs/ufs_quota1.c:1.20	Sat May 24 12:34:04 2014
+++ src/sys/ufs/ufs/ufs_quota1.c	Tue Nov 25 14:48:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.20 2014/05/24 16:34:04 christos Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.21 2014/11/25 19:48:24 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota1.c,v 1.20 2014/05/24 16:34:04 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota1.c,v 1.21 2014/11/25 19:48:24 christos Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -860,7 +860,7 @@ dq1sync(struct vnode *vp, struct dquot *
 	aiov.iov_base = (void *)dq-dq_un.dq1_dqb;
 	aiov.iov_len = sizeof (struct dqblk);
 	auio.uio_resid = sizeof (struct dqblk);
-	auio.uio_offset = (off_t)(dq-dq_id * sizeof (struct dqblk));
+	auio.uio_offset = (off_t)dq-dq_id * sizeof (struct dqblk);
 	auio.uio_rw = UIO_WRITE;
 	UIO_SETUP_SYSSPACE(auio);
 	error = VOP_WRITE(dqvp, auio, 0, dq-dq_ump-um_cred[dq-dq_type]);



CVS commit: src/sys/ufs/ufs

2014-11-19 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed Nov 19 16:26:47 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_extattr.c

Log Message:
Fix uninitialized mutex usage

We use extended attribute mount mutex before testing if it had been
initialized, and as reported by Christos,  this caused panic with
LOCKDEBUG. Fix it by testing before using.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ufs/ufs_extattr.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extattr.c
diff -u src/sys/ufs/ufs/ufs_extattr.c:1.45 src/sys/ufs/ufs/ufs_extattr.c:1.46
--- src/sys/ufs/ufs/ufs_extattr.c:1.45	Sat Nov 15 05:03:55 2014
+++ src/sys/ufs/ufs/ufs_extattr.c	Wed Nov 19 16:26:47 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $	*/
+/*	$NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp $	*/
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -1103,6 +1103,9 @@ vop_getextattr {
 	struct ufsmount *ump = VFSTOUFS(mp);
 	int error;
 
+	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
+		return (EOPNOTSUPP);
+
 	ufs_extattr_uepm_lock(ump);
 
 	error = ufs_extattr_get(ap-a_vp, ap-a_attrnamespace, ap-a_name,
@@ -1129,9 +1132,6 @@ ufs_extattr_get(struct vnode *vp, int at
 	size_t len, old_len;
 	int error = 0;
 
-	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
-		return (EOPNOTSUPP);
-
 	if (strlen(name) == 0)
 		return (EINVAL);
 
@@ -1221,6 +1221,9 @@ vop_listextattr {
 	struct ufsmount *ump = VFSTOUFS(mp);
 	int error;
 
+	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
+		return (EOPNOTSUPP);
+
 	ufs_extattr_uepm_lock(ump);
 
 	error = ufs_extattr_list(ap-a_vp, ap-a_attrnamespace,
@@ -1247,9 +1250,6 @@ ufs_extattr_list(struct vnode *vp, int a
 	size_t listsize = 0;
 	int error = 0;
 
-	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
-		return (EOPNOTSUPP);
-
 	/*
 	 * XXX: We can move this inside the loop and iterate on individual
 	 *	attributes.
@@ -1348,6 +1348,9 @@ vop_deleteextattr {
 	struct ufsmount *ump = VFSTOUFS(mp); 
 	int error;
 
+	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
+		return (EOPNOTSUPP);
+
 	ufs_extattr_uepm_lock(ump);
 
 	error = ufs_extattr_rm(ap-a_vp, ap-a_attrnamespace, ap-a_name,
@@ -1377,6 +1380,9 @@ vop_setextattr {
 	struct ufsmount *ump = VFSTOUFS(mp); 
 	int error;
 
+	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
+		return (EOPNOTSUPP);
+
 	ufs_extattr_uepm_lock(ump);
 
 	/*
@@ -1415,8 +1421,7 @@ ufs_extattr_set(struct vnode *vp, int at
 
 	if (vp-v_mount-mnt_flag  MNT_RDONLY)
 		return (EROFS);
-	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
-		return (EOPNOTSUPP);
+
 	if (!ufs_extattr_valid_attrname(attrnamespace, name))
 		return (EINVAL);
 
@@ -1535,8 +1540,7 @@ ufs_extattr_rm(struct vnode *vp, int att
 
 	if (vp-v_mount-mnt_flag  MNT_RDONLY)  
 		return (EROFS);
-	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
-		return (EOPNOTSUPP);
+
 	if (!ufs_extattr_valid_attrname(attrnamespace, name))
 		return (EINVAL);
 
@@ -1609,12 +1613,10 @@ ufs_extattr_vnode_inactive(struct vnode 
 	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_INITIALIZED))
 		return;
 
-	ufs_extattr_uepm_lock(ump);
-
-	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED)) {
-		ufs_extattr_uepm_unlock(ump);
+	if (!(ump-um_extattr.uepm_flags  UFS_EXTATTR_UEPM_STARTED))
 		return;
-	}
+
+	ufs_extattr_uepm_lock(ump);
 
 	LIST_FOREACH(uele, ump-um_extattr.uepm_list, uele_entries)
 		ufs_extattr_rm(vp, uele-uele_attrnamespace,



CVS commit: src/sys/ufs/ufs

2014-11-14 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat Nov 15 05:03:55 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_extattr.c

Log Message:
Fix UFS1 extended attribute backend autocreation deadlock

UFS1 extended attribute backend autocration goes through a vn_open()
to create the backend file, and this forces us to release the lock
on the target node, in case the target is within the parents of the
backend file. That created a window within which another thread could
acquire a lock on the target vnode and deadlock awaiting for the
mount extended attribute lock.

We fix the problem by also releasing the mount extended attribute lock
when calling vn_open(), but that lets another thread race us for backend
creation. We just detect this using O_EXCL for vn_open() and by checking
for EEXIST return code. If we are raced, we fail backend creation but
this is not a problem since another thread succeeded on it: we just have
to use the result.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/ufs/ufs/ufs_extattr.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extattr.c
diff -u src/sys/ufs/ufs/ufs_extattr.c:1.44 src/sys/ufs/ufs/ufs_extattr.c:1.45
--- src/sys/ufs/ufs/ufs_extattr.c:1.44	Fri Nov 14 10:09:50 2014
+++ src/sys/ufs/ufs/ufs_extattr.c	Sat Nov 15 05:03:55 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extattr.c,v 1.44 2014/11/14 10:09:50 manu Exp $	*/
+/*	$NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $	*/
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.44 2014/11/14 10:09:50 manu Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -210,9 +210,9 @@ ufs_extattr_valid_attrname(int attrnames
 /*
  * Autocreate an attribute storage
  */
-static struct ufs_extattr_list_entry *
+static int
 ufs_extattr_autocreate_attr(struct vnode *vp, int attrnamespace,
-const char *attrname, struct lwp *l)
+const char *attrname, struct lwp *l, struct ufs_extattr_list_entry **uelep)
 {
 	struct mount *mp = vp-v_mount;
 	struct ufsmount *ump = VFSTOUFS(mp);
@@ -246,11 +246,21 @@ ufs_extattr_autocreate_attr(struct vnode
 		break;
 	default:
 		PNBUF_PUT(path);
-		return NULL;
+		*uelep = NULL;
+		return EINVAL;
 		break;
 	}
 
 	/*
+	 * Release extended attribute mount lock, otherwise
+	 * we can deadlock with another thread that would lock 
+	 * vp after we unlock it below, and call 
+	 * ufs_extattr_uepm_lock(ump), for instance
+	 * in ufs_getextattr().
+	 */
+	ufs_extattr_uepm_unlock(ump);
+
+	/*
 	 * XXX unlock/lock should only be done when setting extattr
 	 * on backing store or one of its parent directory 
 	 * including root, but we always do it for now.
@@ -261,7 +271,12 @@ ufs_extattr_autocreate_attr(struct vnode
 	pb = pathbuf_create(path);
 	NDINIT(nd, CREATE, LOCKPARENT, pb);
 	
-	error = vn_open(nd, O_CREAT|O_RDWR, 0600);
+	/*
+	 * Since we do not hold ufs_extattr_uepm_lock anymore,
+	 * another thread may race with us for backend creation,
+	 * but only one can succeed here thanks to O_EXCL
+	 */
+	error = vn_open(nd, O_CREAT|O_EXCL|O_RDWR, 0600);
 
 	/*
 	 * Reacquire the lock on the vnode
@@ -269,10 +284,13 @@ ufs_extattr_autocreate_attr(struct vnode
 	KASSERT(VOP_ISLOCKED(vp) == 0);
 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 
+	ufs_extattr_uepm_lock(ump);
+
 	if (error != 0) {
 		pathbuf_destroy(pb);
 		PNBUF_PUT(path);
-		return NULL;
+		*uelep = NULL;
+		return error;
 	}
 
 	KASSERT(nd.ni_vp != NULL);
@@ -300,7 +318,8 @@ ufs_extattr_autocreate_attr(struct vnode
 		printf(%s: write uef header failed for %s, error = %d\n, 
 		   __func__, attrname, error);
 		vn_close(backing_vp, FREAD|FWRITE, l-l_cred);
-		return NULL;
+		*uelep = NULL;
+		return error;
 	}
 
 	/*
@@ -313,7 +332,8 @@ ufs_extattr_autocreate_attr(struct vnode
 		printf(%s: enable %s failed, error %d\n, 
 		   __func__, attrname, error);
 		vn_close(backing_vp, FREAD|FWRITE, l-l_cred);
-		return NULL;
+		*uelep = NULL;
+		return error;
 	}
 
 	uele = ufs_extattr_find_attr(ump, attrnamespace, attrname);
@@ -321,13 +341,15 @@ ufs_extattr_autocreate_attr(struct vnode
 		printf(%s: atttribute %s created but not found!\n,
 		   __func__, attrname);
 		vn_close(backing_vp, FREAD|FWRITE, l-l_cred);
-		return NULL;
+		*uelep = NULL;
+		return ESRCH; /* really internal error */
 	}
 
 	printf(%s: EA backing store autocreated for %s\n,
 	   mp-mnt_stat.f_mntonname, attrname);
 
-	return uele;
+	*uelep = uele;
+	return 0;
 }
 
 /*
@@ -1405,10 +1427,17 @@ ufs_extattr_set(struct vnode *vp, int at
 
 	attribute = ufs_extattr_find_attr(ump, attrnamespace, name);
 	if (!attribute) {
-		attribute =  ufs_extattr_autocreate_attr(vp, attrnamespace, 
-			 name, l);
-		if  (!attribute)
-			return (ENODATA);
+		error 

CVS commit: src/sys/ufs/ufs

2014-10-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 29 01:13:28 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_extern.h ufs_inode.c ufs_vnops.c

Log Message:
simplify and correct.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/ufs/ufs/ufs_extern.h
cvs rdiff -u -r1.91 -r1.92 src/sys/ufs/ufs/ufs_inode.c
cvs rdiff -u -r1.223 -r1.224 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extern.h
diff -u src/sys/ufs/ufs/ufs_extern.h:1.76 src/sys/ufs/ufs/ufs_extern.h:1.77
--- src/sys/ufs/ufs/ufs_extern.h:1.76	Tue Oct 21 06:39:26 2014
+++ src/sys/ufs/ufs/ufs_extern.h	Tue Oct 28 21:13:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extern.h,v 1.76 2014/10/21 10:39:26 slp Exp $	*/
+/*	$NetBSD: ufs_extern.h,v 1.77 2014/10/29 01:13:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -111,7 +111,7 @@ int	ufs_getlbns(struct vnode *, daddr_t,
 /* ufs_inode.c */
 int	ufs_reclaim(struct vnode *);
 int	ufs_balloc_range(struct vnode *, off_t, off_t, kauth_cred_t, int);
-int	ufs_wapbl_truncate(struct vnode *, uint64_t, uint64_t, uint64_t);
+int	ufs_truncate(struct vnode *, uint64_t, kauth_cred_t);
 
 /* ufs_lookup.c */
 void	ufs_dirbad(struct inode *, doff_t, const char *);

Index: src/sys/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.91 src/sys/ufs/ufs/ufs_inode.c:1.92
--- src/sys/ufs/ufs/ufs_inode.c:1.91	Tue Oct 21 06:39:26 2014
+++ src/sys/ufs/ufs/ufs_inode.c	Tue Oct 28 21:13:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.91 2014/10/21 10:39:26 slp Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.92 2014/10/29 01:13:28 christos Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.91 2014/10/21 10:39:26 slp Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.92 2014/10/29 01:13:28 christos Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -87,7 +87,6 @@ ufs_inactive(void *v)
 	struct mount *transmp;
 	mode_t mode;
 	int error = 0;
-	int logged = 0;
 
 	UFS_WAPBL_JUNLOCK_ASSERT(vp-v_mount);
 
@@ -102,26 +101,8 @@ ufs_inactive(void *v)
 #ifdef UFS_EXTATTR
 		ufs_extattr_vnode_inactive(vp, curlwp);
 #endif
-		if (ip-i_size != 0) {
-			uint64_t incr = MNINDIR(ip-i_ump) 
-			vp-v_mount-mnt_fs_bshift; /* Power of 2 */
-			uint64_t base = UFS_NDADDR 
-			vp-v_mount-mnt_fs_bshift;
-			/*
-			 * When journaling, only truncate one indirect block
-			 * at a time
-			 */
-			if (vp-v_mount-mnt_wapbl  ip-i_size  base + incr) {
-error = ufs_wapbl_truncate(vp, incr, base, 0);
-			}
-			if (!error) {
-error = UFS_WAPBL_BEGIN(vp-v_mount);
-if (error)
-	goto out;
-logged = 1;
-error = UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED);
-			}
-		}
+		if (ip-i_size != 0)
+			error = ufs_truncate(vp, 0, NOCRED);
 #if defined(QUOTA) || defined(QUOTA2)
 		(void)chkiq(ip, -1, NOCRED, 0);
 #endif
@@ -137,16 +118,12 @@ ufs_inactive(void *v)
 	}
 
 	if (ip-i_flag  (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) {
-		if (!logged++) {
-			int err;
-			err = UFS_WAPBL_BEGIN(vp-v_mount);
-			if (err)
-goto out;
-		}
+		error = UFS_WAPBL_BEGIN(vp-v_mount);
+		if (error)
+			goto out;
 		UFS_UPDATE(vp, NULL, NULL, 0);
-	}
-	if (logged)
 		UFS_WAPBL_END(vp-v_mount);
+	}
 out:
 	/*
 	 * If we are done with the inode, reclaim it
@@ -295,25 +272,23 @@ ufs_balloc_range(struct vnode *vp, off_t
 	return error;
 }
 
-int
-ufs_wapbl_truncate(struct vnode *vp, uint64_t incr, uint64_t base,
-uint64_t newsize)
+static int
+ufs_wapbl_truncate(struct vnode *vp, uint64_t newsize, kauth_cred_t cred)
 {
 	struct inode *ip = VTOI(vp);
-	int error;
-
-	error = UFS_WAPBL_BEGIN(vp-v_mount);
-	if (error)
-		return error;
+	int error = 0;
+	uint64_t base, incr;
 
-	while (ip-i_size  base + incr) {
+	base = UFS_NDADDR  vp-v_mount-mnt_fs_bshift;
+	incr = MNINDIR(ip-i_ump)  vp-v_mount-mnt_fs_bshift;/* Power of 2 */
+	while (ip-i_size  base + incr 
+	(newsize == 0 || ip-i_size  newsize + incr)) {
 		/*
 		 * round down to next full indirect
 		 * block boundary.
 		 */
-		uint64_t nsize =
-		base + ((ip-i_size - base - 1)  ~(incr - 1));
-		error = UFS_TRUNCATE(vp, nsize, 0, NOCRED);
+		uint64_t nsize = base + ((ip-i_size - base - 1)  ~(incr - 1));
+		error = UFS_TRUNCATE(vp, nsize, 0, cred);
 		if (error)
 			break;
 		UFS_WAPBL_END(vp-v_mount);
@@ -321,6 +296,23 @@ ufs_wapbl_truncate(struct vnode *vp, uin
 		if (error)
 			return error;
 	}
+	return error;
+}
+
+int
+ufs_truncate(struct vnode *vp, uint64_t newsize, kauth_cred_t cred)
+{
+	int error;
+
+	error = UFS_WAPBL_BEGIN(vp-v_mount);
+	if (error)
+		return error;
+
+	if (vp-v_mount-mnt_wapbl)
+		error = ufs_wapbl_truncate(vp, newsize, cred);
+
+	if (error == 0)
+		error = UFS_TRUNCATE(vp, newsize, 0, cred);
 	UFS_WAPBL_END(vp-v_mount);
 
 	return error;

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u 

CVS commit: src/sys/ufs/ufs

2014-10-21 Thread Sergio Lopez
Module Name:src
Committed By:   slp
Date:   Tue Oct 21 10:39:26 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_extern.h ufs_inode.c ufs_vnops.c

Log Message:
Move and unify indirect block truncate algorithm into a separate function.

Reviewed by joerg.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/ufs/ufs/ufs_extern.h
cvs rdiff -u -r1.90 -r1.91 src/sys/ufs/ufs/ufs_inode.c
cvs rdiff -u -r1.222 -r1.223 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extern.h
diff -u src/sys/ufs/ufs/ufs_extern.h:1.75 src/sys/ufs/ufs/ufs_extern.h:1.76
--- src/sys/ufs/ufs/ufs_extern.h:1.75	Sun May 25 13:48:40 2014
+++ src/sys/ufs/ufs/ufs_extern.h	Tue Oct 21 10:39:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extern.h,v 1.75 2014/05/25 13:48:40 hannken Exp $	*/
+/*	$NetBSD: ufs_extern.h,v 1.76 2014/10/21 10:39:26 slp Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -111,6 +111,7 @@ int	ufs_getlbns(struct vnode *, daddr_t,
 /* ufs_inode.c */
 int	ufs_reclaim(struct vnode *);
 int	ufs_balloc_range(struct vnode *, off_t, off_t, kauth_cred_t, int);
+int	ufs_wapbl_truncate(struct vnode *, uint64_t, uint64_t, uint64_t);
 
 /* ufs_lookup.c */
 void	ufs_dirbad(struct inode *, doff_t, const char *);

Index: src/sys/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.90 src/sys/ufs/ufs/ufs_inode.c:1.91
--- src/sys/ufs/ufs/ufs_inode.c:1.90	Thu May  8 08:21:53 2014
+++ src/sys/ufs/ufs/ufs_inode.c	Tue Oct 21 10:39:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.90 2014/05/08 08:21:53 hannken Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.91 2014/10/21 10:39:26 slp Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.90 2014/05/08 08:21:53 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.91 2014/10/21 10:39:26 slp Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -102,40 +102,25 @@ ufs_inactive(void *v)
 #ifdef UFS_EXTATTR
 		ufs_extattr_vnode_inactive(vp, curlwp);
 #endif
-		error = UFS_WAPBL_BEGIN(vp-v_mount);
-		if (error)
-			goto out;
-		logged = 1;
 		if (ip-i_size != 0) {
+			uint64_t incr = MNINDIR(ip-i_ump) 
+			vp-v_mount-mnt_fs_bshift; /* Power of 2 */
+			uint64_t base = UFS_NDADDR 
+			vp-v_mount-mnt_fs_bshift;
 			/*
 			 * When journaling, only truncate one indirect block
 			 * at a time
 			 */
-			if (vp-v_mount-mnt_wapbl) {
-uint64_t incr = MNINDIR(ip-i_ump) 
-vp-v_mount-mnt_fs_bshift; /* Power of 2 */
-uint64_t base = UFS_NDADDR 
-vp-v_mount-mnt_fs_bshift;
-while (!error  ip-i_size  base + incr) {
-	/*
-	 * round down to next full indirect
-	 * block boundary.
-	 */
-	uint64_t nsize = base +
-	((ip-i_size - base - 1) 
-	~(incr - 1));
-	error = UFS_TRUNCATE(vp, nsize, 0,
-	NOCRED);
-	if (error)
-		break;
-	UFS_WAPBL_END(vp-v_mount);
-	error = UFS_WAPBL_BEGIN(vp-v_mount);
-	if (error)
-		goto out;
-}
+			if (vp-v_mount-mnt_wapbl  ip-i_size  base + incr) {
+error = ufs_wapbl_truncate(vp, incr, base, 0);
 			}
-			if (!error)
+			if (!error) {
+error = UFS_WAPBL_BEGIN(vp-v_mount);
+if (error)
+	goto out;
+logged = 1;
 error = UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED);
+			}
 		}
 #if defined(QUOTA) || defined(QUOTA2)
 		(void)chkiq(ip, -1, NOCRED, 0);
@@ -309,3 +294,35 @@ ufs_balloc_range(struct vnode *vp, off_t
  	kmem_free(pgs, pgssize);
 	return error;
 }
+
+int
+ufs_wapbl_truncate(struct vnode *vp, uint64_t incr, uint64_t base,
+uint64_t newsize)
+{
+	struct inode *ip = VTOI(vp);
+	int error;
+
+	error = UFS_WAPBL_BEGIN(vp-v_mount);
+	if (error)
+		return error;
+
+	while (ip-i_size  base + incr) {
+		/*
+		 * round down to next full indirect
+		 * block boundary.
+		 */
+		uint64_t nsize =
+		base + ((ip-i_size - base - 1)  ~(incr - 1));
+		error = UFS_TRUNCATE(vp, nsize, 0, NOCRED);
+		if (error)
+			break;
+		UFS_WAPBL_END(vp-v_mount);
+		error = UFS_WAPBL_BEGIN(vp-v_mount);
+		if (error)
+			return error;
+	}
+	UFS_WAPBL_END(vp-v_mount);
+
+	return error;
+}
+

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.222 src/sys/ufs/ufs/ufs_vnops.c:1.223
--- src/sys/ufs/ufs/ufs_vnops.c:1.222	Sat Oct 18 08:33:30 2014
+++ src/sys/ufs/ufs/ufs_vnops.c	Tue Oct 21 10:39:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.222 2014/10/18 08:33:30 snj Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.223 2014/10/21 10:39:26 slp Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.222 2014/10/18 08:33:30 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.223 2014/10/21 10:39:26 slp Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -464,6 +464,8 @@ ufs_setattr(void *v)
 	int		error;
 	

CVS commit: src/sys/ufs/ufs

2014-05-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 25 13:46:16 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
ufs_mknod: use vcache_get() to reload the new node.


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.220 src/sys/ufs/ufs/ufs_vnops.c:1.221
--- src/sys/ufs/ufs/ufs_vnops.c:1.220	Thu Jan 23 10:13:57 2014
+++ src/sys/ufs/ufs/ufs_vnops.c	Sun May 25 13:46:16 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.220 2014/01/23 10:13:57 hannken Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.221 2014/05/25 13:46:16 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.220 2014/01/23 10:13:57 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.221 2014/05/25 13:46:16 hannken Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -225,21 +225,20 @@ ufs_mknod(void *v)
 	UFS_WAPBL_UPDATE(*vpp, NULL, NULL, 0);
 	UFS_WAPBL_END1(ap-a_dvp-v_mount, ap-a_dvp);
 	/*
-	 * Remove inode so that it will be reloaded by VFS_VGET and
+	 * Remove inode so that it will be reloaded by vcache_get and
 	 * checked to see if it is an alias of an existing entry in
 	 * the inode cache.
 	 */
 	(*vpp)-v_type = VNON;
 	VOP_UNLOCK(*vpp);
 	vgone(*vpp);
-	error = VFS_VGET(mp, ino, vpp);
+	error = vcache_get(mp, ino, sizeof(ino), vpp);
 out:
 	fstrans_done(ap-a_dvp-v_mount);
 	if (error != 0) {
 		*vpp = NULL;
 		return (error);
 	}
-	VOP_UNLOCK(*vpp);
 	return (0);
 }
 



CVS commit: src/sys/ufs/ufs

2014-05-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 25 13:45:39 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_rename.c

Log Message:
ufs_gro_genealogy: use vcache_get() to lookup DOTDOT.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/ufs_rename.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_rename.c
diff -u src/sys/ufs/ufs/ufs_rename.c:1.10 src/sys/ufs/ufs/ufs_rename.c:1.11
--- src/sys/ufs/ufs/ufs_rename.c:1.10	Thu Feb  6 10:57:12 2014
+++ src/sys/ufs/ufs/ufs_rename.c	Sun May 25 13:45:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_rename.c,v 1.10 2014/02/06 10:57:12 hannken Exp $	*/
+/*	$NetBSD: ufs_rename.c,v 1.11 2014/05/25 13:45:39 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_rename.c,v 1.10 2014/02/06 10:57:12 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_rename.c,v 1.11 2014/05/25 13:45:39 hannken Exp $);
 
 #include sys/param.h
 #include sys/buf.h
@@ -979,20 +979,15 @@ ufs_gro_genealogy(struct mount *mp, kaut
 		}
 
 		/* Neither -- keep ascending the family tree.  */
-
-		/*
-		 * Unlock vp so that we can lock the parent, but keep
-		 * vp referenced until after we have found the parent,
-		 * so that dotdot_ino will not be recycled.
-		 *
-		 * XXX This guarantees that vp's inode number will not
-		 * be recycled, but why can't dotdot_ino be recycled?
-		 */
-		VOP_UNLOCK(vp);
-		error = VFS_VGET(mp, dotdot_ino, dvp);
-		vrele(vp);
+		error = vcache_get(mp, dotdot_ino, sizeof(dotdot_ino), dvp);
+		vput(vp);
 		if (error)
 			return error;
+		error = vn_lock(dvp, LK_EXCLUSIVE);
+		if (error) {
+			vrele(dvp);
+			return error;
+		}
 
 		KASSERT(dvp != NULL);
 		KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);



CVS commit: src/sys/ufs/ufs

2014-05-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 25 13:48:40 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_extern.h ufs_lookup.c

Log Message:
Remove ufs_checkpath() and ufs_readdotdot().  These are relics
from the pre-genfs_rename era.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/ufs/ufs/ufs_extern.h
cvs rdiff -u -r1.130 -r1.131 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extern.h
diff -u src/sys/ufs/ufs/ufs_extern.h:1.74 src/sys/ufs/ufs/ufs_extern.h:1.75
--- src/sys/ufs/ufs/ufs_extern.h:1.74	Thu May  8 08:21:53 2014
+++ src/sys/ufs/ufs/ufs_extern.h	Sun May 25 13:48:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extern.h,v 1.74 2014/05/08 08:21:53 hannken Exp $	*/
+/*	$NetBSD: ufs_extern.h,v 1.75 2014/05/25 13:48:40 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -125,9 +125,6 @@ int	ufs_dirremove(struct vnode *, const 
 int	ufs_dirrewrite(struct inode *, off_t,
 		   struct inode *, ino_t, int, int, int);
 int	ufs_dirempty(struct inode *, ino_t, kauth_cred_t);
-int	ufs_checkpath(struct inode *, struct inode *, kauth_cred_t);
-int	ufs_parentcheck(struct vnode *, struct vnode *, kauth_cred_t,
-			int *, struct vnode **);
 int	ufs_blkatoff(struct vnode *, off_t, char **, struct buf **, bool);
 
 /* ufs_rename.c -- for lfs */

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.130 src/sys/ufs/ufs/ufs_lookup.c:1.131
--- src/sys/ufs/ufs/ufs_lookup.c:1.130	Thu May  8 08:21:53 2014
+++ src/sys/ufs/ufs/ufs_lookup.c	Sun May 25 13:48:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.130 2014/05/08 08:21:53 hannken Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.131 2014/05/25 13:48:40 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.130 2014/05/08 08:21:53 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.131 2014/05/25 13:48:40 hannken Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -1228,204 +1228,6 @@ ufs_dirempty(struct inode *ip, ino_t par
 	return (1);
 }
 
-/*
- * Check if source directory is in the path of the target directory.
- * Target is supplied locked, source is unlocked.
- * The target is always vput before returning.
- */
-int
-ufs_checkpath(struct inode *source, struct inode *target, kauth_cred_t cred)
-{
-	struct vnode *nextvp, *vp;
-	int error, rootino, namlen;
-	struct dirtemplate dirbuf;
-	const int needswap = UFS_MPNEEDSWAP(target-i_ump);
-
-	vp = ITOV(target);
-	if (target-i_number == source-i_number) {
-		error = EEXIST;
-		goto out;
-	}
-	rootino = UFS_ROOTINO;
-	error = 0;
-	if (target-i_number == rootino)
-		goto out;
-
-	for (;;) {
-		if (vp-v_type != VDIR) {
-			error = ENOTDIR;
-			break;
-		}
-		error = vn_rdwr(UIO_READ, vp, (void *)dirbuf,
-		sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE,
-		IO_NODELOCKED, cred, NULL, NULL);
-		if (error != 0)
-			break;
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-		if (FSFMT(vp)  needswap == 0)
-			namlen = dirbuf.dotdot_type;
-		else
-			namlen = dirbuf.dotdot_namlen;
-#else
-		if (FSFMT(vp)  needswap != 0)
-			namlen = dirbuf.dotdot_type;
-		else
-			namlen = dirbuf.dotdot_namlen;
-#endif
-		if (namlen != 2 ||
-		dirbuf.dotdot_name[0] != '.' ||
-		dirbuf.dotdot_name[1] != '.') {
-			error = ENOTDIR;
-			break;
-		}
-		if (ufs_rw32(dirbuf.dotdot_ino, needswap) == source-i_number) {
-			error = EINVAL;
-			break;
-		}
-		if (ufs_rw32(dirbuf.dotdot_ino, needswap) == rootino)
-			break;
-		VOP_UNLOCK(vp);
-		error = VFS_VGET(vp-v_mount,
-		ufs_rw32(dirbuf.dotdot_ino, needswap), nextvp);
-		vrele(vp);
-		if (error) {
-			vp = NULL;
-			break;
-		}
-		vp = nextvp;
-	}
-
-out:
-	if (error == ENOTDIR)
-		printf(checkpath: .. not a directory\n);
-	if (vp != NULL)
-		vput(vp);
-	return (error);
-}
-
-/*
- * Extract the inode number of .. from a directory.
- * Helper for ufs_parentcheck.
- */
-static int
-ufs_readdotdot(struct vnode *vp, int needswap, kauth_cred_t cred, ino_t *result)
-{
-	struct dirtemplate dirbuf;
-	int namlen, error;
-
-	error = vn_rdwr(UIO_READ, vp, dirbuf,
-		sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE,
-		IO_NODELOCKED, cred, NULL, NULL);
-	if (error) {
-		return error;
-	}
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-	if (FSFMT(vp)  needswap == 0)
-		namlen = dirbuf.dotdot_type;
-	else
-		namlen = dirbuf.dotdot_namlen;
-#else
-	if (FSFMT(vp)  needswap != 0)
-		namlen = dirbuf.dotdot_type;
-	else
-		namlen = dirbuf.dotdot_namlen;
-#endif
-	if (namlen != 2 ||
-	dirbuf.dotdot_name[0] != '.' ||
-	dirbuf.dotdot_name[1] != '.') {
-		printf(ufs_readdotdot: directory %llu contains 
-		   garbage instead of ..\n,
-		   (unsigned long long) VTOI(vp)-i_number);
-		return ENOTDIR;
-	}
-	*result = ufs_rw32(dirbuf.dotdot_ino, needswap);
-	return 0;
-}
-
-/*
- * Check if 

CVS commit: src/sys/ufs/ufs

2014-05-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat May 17 19:11:40 UTC 2014

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
Reorder struct ufid members to avoid padding (and save 4 bytes) on some
architectures.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/ufs/ufs/inode.h

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

Modified files:

Index: src/sys/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.67 src/sys/ufs/ufs/inode.h:1.68
--- src/sys/ufs/ufs/inode.h:1.67	Wed May 14 13:46:19 2014
+++ src/sys/ufs/ufs/inode.h	Sat May 17 19:11:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.67 2014/05/14 13:46:19 martin Exp $	*/
+/*	$NetBSD: inode.h,v 1.68 2014/05/17 19:11:40 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -295,8 +295,8 @@ struct indir {
 struct ufid {
 	u_int16_t ufid_len;	/* Length of structure. */
 	u_int16_t ufid_pad;	/* Force 32-bit alignment. */
-	ino_t ufid_ino;	/* File number (ino). */
 	int32_t	  ufid_gen;	/* Generation number. */
+	ino_t ufid_ino;	/* File number (ino). */
 };
 #endif /* _KERNEL */
 



CVS commit: src/sys/ufs/ufs

2014-05-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May 14 13:46:19 UTC 2014

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
Make filehandles on UFS based filesystems use proper 64bit inodes.
32bit restriction noticed by Taylor R Campbell.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/ufs/ufs/inode.h

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

Modified files:

Index: src/sys/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.66 src/sys/ufs/ufs/inode.h:1.67
--- src/sys/ufs/ufs/inode.h:1.66	Thu May  8 08:21:53 2014
+++ src/sys/ufs/ufs/inode.h	Wed May 14 13:46:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.66 2014/05/08 08:21:53 hannken Exp $	*/
+/*	$NetBSD: inode.h,v 1.67 2014/05/14 13:46:19 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -295,7 +295,7 @@ struct indir {
 struct ufid {
 	u_int16_t ufid_len;	/* Length of structure. */
 	u_int16_t ufid_pad;	/* Force 32-bit alignment. */
-	u_int32_t ufid_ino;	/* File number (ino). */
+	ino_t ufid_ino;	/* File number (ino). */
 	int32_t	  ufid_gen;	/* Generation number. */
 };
 #endif /* _KERNEL */



CVS commit: src/sys/ufs/ufs

2014-03-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 17 09:31:35 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_quota1.c

Log Message:
Change quota1_handle_cmd_quotaon() and q1sync() to use vfs_vnode_iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/ufs/ufs/ufs_quota1.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.18 src/sys/ufs/ufs/ufs_quota1.c:1.19
--- src/sys/ufs/ufs/ufs_quota1.c:1.18	Thu Feb  2 03:00:48 2012
+++ src/sys/ufs/ufs/ufs_quota1.c	Mon Mar 17 09:31:35 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.18 2012/02/02 03:00:48 matt Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.19 2014/03/17 09:31:35 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota1.c,v 1.18 2012/02/02 03:00:48 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota1.c,v 1.19 2014/03/17 09:31:35 hannken Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -304,7 +304,8 @@ quota1_handle_cmd_quotaon(struct lwp *l,
 const char *fname)
 {
 	struct mount *mp = ump-um_mountp;
-	struct vnode *vp, **vpp, *mvp;
+	struct vnode *vp, **vpp;
+	struct vnode_iterator *marker;
 	struct dquot *dq;
 	int error;
 	struct pathbuf *pb;
@@ -366,41 +367,33 @@ quota1_handle_cmd_quotaon(struct lwp *l,
 			ump-umq1_itime[type] = dq-dq_itime;
 		dqrele(NULLVP, dq);
 	}
-	/* Allocate a marker vnode. */
-	mvp = vnalloc(mp);
 	/*
 	 * Search vnodes associated with this mount point,
 	 * adding references to quota file being opened.
 	 * NB: only need to add dquot's for inodes being modified.
 	 */
-	mutex_enter(mntvnode_lock);
-again:
-	for (vp = TAILQ_FIRST(mp-mnt_vnodelist); vp; vp = vunmark(mvp)) {
-		vmark(mvp, vp);
+	vfs_vnode_iterator_init(mp, marker);
+	while (vfs_vnode_iterator_next(marker, vp)) {
+		error = vn_lock(vp, LK_EXCLUSIVE);
+		if (error) {
+			vrele(vp);
+			continue;
+		}
 		mutex_enter(vp-v_interlock);
-		if (VTOI(vp) == NULL || vp-v_mount != mp || vismarker(vp) ||
-		vp-v_type == VNON || vp-v_writecount == 0 ||
-		(vp-v_iflag  (VI_XLOCK | VI_CLEAN)) != 0) {
+		if (VTOI(vp) == NULL || vp-v_type == VNON ||
+		vp-v_writecount == 0) {
 			mutex_exit(vp-v_interlock);
+			vput(vp);
 			continue;
 		}
-		mutex_exit(mntvnode_lock);
-		if (vget(vp, LK_EXCLUSIVE)) {
-			mutex_enter(mntvnode_lock);
-			(void)vunmark(mvp);
-			goto again;
-		}
+		mutex_exit(vp-v_interlock);
 		if ((error = getinoquota(VTOI(vp))) != 0) {
 			vput(vp);
-			mutex_enter(mntvnode_lock);
-			(void)vunmark(mvp);
 			break;
 		}
 		vput(vp);
-		mutex_enter(mntvnode_lock);
 	}
-	mutex_exit(mntvnode_lock);
-	vnfree(mvp);
+	vfs_vnode_iterator_destroy(marker);
 
 	mutex_enter(dqlock);
 	ump-umq1_qflags[type] = ~QTF_OPENING;
@@ -421,21 +414,18 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 {
 	struct mount *mp = ump-um_mountp;
 	struct vnode *vp;
-	struct vnode *qvp, *mvp;
+	struct vnode *qvp;
+	struct vnode_iterator *marker;
 	struct dquot *dq;
 	struct inode *ip;
 	kauth_cred_t cred;
 	int i, error;
 
-	/* Allocate a marker vnode. */
-	mvp = vnalloc(mp);
-
 	mutex_enter(dqlock);
 	while ((ump-umq1_qflags[type]  (QTF_CLOSING | QTF_OPENING)) != 0)
 		cv_wait(dqcv, dqlock);
 	if ((qvp = ump-um_quotas[type]) == NULLVP) {
 		mutex_exit(dqlock);
-		vnfree(mvp);
 		return (0);
 	}
 	ump-umq1_qflags[type] |= QTF_CLOSING;
@@ -445,31 +435,24 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 	 * Search vnodes associated with this mount point,
 	 * deleting any references to quota file being closed.
 	 */
-	mutex_enter(mntvnode_lock);
-again:
-	for (vp = TAILQ_FIRST(mp-mnt_vnodelist); vp; vp = vunmark(mvp)) {
-		vmark(mvp, vp);
-		mutex_enter(vp-v_interlock);
-		if (VTOI(vp) == NULL || vp-v_mount != mp || vismarker(vp) ||
-		vp-v_type == VNON ||
-		(vp-v_iflag  (VI_XLOCK | VI_CLEAN)) != 0) {
-			mutex_exit(vp-v_interlock);
+	vfs_vnode_iterator_init(mp, marker);
+	while (vfs_vnode_iterator_next(marker, vp)) {
+		error = vn_lock(vp, LK_EXCLUSIVE);
+		if (error) {
+			vrele(vp);
 			continue;
 		}
-		mutex_exit(mntvnode_lock);
-		if (vget(vp, LK_EXCLUSIVE)) {
-			mutex_enter(mntvnode_lock);
-			(void)vunmark(mvp);
-			goto again;
-		}
 		ip = VTOI(vp);
+		if (ip == NULL || vp-v_type == VNON) {
+			vput(vp);
+			continue;
+		}
 		dq = ip-i_dquot[type];
 		ip-i_dquot[type] = NODQUOT;
 		dqrele(vp, dq);
 		vput(vp);
-		mutex_enter(mntvnode_lock);
 	}
-	mutex_exit(mntvnode_lock);
+	vfs_vnode_iterator_destroy(marker);
 #ifdef DIAGNOSTIC
 	dqflush(qvp);
 #endif
@@ -759,7 +742,8 @@ int
 q1sync(struct mount *mp)
 {
 	struct ufsmount *ump = VFSTOUFS(mp);
-	struct vnode *vp, *mvp;
+	struct vnode *vp;
+	struct vnode_iterator *marker;
 	struct dquot *dq;
 	int i, error;
 
@@ -773,32 +757,19 @@ q1sync(struct mount *mp)
 	if (i == MAXQUOTAS)
 		return (0);
 
-	/* Allocate a marker 

CVS commit: src/sys/ufs/ufs

2014-03-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Mar 16 01:21:35 UTC 2014

Modified Files:
src/sys/ufs/ufs: ufs_quota2.c

Log Message:
Shut up -Wuninitialized on sh3 with gcc 4.8


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/ufs/ufs_quota2.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota2.c
diff -u src/sys/ufs/ufs/ufs_quota2.c:1.37 src/sys/ufs/ufs/ufs_quota2.c:1.38
--- src/sys/ufs/ufs/ufs_quota2.c:1.37	Wed Jan 29 20:13:04 2014
+++ src/sys/ufs/ufs/ufs_quota2.c	Sun Mar 16 01:21:35 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.37 2014/01/29 20:13:04 bouyer Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.38 2014/03/16 01:21:35 uwe Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota2.c,v 1.37 2014/01/29 20:13:04 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota2.c,v 1.38 2014/03/16 01:21:35 uwe Exp $);
 
 #include sys/buf.h
 #include sys/param.h
@@ -1280,7 +1280,7 @@ quota2_handle_cmd_cursorget(struct ufsmo
 	struct q2cursor_state state;
 	struct quota2_entry default_q2e;
 	int idtype;
-	int quota2_hash_size;
+	int quota2_hash_size = 0; /* XXX: sh3 gcc 4.8 -Wuninitialized */
 
 	/*
 	 * Convert and validate the cursor.



CVS commit: src/sys/ufs/ufs

2013-11-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Nov 16 12:49:29 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_quota.c

Log Message:
move variable use and initialisation inside the #ifdef / block that uses it.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/ufs/ufs/ufs_quota.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.113 src/sys/ufs/ufs/ufs_quota.c:1.114
--- src/sys/ufs/ufs/ufs_quota.c:1.113	Fri Oct 18 19:55:37 2013
+++ src/sys/ufs/ufs/ufs_quota.c	Sat Nov 16 12:49:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.113 2013/10/18 19:55:37 christos Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.114 2013/11/16 12:49:29 mrg Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.113 2013/10/18 19:55:37 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.114 2013/11/16 12:49:29 mrg Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_quota.h
@@ -474,19 +474,9 @@ quota_handle_cmd_cursorget(struct mount 
 struct quotactl_args *args)
 {
 	struct ufsmount *ump = VFSTOUFS(mp);
-	struct quotakcursor *cursor;
-	struct quotakey *keys;
-	struct quotaval *vals;
-	unsigned maxnum;
-	unsigned *ret;
 	int error;
 
 	KASSERT(args-qc_op == QUOTACTL_CURSORGET);
-	cursor = args-u.cursorget.qc_cursor;
-	keys = args-u.cursorget.qc_keys;
-	vals = args-u.cursorget.qc_vals;
-	maxnum = args-u.cursorget.qc_maxnum;
-	ret = args-u.cursorget.qc_ret;
 
 	if ((ump-um_flags  UFS_QUOTA2) == 0)
 		return EOPNOTSUPP;
@@ -498,6 +488,12 @@ quota_handle_cmd_cursorget(struct mount 
 		
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
+		struct quotakcursor *cursor = args-u.cursorget.qc_cursor;
+		struct quotakey *keys = args-u.cursorget.qc_keys;
+		struct quotaval *vals = args-u.cursorget.qc_vals;
+		unsigned maxnum = args-u.cursorget.qc_maxnum;
+		unsigned *ret = args-u.cursorget.qc_ret;
+
 		error = quota2_handle_cmd_cursorget(ump, cursor, keys, vals,
 		maxnum, ret);
 	} else
@@ -514,11 +510,9 @@ quota_handle_cmd_cursoropen(struct mount
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
 #endif
-	struct quotakcursor *cursor;
 	int error;
 
 	KASSERT(args-qc_op == QUOTACTL_CURSOROPEN);
-	cursor = args-u.cursoropen.qc_cursor;
 
 	error = kauth_authorize_system(l-l_cred, KAUTH_SYSTEM_FS_QUOTA,
 	KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, NULL, NULL);
@@ -527,6 +521,8 @@ quota_handle_cmd_cursoropen(struct mount
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
+		struct quotakcursor *cursor = args-u.cursoropen.qc_cursor;
+
 		error = quota2_handle_cmd_cursoropen(ump, cursor);
 	} else
 #endif
@@ -542,11 +538,9 @@ quota_handle_cmd_cursorclose(struct moun
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
 #endif
-	struct quotakcursor *cursor;
 	int error;
 
 	KASSERT(args-qc_op == QUOTACTL_CURSORCLOSE);
-	cursor = args-u.cursorclose.qc_cursor;
 
 	error = kauth_authorize_system(l-l_cred, KAUTH_SYSTEM_FS_QUOTA,
 	KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, NULL, NULL);
@@ -555,6 +549,8 @@ quota_handle_cmd_cursorclose(struct moun
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
+		struct quotakcursor *cursor = args-u.cursorclose.qc_cursor;
+
 		error = quota2_handle_cmd_cursorclose(ump, cursor);
 	} else
 #endif
@@ -570,16 +566,16 @@ quota_handle_cmd_cursorskipidtype(struct
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
 #endif
-	struct quotakcursor *cursor;
-	int idtype;
 	int error;
 
 	KASSERT(args-qc_op == QUOTACTL_CURSORSKIPIDTYPE);
-	cursor = args-u.cursorskipidtype.qc_cursor;
-	idtype = args-u.cursorskipidtype.qc_idtype;
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
+		struct quotakcursor *cursor =
+			 args-u.cursorskipidtype.qc_cursor;
+		int idtype = args-u.cursorskipidtype.qc_idtype;
+
 		error = quota2_handle_cmd_cursorskipidtype(ump, cursor, idtype);
 	} else
 #endif
@@ -595,16 +591,15 @@ quota_handle_cmd_cursoratend(struct moun
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
 #endif
-	struct quotakcursor *cursor;
-	int *ret;
 	int error;
 
 	KASSERT(args-qc_op == QUOTACTL_CURSORATEND);
-	cursor = args-u.cursoratend.qc_cursor;
-	ret = args-u.cursoratend.qc_ret;
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
+		struct quotakcursor *cursor = args-u.cursoratend.qc_cursor;
+		unsigned *ret = args-u.cursoratend.qc_ret;
+
 		error = quota2_handle_cmd_cursoratend(ump, cursor, ret);
 	} else
 #endif
@@ -620,14 +615,14 @@ quota_handle_cmd_cursorrewind(struct mou
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
 #endif
-	struct quotakcursor *cursor;
 	int error;
 
 	KASSERT(args-qc_op == QUOTACTL_CURSORREWIND);
-	cursor = args-u.cursorrewind.qc_cursor;
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
+		struct quotakcursor *cursor = args-u.cursorrewind.qc_cursor;
+
 		error = 

CVS commit: src/sys/ufs/ufs

2013-11-16 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Nov 16 17:04:53 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_quota.c

Log Message:
tidy the QUOTA2 blocks a bit more


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/ufs/ufs/ufs_quota.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.114 src/sys/ufs/ufs/ufs_quota.c:1.115
--- src/sys/ufs/ufs/ufs_quota.c:1.114	Sat Nov 16 12:49:29 2013
+++ src/sys/ufs/ufs/ufs_quota.c	Sat Nov 16 17:04:53 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.114 2013/11/16 12:49:29 mrg Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.115 2013/11/16 17:04:53 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.114 2013/11/16 12:49:29 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.115 2013/11/16 17:04:53 dholland Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_quota.h
@@ -509,6 +509,7 @@ quota_handle_cmd_cursoropen(struct mount
 {
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
+	struct quotakcursor *cursor = args-u.cursoropen.qc_cursor;
 #endif
 	int error;
 
@@ -521,8 +522,6 @@ quota_handle_cmd_cursoropen(struct mount
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
-		struct quotakcursor *cursor = args-u.cursoropen.qc_cursor;
-
 		error = quota2_handle_cmd_cursoropen(ump, cursor);
 	} else
 #endif
@@ -537,6 +536,7 @@ quota_handle_cmd_cursorclose(struct moun
 {
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
+	struct quotakcursor *cursor = args-u.cursorclose.qc_cursor;
 #endif
 	int error;
 
@@ -549,8 +549,6 @@ quota_handle_cmd_cursorclose(struct moun
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
-		struct quotakcursor *cursor = args-u.cursorclose.qc_cursor;
-
 		error = quota2_handle_cmd_cursorclose(ump, cursor);
 	} else
 #endif
@@ -565,6 +563,8 @@ quota_handle_cmd_cursorskipidtype(struct
 {
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
+	struct quotakcursor *cursor = args-u.cursorskipidtype.qc_cursor;
+	int idtype = args-u.cursorskipidtype.qc_idtype;
 #endif
 	int error;
 
@@ -572,10 +572,6 @@ quota_handle_cmd_cursorskipidtype(struct
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
-		struct quotakcursor *cursor =
-			 args-u.cursorskipidtype.qc_cursor;
-		int idtype = args-u.cursorskipidtype.qc_idtype;
-
 		error = quota2_handle_cmd_cursorskipidtype(ump, cursor, idtype);
 	} else
 #endif
@@ -590,6 +586,8 @@ quota_handle_cmd_cursoratend(struct moun
 {
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
+	struct quotakcursor *cursor = args-u.cursoratend.qc_cursor;
+	unsigned *ret = args-u.cursoratend.qc_ret;
 #endif
 	int error;
 
@@ -597,9 +595,6 @@ quota_handle_cmd_cursoratend(struct moun
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
-		struct quotakcursor *cursor = args-u.cursoratend.qc_cursor;
-		unsigned *ret = args-u.cursoratend.qc_ret;
-
 		error = quota2_handle_cmd_cursoratend(ump, cursor, ret);
 	} else
 #endif
@@ -614,6 +609,7 @@ quota_handle_cmd_cursorrewind(struct mou
 {
 #ifdef QUOTA2
 	struct ufsmount *ump = VFSTOUFS(mp);
+	struct quotakcursor *cursor = args-u.cursorrewind.qc_cursor;
 #endif
 	int error;
 
@@ -621,8 +617,6 @@ quota_handle_cmd_cursorrewind(struct mou
 
 #ifdef QUOTA2
 	if (ump-um_flags  UFS_QUOTA2) {
-		struct quotakcursor *cursor = args-u.cursorrewind.qc_cursor;
-
 		error = quota2_handle_cmd_cursorrewind(ump, cursor);
 	} else
 #endif



CVS commit: src/sys/ufs/ufs

2013-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 10 18:28:08 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_wapbl.h

Log Message:
__USE a variable for the non-wapbl case


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ufs/ufs_wapbl.h

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

Modified files:

Index: src/sys/ufs/ufs/ufs_wapbl.h
diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.7 src/sys/ufs/ufs/ufs_wapbl.h:1.8
--- src/sys/ufs/ufs/ufs_wapbl.h:1.7	Mon Sep 19 07:18:01 2011
+++ src/sys/ufs/ufs/ufs_wapbl.h	Sun Nov 10 13:28:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_wapbl.h,v 1.7 2011/09/19 11:18:01 gdt Exp $	*/
+/*	$NetBSD: ufs_wapbl.h,v 1.8 2013/11/10 18:28:08 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -163,7 +163,7 @@ ufs_wapbl_end2(struct mount *mp, struct 
 	if (mp-mnt_wapbl) wapbl_register_deallocation(mp-mnt_wapbl, blk, len)
 
 #else /* ! WAPBL */
-#define	UFS_WAPBL_BEGIN(mp) 0
+#define	UFS_WAPBL_BEGIN(mp) (__USE(mp), 0)
 #define	UFS_WAPBL_BEGIN1(mp, v1) 0
 #define	UFS_WAPBL_END(mp)	do { } while (0)
 #define	UFS_WAPBL_END1(mp, v1)



CVS commit: src/sys/ufs/ufs

2013-11-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov  4 19:58:02 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c ufs_rename.c

Log Message:
Add 2 XXX: gcc initializations


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/ufs/ufs/ufs_lookup.c
cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ufs/ufs_rename.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.127 src/sys/ufs/ufs/ufs_lookup.c:1.128
--- src/sys/ufs/ufs/ufs_lookup.c:1.127	Fri Oct 25 12:34:20 2013
+++ src/sys/ufs/ufs/ufs_lookup.c	Mon Nov  4 14:58:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.127 2013/10/25 16:34:20 martin Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.128 2013/11/04 19:58:02 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.127 2013/10/25 16:34:20 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.128 2013/11/04 19:58:02 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -1403,7 +1403,7 @@ ufs_parentcheck(struct vnode *upper, str
 		int *found_ret, struct vnode **upperchild_ret)
 {
 	const int needswap = UFS_MPNEEDSWAP(VTOI(lower)-i_ump);
-	ino_t upper_ino, found_ino;
+	ino_t upper_ino, found_ino = 0;	/* XXX: gcc */
 	struct vnode *current, *next;
 	int error;
 

Index: src/sys/ufs/ufs/ufs_rename.c
diff -u src/sys/ufs/ufs/ufs_rename.c:1.8 src/sys/ufs/ufs/ufs_rename.c:1.9
--- src/sys/ufs/ufs/ufs_rename.c:1.8	Wed Jun 19 13:51:26 2013
+++ src/sys/ufs/ufs/ufs_rename.c	Mon Nov  4 14:58:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_rename.c,v 1.8 2013/06/19 17:51:26 dholland Exp $	*/
+/*	$NetBSD: ufs_rename.c,v 1.9 2013/11/04 19:58:02 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_rename.c,v 1.8 2013/06/19 17:51:26 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_rename.c,v 1.9 2013/11/04 19:58:02 christos Exp $);
 
 #include sys/param.h
 #include sys/buf.h
@@ -930,7 +930,7 @@ ufs_gro_genealogy(struct mount *mp, kaut
 struct vnode **intermediate_node_ret)
 {
 	struct vnode *vp, *dvp;
-	ino_t dotdot_ino;
+	ino_t dotdot_ino = 0;	/* XXX: gcc */
 	int error;
 
 	KASSERT(mp != NULL);



CVS commit: src/sys/ufs/ufs

2013-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 25 16:34:20 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Mark a diagnostic-only variable


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.126 src/sys/ufs/ufs/ufs_lookup.c:1.127
--- src/sys/ufs/ufs/ufs_lookup.c:1.126	Sun Oct 20 00:29:10 2013
+++ src/sys/ufs/ufs/ufs_lookup.c	Fri Oct 25 16:34:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.126 2013/10/20 00:29:10 htodd Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.127 2013/10/25 16:34:20 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.126 2013/10/20 00:29:10 htodd Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.127 2013/10/25 16:34:20 martin Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -1480,7 +1480,7 @@ int
 ufs_blkatoff(struct vnode *vp, off_t offset, char **res, struct buf **bpp,
 bool modify)
 {
-	struct inode *ip;
+	struct inode *ip __diagused;
 	struct buf *bp;
 	daddr_t lbn;
 	const int dirrablks = ufs_dirrablks;



CVS commit: src/sys/ufs/ufs

2013-10-19 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Oct 19 20:12:18 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_bswap.h

Log Message:
convert ufs_rw{16,32,64}() into real inline functions in all cases,
so that they consume their second arguments properly.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/ufs/ufs_bswap.h

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

Modified files:

Index: src/sys/ufs/ufs/ufs_bswap.h
diff -u src/sys/ufs/ufs/ufs_bswap.h:1.19 src/sys/ufs/ufs/ufs_bswap.h:1.20
--- src/sys/ufs/ufs/ufs_bswap.h:1.19	Mon Oct 19 18:41:17 2009
+++ src/sys/ufs/ufs/ufs_bswap.h	Sat Oct 19 20:12:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_bswap.h,v 1.19 2009/10/19 18:41:17 bouyer Exp $	*/
+/*	$NetBSD: ufs_bswap.h,v 1.20 2013/10/19 20:12:18 mrg Exp $	*/
 
 /*
  * Copyright (c) 1998 Manuel Bouyer.
@@ -65,9 +65,23 @@ ufs_rw64(uint64_t a, int ns)
 	return ((ns) ? bswap64(a) : (a));
 }
 #else
-#define ufs_rw16(a, ns) ((uint16_t)(a))
-#define ufs_rw32(a, ns) ((uint32_t)(a))
-#define ufs_rw64(a, ns) ((uint64_t)(a))
+static inline u_int16_t
+ufs_rw16(uint16_t a, int ns)
+{
+	return a;
+}
+
+static inline u_int32_t
+ufs_rw32(uint32_t a, int ns)
+{
+	return a;
+}
+
+static inline u_int64_t
+ufs_rw64(uint64_t a, int ns)
+{
+	return a;
+}
 #endif
 
 #define ufs_add16(a, b, ns) \



CVS commit: src/sys/ufs/ufs

2013-10-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 18 19:55:38 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_quota.c

Log Message:
move code inside ifdef


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/ufs/ufs/ufs_quota.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.112 src/sys/ufs/ufs/ufs_quota.c:1.113
--- src/sys/ufs/ufs/ufs_quota.c:1.112	Sun Sep  9 00:27:49 2012
+++ src/sys/ufs/ufs/ufs_quota.c	Fri Oct 18 15:55:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.112 2012/09/09 04:27:49 manu Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.113 2013/10/18 19:55:37 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.112 2012/09/09 04:27:49 manu Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.113 2013/10/18 19:55:37 christos Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_quota.h
@@ -641,13 +641,9 @@ quota_handle_cmd_quotaon(struct mount *m
 struct quotactl_args *args)
 {
 	struct ufsmount *ump = VFSTOUFS(mp);
-	int idtype;
-	const char *qfile;
 	int error;
 
 	KASSERT(args-qc_op == QUOTACTL_QUOTAON);
-	idtype = args-u.quotaon.qc_idtype;
-	qfile = args-u.quotaon.qc_quotafile;
 
 	if ((ump-um_flags  UFS_QUOTA2) != 0)
 		return EBUSY;
@@ -658,6 +654,8 @@ quota_handle_cmd_quotaon(struct mount *m
 		return error;
 	}
 #ifdef QUOTA
+	int idtype = args-u.quotaon.qc_idtype;
+	const char *qfile = args-u.quotaon.qc_quotafile;
 	error = quota1_handle_cmd_quotaon(l, ump, idtype, qfile);
 #else
 	error = EOPNOTSUPP;
@@ -671,11 +669,9 @@ quota_handle_cmd_quotaoff(struct mount *
 struct quotactl_args *args)
 {
 	struct ufsmount *ump = VFSTOUFS(mp);
-	int idtype;
 	int error;
 
 	KASSERT(args-qc_op == QUOTACTL_QUOTAOFF);
-	idtype = args-u.quotaoff.qc_idtype;
 
 	if ((ump-um_flags  UFS_QUOTA2) != 0)
 		return EOPNOTSUPP;
@@ -686,6 +682,7 @@ quota_handle_cmd_quotaoff(struct mount *
 		return error;
 	}
 #ifdef QUOTA
+	int idtype = args-u.quotaoff.qc_idtype;
 	error = quota1_handle_cmd_quotaoff(l, ump, idtype);
 #else
 	error = EOPNOTSUPP;



CVS commit: src/sys/ufs/ufs

2013-09-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 15 15:08:09 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Remove unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.124 src/sys/ufs/ufs/ufs_lookup.c:1.125
--- src/sys/ufs/ufs/ufs_lookup.c:1.124	Sun Jun 16 13:33:30 2013
+++ src/sys/ufs/ufs/ufs_lookup.c	Sun Sep 15 15:08:09 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.124 2013/06/16 13:33:30 hannken Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.125 2013/09/15 15:08:09 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.124 2013/06/16 13:33:30 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.125 2013/09/15 15:08:09 martin Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -813,7 +813,6 @@ ufs_direnter(struct vnode *dvp, const st
 struct componentname *cnp, struct buf *newdirbp)
 {
 	kauth_cred_t cr;
-	struct lwp *l;
 	int newentrysize;
 	struct inode *dp;
 	struct buf *bp;
@@ -830,7 +829,6 @@ ufs_direnter(struct vnode *dvp, const st
 
 	error = 0;
 	cr = cnp-cn_cred;
-	l = curlwp;
 
 	dp = VTOI(dvp);
 	newentrysize = UFS_DIRSIZ(0, dirp, 0);



CVS commit: src/sys/ufs/ufs

2013-09-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 15 15:32:19 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
Remove unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.217 src/sys/ufs/ufs/ufs_vnops.c:1.218
--- src/sys/ufs/ufs/ufs_vnops.c:1.217	Sun Aug 11 04:36:17 2013
+++ src/sys/ufs/ufs/ufs_vnops.c	Sun Sep 15 15:32:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.217 2013/08/11 04:36:17 dholland Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.218 2013/09/15 15:32:18 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.217 2013/08/11 04:36:17 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.218 2013/09/15 15:32:18 martin Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -280,10 +280,8 @@ ufs_close(void *v)
 		kauth_cred_t	a_cred;
 	} */ *ap = v;
 	struct vnode	*vp;
-	struct inode	*ip;
 
 	vp = ap-a_vp;
-	ip = VTOI(vp);
 	fstrans_start(vp-v_mount, FSTRANS_SHARED);
 	if (vp-v_usecount  1)
 		UFS_ITIMES(vp, NULL, NULL, NULL);
@@ -1624,10 +1622,8 @@ ufsspec_close(void *v)
 		kauth_cred_t	a_cred;
 	} */ *ap = v;
 	struct vnode	*vp;
-	struct inode	*ip;
 
 	vp = ap-a_vp;
-	ip = VTOI(vp);
 	if (vp-v_usecount  1)
 		UFS_ITIMES(vp, NULL, NULL, NULL);
 	return (VOCALL (spec_vnodeop_p, VOFFSET(vop_close), ap));
@@ -1687,10 +1683,8 @@ ufsfifo_close(void *v)
 		kauth_cred_t	a_cred;
 	} */ *ap = v;
 	struct vnode	*vp;
-	struct inode	*ip;
 
 	vp = ap-a_vp;
-	ip = VTOI(vp);
 	if (ap-a_vp-v_usecount  1)
 		UFS_ITIMES(vp, NULL, NULL, NULL);
 	return (VOCALL (fifo_vnodeop_p, VOFFSET(vop_close), ap));



CVS commit: src/sys/ufs/ufs

2013-06-15 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jun 16 00:13:58 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
Add a comment about a matched pair of off-by-one tests that make the
maximum size of short symlinks one byte less than one would think it
should be. Caution against changing it; that would break compatibility
with existing disk images. Behavior noticed by qjsgkem on freenode.

If my analysis is wrong, please correct...


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.215 src/sys/ufs/ufs/ufs_vnops.c:1.216
--- src/sys/ufs/ufs/ufs_vnops.c:1.215	Sun Jun  9 18:54:05 2013
+++ src/sys/ufs/ufs/ufs_vnops.c	Sun Jun 16 00:13:58 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.215 2013/06/09 18:54:05 christos Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.216 2013/06/16 00:13:58 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.215 2013/06/09 18:54:05 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.216 2013/06/16 00:13:58 dholland Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -1267,6 +1267,13 @@ ufs_symlink(void *v)
 	vp = *vpp;
 	len = strlen(ap-a_target);
 	ip = VTOI(vp);
+	/*
+	 * This test is off by one. um_maxsymlinklen contains the
+	 * number of bytes available, and we aren't storing a \0, so
+	 * the test should properly be =. However, it cannot be
+	 * changed as this would break compatibility with existing fs
+	 * images -- see the way ufs_readlink() works.
+	 */
 	if (len  ip-i_ump-um_maxsymlinklen) {
 		memcpy((char *)SHORTLINK(ip), ap-a_target, len);
 		ip-i_size = len;
@@ -1453,6 +1460,12 @@ ufs_readlink(void *v)
 	struct ufsmount	*ump = VFSTOUFS(vp-v_mount);
 	int		isize;
 
+	/*
+	 * The test against um_maxsymlinklen is off by one; it should
+	 * theoretically be =, not . However, it cannot be changed
+	 * as that would break compatibility with existing fs images.
+	 */
+
 	isize = ip-i_size;
 	if (isize  ump-um_maxsymlinklen ||
 	(ump-um_maxsymlinklen == 0  DIP(ip, blocks) == 0)) {



CVS commit: src/sys/ufs/ufs

2013-06-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun  9 18:54:05 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
the speed limit is 80


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.214 src/sys/ufs/ufs/ufs_vnops.c:1.215
--- src/sys/ufs/ufs/ufs_vnops.c:1.214	Sun Jun  9 13:57:09 2013
+++ src/sys/ufs/ufs/ufs_vnops.c	Sun Jun  9 14:54:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.214 2013/06/09 17:57:09 dholland Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.215 2013/06/09 18:54:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.214 2013/06/09 17:57:09 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.215 2013/06/09 18:54:05 christos Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -503,7 +503,8 @@ ufs_setattr(void *v)
 			action |= KAUTH_VNODE_HAS_SYSFLAGS;
 		}
 
-		if ((vap-va_flags  SF_SETTABLE) != (ip-i_flags  SF_SETTABLE)) {
+		if ((vap-va_flags  SF_SETTABLE) !=
+		(ip-i_flags  SF_SETTABLE)) {
 			action |= KAUTH_VNODE_WRITE_SYSFLAGS;
 			changing_sysflags = true;
 		}



CVS commit: src/sys/ufs/ufs

2013-06-08 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jun  9 00:10:55 UTC 2013

Modified Files:
src/sys/ufs/ufs: dinode.h

Log Message:
Get rid of this copy of the accessor macro for di_u.inumber; it breaks
the build now.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ufs/dinode.h

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

Modified files:

Index: src/sys/ufs/ufs/dinode.h
diff -u src/sys/ufs/ufs/dinode.h:1.22 src/sys/ufs/ufs/dinode.h:1.23
--- src/sys/ufs/ufs/dinode.h:1.22	Tue Jan 22 09:39:18 2013
+++ src/sys/ufs/ufs/dinode.h	Sun Jun  9 00:10:55 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp $	*/
+/*	$NetBSD: dinode.h,v 1.23 2013/06/09 00:10:55 dholland Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -137,7 +137,6 @@ struct ufs2_dinode {
  * dev_t value. Short symbolic links place their path in the
  * di_db area.
  */
-#define	di_inumber	di_u.inumber
 #define	di_ogid		di_u.oldids[1]
 #define	di_ouid		di_u.oldids[0]
 #define	di_rdev		di_db[0]



CVS commit: src/sys/ufs/ufs

2013-06-07 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jun  7 23:37:53 UTC 2013

Modified Files:
src/sys/ufs/ufs: dir.h

Log Message:
typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/ufs/dir.h

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

Modified files:

Index: src/sys/ufs/ufs/dir.h
diff -u src/sys/ufs/ufs/dir.h:1.21 src/sys/ufs/ufs/dir.h:1.22
--- src/sys/ufs/ufs/dir.h:1.21	Wed Jul 22 04:49:19 2009
+++ src/sys/ufs/ufs/dir.h	Fri Jun  7 23:37:53 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp $	*/
+/*	$NetBSD: dir.h,v 1.22 2013/06/07 23:37:53 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -145,7 +145,7 @@ struct dirtemplate {
 };
 
 /*
- * This is the old format of directories, sanz type element.
+ * This is the old format of directories, sans type element.
  */
 struct odirtemplate {
 	u_int32_t	dot_ino;



CVS commit: src/sys/ufs/ufs

2013-06-07 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Sat Jun  8 05:47:02 UTC 2013

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
fix clearing of system-flags (schg, sappnd). clearing system flags is possible 
again
at securelevel  1.
reviewed by christos@


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/ufs/ufs/ufs_vnops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.212 src/sys/ufs/ufs/ufs_vnops.c:1.213
--- src/sys/ufs/ufs/ufs_vnops.c:1.212	Mon Mar 18 19:35:48 2013
+++ src/sys/ufs/ufs/ufs_vnops.c	Sat Jun  8 05:47:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.212 2013/03/18 19:35:48 plunky Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.212 2013/03/18 19:35:48 plunky Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -503,7 +503,7 @@ ufs_setattr(void *v)
 			action |= KAUTH_VNODE_HAS_SYSFLAGS;
 		}
 
-		if ((vap-va_flags  UF_SETTABLE) != vap-va_flags) {
+		if ((vap-va_flags  SF_SETTABLE) != (ip-i_flags  SF_SETTABLE)) {
 			action |= KAUTH_VNODE_WRITE_SYSFLAGS;
 			changing_sysflags = true;
 		}



CVS commit: src/sys/ufs/ufs

2012-12-08 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat Dec  8 13:42:36 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_extattr.c

Log Message:
Remove always-true condition and note that the current code is suboptimal.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ufs/ufs_extattr.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extattr.c
diff -u src/sys/ufs/ufs/ufs_extattr.c:1.40 src/sys/ufs/ufs/ufs_extattr.c:1.41
--- src/sys/ufs/ufs/ufs_extattr.c:1.40	Mon Sep 10 14:00:15 2012
+++ src/sys/ufs/ufs/ufs_extattr.c	Sat Dec  8 13:42:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extattr.c,v 1.40 2012/09/10 14:00:15 manu Exp $	*/
+/*	$NetBSD: ufs_extattr.c,v 1.41 2012/12/08 13:42:36 manu Exp $	*/
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.40 2012/09/10 14:00:15 manu Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.41 2012/12/08 13:42:36 manu Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -251,15 +251,12 @@ ufs_extattr_autocreate_attr(struct vnode
 	}
 
 	/*
-	 * When setting attribute on the root vnode, we get it 
-	 * already locked, and vn_open/namei/VFS_ROOT will try to
-	 * look it, causing a panic. Unlock it first.
+	 * XXX unlock/lock should only be done when setting extattr
+	 * on backing store or one of its parent directory 
+	 * including root, but we always do it for now.
 	 */ 
-	if (vp-v_vflag  VV_ROOT) {
-		KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
-		VOP_UNLOCK(vp);
-	}
-	KASSERT(VOP_ISLOCKED(vp) == 0);
+	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
+	VOP_UNLOCK(vp);
 
 	pb = pathbuf_create(path);
 	NDINIT(nd, CREATE, LOCKPARENT, pb);
@@ -267,12 +264,10 @@ ufs_extattr_autocreate_attr(struct vnode
 	error = vn_open(nd, O_CREAT|O_RDWR, 0600);
 
 	/*
-	 * Reacquire the lock on the vnode if it was root.
+	 * Reacquire the lock on the vnode
 	 */
 	KASSERT(VOP_ISLOCKED(vp) == 0);
-	if (vp-v_vflag  VV_ROOT)
-		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 
 	if (error != 0) {
 		pathbuf_destroy(pb);



CVS commit: src/sys/ufs/ufs

2012-11-18 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Nov 19 00:25:29 UTC 2012

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
Move i_e2fs_rdev define to be adjacent to the field it aliases.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/ufs/ufs/inode.h

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

Modified files:

Index: src/sys/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.62 src/sys/ufs/ufs/inode.h:1.63
--- src/sys/ufs/ufs/inode.h:1.62	Mon Jun  4 22:01:07 2012
+++ src/sys/ufs/ufs/inode.h	Mon Nov 19 00:25:29 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.62 2012/06/04 22:01:07 riastradh Exp $	*/
+/*	$NetBSD: inode.h,v 1.63 2012/11/19 00:25:29 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -221,13 +221,13 @@ struct inode {
 #define	i_e2fs_nblock		i_din.e2fs_din-e2di_nblock
 #define	i_e2fs_flags		i_din.e2fs_din-e2di_flags
 #define	i_e2fs_blocks		i_din.e2fs_din-e2di_blocks
+#define	i_e2fs_rdev		i_din.e2fs_din-e2di_rdev
 #define	i_e2fs_gen		i_din.e2fs_din-e2di_gen
 #define	i_e2fs_facl		i_din.e2fs_din-e2di_facl
 #define	i_e2fs_dacl		i_din.e2fs_din-e2di_dacl
 #define	i_e2fs_faddr		i_din.e2fs_din-e2di_faddr
 #define	i_e2fs_nfrag		i_din.e2fs_din-e2di_nfrag
 #define	i_e2fs_fsize		i_din.e2fs_din-e2di_fsize
-#define	i_e2fs_rdev		i_din.e2fs_din-e2di_rdev
 #define	i_e2fs_uid_high		i_din.e2fs_din-e2di_uid_high
 #define	i_e2fs_gid_high		i_din.e2fs_din-e2di_gid_high
 



CVS commit: src/sys/ufs/ufs

2012-10-14 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Oct 14 23:57:32 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Add an XXX comment about a broken error case in ufs_dirremove.
(this was in one of my old rename patches)


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.117 src/sys/ufs/ufs/ufs_lookup.c:1.118
--- src/sys/ufs/ufs/ufs_lookup.c:1.117	Sun Jul 22 00:53:22 2012
+++ src/sys/ufs/ufs/ufs_lookup.c	Sun Oct 14 23:57:32 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.117 2012/07/22 00:53:22 rmind Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.118 2012/10/14 23:57:32 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.117 2012/07/22 00:53:22 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.118 2012/10/14 23:57:32 dholland Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -1115,6 +1115,13 @@ out:
 		ip-i_flag |= IN_CHANGE;
 		UFS_WAPBL_UPDATE(ITOV(ip), NULL, NULL, 0);
 	}
+	/*
+	 * XXX did it ever occur to anyone that it might be a good
+	 * idea to restore ip-i_nlink if this fails? Or something?
+	 * Currently on error return from this function the state of
+	 * ip-i_nlink depends on what happened, and callers
+	 * definitely do not take this into account.
+	 */
 	error = VOP_BWRITE(bp-b_vp, bp);
 	dp-i_flag |= IN_CHANGE | IN_UPDATE;
 	/*



CVS commit: src/sys/ufs/ufs

2012-09-27 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Sep 27 07:47:57 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_quota2.c

Log Message:
Fix quota2 list corruption issue when defaultquotas are 0 (deny any file
and block allocation).

When quota2_check() is called with an uid not yet in the list,
getinoquota2() will call quota2_q2ealloc() to allocate a new entry for this
uid. quota2_q2ealloc() will remove an entry from the free list and
put it at the head of the corresponding hash list, and flush the block
containing the header if it's not the one also containing the allocated entry.
quota2_q2ealloc() then return the alocated entry and corresponding block
to caller (getinoquota2() here), which returns it to quota2_check().
quota2_check() then checks if the allocation can succeed, and returns and
error if not and calls brelse() on the buffer (because from his POW no
change was made to the entry), effectively discarding changes
to the entry that may have been made by quota2_q2ealloc().
Fix by always bwrite()ing the entry in quota2_q2ealloc(), and re-reading
the entry in caller.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/ufs/ufs/ufs_quota2.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota2.c
diff -u src/sys/ufs/ufs/ufs_quota2.c:1.34 src/sys/ufs/ufs/ufs_quota2.c:1.35
--- src/sys/ufs/ufs/ufs_quota2.c:1.34	Mon Feb 13 06:23:41 2012
+++ src/sys/ufs/ufs/ufs_quota2.c	Thu Sep 27 07:47:56 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.34 2012/02/13 06:23:41 dholland Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.35 2012/09/27 07:47:56 bouyer Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota2.c,v 1.34 2012/02/13 06:23:41 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota2.c,v 1.35 2012/09/27 07:47:56 bouyer Exp $);
 
 #include sys/buf.h
 #include sys/param.h
@@ -290,8 +290,7 @@ quota2_umount(struct mount *mp, int flag
 }
 
 static int 
-quota2_q2ealloc(struct ufsmount *ump, int type, uid_t uid, struct dquot *dq,
-struct buf **bpp, struct quota2_entry **q2ep)
+quota2_q2ealloc(struct ufsmount *ump, int type, uid_t uid, struct dquot *dq)
 {
 	int error, error2;
 	struct buf *hbp, *bp;
@@ -361,8 +360,7 @@ quota2_q2ealloc(struct ufsmount *ump, in
 	if (hbp != bp) {
 		bwrite(hbp);
 	}
-	*q2ep = q2e;
-	*bpp = bp;
+	bwrite(bp);
 	return 0;
 }
 
@@ -416,18 +414,17 @@ getinoquota2(struct inode *ip, bool allo
 			}
 			/* need to alloc a new on-disk quot */
 			mutex_enter(dqlock);
-			error = quota2_q2ealloc(ump, i, ino_ids[i], dq,
-			bpp[i], q2ep[i]);
+			error = quota2_q2ealloc(ump, i, ino_ids[i], dq);
 			mutex_exit(dqlock);
 			if (error)
 return error;
-		} else {
-			error = getq2e(ump, i, dq-dq2_lblkno,
-			dq-dq2_blkoff, bpp[i], q2ep[i],
-			modify ? B_MODIFY : 0);
-			if (error)
-return error;
 		}
+		KASSERT(dq-dq2_lblkno != 0 || dq-dq2_blkoff != 0);
+		error = getq2e(ump, i, dq-dq2_lblkno,
+		dq-dq2_blkoff, bpp[i], q2ep[i],
+		modify ? B_MODIFY : 0);
+		if (error)
+			return error;
 	}
 	return 0;
 }
@@ -622,13 +619,14 @@ quota2_handle_cmd_put(struct ufsmount *u
 	if (dq-dq2_lblkno == 0  dq-dq2_blkoff == 0) {
 		/* need to alloc a new on-disk quot */
 		mutex_enter(dqlock);
-		error = quota2_q2ealloc(ump, key-qk_idtype, key-qk_id, dq,
-		bp, q2ep);
+		error = quota2_q2ealloc(ump, key-qk_idtype, key-qk_id, dq);
 		mutex_exit(dqlock);
-	} else {
-		error = getq2e(ump, key-qk_idtype, dq-dq2_lblkno,
-		dq-dq2_blkoff, bp, q2ep, B_MODIFY);
+		if (error)
+			goto out_il;
 	}
+	KASSERT(dq-dq2_lblkno != 0 || dq-dq2_blkoff != 0);
+	error = getq2e(ump, key-qk_idtype, dq-dq2_lblkno,
+	dq-dq2_blkoff, bp, q2ep, B_MODIFY);
 	if (error)
 		goto out_il;
 	



CVS commit: src/sys/ufs/ufs

2012-09-10 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Sep 10 14:00:15 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_extattr.c

Log Message:
Fix unmount returnign EBUSY if an attribute was autocreated: we hold
a useless reference that we never gave back


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/ufs/ufs_extattr.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extattr.c
diff -u src/sys/ufs/ufs/ufs_extattr.c:1.39 src/sys/ufs/ufs/ufs_extattr.c:1.40
--- src/sys/ufs/ufs/ufs_extattr.c:1.39	Tue May  1 07:48:25 2012
+++ src/sys/ufs/ufs/ufs_extattr.c	Mon Sep 10 14:00:15 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extattr.c,v 1.39 2012/05/01 07:48:25 manu Exp $	*/
+/*	$NetBSD: ufs_extattr.c,v 1.40 2012/09/10 14:00:15 manu Exp $	*/
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.39 2012/05/01 07:48:25 manu Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.40 2012/09/10 14:00:15 manu Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -309,12 +309,6 @@ ufs_extattr_autocreate_attr(struct vnode
 	}
 
 	/*
-	 * ufs_extattr_enable_with_open increases the vnode reference
-	 * count. Not sure why, but do the same here.
-	 */
-	vref(vp);
-
-	/*
 	 * Now enable attribute. 
 	 */
 	error = ufs_extattr_enable(ump,attrnamespace, attrname, backing_vp, l);



CVS commit: src/sys/ufs/ufs

2012-09-08 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sun Sep  9 04:27:49 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_quota.c

Log Message:
Temporary fix for quotactl authorization: it must use the effective UID
and not the real UID.

Further work is required to move the check to the kauth listener instead
of having it in UFS code.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/ufs/ufs/ufs_quota.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.111 src/sys/ufs/ufs/ufs_quota.c:1.112
--- src/sys/ufs/ufs/ufs_quota.c:1.111	Sun Aug 26 02:32:14 2012
+++ src/sys/ufs/ufs/ufs_quota.c	Sun Sep  9 04:27:49 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.111 2012/08/26 02:32:14 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.112 2012/09/09 04:27:49 manu Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.111 2012/08/26 02:32:14 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.112 2012/09/09 04:27:49 manu Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_quota.h
@@ -335,7 +335,7 @@ quota_handle_cmd_objtypestat(struct moun
 static int
 quota_get_auth(struct mount *mp, struct lwp *l, uid_t id) {
 	/* The user can always query about his own quota. */
-	if (id == kauth_cred_getuid(l-l_cred))
+	if (id == kauth_cred_geteuid(l-l_cred))
 		return 0;
 	return kauth_authorize_system(l-l_cred, KAUTH_SYSTEM_FS_QUOTA,
 	KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, KAUTH_ARG(id), NULL);



CVS commit: src/sys/ufs/ufs

2012-08-25 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 26 02:32:14 UTC 2012

Modified Files:
src/sys/ufs/ufs: quota.h quota1.h ufs_quota.c

Log Message:
Move INITQFNAMES to the right header file.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/ufs/quota.h
cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/ufs/quota1.h
cvs rdiff -u -r1.110 -r1.111 src/sys/ufs/ufs/ufs_quota.c

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

Modified files:

Index: src/sys/ufs/ufs/quota.h
diff -u src/sys/ufs/ufs/quota.h:1.29 src/sys/ufs/ufs/quota.h:1.30
--- src/sys/ufs/ufs/quota.h:1.29	Sun Jan 29 07:16:00 2012
+++ src/sys/ufs/ufs/quota.h	Sun Aug 26 02:32:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.h,v 1.29 2012/01/29 07:16:00 dholland Exp $	*/
+/*	$NetBSD: quota.h,v 1.30 2012/08/26 02:32:14 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -53,6 +53,14 @@
 #define	USRQUOTA	0	/* element used for user quotas */
 #define	GRPQUOTA	1	/* element used for group quotas */
 
+/*
+ * Initializer for the strings corresponding to the quota ID types.
+ * (in quota1 these are also the default names of the quota files)
+ */
+#define INITQFNAMES { \
+	user,		/* USRQUOTA */ \
+	group,	/* GRPQUOTA */ \
+}
 
 #if !defined(HAVE_NBTOOL_CONFIG_H)
 #include sys/quota.h

Index: src/sys/ufs/ufs/quota1.h
diff -u src/sys/ufs/ufs/quota1.h:1.6 src/sys/ufs/ufs/quota1.h:1.7
--- src/sys/ufs/ufs/quota1.h:1.6	Sun Jan 29 06:23:20 2012
+++ src/sys/ufs/ufs/quota1.h	Sun Aug 26 02:32:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota1.h,v 1.6 2012/01/29 06:23:20 dholland Exp $	*/
+/*	$NetBSD: quota1.h,v 1.7 2012/08/26 02:32:14 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -47,14 +47,6 @@
  */
 
 /*
- * Definitions for the default names of the quotas files/quota types.
- */
-#define INITQFNAMES { \
-	user,		/* USRQUOTA */ \
-	group,	/* GRPQUOTA */ \
-}
-
-/*
  * Definitions for disk quotas imposed on the average user
  * (big brother finally hits UNIX).
  *

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.110 src/sys/ufs/ufs/ufs_quota.c:1.111
--- src/sys/ufs/ufs/ufs_quota.c:1.110	Sun Jul 29 08:32:27 2012
+++ src/sys/ufs/ufs/ufs_quota.c	Sun Aug 26 02:32:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.110 2012/07/29 08:32:27 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.111 2012/08/26 02:32:14 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.110 2012/07/29 08:32:27 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.111 2012/08/26 02:32:14 dholland Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_quota.h
@@ -52,7 +52,6 @@ __KERNEL_RCSID(0, $NetBSD: ufs_quota.c,
 
 #include sys/quotactl.h
 #include ufs/ufs/quota.h
-#include ufs/ufs/quota1.h /* for INITQFNAMES; should be moved to quota.h */
 #include ufs/ufs/inode.h
 #include ufs/ufs/ufsmount.h
 #include ufs/ufs/ufs_extern.h



CVS commit: src/sys/ufs/ufs

2012-07-29 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jul 29 08:32:27 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_quota.c

Log Message:
Restore accidentally lost initialization of quotatypes[].
Fixes (null) in the kernel message triggered when you go over quota, and
maybe other things. Reported by Matthew Mondor.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/ufs/ufs/ufs_quota.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.109 src/sys/ufs/ufs/ufs_quota.c:1.110
--- src/sys/ufs/ufs/ufs_quota.c:1.109	Sat Feb 18 06:13:23 2012
+++ src/sys/ufs/ufs/ufs_quota.c	Sun Jul 29 08:32:27 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.109 2012/02/18 06:13:23 matt Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.110 2012/07/29 08:32:27 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.109 2012/02/18 06:13:23 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.110 2012/07/29 08:32:27 dholland Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_quota.h
@@ -52,6 +52,7 @@ __KERNEL_RCSID(0, $NetBSD: ufs_quota.c,
 
 #include sys/quotactl.h
 #include ufs/ufs/quota.h
+#include ufs/ufs/quota1.h /* for INITQFNAMES; should be moved to quota.h */
 #include ufs/ufs/inode.h
 #include ufs/ufs/ufsmount.h
 #include ufs/ufs/ufs_extern.h
@@ -59,7 +60,7 @@ __KERNEL_RCSID(0, $NetBSD: ufs_quota.c,
 
 kmutex_t dqlock;
 kcondvar_t dqcv;
-const char *quotatypes[MAXQUOTAS];
+const char *quotatypes[MAXQUOTAS] = INITQFNAMES;
 
 /*
  * Code pertaining to management of the in-core dquot data structures.



CVS commit: src/sys/ufs/ufs

2012-06-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun  4 16:46:46 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Tidy up some typos and vestiges in comments after the ulr changes.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.115 src/sys/ufs/ufs/ufs_lookup.c:1.116
--- src/sys/ufs/ufs/ufs_lookup.c:1.115	Wed May  9 00:21:18 2012
+++ src/sys/ufs/ufs/ufs_lookup.c	Mon Jun  4 16:46:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.115 2012/05/09 00:21:18 riastradh Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.116 2012/06/04 16:46:45 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.115 2012/05/09 00:21:18 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.116 2012/06/04 16:46:45 riastradh Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -816,13 +816,6 @@ ufs_direnter(struct vnode *dvp, const st
 	dp = VTOI(dvp);
 	newentrysize = DIRSIZ(0, dirp, 0);
 
-#if 0
-	struct ufs_lookup_results *ulr;
-	/* XXX should handle this material another way */
-	ulr = dp-i_crap;
-	UFS_CHECK_CRAPCOUNTER(dp);
-#endif
-
 	if (ulr-ulr_count == 0) {
 		/*
 		 * If ulr_count is 0, then namei could find no
@@ -873,7 +866,7 @@ ufs_direnter(struct vnode *dvp, const st
 
 	/*
 	 * If ulr_count is non-zero, then namei found space for the new
-	 * entry in the range ulr_offset to url_offset + url_count
+	 * entry in the range ulr_offset to ulr_offset + ulr_count
 	 * in the directory. To use this space, we may have to compact
 	 * the entries located there, by copying them together towards the
 	 * beginning of the block, leaving the free space in one usable
@@ -907,8 +900,8 @@ ufs_direnter(struct vnode *dvp, const st
 	/*
 	 * Find space for the new entry. In the simple case, the entry at
 	 * offset base will have the space. If it does not, then namei
-	 * arranged that compacting the region dp-i_offset to
-	 * dp-i_offset + dp-i_count would yield the space.
+	 * arranged that compacting the region ulr_offset to
+	 * ulr_offset + ulr_count would yield the space.
 	 */
 	ep = (struct direct *)dirbuf;
 	dsize = (ep-d_ino != 0) ? DIRSIZ(FSFMT(dvp), ep, needswap) : 0;
@@ -1084,7 +1077,7 @@ ufs_dirremove(struct vnode *dvp, const s
 #ifdef UFS_DIRHASH
 	/*
 	 * Remove the dirhash entry. This is complicated by the fact
-	 * that `ep' is the previous entry when dp-i_count != 0.
+	 * that `ep' is the previous entry when ulr_count != 0.
 	 */
 	if (dp-i_dirhash != NULL)
 		ufsdirhash_remove(dp, (ulr-ulr_count == 0) ? ep :



CVS commit: src/sys/ufs/ufs

2012-06-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun  4 19:58:57 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_rename.c

Log Message:
Fix typo in comment: bp-b_bcount, not bp-b_count.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/ufs/ufs_rename.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_rename.c
diff -u src/sys/ufs/ufs/ufs_rename.c:1.3 src/sys/ufs/ufs/ufs_rename.c:1.4
--- src/sys/ufs/ufs/ufs_rename.c:1.3	Mon Jun  4 19:37:36 2012
+++ src/sys/ufs/ufs/ufs_rename.c	Mon Jun  4 19:58:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_rename.c,v 1.3 2012/06/04 19:37:36 riastradh Exp $	*/
+/*	$NetBSD: ufs_rename.c,v 1.4 2012/06/04 19:58:57 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_rename.c,v 1.3 2012/06/04 19:37:36 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_rename.c,v 1.4 2012/06/04 19:58:57 riastradh Exp $);
 
 #include sys/param.h
 #include sys/buf.h
@@ -680,7 +680,7 @@ ufs_rename_recalculate_fulr(struct vnode
 	/*
 	 * Guarantee we sha'n't go past the end of the buffer we got.
 	 * dirbuf is bp-b_data + (search_start  (iosize - 1)), and
-	 * the valid range is [bp-b_data, bp-b_data + bp-b_count).
+	 * the valid range is [bp-b_data, bp-b_data + bp-b_bcount).
 	 */
 	KASSERT((search_end - search_start) =
 	(bp-b_bcount - (search_start  (mp-mnt_stat.f_iosize - 1;



CVS commit: src/sys/ufs/ufs

2012-06-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun  4 22:01:08 UTC 2012

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
Use two separate comments for stub where IN_RENAME was.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/ufs/ufs/inode.h

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

Modified files:

Index: src/sys/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.61 src/sys/ufs/ufs/inode.h:1.62
--- src/sys/ufs/ufs/inode.h:1.61	Mon Jun  4 20:13:47 2012
+++ src/sys/ufs/ufs/inode.h	Mon Jun  4 22:01:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.61 2012/06/04 20:13:47 riastradh Exp $	*/
+/*	$NetBSD: inode.h,v 1.62 2012/06/04 22:01:07 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -238,7 +238,7 @@ struct inode {
 #define	IN_MODIFY	0x2000		/* Modification time update request. */
 #define	IN_MODIFIED	0x0008		/* Inode has been modified. */
 #define	IN_ACCESSED	0x0010		/* Inode has been accessed. */
-/* #define	IN_UNUSED	0x0020		/* unused, was IN_RENAME */
+/* #define	IN_UNUSED	0x0020 */	/* unused, was IN_RENAME */
 #define	IN_SHLOCK	0x0040		/* File has shared lock. */
 #define	IN_EXLOCK	0x0080		/* File has exclusive lock. */
 #define	IN_CLEANING	0x0100		/* LFS: file is being cleaned */



CVS commit: src/sys/ufs/ufs

2012-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 10 07:57:02 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_rename.c

Log Message:
Disable scary but probably harmless printf.

Still need to find why this harmless-but-shouldn't-happen case is
happening, but in the mean time, we can stop scaring people with it.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ufs/ufs_rename.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_rename.c
diff -u src/sys/ufs/ufs/ufs_rename.c:1.1 src/sys/ufs/ufs/ufs_rename.c:1.2
--- src/sys/ufs/ufs/ufs_rename.c:1.1	Wed May  9 00:21:18 2012
+++ src/sys/ufs/ufs/ufs_rename.c	Thu May 10 07:57:02 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_rename.c,v 1.1 2012/05/09 00:21:18 riastradh Exp $	*/
+/*	$NetBSD: ufs_rename.c,v 1.2 2012/05/10 07:57:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_rename.c,v 1.1 2012/05/09 00:21:18 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_rename.c,v 1.2 2012/05/10 07:57:02 riastradh Exp $);
 
 #include sys/param.h
 #include sys/buf.h
@@ -691,7 +691,7 @@ ufs_rename_recalculate_fulr(struct vnode
 		 * If we are at an I/O block boundary, fetch the next block.
 		 */
 		if ((offset  io_block_mask) == 0) {
-#ifdef DIAGNOSTIC		/* XXX */
+#if 0/* XXX */
 			printf(%s: directory block of inode 0x%llx
 			 extends across I/O block boundary,
 			 which shouldn't happen!\n,



CVS commit: src/sys/ufs/ufs

2012-05-04 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sat May  5 04:08:53 UTC 2012

Modified Files:
src/sys/ufs/ufs: inode.h ufs_lookup.c

Log Message:
comments and cosmetics.  no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/ufs/ufs/inode.h
cvs rdiff -u -r1.113 -r1.114 src/sys/ufs/ufs/ufs_lookup.c

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

Modified files:

Index: src/sys/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.59 src/sys/ufs/ufs/inode.h:1.60
--- src/sys/ufs/ufs/inode.h:1.59	Mon Jan  2 22:10:45 2012
+++ src/sys/ufs/ufs/inode.h	Sat May  5 04:08:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.59 2012/01/02 22:10:45 perseant Exp $	*/
+/*	$NetBSD: inode.h,v 1.60 2012/05/05 04:08:53 yamt Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -50,6 +50,9 @@
  * Lookup result state (other than the result inode). This is
  * currently stashed in the vnode between VOP_LOOKUP and directory
  * operation VOPs, which is gross.
+ *
+ * XXX ulr_diroff is a lookup hint from the previos call of VOP_LOOKUP.
+ * probably it should not be here.
  */
 struct ufs_lookup_results {
 	int32_t	  ulr_count;	/* Size of free slot in directory. */

Index: src/sys/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.113 src/sys/ufs/ufs/ufs_lookup.c:1.114
--- src/sys/ufs/ufs/ufs_lookup.c:1.113	Fri Mar 16 08:39:54 2012
+++ src/sys/ufs/ufs/ufs_lookup.c	Sat May  5 04:08:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.114 2012/05/05 04:08:53 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.114 2012/05/05 04:08:53 yamt Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -124,19 +124,27 @@ ufs_lookup(void *v)
 	struct buf *bp;			/* a buffer of directory entries */
 	struct direct *ep;		/* the current directory entry */
 	int entryoffsetinblock;		/* offset of ep in bp's buffer */
-	enum {NONE, COMPACT, FOUND} slotstatus;
-	doff_t slotoffset;		/* offset of area with free space */
+	enum {
+		NONE,		/* need to search a slot for our new entry */
+		COMPACT,	/* a compaction can make a slot in the current
+   DIRBLKSIZ block */
+		FOUND,		/* found a slot (or no need to search) */
+	} slotstatus;
+	doff_t slotoffset;		/* offset of area with free space.
+	   a special value -1 for invalid */
 	int slotsize;			/* size of area at slotoffset */
-	int slotfreespace;		/* amount of space free in slot */
+	int slotfreespace;		/* accumulated amount of space free in
+	   the current DIRBLKSIZ block */
 	int slotneeded;			/* size of the entry we're seeking */
 	int numdirpasses;		/* strategy for directory search */
 	doff_t endsearch;		/* offset to end directory search */
-	doff_t prevoff;			/* prev entry dp-i_offset */
+	doff_t prevoff;			/* previous value of ulr_offset */
 	struct vnode *pdp;		/* saved dp during symlink work */
 	struct vnode *tdp;		/* returned by VFS_VGET */
-	doff_t enduseful;		/* pointer past last used dir slot */
+	doff_t enduseful;		/* pointer past last used dir slot.
+	   used for directory truncation. */
 	u_long bmask;			/* block offset mask */
-	int namlen, error;
+	int error;
 	struct vnode **vpp = ap-a_vpp;
 	struct componentname *cnp = ap-a_cnp;
 	kauth_cred_t cred = cnp-cn_cred;
@@ -194,8 +202,7 @@ ufs_lookup(void *v)
 	 */
 	slotstatus = FOUND;
 	slotfreespace = slotsize = slotneeded = 0;
-	if ((nameiop == CREATE || nameiop == RENAME) 
-	(flags  ISLASTCN)) {
+	if ((nameiop == CREATE || nameiop == RENAME)  (flags  ISLASTCN)) {
 		slotstatus = NONE;
 		slotneeded = DIRECTSIZ(cnp-cn_namelen);
 	}
@@ -280,8 +287,8 @@ searchloop:
 		if ((results-ulr_offset  bmask) == 0) {
 			if (bp != NULL)
 brelse(bp, 0);
-			error = ufs_blkatoff(vdp, (off_t)results-ulr_offset, NULL,
-			bp, false);
+			error = ufs_blkatoff(vdp, (off_t)results-ulr_offset,
+			NULL, bp, false);
 			if (error)
 goto out;
 			entryoffsetinblock = 0;
@@ -351,6 +358,8 @@ searchloop:
 		 * Check for a name match.
 		 */
 		if (ep-d_ino) {
+			int namlen;
+
 #if (BYTE_ORDER == LITTLE_ENDIAN)
 			if (FSFMT(vdp)  needswap == 0)
 namlen = ep-d_type;
@@ -370,8 +379,7 @@ foundentry:
 #endif
 /*
  * Save directory entry's inode number and
- * reclen in ndp-ni_ufs area, and release
- * directory buffer.
+ * reclen, and release directory buffer.
  */
 if (!FSFMT(vdp)  ep-d_type == DT_WHT) {
 	slotstatus = FOUND;
@@ -380,8 +388,9 @@ foundentry:
 	needswap);
 	results-ulr_reclen = slotsize;
 	/*
-	 * This is used to set results-ulr_endoff,
-	 * which may be used by ufs_direnter2()
+	 * This is used to set
+	 * results-ulr_endoff,
+	 * which may be used by ufs_direnter()
 	 * as a 

CVS commit: src/sys/ufs/ufs

2012-04-04 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Wed Apr  4 19:52:48 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_vfsops.c

Log Message:
Assert that we can a valid inode when looking up a file handle.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ufs/ufs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vfsops.c
diff -u src/sys/ufs/ufs/ufs_vfsops.c:1.50 src/sys/ufs/ufs/ufs_vfsops.c:1.51
--- src/sys/ufs/ufs/ufs_vfsops.c:1.50	Wed Feb  1 05:34:43 2012
+++ src/sys/ufs/ufs/ufs_vfsops.c	Wed Apr  4 19:52:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vfsops.c,v 1.50 2012/02/01 05:34:43 dholland Exp $	*/
+/*	$NetBSD: ufs_vfsops.c,v 1.51 2012/04/04 19:52:48 tron Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vfsops.c,v 1.50 2012/02/01 05:34:43 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vfsops.c,v 1.51 2012/04/04 19:52:48 tron Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -223,6 +223,7 @@ ufs_fhtovp(struct mount *mp, struct ufid
 		return (error);
 	}
 	ip = VTOI(nvp);
+	KASSERT(ip != NULL);
 	if (ip-i_mode == 0 || ip-i_gen != ufhp-ufid_gen) {
 		vput(nvp);
 		*vpp = NULLVP;



CVS commit: src/sys/ufs/ufs

2012-03-26 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Mar 26 11:03:44 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_extattr.c

Log Message:
Fix wrong variable in snprintf. From Henning Petersen in PR 46259,
ok manu@


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/ufs/ufs_extattr.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_extattr.c
diff -u src/sys/ufs/ufs/ufs_extattr.c:1.37 src/sys/ufs/ufs/ufs_extattr.c:1.38
--- src/sys/ufs/ufs/ufs_extattr.c:1.37	Tue Mar 13 18:41:14 2012
+++ src/sys/ufs/ufs/ufs_extattr.c	Mon Mar 26 11:03:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extattr.c,v 1.37 2012/03/13 18:41:14 elad Exp $	*/
+/*	$NetBSD: ufs_extattr.c,v 1.38 2012/03/26 11:03:43 wiz Exp $	*/
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.37 2012/03/13 18:41:14 elad Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.38 2012/03/26 11:03:43 wiz Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ffs.h
@@ -133,7 +133,7 @@ from_freebsd_extattr(int attrnamespace, 
 
 	attr = kmem_alloc(len, KM_SLEEP);
 
-	snprintf(attr, len, %s.%s, namespace, attr);
+	snprintf(attr, len, %s.%s, namespace, attrname);
 
 	return attr;
 }



CVS commit: src/sys/ufs/ufs

2012-02-17 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sat Feb 18 06:13:23 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_quota.c ufs_quota.h

Log Message:
Eliminate a common in a header file (add a missing extern) and
declare it in the approriate C file.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/ufs/ufs/ufs_quota.c
cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/ufs/ufs_quota.h

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.108 src/sys/ufs/ufs/ufs_quota.c:1.109
--- src/sys/ufs/ufs/ufs_quota.c:1.108	Wed Feb  1 05:43:54 2012
+++ src/sys/ufs/ufs/ufs_quota.c	Sat Feb 18 06:13:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.108 2012/02/01 05:43:54 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.109 2012/02/18 06:13:23 matt Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.108 2012/02/01 05:43:54 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota.c,v 1.109 2012/02/18 06:13:23 matt Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_quota.h
@@ -59,6 +59,7 @@ __KERNEL_RCSID(0, $NetBSD: ufs_quota.c,
 
 kmutex_t dqlock;
 kcondvar_t dqcv;
+const char *quotatypes[MAXQUOTAS];
 
 /*
  * Code pertaining to management of the in-core dquot data structures.

Index: src/sys/ufs/ufs/ufs_quota.h
diff -u src/sys/ufs/ufs/ufs_quota.h:1.20 src/sys/ufs/ufs/ufs_quota.h:1.21
--- src/sys/ufs/ufs/ufs_quota.h:1.20	Sun Jan 29 07:09:52 2012
+++ src/sys/ufs/ufs/ufs_quota.h	Sat Feb 18 06:13:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.h,v 1.20 2012/01/29 07:09:52 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.h,v 1.21 2012/02/18 06:13:23 matt Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -103,7 +103,7 @@ extern kcondvar_t dqcv;
 /*
  * Quota name to error message mapping.
  */
-const char *quotatypes[MAXQUOTAS];
+extern const char *quotatypes[MAXQUOTAS];
 
 int  getinoquota(struct inode *);
 int  dqget(struct vnode *, u_long, struct ufsmount *, int, struct dquot **);



CVS commit: src/sys/ufs/ufs

2012-02-12 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Feb 13 06:23:41 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_quota2.c

Log Message:
Fix another problem with quota cursor iteration. ok riz


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/ufs/ufs/ufs_quota2.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota2.c
diff -u src/sys/ufs/ufs/ufs_quota2.c:1.33 src/sys/ufs/ufs/ufs_quota2.c:1.34
--- src/sys/ufs/ufs/ufs_quota2.c:1.33	Sun Feb  5 14:19:04 2012
+++ src/sys/ufs/ufs/ufs_quota2.c	Mon Feb 13 06:23:41 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.33 2012/02/05 14:19:04 dholland Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.34 2012/02/13 06:23:41 dholland Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota2.c,v 1.33 2012/02/05 14:19:04 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota2.c,v 1.34 2012/02/13 06:23:41 dholland Exp $);
 
 #include sys/buf.h
 #include sys/param.h
@@ -957,6 +957,7 @@ struct q2cursor_getids {
 	unsigned skip;		/* number of ids to skip over */
 	unsigned new_skip;	/* number of ids to skip over next time */
 	unsigned skipped;	/* number skipped so far */
+	int stopped;		/* true if we stopped quota_walk_list early */
 };
 
 /*
@@ -1109,6 +1110,7 @@ q2cursor_getids_callback(struct ufsmount
 	gi-new_skip++;
 	if (gi-state-numids = gi-state-maxids) {
 		/* got enough ids, stop now */
+		gi-stopped = 1;
 		return Q2WL_ABORT;
 	}
 	return 0;
@@ -1175,11 +1177,16 @@ q2cursor_getkeys(struct ufsmount *ump, i
 		gi.skip = cursor-q2c_uidpos;
 		gi.new_skip = gi.skip;
 		gi.skipped = 0;
+		gi.stopped = 0;
 		offset = q2h-q2h_entries[cursor-q2c_hashpos];
 
 		error = quota2_walk_list(ump, hbp, idtype, offset, 0, gi,
 		q2cursor_getids_callback);
-		if (error == Q2WL_ABORT) {
+		KASSERT(error != Q2WL_ABORT);
+		if (error) {
+			break;
+		}
+		if (gi.stopped) {
 			/* callback stopped before reading whole chain */
 			cursor-q2c_uidpos = gi.new_skip;
 			/* if we didn't get both halves, back up */
@@ -1187,10 +1194,6 @@ q2cursor_getkeys(struct ufsmount *ump, i
 KASSERT(cursor-q2c_uidpos  0);
 cursor-q2c_uidpos--;
 			}
-			/* not an error */
-			error = 0;
-		} else if (error) {
-			break;
 		} else {
 			/* read whole chain */
 			/* if we got both halves of the last id, advance */



CVS commit: src/sys/ufs/ufs

2012-02-01 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Feb  2 03:00:49 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_quota1.c

Log Message:
Make this compile on vax (uninitialized use warning).


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/ufs/ufs_quota1.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.17 src/sys/ufs/ufs/ufs_quota1.c:1.18
--- src/sys/ufs/ufs/ufs_quota1.c:1.17	Wed Feb  1 05:43:54 2012
+++ src/sys/ufs/ufs/ufs_quota1.c	Thu Feb  2 03:00:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.17 2012/02/01 05:43:54 dholland Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.18 2012/02/02 03:00:48 matt Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota1.c,v 1.17 2012/02/01 05:43:54 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota1.c,v 1.18 2012/02/02 03:00:48 matt Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -611,19 +611,17 @@ quota1_handle_cmd_put(struct ufsmount *u
 	dqb.dqb_curinodes = dq-dq_curinodes;
 	dqb.dqb_btime = dq-dq_btime;
 	dqb.dqb_itime = dq-dq_itime;
-	switch (key-qk_objtype) {
-	case QUOTA_OBJTYPE_BLOCKS:
+	if (key-qk_objtype == QUOTA_OBJTYPE_BLOCKS) {
 		dqb.dqb_bsoftlimit = quota1_encode_limit(val-qv_softlimit);
 		dqb.dqb_bhardlimit = quota1_encode_limit(val-qv_hardlimit);
 		dqb.dqb_isoftlimit = dq-dq_isoftlimit;
 		dqb.dqb_ihardlimit = dq-dq_ihardlimit;
-		break;
-	case QUOTA_OBJTYPE_FILES:
+	} else {
+		KASSERT(key-qk_objtype == QUOTA_OBJTYPE_FILES);
 		dqb.dqb_bsoftlimit = dq-dq_bsoftlimit;
 		dqb.dqb_bhardlimit = dq-dq_bhardlimit;
 		dqb.dqb_isoftlimit = quota1_encode_limit(val-qv_softlimit);
 		dqb.dqb_ihardlimit = quota1_encode_limit(val-qv_hardlimit);
-		break;
 	}
 	if (dq-dq_id == 0  val-qv_grace != QUOTA_NOTIME) {
 		/* also update grace time if available */



CVS commit: src/sys/ufs/ufs

2012-01-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Feb  1 05:10:45 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_quota2.c

Log Message:
Fix problems in cursor iteration that came to light when iterating one
value at a time, instead of in bulk. Yeah, repquota should do bulk get,
but it doesn't yet.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/ufs/ufs_quota2.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota2.c
diff -u src/sys/ufs/ufs/ufs_quota2.c:1.30 src/sys/ufs/ufs/ufs_quota2.c:1.31
--- src/sys/ufs/ufs/ufs_quota2.c:1.30	Sun Jan 29 07:21:00 2012
+++ src/sys/ufs/ufs/ufs_quota2.c	Wed Feb  1 05:10:44 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.30 2012/01/29 07:21:00 dholland Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.31 2012/02/01 05:10:44 dholland Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_quota2.c,v 1.30 2012/01/29 07:21:00 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_quota2.c,v 1.31 2012/02/01 05:10:44 dholland Exp $);
 
 #include sys/buf.h
 #include sys/param.h
@@ -1158,7 +1158,10 @@ q2cursor_getkeys(struct ufsmount *ump, i
 	/* If we haven't done the defaults yet, that goes first. */
 	if (cursor-q2c_defaults_done == 0) {
 		q2cursor_addid(state, idtype, QUOTA_DEFAULTID);
-		cursor-q2c_defaults_done = 1;
+		/* if we read both halves, mark it done */
+		if (state-numids  state-maxids || !state-skiplast) {
+			cursor-q2c_defaults_done = 1;
+		}
 	}
 
 	gi.state = state;
@@ -1181,14 +1184,22 @@ q2cursor_getkeys(struct ufsmount *ump, i
 		if (error == Q2WL_ABORT) {
 			/* callback stopped before reading whole chain */
 			cursor-q2c_uidpos = gi.new_skip;
+			/* if we didn't get both halves, back up */
+			if (state-numids == state-maxids  state-skiplast){
+KASSERT(cursor-q2c_uidpos  0);
+cursor-q2c_uidpos--;
+			}
 			/* not an error */
 			error = 0;
 		} else if (error) {
 			break;
 		} else {
-			/* read whole chain, advance to next */
-			cursor-q2c_uidpos = 0;
-			cursor-q2c_hashpos++;
+			/* read whole chain */
+			/* if we got both halves of the last id, advance */
+			if (state-numids  state-maxids || !state-skiplast){
+cursor-q2c_uidpos = 0;
+cursor-q2c_hashpos++;
+			}
 		}
 	}
 



CVS commit: src/sys/ufs/ufs

2012-01-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jan 29 08:49:02 UTC 2012

Modified Files:
src/sys/ufs/ufs: ufs_vfsops.c

Log Message:
Fix errors in !defined(QUOTA)  !defined(QUOTA2) case.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ufs/ufs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_vfsops.c
diff -u src/sys/ufs/ufs/ufs_vfsops.c:1.48 src/sys/ufs/ufs/ufs_vfsops.c:1.49
--- src/sys/ufs/ufs/ufs_vfsops.c:1.48	Sun Jan 29 07:16:54 2012
+++ src/sys/ufs/ufs/ufs_vfsops.c	Sun Jan 29 08:49:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vfsops.c,v 1.48 2012/01/29 07:16:54 dholland Exp $	*/
+/*	$NetBSD: ufs_vfsops.c,v 1.49 2012/01/29 08:49:01 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ufs_vfsops.c,v 1.48 2012/01/29 07:16:54 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: ufs_vfsops.c,v 1.49 2012/01/29 08:49:01 tsutsui Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ffs.h
@@ -102,15 +102,13 @@ ufs_root(struct mount *mp, struct vnode 
 int
 ufs_quotactl(struct mount *mp, struct vfs_quotactl_args *args)
 {
-	struct lwp *l = curlwp;
 
 #if !defined(QUOTA)  !defined(QUOTA2)
 	(void) mp;
-	(void) cmddict;
-	(void) dummy;
-	(void) l;
+	(void) args;
 	return (EOPNOTSUPP);
 #else
+	struct lwp *l = curlwp;
 	int error;
 
 	/* Mark the mount busy, as we're passing it to kauth(9). */



  1   2   >