CVS commit: src/sys/fs/udf

2020-04-14 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Apr 14 12:47:44 UTC 2020

Modified Files:
src/sys/fs/udf: udf_vfsops.c

Log Message:
Move comment related to the sysctl_createv() in SYSCTL_SETUP() from the old
place to the new place too.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/fs/udf/udf_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/fs/udf/udf_vfsops.c
diff -u src/sys/fs/udf/udf_vfsops.c:1.79 src/sys/fs/udf/udf_vfsops.c:1.80
--- src/sys/fs/udf/udf_vfsops.c:1.79	Mon Apr 13 19:23:18 2020
+++ src/sys/fs/udf/udf_vfsops.c	Tue Apr 14 12:47:44 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vfsops.c,v 1.79 2020/04/13 19:23:18 ad Exp $ */
+/* $NetBSD: udf_vfsops.c,v 1.80 2020/04/14 12:47:44 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.79 2020/04/13 19:23:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.80 2020/04/14 12:47:44 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -167,6 +167,11 @@ udf_done(void)
  */
 #define UDF_VERBOSE_SYSCTLOPT1
 
+/*
+ * XXX the "24" below could be dynamic, thereby eliminating one
+ * more instance of the "number to vfs" mapping problem, but
+ * "24" is the order as taken from sys/mount.h
+ */
 SYSCTL_SETUP(udf_sysctl_setup, "udf sysctl")
 {
 	const struct sysctlnode *node;
@@ -197,11 +202,6 @@ udf_modcmd(modcmd_t cmd, void *arg)
 		error = vfs_attach(_vfsops);
 		if (error != 0)
 			break;
-		/*
-		 * XXX the "24" below could be dynamic, thereby eliminating one
-		 * more instance of the "number to vfs" mapping problem, but
-		 * "24" is the order as taken from sys/mount.h
-		 */
 		break;
 	case MODULE_CMD_FINI:
 		error = vfs_detach(_vfsops);



CVS commit: src/sys/fs/udf

2020-04-14 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Apr 14 11:45:43 UTC 2020

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
fix debug print flag


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.110 src/sys/fs/udf/udf_vnops.c:1.111
--- src/sys/fs/udf/udf_vnops.c:1.110	Mon Apr 13 19:23:18 2020
+++ src/sys/fs/udf/udf_vnops.c	Tue Apr 14 11:45:42 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.110 2020/04/13 19:23:18 ad Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.111 2020/04/14 11:45:42 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.110 2020/04/13 19:23:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.111 2020/04/14 11:45:42 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -1992,7 +1992,7 @@ udf_rmdir(void *v)
 	struct udf_mount *ump = dir_node->ump;
 	int error, isempty;
 
-	DPRINTF(NOTIMPL, ("udf_rmdir '%s' called\n", cnp->cn_nameptr));
+	DPRINTF(CALL, ("udf_rmdir '%s' called\n", cnp->cn_nameptr));
 
 	/* don't allow '.' to be deleted */
 	if (dir_node == udf_node) {



CVS commit: src/sys/fs/udf

2020-04-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Apr  6 14:31:06 UTC 2020

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
udf_get_node(): fix typo and honor "lktype" argument.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.149 src/sys/fs/udf/udf_subr.c:1.150
--- src/sys/fs/udf/udf_subr.c:1.149	Thu Feb 27 22:12:54 2020
+++ src/sys/fs/udf/udf_subr.c	Mon Apr  6 14:31:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.149 2020/02/27 22:12:54 ad Exp $ */
+/* $NetBSD: udf_subr.c,v 1.150 2020/04/06 14:31:06 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.149 2020/02/27 22:12:54 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.150 2020/04/06 14:31:06 hannken Exp $");
 #endif /* not lint */
 
 
@@ -5641,7 +5641,7 @@ udf_get_node(struct udf_mount *ump, stru
 	sizeof(node_icb_loc->loc), );
 	if (error)
 		return error;
-	error = vn_lock(vp, LK_EXCLUSIVE);
+	error = vn_lock(vp, lktype);
 	if (error) {
 		vrele(vp);
 		return error;



CVS commit: src/sys/fs/udf

2018-08-09 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Aug  9 20:30:26 UTC 2018

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Fix length calculation


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.142 src/sys/fs/udf/udf_subr.c:1.143
--- src/sys/fs/udf/udf_subr.c:1.142	Wed Jul 25 11:09:22 2018
+++ src/sys/fs/udf/udf_subr.c	Thu Aug  9 20:30:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.142 2018/07/25 11:09:22 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.143 2018/08/09 20:30:26 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.142 2018/07/25 11:09:22 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.143 2018/08/09 20:30:26 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -2623,7 +2623,7 @@ udf_update_lvid_from_vat_extattr(struct 
 		return error;
 
 	/* paranoia */
-	if (a_l != sizeof(*implext) -1 + udf_rw32(implext->iu_l) + sizeof(lvext)) {
+	if (a_l != sizeof(*implext) -2 + udf_rw32(implext->iu_l) + sizeof(lvext)) {
 		DPRINTF(VOLUMES, ("VAT LVExtension size doesn't compute\n"));
 		return EINVAL;
 	}



CVS commit: src/sys/fs/udf

2018-08-09 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Aug  9 13:49:30 UTC 2018

Modified Files:
src/sys/fs/udf: ecma167-udf.h

Log Message:
Sync with UDFclient


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/fs/udf/ecma167-udf.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/fs/udf/ecma167-udf.h
diff -u src/sys/fs/udf/ecma167-udf.h:1.15 src/sys/fs/udf/ecma167-udf.h:1.16
--- src/sys/fs/udf/ecma167-udf.h:1.15	Wed Jul 25 19:56:56 2018
+++ src/sys/fs/udf/ecma167-udf.h	Thu Aug  9 13:49:30 2018
@@ -1,8 +1,8 @@
-/* $NetBSD: ecma167-udf.h,v 1.15 2018/07/25 19:56:56 kamil Exp $ */
+/* $NetBSD: ecma167-udf.h,v 1.16 2018/08/09 13:49:30 reinoud Exp $ */
 
 /*-
- * Copyright (c) 2003, 2004, 2005, 2006, 2008, 2009
- * 	Reinoud Zandijk * 
+ * Copyright (c) 2003, 2004, 2005, 2006, 2008, 2009, 2017, 2018
+ * 	Reinoud Zandijk 
  * Copyright (c) 2001, 2002 Scott Long 
  * All rights reserved.
  *
@@ -264,7 +264,10 @@ struct regid {
 struct icb_tag {
 	uint32_t	prev_num_dirs;
 	uint16_t	strat_type;
-	uint8_t		strat_param[2];
+	union {
+		uint8_t	 strat_param[2];
+		uint16_t strat_param16;
+	};
 	uint16_t	max_num_entries;
 	uint8_t		reserved;
 	uint8_t		file_type;
@@ -682,7 +685,10 @@ struct impl_extattr_entry {
 	struct extattr_entryhdr;
 	uint32_t		iu_l;
 	struct regid		imp_id;
-	uint8_t			data[1];
+	union {
+		uint8_t	 data[1];
+		uint16_t data16;
+	};
 } __packed;
 
 



CVS commit: src/sys/fs/udf

2018-07-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jul 25 19:56:56 UTC 2018

Modified Files:
src/sys/fs/udf: ecma167-udf.h

Log Message:
Avoid undefined behavior in ecma167-udf.h

Define the UDF_EXT_* symbols as unsigned values.
This prevents undefined behavior of altering the signedness bit in a part
of them. Swap the remaining symbols to unsigned values to keep the
consistency.

Required by GCC when building with Undefined Behavior Sanitizer.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/fs/udf/ecma167-udf.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/fs/udf/ecma167-udf.h
diff -u src/sys/fs/udf/ecma167-udf.h:1.14 src/sys/fs/udf/ecma167-udf.h:1.15
--- src/sys/fs/udf/ecma167-udf.h:1.14	Thu Jul  7 17:45:38 2011
+++ src/sys/fs/udf/ecma167-udf.h	Wed Jul 25 19:56:56 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ecma167-udf.h,v 1.14 2011/07/07 17:45:38 reinoud Exp $ */
+/* $NetBSD: ecma167-udf.h,v 1.15 2018/07/25 19:56:56 kamil Exp $ */
 
 /*-
  * Copyright (c) 2003, 2004, 2005, 2006, 2008, 2009
@@ -203,14 +203,14 @@ union icb {
 
 
 /* short/long/ext extent have flags encoded in length */
-#define UDF_EXT_ALLOCATED  (0<<30)
-#define UDF_EXT_FREED  (1<<30)
-#define UDF_EXT_ALLOCATED_BUT_NOT_USED (1<<30)
-#define UDF_EXT_FREE   (2<<30)
-#define UDF_EXT_REDIRECT   (3<<30)
-#define UDF_EXT_FLAGS(len) ((len) & (3<<30))
-#define UDF_EXT_LEN(len)   ((len) & ((1<<30)-1))
-#define UDF_EXT_MAXLEN ((1<<30)-1)
+#define UDF_EXT_ALLOCATED  (0U<<30)
+#define UDF_EXT_FREED  (1U<<30)
+#define UDF_EXT_ALLOCATED_BUT_NOT_USED (1U<<30)
+#define UDF_EXT_FREE   (2U<<30)
+#define UDF_EXT_REDIRECT   (3U<<30)
+#define UDF_EXT_FLAGS(len) ((len) & (3U<<30))
+#define UDF_EXT_LEN(len)   ((len) & ((1U<<30)-1))
+#define UDF_EXT_MAXLEN ((1U<<30)-1)
 
 
 /* Character set spec [1/7.2.1] */
@@ -832,4 +832,3 @@ union dscrptr {
 
 
 #endif /* !_FS_UDF_ECMA167_UDF_H_ */
-



CVS commit: src/sys/fs/udf

2018-07-25 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul 25 11:09:22 UTC 2018

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Enhance logical volume integrity descriptor handling and provide
bug-compatibility for Linux mkudffs 1.3 images.


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.141 src/sys/fs/udf/udf_subr.c:1.142
--- src/sys/fs/udf/udf_subr.c:1.141	Wed Jun  6 01:49:09 2018
+++ src/sys/fs/udf/udf_subr.c	Wed Jul 25 11:09:22 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.141 2018/06/06 01:49:09 maya Exp $ */
+/* $NetBSD: udf_subr.c,v 1.142 2018/07/25 11:09:22 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.141 2018/06/06 01:49:09 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.142 2018/07/25 11:09:22 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -1233,7 +1233,7 @@ udf_retrieve_lvint(struct udf_mount *ump
 
 		/* are we linking to a new piece? */
 		if (dscr && lvint->next_extent.len) {
-			len= udf_rw32(lvint->next_extent.len);
+			len   = udf_rw32(lvint->next_extent.len);
 			lbnum = udf_rw32(lvint->next_extent.loc);
 
 			if (trace_len >= UDF_LVDINT_SEGMENTS-1) {
@@ -1279,7 +1279,7 @@ udf_loose_lvint_history(struct udf_mount
 	uint32_t out_ext, out_wpos, out_len;
 	uint32_t lb_num;
 	uint32_t len, start;
-	int ext, minext, extlen, cnt, cpy_len, dscr_type;
+	int ext, sumext, extlen, cnt, cpy_len, dscr_type;
 	int losing;
 	int error;
 
@@ -1287,18 +1287,29 @@ udf_loose_lvint_history(struct udf_mount
 
 	/* search smallest extent */
 	trace = >lvint_trace[0];
-	minext = trace->end - trace->start;
+	sumext = trace->end - trace->start;
 	for (ext = 1; ext < UDF_LVDINT_SEGMENTS; ext++) {
 		trace = >lvint_trace[ext];
 		extlen = trace->end - trace->start;
 		if (extlen == 0)
 			break;
-		minext = MIN(minext, extlen);
+		sumext += extlen;
 	}
-	losing = MIN(minext, UDF_LVINT_LOSSAGE);
-	/* no sense wiping all */
-	if (losing == minext)
-		losing--;
+
+	/* just one element? its not legal but be bug compatible */
+	if (sumext == 1) {
+		/* overwrite the only entry */
+		DPRINTF(VOLUMES, ("\tLinux bugcompat overwriting sole entry\n"));
+		trace = >lvint_trace[0];
+		trace->wpos = 0;
+		return 0;
+	}
+
+	losing = MIN(sumext, UDF_LVINT_LOSSAGE);
+
+	/* no sense wiping too much */
+	if (sumext == UDF_LVINT_LOSSAGE)
+		losing = UDF_LVINT_LOSSAGE/2;
 
 	DPRINTF(VOLUMES, ("\tlosing %d entries\n", losing));
 
@@ -1435,7 +1446,6 @@ udf_writeout_lvint(struct udf_mount *ump
 
 	DPRINTF(VOLUMES, ("writing out logvol integrity descriptor\n"));
 
-again:
 	/* get free space in last chunk */
 	trace = ump->lvint_trace;
 	while (trace->wpos > (trace->end - trace->start)) {
@@ -1463,11 +1473,20 @@ again:
 	if (space < 1) {
 		if (lvflag & UDF_APPENDONLY_LVINT)
 			return EROFS;
+
 		/* loose history by re-writing extents */
 		error = udf_loose_lvint_history(ump);
 		if (error)
 			return error;
-		goto again;
+
+		trace = ump->lvint_trace;
+		while (trace->wpos > (trace->end - trace->start))
+			trace++;
+		space = (trace->end - trace->start) - trace->wpos;
+		DPRINTF(VOLUMES, ("new try: write start = %d, end = %d, "
+  "pos = %d, wpos = %d, "
+  "space = %d\n", trace->start, trace->end,
+  trace->pos, trace->wpos, space));
 	}
 
 	/* update our integrity descriptor to identify us and timestamp it */
@@ -1671,6 +1690,14 @@ udf_write_physical_partition_spacetables
 		DPRINTF(VOLUMES, ("Write unalloc. space bitmap %d\n",
 			lb_num + ptov));
 		dscr = (union dscrptr *) ump->part_unalloc_dscr[phys_part];
+
+		/* force a sane minimum for descriptors CRC length */
+		/* see UDF 2.3.1.2 and 2.3.8.1 */
+		KASSERT(udf_rw16(dscr->sbd.tag.id) == TAGID_SPACE_BITMAP);
+		if (udf_rw16(dscr->sbd.tag.desc_crc_len) == 0)
+			dscr->sbd.tag.desc_crc_len = udf_rw16(8);
+
+		/* write out space bitmap */
 		error = udf_write_phys_dscr_sync(ump, NULL, UDF_C_DSCR,
 (union dscrptr *) dscr,
 ptov + lb_num, lb_num);
@@ -1697,6 +1724,14 @@ udf_write_physical_partition_spacetables
 		DPRINTF(VOLUMES, ("Write freed space bitmap %d\n",
 			lb_num + ptov));
 		dscr = (union dscrptr *) ump->part_freed_dscr[phys_part];
+
+		/* force a sane minimum for descriptors CRC length */
+		/* see UDF 2.3.1.2 and 2.3.8.1 */
+		KASSERT(udf_rw16(dscr->sbd.tag.id) == TAGID_SPACE_BITMAP);
+		if (udf_rw16(dscr->sbd.tag.desc_crc_len) == 0)
+			dscr->sbd.tag.desc_crc_len = udf_rw16(8);
+
+		/* write out space bitmap */
 		error = udf_write_phys_dscr_sync(ump, NULL, UDF_C_DSCR,
 (union dscrptr *) dscr,
 ptov + lb_num, lb_num);



CVS commit: src/sys/fs/udf

2017-06-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun 24 12:13:16 UTC 2017

Modified Files:
src/sys/fs/udf: udf_vfsops.c

Log Message:
No need to call vflush from failing udf_mount().  If the system nodes
really have to disappear we should change vrele() to vrecycle() here.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/fs/udf/udf_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/fs/udf/udf_vfsops.c
diff -u src/sys/fs/udf/udf_vfsops.c:1.75 src/sys/fs/udf/udf_vfsops.c:1.76
--- src/sys/fs/udf/udf_vfsops.c:1.75	Sat Apr  1 19:35:56 2017
+++ src/sys/fs/udf/udf_vfsops.c	Sat Jun 24 12:13:16 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vfsops.c,v 1.75 2017/04/01 19:35:56 riastradh Exp $ */
+/* $NetBSD: udf_vfsops.c,v 1.76 2017/06/24 12:13:16 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.75 2017/04/01 19:35:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.76 2017/06/24 12:13:16 hannken Exp $");
 #endif /* not lint */
 
 
@@ -277,7 +277,6 @@ static void
 udf_release_system_nodes(struct mount *mp)
 {
 	struct udf_mount *ump = VFSTOUDF(mp);
-	int error;
 
 	/* if we haven't even got an ump, dont bother */
 	if (!ump)
@@ -294,10 +293,6 @@ udf_release_system_nodes(struct mount *m
 		vrele(ump->metadatamirror_node->vnode);
 	if (ump->metadatabitmap_node)
 		vrele(ump->metadatabitmap_node->vnode);
-
-	/* This flush should NOT write anything nor allow any node to remain */
-	if ((error = vflush(ump->vfs_mountp, NULLVP, 0)) != 0)
-		panic("Failure to flush UDF system vnodes\n");
 }
 
 
@@ -520,6 +515,10 @@ udf_unmount(struct mount *mp, int mntfla
 	/* NOTE release system nodes should NOT write anything */
 	udf_release_system_nodes(mp);
 
+	/* This flush should NOT write anything nor allow any node to remain */
+	if ((error = vflush(ump->vfs_mountp, NULLVP, 0)) != 0)
+		panic("Failure to flush UDF system vnodes\n");
+
 	/* finalise disc strategy */
 	udf_discstrat_finish(ump);
 



CVS commit: src/sys/fs/udf

2017-01-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan  4 15:53:14 UTC 2017

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
PR/51777: David Binderman: Remove unused computation


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.38 src/sys/fs/udf/udf_allocation.c:1.39
--- src/sys/fs/udf/udf_allocation.c:1.38	Mon Aug 24 04:30:17 2015
+++ src/sys/fs/udf/udf_allocation.c	Wed Jan  4 10:53:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.38 2015/08/24 08:30:17 hannken Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.39 2017/01/04 15:53:14 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.38 2015/08/24 08:30:17 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.39 2017/01/04 15:53:14 christos Exp $");
 #endif /* not lint */
 
 
@@ -1001,7 +1001,7 @@ udf_bitmap_check_trunc_free(struct udf_b
 		bitval = (1 << bit);
 		if (!(*bpos & bitval))
 			seq_free = 0;
-		offset++; to_trunc--;
+		to_trunc--;
 		bit++;
 		if (bit == 8) {
 			bpos++;



CVS commit: src/sys/fs/udf

2016-05-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue May 24 09:55:57 UTC 2016

Modified Files:
src/sys/fs/udf: udf.h udf_readwrite.c udf_strat_bootstrap.c
udf_strat_direct.c udf_strat_rmw.c udf_strat_sequential.c
udf_subr.c udf_subr.h

Log Message:
Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/udf/udf_readwrite.c
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/udf/udf_strat_bootstrap.c
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/udf/udf_strat_direct.c
cvs rdiff -u -r1.27 -r1.28 src/sys/fs/udf/udf_strat_rmw.c
cvs rdiff -u -r1.14 -r1.15 src/sys/fs/udf/udf_strat_sequential.c
cvs rdiff -u -r1.137 -r1.138 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.19 -r1.20 src/sys/fs/udf/udf_subr.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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.51 src/sys/fs/udf/udf.h:1.52
--- src/sys/fs/udf/udf.h:1.51	Tue May 10 15:23:39 2016
+++ src/sys/fs/udf/udf.h	Tue May 24 09:55:57 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.51 2016/05/10 15:23:39 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.52 2016/05/24 09:55:57 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -76,7 +76,7 @@ extern int udf_verbose;
 #define UDF_DEBUG_RESERVE	0x100
 
 /* initial value of udf_verbose */
-#define UDF_DEBUGGING		0
+#define UDF_DEBUGGING		(0)
 
 #ifdef UDF_DEBUG
 #define DPRINTF(name, arg) { \
@@ -252,6 +252,7 @@ struct udf_strategy {
 	int  (*read_logvol_dscr)(struct udf_strat_args *args);
 	int  (*write_logvol_dscr)   (struct udf_strat_args *args);
 	void (*queuebuf)	(struct udf_strat_args *args);
+	void (*sync_caches)	(struct udf_strat_args *args);
 	void (*discstrat_init)  (struct udf_strat_args *args);
 	void (*discstrat_finish)(struct udf_strat_args *args);
 };

Index: src/sys/fs/udf/udf_readwrite.c
diff -u src/sys/fs/udf/udf_readwrite.c:1.11 src/sys/fs/udf/udf_readwrite.c:1.12
--- src/sys/fs/udf/udf_readwrite.c:1.11	Sun Jun 12 03:35:55 2011
+++ src/sys/fs/udf/udf_readwrite.c	Tue May 24 09:55:57 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_readwrite.c,v 1.11 2011/06/12 03:35:55 rmind Exp $ */
+/* $NetBSD: udf_readwrite.c,v 1.12 2016/05/24 09:55:57 reinoud Exp $ */
 
 /*
  * Copyright (c) 2007, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_readwrite.c,v 1.11 2011/06/12 03:35:55 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_readwrite.c,v 1.12 2016/05/24 09:55:57 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -696,6 +696,19 @@ udf_discstrat_queuebuf(struct udf_mount 
 
 
 void
+udf_synchronise_caches(struct udf_mount *ump)
+{
+	struct udf_strategy *strategy = ump->strategy;
+	struct udf_strat_args args;
+
+	KASSERT(strategy);
+	args.ump = ump;
+
+	(strategy->sync_caches)();
+}
+
+
+void
 udf_discstrat_init(struct udf_mount *ump)
 {
 	struct udf_strategy *strategy = ump->strategy;

Index: src/sys/fs/udf/udf_strat_bootstrap.c
diff -u src/sys/fs/udf/udf_strat_bootstrap.c:1.4 src/sys/fs/udf/udf_strat_bootstrap.c:1.5
--- src/sys/fs/udf/udf_strat_bootstrap.c:1.4	Mon Nov 10 18:46:33 2014
+++ src/sys/fs/udf/udf_strat_bootstrap.c	Tue May 24 09:55:57 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_bootstrap.c,v 1.4 2014/11/10 18:46:33 maxv Exp $ */
+/* $NetBSD: udf_strat_bootstrap.c,v 1.5 2016/05/24 09:55:57 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_bootstrap.c,v 1.4 2014/11/10 18:46:33 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_bootstrap.c,v 1.5 2016/05/24 09:55:57 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -115,6 +115,14 @@ udf_queuebuf_bootstrap(struct udf_strat_
 	VOP_STRATEGY(ump->devvp, buf);
 }
 
+
+static void
+udf_sync_caches_bootstrap(struct udf_strat_args *args)
+{
+	/* empty */
+}
+
+
 static void
 udf_discstrat_init_bootstrap(struct udf_strat_args *args)
 {
@@ -137,6 +145,7 @@ struct udf_strategy udf_strat_bootstrap 
 	udf_read_logvol_dscr_bootstrap,
 	udf_write_logvol_dscr_bootstrap,
 	udf_queuebuf_bootstrap,
+	udf_sync_caches_bootstrap,
 	udf_discstrat_init_bootstrap,
 	udf_discstrat_finish_bootstrap
 };

Index: src/sys/fs/udf/udf_strat_direct.c
diff -u src/sys/fs/udf/udf_strat_direct.c:1.13 src/sys/fs/udf/udf_strat_direct.c:1.14
--- src/sys/fs/udf/udf_strat_direct.c:1.13	Tue Oct  6 08:57:34 2015
+++ src/sys/fs/udf/udf_strat_direct.c	Tue May 24 09:55:57 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_direct.c,v 1.13 2015/10/06 08:57:34 hannken Exp $ */
+/* $NetBSD: udf_strat_direct.c,v 1.14 2016/05/24 09:55:57 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 

CVS commit: src/sys/fs/udf

2016-05-10 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue May 10 15:23:39 UTC 2016

Modified Files:
src/sys/fs/udf: udf.h udf_subr.c

Log Message:
Rework VAT searching on recordable media. It is now a lot more resilliant to
errors and it allows for VAT searching on crashed writeouts.

While here, make sure the node pointer is always initialised in
udf_get_node().


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.136 -r1.137 src/sys/fs/udf/udf_subr.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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.50 src/sys/fs/udf/udf.h:1.51
--- src/sys/fs/udf/udf.h:1.50	Mon Aug 24 08:31:56 2015
+++ src/sys/fs/udf/udf.h	Tue May 10 15:23:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.50 2015/08/24 08:31:56 hannken Exp $ */
+/* $NetBSD: udf.h,v 1.51 2016/05/10 15:23:39 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -417,11 +417,12 @@ struct udf_node {
 #define	IN_SYNCED		0x0200	/* node is being used by sync */
 #define	IN_CALLBACK_ULK		0x0400	/* node will be unlocked by callback */
 #define	IN_NODE_REBUILD		0x0800	/* node is rebuild */
+#define IN_NO_DELETE		0x1000	/* node is not to be deleted */
 
 
 #define IN_FLAGBITS \
 	"\10\1IN_ACCESS\2IN_CHANGE\3IN_UPDATE\4IN_MODIFY\5IN_MODIFIED" \
 	"\6IN_ACCESSED\7IN_RENAME\10IN_DELETED\11IN_LOCKED\12IN_SYNCED" \
-	"\13IN_CALLBACK_ULK\14IN_NODE_REBUILD"
+	"\13IN_CALLBACK_ULK\14IN_NODE_REBUILD\15IN_NO_DELETE"
 
 #endif /* !_FS_UDF_UDF_H_ */

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.136 src/sys/fs/udf/udf_subr.c:1.137
--- src/sys/fs/udf/udf_subr.c:1.136	Wed Jan 27 00:06:49 2016
+++ src/sys/fs/udf/udf_subr.c	Tue May 10 15:23:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.136 2016/01/27 00:06:49 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.137 2016/05/10 15:23:39 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.136 2016/01/27 00:06:49 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.137 2016/05/10 15:23:39 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -946,7 +946,7 @@ udf_read_anchors(struct udf_mount *ump)
 
 	/* VATs are only recorded on sequential media, but initialise */
 	ump->first_possible_vat_location = track_start + 2;
-	ump->last_possible_vat_location  = track_end + last_track.packet_size;
+	ump->last_possible_vat_location  = track_end;
 
 	return ok;
 }
@@ -2995,6 +2995,10 @@ udf_check_for_vat(struct udf_node *vat_n
 	ump->logvol_integrity->integrity_type = udf_rw32(UDF_INTEGRITY_CLOSED);
 	ump->logvol_integrity->time   = *mtime;
 
+	/* if we're updating, free old allocated space */
+	if (ump->vat_table)
+		free(ump->vat_table, M_UDFVOLD);
+
 	ump->vat_table_len = vat_length;
 	ump->vat_table_alloc_len = vat_table_alloc_len;
 	ump->vat_table   = vat_table;
@@ -3017,49 +3021,70 @@ out:
 static int
 udf_search_vat(struct udf_mount *ump, union udf_pmap *mapping)
 {
-	struct udf_node *vat_node;
+	struct udf_node *vat_node, *accepted_vat_node;
 	struct long_ad	 icb_loc;
-	uint32_t early_vat_loc, vat_loc;
+	uint32_t early_vat_loc, late_vat_loc, vat_loc;
 	int error;
 
 	/* mapping info not needed */
 	mapping = mapping;
 
-	vat_loc = ump->last_possible_vat_location;
-	early_vat_loc = vat_loc - 256;	/* 8 blocks of 32 sectors */
-
-	DPRINTF(VOLUMES, ("1) last possible %d, early_vat_loc %d \n",
-		vat_loc, early_vat_loc));
-	early_vat_loc = MAX(early_vat_loc, ump->first_possible_vat_location);
-
-	DPRINTF(VOLUMES, ("2) last possible %d, early_vat_loc %d \n",
-		vat_loc, early_vat_loc));
-
-	/* start looking from the end of the range */
+	DPRINTF(VOLUMES, ("Searching VAT\n"));
+	
+	/*
+	 * Start reading forward in blocks from the first possible vat
+	 * location. If not found in this block, start again a bit before
+	 * until we get a hit.
+	 */
+	late_vat_loc = ump->last_possible_vat_location;
+	early_vat_loc = MAX(late_vat_loc - 64, ump->first_possible_vat_location);
+ 
+	DPRINTF(VOLUMES, ("\tfull range %d to %d\n", early_vat_loc, late_vat_loc));
+	accepted_vat_node = NULL;
 	do {
-		DPRINTF(VOLUMES, ("Checking for VAT at sector %d\n", vat_loc));
-		icb_loc.loc.part_num = udf_rw16(UDF_VTOP_RAWPART);
-		icb_loc.loc.lb_num   = udf_rw32(vat_loc);
+		vat_loc = early_vat_loc;
+		DPRINTF(VOLUMES, ("\tchecking range %d to %d\n",
+			early_vat_loc, late_vat_loc));
+		do {
+			DPRINTF(VOLUMES, ("\t\tChecking for VAT at sector %d\n",
+vat_loc));
+			icb_loc.loc.part_num = udf_rw16(UDF_VTOP_RAWPART);
+			icb_loc.loc.lb_num   = udf_rw32(vat_loc);
 
-		error = udf_get_node(ump, _loc, _node);
-		if (!error) {
-			error = udf_check_for_vat(vat_node);
-			DPRINTFIF(VOLUMES, !error,
-("VAT accepted at %d\n", vat_loc));
-			if (!error)
-break;
-		}
-		if (vat_node) {
-			vput(vat_node->vnode);
-			

CVS commit: src/sys/fs/udf

2016-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 29 10:42:30 UTC 2016

Modified Files:
src/sys/fs/udf: udf_vfsops.c

Log Message:
It is meaningless to check the root node if there was an error.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/fs/udf/udf_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/fs/udf/udf_vfsops.c
diff -u src/sys/fs/udf/udf_vfsops.c:1.71 src/sys/fs/udf/udf_vfsops.c:1.72
--- src/sys/fs/udf/udf_vfsops.c:1.71	Mon Aug 24 04:31:56 2015
+++ src/sys/fs/udf/udf_vfsops.c	Fri Jan 29 05:42:30 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vfsops.c,v 1.71 2015/08/24 08:31:56 hannken Exp $ */
+/* $NetBSD: udf_vfsops.c,v 1.72 2016/01/29 10:42:30 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.71 2015/08/24 08:31:56 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.72 2016/01/29 10:42:30 christos Exp $");
 #endif /* not lint */
 
 
@@ -756,11 +756,12 @@ udf_root(struct mount *mp, struct vnode 
 	dir_loc = >fileset_desc->rootdir_icb;
 	error = udf_get_node(ump, dir_loc, _dir);
 
-	if (!root_dir)
-		error = ENOENT;
 	if (error)
 		return error;
 
+	if (!root_dir)
+		error = ENOENT;
+
 	vp = root_dir->vnode;
 	KASSERT(vp->v_vflag & VV_ROOT);
 



CVS commit: src/sys/fs/udf

2016-01-26 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jan 27 00:06:49 UTC 2016

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Fix filename creation and deleting with illegal file names. UDF has a
machanism for it but it allowed to create a file with a name it considered
illegal that then couldn't be deleted with the same name.

Fixes PR kern/50608. When confirmed, it can be closed.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.135 src/sys/fs/udf/udf_subr.c:1.136
--- src/sys/fs/udf/udf_subr.c:1.135	Sat Dec 19 03:16:09 2015
+++ src/sys/fs/udf/udf_subr.c	Wed Jan 27 00:06:49 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.135 2015/12/19 03:16:09 dholland Exp $ */
+/* $NetBSD: udf_subr.c,v 1.136 2016/01/27 00:06:49 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.135 2015/12/19 03:16:09 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.136 2016/01/27 00:06:49 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -4486,7 +4486,8 @@ udf_lookup_name_in_dir(struct vnode *vp,
 	struct dirhash   *dirh;
 	struct dirhash_entry *dirh_ep;
 	struct fileid_desc *fid;
-	struct dirent *dirent;
+	struct dirent *dirent, *s_dirent;
+	struct charspec osta_charspec;
 	uint64_t diroffset;
 	uint32_t lb_size;
 	int hit, error;
@@ -4504,18 +4505,28 @@ udf_lookup_name_in_dir(struct vnode *vp,
 	dirh = dir_node->dir_hash;
 
 	/* allocate temporary space for fid */
-	lb_size = udf_rw32(dir_node->ump->logical_vol->lb_size);
-	fid = malloc(lb_size, M_UDFTEMP, M_WAITOK);
-	dirent  = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK);
+	lb_size  = udf_rw32(dir_node->ump->logical_vol->lb_size);
+	fid  = malloc(lb_size, M_UDFTEMP, M_WAITOK);
+	dirent   = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK);
+	s_dirent = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK);
 
 	DPRINTF(DIRHASH, ("dirhash_lookup looking for `%*.*s`\n",
 		namelen, namelen, name));
 
+	/* convert given unix name to canonical unix name */
+	udf_osta_charset(_charspec);
+	unix_to_udf_name((char *) fid->data, >l_fi,
+		name, namelen, _charspec);
+	udf_to_unix_name(s_dirent->d_name, NAME_MAX,
+		(char *) fid->data, fid->l_fi,
+		_charspec);
+	s_dirent->d_namlen = strlen(s_dirent->d_name);
+
 	/* search our dirhash hits */
 	memset(icb_loc, 0, sizeof(*icb_loc));
 	dirh_ep = NULL;
 	for (;;) {
-		hit = dirhash_lookup(dirh, name, namelen, _ep);
+		hit = dirhash_lookup(dirh, s_dirent->d_name, s_dirent->d_namlen, _ep);
 		/* if no hit, abort the search */
 		if (!hit)
 			break;
@@ -4532,16 +4543,7 @@ udf_lookup_name_in_dir(struct vnode *vp,
 			dirent->d_namlen, dirent->d_namlen, dirent->d_name));
 
 		/* see if its our entry */
-#ifdef DIAGNOSTIC
-		if (dirent->d_namlen != namelen) {
-			printf("WARNING: dirhash_lookup() returned wrong "
-"d_namelen: %d and ought to be %d\n",
-dirent->d_namlen, namelen);
-			printf("\tlooked for `%s' and got `%s'\n",
-name, dirent->d_name);
-		}
-#endif
-		if (strncmp(dirent->d_name, name, namelen) == 0) {
+		if (strncmp(dirent->d_name, s_dirent->d_name, s_dirent->d_namlen) == 0) {
 			*found = 1;
 			*icb_loc = fid->icb;
 			break;
@@ -4549,6 +4551,7 @@ udf_lookup_name_in_dir(struct vnode *vp,
 	}
 	free(fid, M_UDFTEMP);
 	free(dirent, M_UDFTEMP);
+	free(s_dirent, M_UDFTEMP);
 
 	dirhash_put(dir_node->dir_hash);
 
@@ -4718,12 +4721,11 @@ udf_dir_detach(struct udf_mount *ump, st
 	struct dirhash_entry *dirh_ep;
 	struct file_entry*fe  = dir_node->fe;
 	struct fileid_desc *fid;
-	struct dirent *dirent;
+	struct dirent *dirent, *s_dirent;
+	struct charspec osta_charspec;
 	uint64_t diroffset;
 	uint32_t lb_size, fidsize;
 	int found, error;
-	char const *name  = cnp->cn_nameptr;
-	int namelen = cnp->cn_namelen;
 	int hit, refcnt;
 
 	/* get our dirhash and make sure its read in */
@@ -4740,16 +4742,26 @@ udf_dir_detach(struct udf_mount *ump, st
 		assert(dir_node->efe);
 	}
 
-	/* allocate temporary space for fid */
-	lb_size = udf_rw32(dir_node->ump->logical_vol->lb_size);
-	fid = malloc(lb_size, M_UDFTEMP, M_WAITOK);
-	dirent  = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK);
+	/* allocate temporary space for fid and dirents */
+	lb_size  = udf_rw32(dir_node->ump->logical_vol->lb_size);
+	fid  = malloc(lb_size, M_UDFTEMP, M_WAITOK);
+	dirent   = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK);
+	s_dirent = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK);
+
+	/* convert given unix name to canonical unix name */
+	udf_osta_charset(_charspec);
+	unix_to_udf_name((char *) fid->data, >l_fi,
+		cnp->cn_nameptr, cnp->cn_namelen, _charspec);
+	udf_to_unix_name(s_dirent->d_name, NAME_MAX,
+		(char *) fid->data, 

CVS commit: src/sys/fs/udf

2015-12-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 19 01:51:42 UTC 2015

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
add missing ,


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.133 src/sys/fs/udf/udf_subr.c:1.134
--- src/sys/fs/udf/udf_subr.c:1.133	Fri Dec 18 20:18:00 2015
+++ src/sys/fs/udf/udf_subr.c	Fri Dec 18 20:51:42 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.133 2015/12/19 01:18:00 christos Exp $ */
+/* $NetBSD: udf_subr.c,v 1.134 2015/12/19 01:51:42 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.133 2015/12/19 01:18:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.134 2015/12/19 01:51:42 christos Exp $");
 #endif /* not lint */
 
 
@@ -6463,7 +6463,7 @@ udf_read_internal(struct udf_node *node,
 
 	/* copy out info */
 	memcpy(blob, pos, inflen);
-	memset([inflen] 0, sector_size - inflen);
+	memset([inflen], 0, sector_size - inflen);
 
 	return 0;
 }



CVS commit: src/sys/fs/udf

2015-12-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 19 01:18:00 UTC 2015

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
PR/50571: David Binderman: src/sys/fs/udf/udf_subr.c:6465: obvious
performance tidyup


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.132 src/sys/fs/udf/udf_subr.c:1.133
--- src/sys/fs/udf/udf_subr.c:1.132	Mon Aug 24 04:31:56 2015
+++ src/sys/fs/udf/udf_subr.c	Fri Dec 18 20:18:00 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.132 2015/08/24 08:31:56 hannken Exp $ */
+/* $NetBSD: udf_subr.c,v 1.133 2015/12/19 01:18:00 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.132 2015/08/24 08:31:56 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.133 2015/12/19 01:18:00 christos Exp $");
 #endif /* not lint */
 
 
@@ -6462,8 +6462,8 @@ udf_read_internal(struct udf_node *node,
 	assert(inflen < sector_size);
 
 	/* copy out info */
-	memset(blob, 0, sector_size);
 	memcpy(blob, pos, inflen);
+	memset([inflen] 0, sector_size - inflen);
 
 	return 0;
 }



CVS commit: src/sys/fs/udf

2015-12-18 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Dec 19 03:16:09 UTC 2015

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Improve misleading variable name. Related to PR 50571.

XXX: also there should be real bounds-check logic in here.
XXX: if the on-disk data structure contains rubbish this code will
XXX: leak or trample arbitrary kernel memory.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.134 src/sys/fs/udf/udf_subr.c:1.135
--- src/sys/fs/udf/udf_subr.c:1.134	Sat Dec 19 01:51:42 2015
+++ src/sys/fs/udf/udf_subr.c	Sat Dec 19 03:16:09 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.134 2015/12/19 01:51:42 christos Exp $ */
+/* $NetBSD: udf_subr.c,v 1.135 2015/12/19 03:16:09 dholland Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.134 2015/12/19 01:51:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.135 2015/12/19 03:16:09 dholland Exp $");
 #endif /* not lint */
 
 
@@ -6438,21 +6438,26 @@ udf_read_internal(struct udf_node *node,
 	struct extfile_entry *efe = node->efe;
 	uint64_t inflen;
 	uint32_t sector_size;
-	uint8_t  *pos;
+	uint8_t  *srcpos;
 	int icbflags, addr_type;
 
 	/* get extent and do some paranoia checks */
 	ump = node->ump;
 	sector_size = ump->discinfo.sector_size;
 
+	/*
+	 * XXX there should be real bounds-checking logic here,
+	 * in case ->l_ea or ->inf_len contains nonsense.
+	 */
+
 	if (fe) {
 		inflen   = udf_rw64(fe->inf_len);
-		pos  = >data[0] + udf_rw32(fe->l_ea);
+		srcpos   = >data[0] + udf_rw32(fe->l_ea);
 		icbflags = udf_rw16(fe->icbtag.flags);
 	} else {
 		assert(node->efe);
 		inflen   = udf_rw64(efe->inf_len);
-		pos  = >data[0] + udf_rw32(efe->l_ea);
+		srcpos   = >data[0] + udf_rw32(efe->l_ea);
 		icbflags = udf_rw16(efe->icbtag.flags);
 	}
 	addr_type = icbflags & UDF_ICB_TAG_FLAGS_ALLOC_MASK;
@@ -6462,7 +6467,7 @@ udf_read_internal(struct udf_node *node,
 	assert(inflen < sector_size);
 
 	/* copy out info */
-	memcpy(blob, pos, inflen);
+	memcpy(blob, srcpos, inflen);
 	memset([inflen], 0, sector_size - inflen);
 
 	return 0;



CVS commit: src/sys/fs/udf

2015-10-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Oct  6 08:57:34 UTC 2015

Modified Files:
src/sys/fs/udf: udf_strat_direct.c udf_strat_rmw.c
udf_strat_sequential.c

Log Message:
Remove dubious vhold()/holdrele() from write_logvol_dscr strategies.

The udf_node already gets locked with UDF_LOCK_NODE() and udf_reclaim()
will wait for the lock to clear.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/fs/udf/udf_strat_direct.c
cvs rdiff -u -r1.26 -r1.27 src/sys/fs/udf/udf_strat_rmw.c
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/udf/udf_strat_sequential.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/fs/udf/udf_strat_direct.c
diff -u src/sys/fs/udf/udf_strat_direct.c:1.12 src/sys/fs/udf/udf_strat_direct.c:1.13
--- src/sys/fs/udf/udf_strat_direct.c:1.12	Wed Oct 30 08:41:38 2013
+++ src/sys/fs/udf/udf_strat_direct.c	Tue Oct  6 08:57:34 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_direct.c,v 1.12 2013/10/30 08:41:38 mrg Exp $ */
+/* $NetBSD: udf_strat_direct.c,v 1.13 2015/10/06 08:57:34 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_direct.c,v 1.12 2013/10/30 08:41:38 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_direct.c,v 1.13 2015/10/06 08:57:34 hannken Exp $");
 #endif /* not lint */
 
 
@@ -118,8 +118,6 @@ udf_wr_nodedscr_callback(struct buf *buf
 		UDF_UNLOCK_NODE(udf_node, 0);
 		wakeup(_node->outstanding_nodedscr);
 	}
-	/* unreference the vnode so it can be recycled */
-	holdrele(udf_node->vnode);
 
 	putiobuf(buf);
 }
@@ -208,9 +206,6 @@ udf_write_nodedscr_direct(struct udf_str
 	if (error)
 		goto out;
 
-	/* add reference to the vnode to prevent recycling */
-	vhold(udf_node->vnode);
-
 	if (waitfor) {
 		DPRINTF(WRITE, ("udf_write_nodedscr: sync write\n"));
 
@@ -224,8 +219,6 @@ udf_write_nodedscr_direct(struct udf_str
 		/* will be UNLOCKED in call back */
 		return error;
 	}
-
-	holdrele(udf_node->vnode);
 out:
 	udf_node->outstanding_nodedscr--;
 	if (udf_node->outstanding_nodedscr == 0) {

Index: src/sys/fs/udf/udf_strat_rmw.c
diff -u src/sys/fs/udf/udf_strat_rmw.c:1.26 src/sys/fs/udf/udf_strat_rmw.c:1.27
--- src/sys/fs/udf/udf_strat_rmw.c:1.26	Sat Sep 12 19:50:08 2015
+++ src/sys/fs/udf/udf_strat_rmw.c	Tue Oct  6 08:57:34 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_rmw.c,v 1.26 2015/09/12 19:50:08 christos Exp $ */
+/* $NetBSD: udf_strat_rmw.c,v 1.27 2015/10/06 08:57:34 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.26 2015/09/12 19:50:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.27 2015/10/06 08:57:34 hannken Exp $");
 #endif /* not lint */
 
 
@@ -719,9 +719,6 @@ udf_write_nodedscr_rmw(struct udf_strat_
 	if (error)
 		return error;
 
-	/* paranoia: add reference to the vnode to prevent recycling */
-	vhold(udf_node->vnode);
-
 	/* get our eccline */
 	eccline = udf_geteccline(ump, sectornr, 0);
 	eccsect = sectornr - eccline->start_sector;
@@ -761,7 +758,6 @@ udf_write_nodedscr_rmw(struct udf_strat_
 		UDF_UNLOCK_NODE(udf_node, 0);
 		wakeup(_node->outstanding_nodedscr);
 	}
-	holdrele(udf_node->vnode);
 	udf_puteccline(eccline);
 
 	/* XXX waitfor not used */

Index: src/sys/fs/udf/udf_strat_sequential.c
diff -u src/sys/fs/udf/udf_strat_sequential.c:1.13 src/sys/fs/udf/udf_strat_sequential.c:1.14
--- src/sys/fs/udf/udf_strat_sequential.c:1.13	Sun Mar 23 09:34:42 2014
+++ src/sys/fs/udf/udf_strat_sequential.c	Tue Oct  6 08:57:34 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_sequential.c,v 1.13 2014/03/23 09:34:42 christos Exp $ */
+/* $NetBSD: udf_strat_sequential.c,v 1.14 2015/10/06 08:57:34 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_sequential.c,v 1.13 2014/03/23 09:34:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_sequential.c,v 1.14 2015/10/06 08:57:34 hannken Exp $");
 #endif /* not lint */
 
 
@@ -129,9 +129,6 @@ udf_wr_nodedscr_callback(struct buf *buf
 		wakeup(_node->outstanding_nodedscr);
 	}
 
-	/* unreference the vnode so it can be recycled */
-	holdrele(udf_node->vnode);
-
 	putiobuf(buf);
 }
 
@@ -219,9 +216,6 @@ udf_write_logvol_dscr_seq(struct udf_str
 			goto out;
 	}
 
-	/* add reference to the vnode to prevent recycling */
-	vhold(udf_node->vnode);
-
 	if (waitfor) {
 		DPRINTF(WRITE, ("udf_write_logvol_dscr: sync write\n"));
 
@@ -235,8 +229,6 @@ udf_write_logvol_dscr_seq(struct udf_str
 		/* will be UNLOCKED in call back */
 		return error;
 	}
-
-	holdrele(udf_node->vnode);
 out:
 	udf_node->outstanding_nodedscr--;
 	if (udf_node->outstanding_nodedscr == 0) {



CVS commit: src/sys/fs/udf

2015-09-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep 12 19:33:03 UTC 2015

Modified Files:
src/sys/fs/udf: udf_strat_rmw.c

Log Message:
remove identity assignment, found by brainy.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/fs/udf/udf_strat_rmw.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/fs/udf/udf_strat_rmw.c
diff -u src/sys/fs/udf/udf_strat_rmw.c:1.24 src/sys/fs/udf/udf_strat_rmw.c:1.25
--- src/sys/fs/udf/udf_strat_rmw.c:1.24	Wed Oct 30 04:41:38 2013
+++ src/sys/fs/udf/udf_strat_rmw.c	Sat Sep 12 15:33:03 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_rmw.c,v 1.24 2013/10/30 08:41:38 mrg Exp $ */
+/* $NetBSD: udf_strat_rmw.c,v 1.25 2015/09/12 19:33:03 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.24 2013/10/30 08:41:38 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.25 2015/09/12 19:33:03 christos Exp $");
 #endif /* not lint */
 
 
@@ -619,7 +619,6 @@ udf_read_nodedscr_rmw(struct udf_strat_a
 	int lb_size = udf_rw32(ump->logical_vol->lb_size);
 	int i, error, dscrlen, eccsect;
 
-	lb_size = lb_size;
 	KASSERT(sector_size == lb_size);
 	error = udf_translate_vtop(ump, icb, , );
 	if (error)
@@ -714,7 +713,6 @@ udf_write_nodedscr_rmw(struct udf_strat_
 	int lb_size = udf_rw32(ump->logical_vol->lb_size);
 	int error, eccsect;
 
-	lb_size = lb_size;
 	KASSERT(sector_size == lb_size);
 	sectornr= 0;
 	error = udf_translate_vtop(ump, icb, , );



CVS commit: src/sys/fs/udf

2015-09-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep 12 19:50:08 UTC 2015

Modified Files:
src/sys/fs/udf: udf_strat_rmw.c

Log Message:
diagused some variables.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/fs/udf/udf_strat_rmw.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/fs/udf/udf_strat_rmw.c
diff -u src/sys/fs/udf/udf_strat_rmw.c:1.25 src/sys/fs/udf/udf_strat_rmw.c:1.26
--- src/sys/fs/udf/udf_strat_rmw.c:1.25	Sat Sep 12 15:33:03 2015
+++ src/sys/fs/udf/udf_strat_rmw.c	Sat Sep 12 15:50:08 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_rmw.c,v 1.25 2015/09/12 19:33:03 christos Exp $ */
+/* $NetBSD: udf_strat_rmw.c,v 1.26 2015/09/12 19:50:08 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.25 2015/09/12 19:33:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.26 2015/09/12 19:50:08 christos Exp $");
 #endif /* not lint */
 
 
@@ -616,7 +616,7 @@ udf_read_nodedscr_rmw(struct udf_strat_a
 	uint32_t sectornr, dummy;
 	uint8_t *pos;
 	int sector_size = ump->discinfo.sector_size;
-	int lb_size = udf_rw32(ump->logical_vol->lb_size);
+	int lb_size __diagused = udf_rw32(ump->logical_vol->lb_size);
 	int i, error, dscrlen, eccsect;
 
 	KASSERT(sector_size == lb_size);
@@ -710,7 +710,7 @@ udf_write_nodedscr_rmw(struct udf_strat_
 	uint32_t sectornr, logsectornr, dummy;
 	// int waitfor  = args->waitfor;
 	int sector_size = ump->discinfo.sector_size;
-	int lb_size = udf_rw32(ump->logical_vol->lb_size);
+	int lb_size __diagused = udf_rw32(ump->logical_vol->lb_size);
 	int error, eccsect;
 
 	KASSERT(sector_size == lb_size);



CVS commit: src/sys/fs/udf

2015-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 24 08:31:56 UTC 2015

Modified Files:
src/sys/fs/udf: udf.h udf_subr.c udf_vfsops.c

Log Message:
Use vfs_vnode_iterator for udf_do_sync.

- Build rb_tree to get an ordered list of nodes, sync them and
  clean the tree.

- Stop abusing mntvnode_lock to serialize udf_do_sync, use new
  mutex ump-sync_lock instead.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.131 -r1.132 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.70 -r1.71 src/sys/fs/udf/udf_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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.49 src/sys/fs/udf/udf.h:1.50
--- src/sys/fs/udf/udf.h:1.49	Mon Aug 24 08:30:17 2015
+++ src/sys/fs/udf/udf.h	Mon Aug 24 08:31:56 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.49 2015/08/24 08:30:17 hannken Exp $ */
+/* $NetBSD: udf.h,v 1.50 2015/08/24 08:31:56 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -339,11 +339,11 @@ struct udf_mount {
 	uint8_t			 metadata_flags;
 
 	/* rb tree for lookup icb to udf_node and sorted list for sync */
-	kmutex_t	ihash_lock;
 	struct rb_tree	udf_node_tree;
 
 	/* syncing */
 	int		syncing;			/* are we syncing?   */
+	kmutex_t	sync_lock;			/* serialize syncing */
 
 	/* late allocation */
 	int32_t			 uncommitted_lbs[UDF_PARTITIONS];

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.131 src/sys/fs/udf/udf_subr.c:1.132
--- src/sys/fs/udf/udf_subr.c:1.131	Mon Aug 24 08:30:17 2015
+++ src/sys/fs/udf/udf_subr.c	Mon Aug 24 08:31:56 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.131 2015/08/24 08:30:17 hannken Exp $ */
+/* $NetBSD: udf_subr.c,v 1.132 2015/08/24 08:31:56 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.131 2015/08/24 08:30:17 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.132 2015/08/24 08:31:56 hannken Exp $);
 #endif /* not lint */
 
 
@@ -3444,29 +3444,6 @@ udf_init_nodes_tree(struct udf_mount *um
 }
 
 
-static void
-udf_register_node(struct udf_node *udf_node)
-{
-	struct udf_mount *ump = udf_node-ump;
-
-	/* add node to the rb tree */
-	mutex_enter(ump-ihash_lock);
-	rb_tree_insert_node(ump-udf_node_tree, udf_node);
-	mutex_exit(ump-ihash_lock);
-}
-
-
-static void
-udf_deregister_node(struct udf_node *udf_node) 
-{
-	struct udf_mount *ump = udf_node-ump;
-
-	/* remove node from the rb tree */
-	mutex_enter(ump-ihash_lock);
-	rb_tree_remove_node(ump-udf_node_tree, udf_node);
-	mutex_exit(ump-ihash_lock);
-}
-
 /* - */
 
 static int
@@ -5310,9 +5287,6 @@ udf_loadvnode(struct mount *mp, struct v
 		sizeof(struct long_ad)) == 0)
 			vp-v_vflag |= VV_ROOT;
 
-	/* insert into the hash lookup */
-	udf_register_node(udf_node);
-
 	icb_loc = node_icb_loc;
 	needs_indirect = 0;
 	strat4096 = 0;
@@ -5681,16 +5655,15 @@ udf_dispose_node(struct udf_node *udf_no
 	/* remove dirhash if present */
 	dirhash_purge(udf_node-dir_hash);
 
-	/* remove from our hash lookup table */
-	udf_deregister_node(udf_node);
-
 	/* destroy our lock */
 	mutex_destroy(udf_node-node_mutex);
 	cv_destroy(udf_node-node_lock);
 
 	/* dissociate our udf_node from the vnode */
 	genfs_node_destroy(udf_node-vnode);
+	mutex_enter(vp-v_interlock);
 	vp-v_data = NULL;
+	mutex_exit(vp-v_interlock);
 
 	/* free associated memory and the node itself */
 	for (extnr = 0; extnr  udf_node-num_extensions; extnr++) {
@@ -5828,9 +5801,6 @@ udf_newvnode(struct mount *mp, struct vn
 	/* initialise genfs */
 	genfs_node_init(vp, udf_genfsops);
 
-	/* insert into the hash lookup */
-	udf_register_node(udf_node);
-
 	/* get parent's unique ID for refering '..' if its a directory */
 	if (dir_node-fe) {
 		parent_unique_id = udf_rw64(dir_node-fe-unique_id);
@@ -6316,64 +6286,27 @@ brokendir:
 /* - */
 
 static void
-udf_sync_pass(struct udf_mount *ump, kauth_cred_t cred, int waitfor,
-	int pass, int *ndirty)
+udf_sync_pass(struct udf_mount *ump, kauth_cred_t cred, int pass, int *ndirty)
 {
 	struct udf_node *udf_node, *n_udf_node;
 	struct vnode *vp;
 	int vdirty, error;
-	int on_type, on_flags, on_vnode;
 
-derailed:
-	KASSERT(mutex_owned(mntvnode_lock));
+	KASSERT(mutex_owned(ump-sync_lock));
 
 	DPRINTF(SYNC, (sync_pass %d\n, pass));
 	udf_node = RB_TREE_MIN(ump-udf_node_tree);
 	for (;udf_node; udf_node = n_udf_node) {
 		DPRINTF(SYNC, (.));
 
-		udf_node-i_flags = ~IN_SYNCED;
 		vp = udf_node-vnode;
 
-		mutex_enter(vp-v_interlock);
 		n_udf_node = rb_tree_iterate(ump-udf_node_tree,
 		udf_node, RB_DIR_RIGHT);
 
-		if (n_udf_node)
-			n_udf_node-i_flags |= IN_SYNCED;
-
-		/* system nodes are not synced this way */
-		if (vp-v_vflag  

CVS commit: src/sys/fs/udf

2015-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 24 08:30:17 UTC 2015

Modified Files:
src/sys/fs/udf: udf.h udf_allocation.c udf_subr.c udf_vfsops.c

Log Message:
Remove dirtynodes_cv, it is only used for timed waits without any signals.

Replace the cv_timedwait with kpause.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.37 -r1.38 src/sys/fs/udf/udf_allocation.c
cvs rdiff -u -r1.130 -r1.131 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.68 -r1.69 src/sys/fs/udf/udf_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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.48 src/sys/fs/udf/udf.h:1.49
--- src/sys/fs/udf/udf.h:1.48	Mon Apr  6 08:39:23 2015
+++ src/sys/fs/udf/udf.h	Mon Aug 24 08:30:17 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.48 2015/04/06 08:39:23 hannken Exp $ */
+/* $NetBSD: udf.h,v 1.49 2015/08/24 08:30:17 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -344,7 +344,6 @@ struct udf_mount {
 
 	/* syncing */
 	int		syncing;			/* are we syncing?   */
-	kcondvar_t 	dirtynodes_cv;			/* sleeping on sync  */
 
 	/* late allocation */
 	int32_t			 uncommitted_lbs[UDF_PARTITIONS];

Index: src/sys/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.37 src/sys/fs/udf/udf_allocation.c:1.38
--- src/sys/fs/udf/udf_allocation.c:1.37	Wed Dec  3 21:34:55 2014
+++ src/sys/fs/udf/udf_allocation.c	Mon Aug 24 08:30:17 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.37 2014/12/03 21:34:55 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.38 2015/08/24 08:30:17 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.37 2014/12/03 21:34:55 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.38 2015/08/24 08:30:17 hannken Exp $);
 #endif /* not lint */
 
 
@@ -1084,11 +1084,8 @@ udf_reserve_space(struct udf_mount *ump,
 		DPRINTF(RESERVE, (udf_reserve_space: issuing sync\n));
 		mutex_exit(ump-allocate_mutex);
 		udf_do_sync(ump, FSCRED, 0);
-		mutex_enter(mntvnode_lock);
 		/* 1/8 second wait */
-		cv_timedwait(ump-dirtynodes_cv, mntvnode_lock,
-			hz/8);
-		mutex_exit(mntvnode_lock);
+		kpause(udfsync2, false, hz/8, NULL);
 		mutex_enter(ump-allocate_mutex);
 	}
 

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.130 src/sys/fs/udf/udf_subr.c:1.131
--- src/sys/fs/udf/udf_subr.c:1.130	Mon Apr 20 13:44:16 2015
+++ src/sys/fs/udf/udf_subr.c	Mon Aug 24 08:30:17 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.130 2015/04/20 13:44:16 riastradh Exp $ */
+/* $NetBSD: udf_subr.c,v 1.131 2015/08/24 08:30:17 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.130 2015/04/20 13:44:16 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.131 2015/08/24 08:30:17 hannken Exp $);
 #endif /* not lint */
 
 
@@ -6433,8 +6433,7 @@ recount:
 	
 		if (ndirty) {
 			/* 1/4 second wait */
-			cv_timedwait(ump-dirtynodes_cv, mntvnode_lock,
-hz/4);
+			kpause(udfsync2, false, hz/4, NULL);
 			goto recount;
 		}
 	}

Index: src/sys/fs/udf/udf_vfsops.c
diff -u src/sys/fs/udf/udf_vfsops.c:1.68 src/sys/fs/udf/udf_vfsops.c:1.69
--- src/sys/fs/udf/udf_vfsops.c:1.68	Mon Apr  6 08:39:23 2015
+++ src/sys/fs/udf/udf_vfsops.c	Mon Aug 24 08:30:17 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vfsops.c,v 1.68 2015/04/06 08:39:23 hannken Exp $ */
+/* $NetBSD: udf_vfsops.c,v 1.69 2015/08/24 08:30:17 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vfsops.c,v 1.68 2015/04/06 08:39:23 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vfsops.c,v 1.69 2015/08/24 08:30:17 hannken Exp $);
 #endif /* not lint */
 
 
@@ -262,7 +262,6 @@ free_udf_mountinfo(struct mount *mp)
 		mutex_destroy(ump-ihash_lock);
 		mutex_destroy(ump-logvol_mutex);
 		mutex_destroy(ump-allocate_mutex);
-		cv_destroy(ump-dirtynodes_cv);
 
 		MPFREE(ump-vat_table, M_UDFVOLD);
 
@@ -583,7 +582,6 @@ udf_mountfs(struct vnode *devvp, struct 
 	mutex_init(ump-logvol_mutex, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(ump-ihash_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(ump-allocate_mutex, MUTEX_DEFAULT, IPL_NONE);
-	cv_init(ump-dirtynodes_cv, udfsync2);
 
 	/* init rbtree for nodes, ordered by their icb address (long_ad) */
 	udf_init_nodes_tree(ump);



CVS commit: src/sys/fs/udf

2015-08-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 24 08:30:52 UTC 2015

Modified Files:
src/sys/fs/udf: udf_vfsops.c

Log Message:
Use vfs_vnode_iterator for udf_unmount_sanity_check.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/fs/udf/udf_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/fs/udf/udf_vfsops.c
diff -u src/sys/fs/udf/udf_vfsops.c:1.69 src/sys/fs/udf/udf_vfsops.c:1.70
--- src/sys/fs/udf/udf_vfsops.c:1.69	Mon Aug 24 08:30:17 2015
+++ src/sys/fs/udf/udf_vfsops.c	Mon Aug 24 08:30:52 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vfsops.c,v 1.69 2015/08/24 08:30:17 hannken Exp $ */
+/* $NetBSD: udf_vfsops.c,v 1.70 2015/08/24 08:30:52 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vfsops.c,v 1.69 2015/08/24 08:30:17 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vfsops.c,v 1.70 2015/08/24 08:30:52 hannken Exp $);
 #endif /* not lint */
 
 
@@ -438,20 +438,28 @@ udf_mount(struct mount *mp, const char *
 /* - */
 
 #ifdef DEBUG
+static bool
+udf_sanity_selector(void *cl, struct vnode *vp)
+{
+
+	vprint(, vp);
+	if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) {
+		printf(  is locked\n);
+	}
+	if (vp-v_usecount  1)
+		printf(  more than one usecount %d\n, vp-v_usecount);
+	return false;
+}
+
 static void
 udf_unmount_sanity_check(struct mount *mp)
 {
-	struct vnode *vp;
+	struct vnode_iterator *marker;
 
 	printf(On unmount, i found the following nodes:\n);
-	TAILQ_FOREACH(vp, mp-mnt_vnodelist, v_mntvnodes) {
-		vprint(, vp);
-		if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) {
-			printf(  is locked\n);
-		}
-		if (vp-v_usecount  1)
-			printf(  more than one usecount %d\n, vp-v_usecount);
-	}
+	vfs_vnode_iterator_init(mp, marker);
+	vfs_vnode_iterator_next(marker, udf_sanity_selector, NULL);
+	vfs_vnode_iterator_destroy(marker);
 }
 #endif
 



CVS commit: src/sys/fs/udf

2015-04-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Apr  6 08:39:23 UTC 2015

Modified Files:
src/sys/fs/udf: udf.h udf_subr.c udf_vfsops.c udf_vnops.c

Log Message:
Change udf to vcache, keyed on udf_node-loc.loc.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.128 -r1.129 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.67 -r1.68 src/sys/fs/udf/udf_vfsops.c
cvs rdiff -u -r1.99 -r1.100 src/sys/fs/udf/udf_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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.47 src/sys/fs/udf/udf.h:1.48
--- src/sys/fs/udf/udf.h:1.47	Wed Sep 17 19:47:05 2014
+++ src/sys/fs/udf/udf.h	Mon Apr  6 08:39:23 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.47 2014/09/17 19:47:05 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.48 2015/04/06 08:39:23 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -94,6 +94,7 @@ extern int udf_verbose;
 #define DPRINTFIF(name, cond, arg) {}
 #endif
 
+VFS_PROTOS(udf);
 
 /* constants to identify what kind of identifier we are dealing with */
 #define UDF_REGID_DOMAIN		 1
@@ -339,7 +340,6 @@ struct udf_mount {
 
 	/* rb tree for lookup icb to udf_node and sorted list for sync */
 	kmutex_t	ihash_lock;
-	kmutex_t	get_node_lock;
 	struct rb_tree	udf_node_tree;
 
 	/* syncing */

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.128 src/sys/fs/udf/udf_subr.c:1.129
--- src/sys/fs/udf/udf_subr.c:1.128	Sat Feb  7 04:18:03 2015
+++ src/sys/fs/udf/udf_subr.c	Mon Apr  6 08:39:23 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.128 2015/02/07 04:18:03 christos Exp $ */
+/* $NetBSD: udf_subr.c,v 1.129 2015/04/06 08:39:23 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.128 2015/02/07 04:18:03 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.129 2015/04/06 08:39:23 hannken Exp $);
 #endif /* not lint */
 
 
@@ -3444,31 +3444,6 @@ udf_init_nodes_tree(struct udf_mount *um
 }
 
 
-static struct udf_node *
-udf_node_lookup(struct udf_mount *ump, struct long_ad *icbptr)
-{
-	struct udf_node *udf_node;
-	struct vnode *vp;
-
-loop:
-	mutex_enter(ump-ihash_lock);
-
-	udf_node = rb_tree_find_node(ump-udf_node_tree, icbptr);
-	if (udf_node) {
-		vp = udf_node-vnode;
-		assert(vp);
-		mutex_enter(vp-v_interlock);
-		mutex_exit(ump-ihash_lock);
-		if (vget(vp, LK_EXCLUSIVE))
-			goto loop;
-		return udf_node;
-	}
-	mutex_exit(ump-ihash_lock);
-
-	return NULL;
-}
-
-
 static void
 udf_register_node(struct udf_node *udf_node)
 {
@@ -5279,44 +5254,33 @@ error_out:
  */
 
 int
-udf_get_node(struct udf_mount *ump, struct long_ad *node_icb_loc,
-	 struct udf_node **udf_noderes)
+udf_loadvnode(struct mount *mp, struct vnode *vp,
+ const void *key, size_t key_len, const void **new_key)
 {
 	union dscrptr   *dscr;
+	struct udf_mount *ump;
 	struct udf_node *udf_node;
-	struct vnode*nvp;
-	struct long_ad   icb_loc, next_icb_loc, last_fe_icb_loc;
+	struct long_ad node_icb_loc, icb_loc, next_icb_loc, last_fe_icb_loc;
 	uint64_t file_size;
 	uint32_t lb_size, sector, dummy;
 	int udf_file_type, dscr_type, strat, strat4096, needs_indirect;
 	int slot, eof, error;
 	int num_indir_followed = 0;
 
-	DPRINTF(NODE, (udf_get_node called\n));
-	*udf_noderes = udf_node = NULL;
-
-	/* lock to disallow simultanious creation of same udf_node */
-	mutex_enter(ump-get_node_lock);
-
-	DPRINTF(NODE, (\tlookup in hash table\n));
-	/* lookup in hash table */
-	assert(ump);
-	assert(node_icb_loc);
-	udf_node = udf_node_lookup(ump, node_icb_loc);
-	if (udf_node) {
-		DPRINTF(NODE, (\tgot it from the hash!\n));
-		/* vnode is returned locked */
-		*udf_noderes = udf_node;
-		mutex_exit(ump-get_node_lock);
-		return 0;
-	}
+	DPRINTF(NODE, (udf_loadvnode called\n));
+	udf_node = NULL;
+	ump = VFSTOUDF(mp);
+
+	KASSERT(key_len == sizeof(node_icb_loc.loc));
+	memset(node_icb_loc, 0, sizeof(node_icb_loc));
+	node_icb_loc.len = ump-logical_vol-lb_size;
+	memcpy(node_icb_loc.loc, key, key_len);
 
 	/* garbage check: translate udf_node_icb_loc to sectornr */
-	error = udf_translate_vtop(ump, node_icb_loc, sector, dummy);
+	error = udf_translate_vtop(ump, node_icb_loc, sector, dummy);
 	if (error) {
 		DPRINTF(NODE, (\tcan't translate icb address!\n));
 		/* no use, this will fail anyway */
-		mutex_exit(ump-get_node_lock);
 		return EINVAL;
 	}
 
@@ -5324,33 +5288,18 @@ udf_get_node(struct udf_mount *ump, stru
 	udf_node = pool_get(udf_node_pool, PR_WAITOK);
 	memset(udf_node, 0, sizeof(struct udf_node));
 
-	DPRINTF(NODE, (\tget new vnode\n));
-	/* give it a vnode */
-	error = getnewvnode(VT_UDF, ump-vfs_mountp, udf_vnodeop_p, NULL, nvp);
-	if (error) {
-		pool_put(udf_node_pool, udf_node);
-		mutex_exit(ump-get_node_lock);
-		return error;
-	}
-
-	/* always return locked vnode */
-	if 

CVS commit: src/sys/fs/udf

2015-04-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Apr  6 08:38:25 UTC 2015

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Move the removal of unlinked nodes from udf_inactive() to udf_reclaim().


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.98 src/sys/fs/udf/udf_vnops.c:1.99
--- src/sys/fs/udf/udf_vnops.c:1.98	Sat Apr  4 12:34:45 2015
+++ src/sys/fs/udf/udf_vnops.c	Mon Apr  6 08:38:25 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.98 2015/04/04 12:34:45 riastradh Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.99 2015/04/06 08:38:25 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.98 2015/04/04 12:34:45 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.99 2015/04/06 08:38:25 hannken Exp $);
 #endif /* not lint */
 
 
@@ -97,9 +97,7 @@ udf_inactive(void *v)
 	}
 
 	/*
-	 * Optionally flush metadata to disc. If the file has not been
-	 * referenced anymore in a directory we ought to free up the resources
-	 * on disc if applicable.
+	 * Optionally flush metadata to disc.
 	 */
 	if (udf_node-fe) {
 		refcnt = udf_rw16(udf_node-fe-link_cnt);
@@ -116,10 +114,7 @@ udf_inactive(void *v)
 
 	*ap-a_recycle = false;
 	if ((refcnt == 0)  ((vp-v_vflag  VV_SYSTEM) == 0)) {
-	 	/* remove this file's allocation */
-		DPRINTF(NODE, (udf_inactive deleting unlinked file\n));
 		*ap-a_recycle = true;
-		udf_delete_node(udf_node);
 		VOP_UNLOCK(vp);
 		return 0;
 	}
@@ -144,6 +139,7 @@ udf_reclaim(void *v)
 	} */ *ap = v;
 	struct vnode *vp = ap-a_vp;
 	struct udf_node *udf_node = VTOI(vp);
+	int refcnt;
 
 	DPRINTF(NODE, (udf_reclaim called for node %p\n, udf_node));
 	if (prtactive  vp-v_usecount  1)
@@ -154,6 +150,23 @@ udf_reclaim(void *v)
 		return 0;
 	}
 
+	/*
+	 * If the file has not been referenced anymore in a directory
+	 * we ought to free up the resources on disc if applicable.
+	 */
+	if (udf_node-fe) {
+		refcnt = udf_rw16(udf_node-fe-link_cnt);
+	} else {
+		assert(udf_node-efe);
+		refcnt = udf_rw16(udf_node-efe-link_cnt);
+	}
+
+	if ((refcnt == 0)  ((vp-v_vflag  VV_SYSTEM) == 0)) {
+	 	/* remove this file's allocation */
+		DPRINTF(NODE, (udf_inactive deleting unlinked file\n));
+		udf_delete_node(udf_node);
+	}
+
 	/* update note for closure */
 	udf_update(vp, NULL, NULL, NULL, UPDATE_CLOSE);
 



CVS commit: src/sys/fs/udf

2015-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb  7 04:18:03 UTC 2015

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
fix udf_node leak. Reported by:
http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.127 src/sys/fs/udf/udf_subr.c:1.128
--- src/sys/fs/udf/udf_subr.c:1.127	Wed Sep 17 17:18:43 2014
+++ src/sys/fs/udf/udf_subr.c	Fri Feb  6 23:18:03 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.127 2014/09/17 21:18:43 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.128 2015/02/07 04:18:03 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.127 2014/09/17 21:18:43 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.128 2015/02/07 04:18:03 christos Exp $);
 #endif /* not lint */
 
 
@@ -5335,8 +5335,9 @@ udf_get_node(struct udf_mount *ump, stru
 
 	/* always return locked vnode */
 	if ((error = vn_lock(nvp, LK_EXCLUSIVE | LK_RETRY))) {
-		/* recycle vnode and unlock; simultanious will fail too */
+		/* recycle vnode and unlock; simultaneous will fail too */
 		ungetnewvnode(nvp);
+		pool_put(udf_node_pool, udf_node);
 		mutex_exit(ump-get_node_lock);
 		return error;
 	}



CVS commit: src/sys/fs/udf

2015-01-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan 28 14:00:58 UTC 2015

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
When udf_symlink() fails, do not explicitly call udf_delete_node(), as
vrele() called next will do that again - avoids a double free of the
bitmap, leading to a KASSERT failure (or worse in real life) in the
udf_symlink_long in the fs/vfs::t_vnops test.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.96 src/sys/fs/udf/udf_vnops.c:1.97
--- src/sys/fs/udf/udf_vnops.c:1.96	Sun Jan  4 14:23:37 2015
+++ src/sys/fs/udf/udf_vnops.c	Wed Jan 28 14:00:58 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.96 2015/01/04 14:23:37 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.97 2015/01/28 14:00:58 martin Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.96 2015/01/04 14:23:37 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.97 2015/01/28 14:00:58 martin Exp $);
 #endif /* not lint */
 
 
@@ -1741,7 +1741,6 @@ udf_symlink(void *v)
 		if (error) {
 			/* remove node */
 			udf_dir_detach(udf_node-ump, dir_node, udf_node, cnp);
-			udf_delete_node(udf_node);
 			vrele(*vpp);
 			*vpp = NULL;
 		}



CVS commit: src/sys/fs/udf

2015-01-04 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Jan  4 14:23:37 UTC 2015

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Add missing vrele() as found by the testsuite.

Thanks Jurgen Hannken for the patch.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.95 src/sys/fs/udf/udf_vnops.c:1.96
--- src/sys/fs/udf/udf_vnops.c:1.95	Wed Dec  3 21:37:55 2014
+++ src/sys/fs/udf/udf_vnops.c	Sun Jan  4 14:23:37 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.95 2014/12/03 21:37:55 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.96 2015/01/04 14:23:37 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.95 2014/12/03 21:37:55 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.96 2015/01/04 14:23:37 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1742,6 +1742,8 @@ udf_symlink(void *v)
 			/* remove node */
 			udf_dir_detach(udf_node-ump, dir_node, udf_node, cnp);
 			udf_delete_node(udf_node);
+			vrele(*vpp);
+			*vpp = NULL;
 		}
 	}
 	return error;



CVS commit: src/sys/fs/udf

2014-12-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Dec  3 21:34:55 UTC 2014

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
Relax the KASSERT since an equal size is no issue


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.36 src/sys/fs/udf/udf_allocation.c:1.37
--- src/sys/fs/udf/udf_allocation.c:1.36	Wed Oct 30 08:41:38 2013
+++ src/sys/fs/udf/udf_allocation.c	Wed Dec  3 21:34:55 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.36 2013/10/30 08:41:38 mrg Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.37 2014/12/03 21:34:55 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.36 2013/10/30 08:41:38 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.37 2014/12/03 21:34:55 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -2954,7 +2954,7 @@ udf_shrink_node(struct udf_node *udf_nod
 		error = 0;
 
 		/* clear the space in the descriptor */
-		KASSERT(old_size  new_size);
+		KASSERT(old_size = new_size);
 		memset(data_pos + new_size, 0, old_size - new_size);
 
 		/* TODO zero appened space in buffer! */



CVS commit: src/sys/fs/udf

2014-12-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Dec  3 21:37:55 UTC 2014

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Explicitly delete the failing node; it would be killed with the unlink too but
explicitly deleting it is better than just setting the file size to zero.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.94 src/sys/fs/udf/udf_vnops.c:1.95
--- src/sys/fs/udf/udf_vnops.c:1.94	Tue Jul 29 15:48:22 2014
+++ src/sys/fs/udf/udf_vnops.c	Wed Dec  3 21:37:55 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.94 2014/07/29 15:48:22 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.95 2014/12/03 21:37:55 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.94 2014/07/29 15:48:22 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.95 2014/12/03 21:37:55 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1740,8 +1740,8 @@ udf_symlink(void *v)
 		error = udf_do_symlink(udf_node, ap-a_target);
 		if (error) {
 			/* remove node */
-			udf_shrink_node(udf_node, 0);
 			udf_dir_detach(udf_node-ump, dir_node, udf_node, cnp);
+			udf_delete_node(udf_node);
 		}
 	}
 	return error;



CVS commit: src/sys/fs/udf

2014-11-10 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Nov 10 19:44:08 UTC 2014

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
Revert previous, it is actually needed.  (builds are failing)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.11 src/sys/fs/udf/udf_rename.c:1.12
--- src/sys/fs/udf/udf_rename.c:1.11	Mon Nov 10 18:46:33 2014
+++ src/sys/fs/udf/udf_rename.c	Mon Nov 10 19:44:08 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.11 2014/11/10 18:46:33 maxv Exp $ */
+/* $NetBSD: udf_rename.c,v 1.12 2014/11/10 19:44:08 riz Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.11 2014/11/10 18:46:33 maxv Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.12 2014/11/10 19:44:08 riz Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, $NetBSD: udf_rename.c
 #include sys/mount.h
 #include sys/namei.h
 #include sys/stat.h
+#include sys/malloc.h
 #include sys/dirent.h
 #include sys/vnode.h
 #include sys/vnode_if.h



CVS commit: src/sys/fs/udf

2014-09-17 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Sep 17 19:47:05 UTC 2014

Modified Files:
src/sys/fs/udf: udf.h udf_subr.c

Log Message:
As pointed out by wiz@ prevent a possible attack or corruption that results in
an endless loop of indirect descriptors being processed.

The number of indirect descriptors followed is now maximized.
While here, also fix a use-after-free bug!


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.125 -r1.126 src/sys/fs/udf/udf_subr.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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.46 src/sys/fs/udf/udf.h:1.47
--- src/sys/fs/udf/udf.h:1.46	Fri Oct 18 19:56:55 2013
+++ src/sys/fs/udf/udf.h	Wed Sep 17 19:47:05 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.46 2013/10/18 19:56:55 christos Exp $ */
+/* $NetBSD: udf.h,v 1.47 2014/09/17 19:47:05 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -128,6 +128,8 @@ extern int udf_verbose;
 #define UDF_DISC_SLACK		(128)			/* picked, at least 64 kb or 128 */
 #define UDF_ISO_VRS_SIZE	(32*2048)		/* 32 ISO `sectors' */
 
+#define UDF_MAX_INDIRS_FOLLOW	1024			/* picked */
+
 
 /* structure space */
 #define UDF_ANCHORS		4	/* 256, 512, N-256, N */

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.125 src/sys/fs/udf/udf_subr.c:1.126
--- src/sys/fs/udf/udf_subr.c:1.125	Tue Jul 29 15:36:43 2014
+++ src/sys/fs/udf/udf_subr.c	Wed Sep 17 19:47:05 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.125 2014/07/29 15:36:43 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.126 2014/09/17 19:47:05 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.125 2014/07/29 15:36:43 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.126 2014/09/17 19:47:05 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -5290,6 +5290,7 @@ udf_get_node(struct udf_mount *ump, stru
 	uint32_t lb_size, sector, dummy;
 	int udf_file_type, dscr_type, strat, strat4096, needs_indirect;
 	int slot, eof, error;
+	int num_indir_followed = 0;
 
 	DPRINTF(NODE, (udf_get_node called\n));
 	*udf_noderes = udf_node = NULL;
@@ -5392,8 +5393,12 @@ udf_get_node(struct udf_mount *ump, stru
 		/* if dealing with an indirect entry, follow the link */
 		if (dscr_type == TAGID_INDIRECTENTRY) {
 			needs_indirect = 0;
-			udf_free_logvol_dscr(ump, icb_loc, dscr);
 			icb_loc = dscr-inde.indirect_icb;
+			udf_free_logvol_dscr(ump, icb_loc, dscr);
+			if (++num_indir_followed  UDF_MAX_INDIRS_FOLLOW) {
+error = EMLINK;
+break;
+			}
 			continue;
 		}
 



CVS commit: src/sys/fs/udf

2014-09-17 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Sep 17 21:18:43 UTC 2014

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Fix bug introduced in last patch


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.126 src/sys/fs/udf/udf_subr.c:1.127
--- src/sys/fs/udf/udf_subr.c:1.126	Wed Sep 17 19:47:05 2014
+++ src/sys/fs/udf/udf_subr.c	Wed Sep 17 21:18:43 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.126 2014/09/17 19:47:05 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.127 2014/09/17 21:18:43 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.126 2014/09/17 19:47:05 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.127 2014/09/17 21:18:43 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -5285,7 +5285,7 @@ udf_get_node(struct udf_mount *ump, stru
 	union dscrptr   *dscr;
 	struct udf_node *udf_node;
 	struct vnode*nvp;
-	struct long_ad   icb_loc, last_fe_icb_loc;
+	struct long_ad   icb_loc, next_icb_loc, last_fe_icb_loc;
 	uint64_t file_size;
 	uint32_t lb_size, sector, dummy;
 	int udf_file_type, dscr_type, strat, strat4096, needs_indirect;
@@ -5393,8 +5393,9 @@ udf_get_node(struct udf_mount *ump, stru
 		/* if dealing with an indirect entry, follow the link */
 		if (dscr_type == TAGID_INDIRECTENTRY) {
 			needs_indirect = 0;
-			icb_loc = dscr-inde.indirect_icb;
+			next_icb_loc = dscr-inde.indirect_icb;
 			udf_free_logvol_dscr(ump, icb_loc, dscr);
+			icb_loc = next_icb_loc;
 			if (++num_indir_followed  UDF_MAX_INDIRS_FOLLOW) {
 error = EMLINK;
 break;



CVS commit: src/sys/fs/udf

2014-07-29 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Jul 29 11:10:12 UTC 2014

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Access time should only be set on accessing the data or messing with the
contents, not on inode access rights and ownership changes. Should address
PR kern/49033 for UDF.

Test results now come clean for bugs related to this issue in the ATF.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.92 src/sys/fs/udf/udf_vnops.c:1.93
--- src/sys/fs/udf/udf_vnops.c:1.92	Fri Jul 25 08:20:52 2014
+++ src/sys/fs/udf/udf_vnops.c	Tue Jul 29 11:10:12 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.92 2014/07/25 08:20:52 dholland Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.93 2014/07/29 11:10:12 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.92 2014/07/25 08:20:52 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.93 2014/07/29 11:10:12 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1020,8 +1020,6 @@ udf_chown(struct vnode *vp, uid_t new_ui
 
 	/* mark node changed */
 	udf_node-i_flags |= IN_CHANGE;
-	if (vp-v_mount-mnt_flag  MNT_RELATIME)
-		udf_node-i_flags |= IN_ACCESS;
 
 	return 0;
 }
@@ -1059,8 +1057,6 @@ udf_chmod(struct vnode *vp, mode_t mode,
 
 	/* mark node changed */
 	udf_node-i_flags |= IN_CHANGE;
-	if (vp-v_mount-mnt_flag  MNT_RELATIME)
-		udf_node-i_flags |= IN_ACCESS;
 
 	return 0;
 }



CVS commit: src/sys/fs/udf

2014-07-29 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Jul 29 15:36:43 UTC 2014

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Fix debug printout of udf_write_metadata_partition_spacetable(), it referred
to an old variable.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.124 src/sys/fs/udf/udf_subr.c:1.125
--- src/sys/fs/udf/udf_subr.c:1.124	Sun Mar 23 09:34:42 2014
+++ src/sys/fs/udf/udf_subr.c	Tue Jul 29 15:36:43 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.124 2014/03/23 09:34:42 christos Exp $ */
+/* $NetBSD: udf_subr.c,v 1.125 2014/07/29 15:36:43 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.124 2014/03/23 09:34:42 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.125 2014/07/29 15:36:43 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1808,8 +1808,8 @@ udf_write_metadata_partition_spacetable(
 	dscr = (union dscrptr *) ump-metadata_unalloc_dscr;
 	new_inflen = udf_tagsize(dscr, 1);
 
-	DPRINTF(VOLUMES, (Resize and write out metadata space bitmap from 
-		%PRIu64 to %PRIu64 bytes\n, inflen, new_inflen));
+	DPRINTF(VOLUMES, (Resize and write out metadata space bitmap 
+		 for %PRIu64 bytes\n, new_inflen));
 
 	error = udf_resize_node(bitmap_node, new_inflen, dummy);
 	if (error)



CVS commit: src/sys/fs/udf

2014-07-29 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Jul 29 15:48:22 UTC 2014

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Posix requires the va_size of a symlink to be pathlength for symbolic links.
This fixes yet another atf case.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.93 src/sys/fs/udf/udf_vnops.c:1.94
--- src/sys/fs/udf/udf_vnops.c:1.93	Tue Jul 29 11:10:12 2014
+++ src/sys/fs/udf/udf_vnops.c	Tue Jul 29 15:48:22 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.93 2014/07/29 11:10:12 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.94 2014/07/29 15:48:22 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.93 2014/07/29 11:10:12 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.94 2014/07/29 15:48:22 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -67,6 +67,9 @@ __KERNEL_RCSID(0, $NetBSD: udf_vnops.c,
 
 #define VTOI(vnode) ((struct udf_node *) (vnode)-v_data)
 
+/* forward declarations */
+static int udf_do_readlink(struct udf_node *udf_node, uint64_t filesize,
+	uint8_t *targetbuf, int *length);
 
 /* externs */
 extern int prtactive;
@@ -865,10 +868,10 @@ udf_getattr(void *v)
 	uint64_t filesize, blkssize;
 	uint32_t nlink;
 	uint32_t offset, a_l;
-	uint8_t *filedata;
+	uint8_t *filedata, *targetbuf;
 	uid_t uid;
 	gid_t gid;
-	int error;
+	int length, error;
 
 	DPRINTF(CALL, (udf_getattr called\n));
 
@@ -939,6 +942,22 @@ udf_getattr(void *v)
 	if (vap-va_type == VDIR)
 		vap-va_nlink++;
 
+	/*
+	 * BUG-ALERT: Posix requires the va_size to be pathlength for symbolic
+	 * links.
+	 */
+	if (vap-va_type == VLNK) {
+		/* claim temporary buffers for translation */
+		targetbuf = malloc(PATH_MAX+1, M_UDFTEMP, M_WAITOK);
+		error = udf_do_readlink(udf_node, filesize, targetbuf, length);
+		if (!error) {
+			vap-va_size = length;
+			KASSERT(length == strlen(targetbuf));
+		}
+		free(targetbuf, M_UDFTEMP);
+		/* XXX return error? */
+	}
+
 	/* access times */
 	udf_timestamp_to_timespec(ump, atime,vap-va_atime);
 	udf_timestamp_to_timespec(ump, mtime,vap-va_mtime);
@@ -1730,49 +1749,30 @@ udf_symlink(void *v)
 
 /* - */
 
-int
-udf_readlink(void *v)
+static int
+udf_do_readlink(struct udf_node *udf_node, uint64_t filesize,
+	uint8_t *targetbuf, int *length)
 {
-	struct vop_readlink_args /* {
-		struct vnode *a_vp;
-		struct uio *a_uio;
-		kauth_cred_t a_cred;
-	} */ *ap = v;
-	struct vnode *vp = ap-a_vp;
-	struct uio *uio = ap-a_uio;
-	kauth_cred_t cred = ap-a_cred;
-	struct udf_node *udf_node;
 	struct pathcomp pathcomp;
-	struct vattr vattr;
-	uint8_t *pathbuf, *targetbuf, *tmpname;
+	uint8_t *pathbuf, *tmpname;
 	uint8_t *pathpos, *targetpos;
 	char *mntonname;
 	int pathlen, targetlen, namelen, mntonnamelen, len, l_ci;
 	int first, error;
 
-	DPRINTF(CALL, (udf_readlink called\n));
-
-	udf_node = VTOI(vp);
-	error = VOP_GETATTR(vp, vattr, cred);
-	if (error)
-		return error;
-
-	/* claim temporary buffers for translation */
 	pathbuf   = malloc(UDF_SYMLINKBUFLEN, M_UDFTEMP, M_WAITOK);
-	targetbuf = malloc(PATH_MAX+1, M_UDFTEMP, M_WAITOK);
 	tmpname   = malloc(PATH_MAX+1, M_UDFTEMP, M_WAITOK);
 	memset(pathbuf, 0, UDF_SYMLINKBUFLEN);
 	memset(targetbuf, 0, PATH_MAX);
 
 	/* read contents of file in our temporary buffer */
 	error = vn_rdwr(UIO_READ, udf_node-vnode,
-		pathbuf, vattr.va_size, 0,
+		pathbuf, filesize, 0,
 		UIO_SYSSPACE, IO_NODELOCKED | IO_ALTSEMANTICS,
 		FSCRED, NULL, NULL);
 	if (error) {
 		/* failed to read in symlink contents */
 		free(pathbuf, M_UDFTEMP);
-		free(targetbuf, M_UDFTEMP);
 		free(tmpname, M_UDFTEMP);
 		return error;
 	}
@@ -1787,7 +1787,7 @@ udf_readlink(void *v)
 
 	error = 0;
 	first = 1;
-	while (vattr.va_size - pathlen = UDF_PATH_COMP_SIZE) {
+	while (filesize - pathlen = UDF_PATH_COMP_SIZE) {
 		len = UDF_PATH_COMP_SIZE;
 		memcpy(pathcomp, pathpos, len);
 		l_ci = pathcomp.l_ci;
@@ -1808,7 +1808,7 @@ udf_readlink(void *v)
 			}
 			memcpy(targetpos, mntonname, mntonnamelen);
 			targetpos += mntonnamelen; targetlen -= mntonnamelen;
-			if (vattr.va_size-pathlen  UDF_PATH_COMP_SIZE+l_ci) {
+			if (filesize-pathlen  UDF_PATH_COMP_SIZE+l_ci) {
 /* more follows, so must be directory */
 *targetpos++ = '/'; targetlen--;
 			}
@@ -1849,7 +1849,7 @@ udf_readlink(void *v)
 			}
 			memcpy(targetpos, tmpname, namelen);
 			targetpos += namelen; targetlen -= namelen;
-			if (vattr.va_size-pathlen  UDF_PATH_COMP_SIZE+l_ci) {
+			if (filesize-pathlen  UDF_PATH_COMP_SIZE+l_ci) {
 /* more follows, so must be directory */
 *targetpos++ = '/'; targetlen--;
 			}
@@ -1866,17 +1866,54 @@ 

CVS commit: src/sys/fs/udf

2014-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 23 09:34:42 UTC 2014

Modified Files:
src/sys/fs/udf: udf_strat_sequential.c udf_subr.c udf_vnops.c

Log Message:
fix unused


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/fs/udf/udf_strat_sequential.c
cvs rdiff -u -r1.123 -r1.124 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.90 -r1.91 src/sys/fs/udf/udf_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/fs/udf/udf_strat_sequential.c
diff -u src/sys/fs/udf/udf_strat_sequential.c:1.12 src/sys/fs/udf/udf_strat_sequential.c:1.13
--- src/sys/fs/udf/udf_strat_sequential.c:1.12	Fri Oct 18 15:56:55 2013
+++ src/sys/fs/udf/udf_strat_sequential.c	Sun Mar 23 05:34:42 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_sequential.c,v 1.12 2013/10/18 19:56:55 christos Exp $ */
+/* $NetBSD: udf_strat_sequential.c,v 1.13 2014/03/23 09:34:42 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_strat_sequential.c,v 1.12 2013/10/18 19:56:55 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_strat_sequential.c,v 1.13 2014/03/23 09:34:42 christos Exp $);
 #endif /* not lint */
 
 
@@ -525,6 +525,7 @@ udf_doshedule(struct udf_mount *ump)
 	ump-metadata_track);
 			assert(error == 0);
 			mutex_enter(priv-discstrat_mutex);
+			__USE(error);
 		}
 	}
 

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.123 src/sys/fs/udf/udf_subr.c:1.124
--- src/sys/fs/udf/udf_subr.c:1.123	Thu Jan 23 05:13:56 2014
+++ src/sys/fs/udf/udf_subr.c	Sun Mar 23 05:34:42 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.123 2014/01/23 10:13:56 hannken Exp $ */
+/* $NetBSD: udf_subr.c,v 1.124 2014/03/23 09:34:42 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.123 2014/01/23 10:13:56 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.124 2014/03/23 09:34:42 christos Exp $);
 #endif /* not lint */
 
 
@@ -2471,6 +2471,7 @@ udf_extattr_insert_internal(struct udf_m
 
 	/* can't append already written to file descriptors yet */
 	assert(l_ad == 0);
+	__USE(l_ad);
 
 	/* should have a header! */
 	extattrhdr = (struct extattrhdr_desc *) data;
@@ -6512,6 +6513,7 @@ udf_read_internal(struct udf_node *node,
 	addr_type = icbflags  UDF_ICB_TAG_FLAGS_ALLOC_MASK;
 
 	assert(addr_type == UDF_ICB_INTERN_ALLOC);
+	__USE(addr_type);
 	assert(inflen  sector_size);
 
 	/* copy out info */
@@ -6550,7 +6552,9 @@ udf_write_internal(struct udf_node *node
 	addr_type = icbflags  UDF_ICB_TAG_FLAGS_ALLOC_MASK;
 
 	assert(addr_type == UDF_ICB_INTERN_ALLOC);
+	__USE(addr_type);
 	assert(inflen  sector_size);
+	__USE(sector_size);
 
 	/* copy in blob */
 	/* memset(pos, 0, inflen); */

Index: src/sys/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.90 src/sys/fs/udf/udf_vnops.c:1.91
--- src/sys/fs/udf/udf_vnops.c:1.90	Fri Feb  7 10:29:22 2014
+++ src/sys/fs/udf/udf_vnops.c	Sun Mar 23 05:34:42 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.90 2014/02/07 15:29:22 hannken Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.91 2014/03/23 09:34:42 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.90 2014/02/07 15:29:22 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.91 2014/03/23 09:34:42 christos Exp $);
 #endif /* not lint */
 
 
@@ -487,6 +487,7 @@ udf_vfsstrategy(void *v)
 
 	/* check assertions: we OUGHT to always get multiples of this */
 	assert(sectors * lb_size == bp-b_bcount);
+	__USE(sectors);
 
 	/* issue buffer */
 	if (bp-b_flags  B_READ) {



CVS commit: src/sys/fs/udf

2013-11-21 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Nov 21 23:42:09 UTC 2013

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Don't create a variable just to assert() on it - assert on the
thing the variable got assigned.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.121 src/sys/fs/udf/udf_subr.c:1.122
--- src/sys/fs/udf/udf_subr.c:1.121	Fri Oct 18 19:56:55 2013
+++ src/sys/fs/udf/udf_subr.c	Thu Nov 21 23:42:09 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.121 2013/10/18 19:56:55 christos Exp $ */
+/* $NetBSD: udf_subr.c,v 1.122 2013/11/21 23:42:09 riz Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.121 2013/10/18 19:56:55 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.122 2013/11/21 23:42:09 riz Exp $);
 #endif /* not lint */
 
 
@@ -4764,7 +4764,6 @@ udf_dir_detach(struct udf_mount *ump, st
 	struct dirhash   *dirh;
 	struct dirhash_entry *dirh_ep;
 	struct file_entry*fe  = dir_node-fe;
-	struct extfile_entry *efe = dir_node-efe;
 	struct fileid_desc *fid;
 	struct dirent *dirent;
 	uint64_t diroffset;
@@ -4785,7 +4784,7 @@ udf_dir_detach(struct udf_mount *ump, st
 
 	/* get directory filesize */
 	if (!fe) {
-		assert(efe);
+		assert(dir_node-efe);
 	}
 
 	/* allocate temporary space for fid */



CVS commit: src/sys/fs/udf

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

Modified Files:
src/sys/fs/udf: udf.h udf_allocation.c udf_strat_direct.c
udf_strat_rmw.c udf_strat_sequential.c udf_subr.c udf_vnops.c

Log Message:
fix unused variable warnings


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.34 -r1.35 src/sys/fs/udf/udf_allocation.c
cvs rdiff -u -r1.10 -r1.11 src/sys/fs/udf/udf_strat_direct.c
cvs rdiff -u -r1.22 -r1.23 src/sys/fs/udf/udf_strat_rmw.c
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/udf/udf_strat_sequential.c
cvs rdiff -u -r1.120 -r1.121 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.86 -r1.87 src/sys/fs/udf/udf_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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.45 src/sys/fs/udf/udf.h:1.46
--- src/sys/fs/udf/udf.h:1.45	Fri Jul 27 18:55:30 2012
+++ src/sys/fs/udf/udf.h	Fri Oct 18 15:56:55 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.45 2012/07/27 22:55:30 drochner Exp $ */
+/* $NetBSD: udf.h,v 1.46 2013/10/18 19:56:55 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -78,7 +78,7 @@ extern int udf_verbose;
 /* initial value of udf_verbose */
 #define UDF_DEBUGGING		0
 
-#ifdef DEBUG
+#ifdef UDF_DEBUG
 #define DPRINTF(name, arg) { \
 		if (udf_verbose  UDF_DEBUG_##name) {\
 			printf arg;\

Index: src/sys/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.34 src/sys/fs/udf/udf_allocation.c:1.35
--- src/sys/fs/udf/udf_allocation.c:1.34	Fri Aug  9 16:13:18 2013
+++ src/sys/fs/udf/udf_allocation.c	Fri Oct 18 15:56:55 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.34 2013/08/09 20:13:18 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.35 2013/10/18 19:56:55 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.34 2013/08/09 20:13:18 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.35 2013/10/18 19:56:55 christos Exp $);
 #endif /* not lint */
 
 
@@ -342,23 +342,15 @@ udf_node_sanity_check(struct udf_node *u
 		uint64_t *cnt_inflen, uint64_t *cnt_logblksrec) {
 	struct file_entry*fe;
 	struct extfile_entry *efe;
-	struct icb_tag *icbtag;
 	uint64_t inflen, logblksrec;
-	int dscr_size, lb_size;
-
-	lb_size = udf_rw32(udf_node-ump-logical_vol-lb_size);
 
 	fe  = udf_node-fe;
 	efe = udf_node-efe;
 	if (fe) {
-		icbtag = fe-icbtag;
 		inflen = udf_rw64(fe-inf_len);
-		dscr_size  = sizeof(struct file_entry) -1;
 		logblksrec = udf_rw64(fe-logblks_rec);
 	} else {
-		icbtag = efe-icbtag;
 		inflen = udf_rw64(efe-inf_len);
-		dscr_size  = sizeof(struct extfile_entry) -1;
 		logblksrec = udf_rw64(efe-logblks_rec);
 	}
 	*cnt_logblksrec = logblksrec;
@@ -1311,9 +1303,8 @@ udf_free_allocated_space(struct udf_moun
 	uint16_t vpart_num, uint32_t num_lb)
 {
 	struct udf_bitmap *bitmap;
-	struct part_desc *pdesc;
 	struct logvol_int_desc *lvid;
-	uint32_t ptov, lb_map, udf_rw32_lbmap;
+	uint32_t lb_map, udf_rw32_lbmap;
 	uint32_t *freepos, free_lbs;
 	int phys_part;
 	int error;
@@ -1327,14 +1318,10 @@ udf_free_allocated_space(struct udf_moun
 
 	mutex_enter(ump-allocate_mutex);
 
-	/* get partition backing up this vpart_num */
-	pdesc = ump-partitions[ump-vtop[vpart_num]];
-
 	switch (ump-vtop_tp[vpart_num]) {
 	case UDF_VTOP_TYPE_PHYS :
 	case UDF_VTOP_TYPE_SPARABLE :
 		/* free space to freed or unallocated space bitmap */
-		ptov  = udf_rw32(pdesc-start_loc);
 		phys_part = ump-vtop[vpart_num];
 
 		/* first try freed space bitmap */
@@ -1653,7 +1640,7 @@ udf_late_allocate_buf(struct udf_mount *
 	uint64_t *lmapping, struct long_ad *node_ad_cpy, uint16_t *vpart_nump)
 {
 	struct udf_node  *udf_node = VTOI(buf-b_vp);
-	int lb_size, blks, udf_c_type;
+	int lb_size, udf_c_type;
 	int vpart_num, num_lb;
 	int error, s;
 
@@ -1666,7 +1653,6 @@ udf_late_allocate_buf(struct udf_mount *
 
 	lb_size= udf_rw32(ump-logical_vol-lb_size);
 	num_lb = (buf-b_bcount + lb_size -1) / lb_size;
-	blks   = lb_size / DEV_BSIZE;
 	udf_c_type = buf-b_udf_c_type;
 
 	KASSERT(lb_size == ump-discinfo.sector_size);
@@ -1774,8 +1760,7 @@ udf_wipe_adslots(struct udf_node *udf_no
 	struct file_entry  *fe;
 	struct extfile_entry   *efe;
 	struct alloc_ext_entry *ext;
-	uint64_t inflen, objsize;
-	uint32_t lb_size, dscr_size, l_ea, l_ad, max_l_ad, crclen;
+	uint32_t lb_size, dscr_size, l_ea, max_l_ad, crclen;
 	uint8_t *data_pos;
 	int extnr;
 
@@ -1784,18 +1769,12 @@ udf_wipe_adslots(struct udf_node *udf_no
 	fe  = udf_node-fe;
 	efe = udf_node-efe;
 	if (fe) {
-		inflen  = udf_rw64(fe-inf_len);
-		objsize = inflen;
 		dscr_size  = sizeof(struct file_entry) -1;
 		l_ea   = udf_rw32(fe-l_ea);
-		l_ad   = udf_rw32(fe-l_ad);
 		data_pos = (uint8_t *) fe + dscr_size + l_ea;
 	} else {
-		inflen  = 

CVS commit: src/sys/fs/udf

2013-10-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct  4 08:35:08 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Remove a bogus vrecycle() from udf_inactive().  Vrecycle() works on inactive
vnodes while VOP_INACTIVE() should never be called on an inactive vnode.

Ok: Reinoud Zandijk rein...@netbsd.org


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.85 src/sys/fs/udf/udf_vnops.c:1.86
--- src/sys/fs/udf/udf_vnops.c:1.85	Wed Jul 10 15:10:56 2013
+++ src/sys/fs/udf/udf_vnops.c	Fri Oct  4 08:35:08 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.85 2013/07/10 15:10:56 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.86 2013/10/04 08:35:08 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.85 2013/07/10 15:10:56 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.86 2013/10/04 08:35:08 hannken Exp $);
 #endif /* not lint */
 
 
@@ -118,7 +118,6 @@ udf_inactive(void *v)
 		*ap-a_recycle = true;
 		udf_delete_node(udf_node);
 		VOP_UNLOCK(vp);
-		vrecycle(vp, NULL, curlwp);
 		return 0;
 	}
 



CVS commit: src/sys/fs/udf

2013-08-09 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Aug  9 20:13:18 UTC 2013

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
Fix 32 bit issue in main file read-in function. On both 32 bit and 64 bit
hosts a missing cast would result in `garbage' after the 4Gbyte limit.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.33 src/sys/fs/udf/udf_allocation.c:1.34
--- src/sys/fs/udf/udf_allocation.c:1.33	Wed Jul  3 11:50:59 2013
+++ src/sys/fs/udf/udf_allocation.c	Fri Aug  9 20:13:18 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.33 2013/07/03 11:50:59 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.34 2013/08/09 20:13:18 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.33 2013/07/03 11:50:59 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.34 2013/08/09 20:13:18 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -586,7 +586,7 @@ translate_again:
 
 			end_foffset = foffset + len;
 
-			if (end_foffset  lb_num * lb_size)
+			if (end_foffset  (uint64_t) lb_num * lb_size)
 break;	/* found */
 			foffset = end_foffset;
 			slot++;
@@ -724,13 +724,13 @@ udf_translate_file_extent(struct udf_nod
 
 		end_foffset = foffset + len;
 
-		if (end_foffset  from * lb_size)
+		if (end_foffset  (uint64_t) from * lb_size)
 			break;	/* found */
 		foffset = end_foffset;
 		slot++;
 	}
 	/* found overlapping slot */
-	ext_offset = from * lb_size - foffset;
+	ext_offset = (uint64_t) from * lb_size - foffset;
 
 	for (;;) {
 		udf_get_adslot(udf_node, slot, s_ad, eof);



CVS commit: src/sys/fs/udf

2013-08-05 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Aug  5 17:02:54 UTC 2013

Modified Files:
src/sys/fs/udf: udf_osta.c

Log Message:
Support tools build.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/fs/udf/udf_osta.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/fs/udf/udf_osta.c
diff -u src/sys/fs/udf/udf_osta.c:1.9 src/sys/fs/udf/udf_osta.c:1.10
--- src/sys/fs/udf/udf_osta.c:1.9	Wed Mar 18 10:22:42 2009
+++ src/sys/fs/udf/udf_osta.c	Mon Aug  5 17:02:54 2013
@@ -1,9 +1,10 @@
-/* $NetBSD: udf_osta.c,v 1.9 2009/03/18 10:22:42 cegger Exp $ */
+/* $NetBSD: udf_osta.c,v 1.10 2013/08/05 17:02:54 joerg Exp $ */
+#if HAVE_NBTOOL_CONFIG_H
+#include nbtool_config.h
+#endif
 
 #include sys/cdefs.h
-#ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_osta.c,v 1.9 2009/03/18 10:22:42 cegger Exp $);
-#endif /* not lint */
+__KERNEL_RCSID(0, $NetBSD: udf_osta.c,v 1.10 2013/08/05 17:02:54 joerg Exp $);
 
 /*
  * Various routines from the OSTA 2.01 specs.  Copyrights are included with



CVS commit: src/sys/fs/udf

2013-07-16 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Jul 16 10:49:36 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
Remove udf_node * as state variables and add the loop invariants UFS and tmpfs
carry to make it easier to debug.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.9 src/sys/fs/udf/udf_rename.c:1.10
--- src/sys/fs/udf/udf_rename.c:1.9	Mon Jul 15 14:40:21 2013
+++ src/sys/fs/udf/udf_rename.c	Tue Jul 16 10:49:36 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.9 2013/07/15 14:40:21 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.10 2013/07/16 10:49:36 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.9 2013/07/15 14:40:21 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.10 2013/07/16 10:49:36 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -503,7 +503,8 @@ udf_gro_genealogy(struct mount *mp, kaut
 struct vnode **intermediate_node_ret)
 {
 	struct udf_mount *ump;
-	struct udf_node *source, *target, *parent_node, *child_node;
+	struct udf_node *parent_node;
+	struct vnode *vp, *dvp;
 	struct long_ad parent_loc;
 	const char *name;
 	int namelen;
@@ -532,91 +533,97 @@ udf_gro_genealogy(struct mount *mp, kaut
 	if (error)
 		return error;
 
-	source = VTOI(fdvp);
-	target = VTOI(tdvp);
-
 	name = ..;
 	namelen  = 2;
 	error= 0;
 
-	ump = target-ump;
+	ump = VTOI(tdvp)-ump;
 
 	/* if nodes are equal, it is no use looking */
-	KASSERT(udf_compare_icb(source-loc, target-loc) != 0);
+	KASSERT(udf_compare_icb(VTOI(fdvp)-loc, VTOI(tdvp)-loc) != 0);
 
-	child_node = target;
-	vref(child_node-vnode);
+	/* start at destination vnode and walk up the tree */
+	vp = tdvp;
+	vref(vp);
 
 	for (;;) {
+		KASSERT(vp != NULL);
+		KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
+		KASSERT(vp-v_mount == mp);
+		KASSERT(vp-v_type == VDIR);
+		KASSERT(!udf_rmdired_p(vp));
+
 		DPRINTF(NODE, (udf_gro_genealogy : 
-			source vp %p, looking at vp %p\n,
-			source-vnode, child_node-vnode));
+			fdvp %p, looking at vp %p\n,
+			fdvp, vp));
 
 		/* sanity check */
-		if (child_node-vnode-v_type != VDIR) {
-			vput(child_node-vnode);
+		if (vp-v_type != VDIR) {
+			vput(vp);
 			return ENOTDIR;
 		}
 
 		/* go down one level */
-		error = udf_lookup_name_in_dir(child_node-vnode, name, namelen,
+		error = udf_lookup_name_in_dir(vp, name, namelen,
 			parent_loc, found);
 		DPRINTF(NODE, (\tlookup of parent '..' resulted in error %d, 
 			found %d\n, error, found));
 		if (!found)
 			error = ENOENT;
 		if (error) {
-			vput(child_node-vnode);
+			vput(vp);
 			return error;
 		}
 
 		/* did we encounter the root node? i.e. loop back */
-		if (udf_compare_icb(parent_loc, child_node-loc) == 0) {
+		if (udf_compare_icb(parent_loc, VTOI(vp)-loc) == 0) {
 			DPRINTF(NODE, (ROOT found!\n));
-			vput(child_node-vnode);
+			vput(vp);
 			*intermediate_node_ret = NULL;
 			return 0;
 		}
 
-		/* did we encounter source node? */
-		if (udf_compare_icb(parent_loc, source-loc) == 0) {
-			DPRINTF(NODE, (SOURCE NODE FOUND\n));
-			*intermediate_node_ret = child_node-vnode;
-			VOP_UNLOCK(child_node-vnode);
+		/* Did we find that fdvp is an ancestor of tdvp? */
+		if (udf_compare_icb(parent_loc, VTOI(fdvp)-loc) == 0) {
+			DPRINTF(NODE, (fdvp is ancestor of tdvp\n));
+			*intermediate_node_ret = vp;
+			VOP_UNLOCK(vp);
 			return 0;
 		}
 
 		/*
 		 * Unlock vp so that we can lock the parent, but keep child 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?
+		 * parent_node will not be recycled.
 		 */
 		DPRINTF(NODE, (\tgetting the parent node\n));
-		VOP_UNLOCK(child_node-vnode);
+		VOP_UNLOCK(vp);
 		error = udf_get_node(ump, parent_loc, parent_node);
-		vrele(child_node-vnode);
+		vrele(vp);
 		if (error) 
 			return error;
 
+		dvp = parent_node-vnode;
+
+		/* switch */
+		KASSERT(dvp != NULL);
+		KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+		vp  = dvp;
+
 		/* sanity check */
-		if (parent_node-vnode-v_type != VDIR) {
+		if (vp-v_type != VDIR) {
 			/* 
 			 * Odd, but can happen if we loose the race and the
 			 * '..' node has been recycled.
 			 */
-			vput(child_node-vnode);
+			vput(vp);
 			return ENOTDIR;
 		}
 
-		if (udf_rmdired_p(parent_node-vnode)) {
-			vput(parent_node-vnode);
+		if (udf_rmdired_p(vp)) {
+			vput(vp);
 			return ENOENT;
 		}
-
-		child_node = parent_node;
 	}
 }
 



CVS commit: src/sys/fs/udf

2013-07-15 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Jul 15 14:40:21 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
First step in rewriting the genealogy case


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.8 src/sys/fs/udf/udf_rename.c:1.9
--- src/sys/fs/udf/udf_rename.c:1.8	Sat Jul 13 19:42:26 2013
+++ src/sys/fs/udf/udf_rename.c	Mon Jul 15 14:40:21 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.8 2013/07/13 19:42:26 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.9 2013/07/15 14:40:21 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.8 2013/07/13 19:42:26 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.9 2013/07/15 14:40:21 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -586,24 +586,36 @@ udf_gro_genealogy(struct mount *mp, kaut
 			return 0;
 		}
 
+		/*
+		 * Unlock vp so that we can lock the parent, but keep child 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?
+		 */
 		DPRINTF(NODE, (\tgetting the parent node\n));
+		VOP_UNLOCK(child_node-vnode);
 		error = udf_get_node(ump, parent_loc, parent_node);
-		if (error) {
-			vput(child_node-vnode);
+		vrele(child_node-vnode);
+		if (error) 
 			return error;
+
+		/* sanity check */
+		if (parent_node-vnode-v_type != VDIR) {
+			/* 
+			 * Odd, but can happen if we loose the race and the
+			 * '..' node has been recycled.
+			 */
+			vput(child_node-vnode);
+			return ENOTDIR;
 		}
 
 		if (udf_rmdired_p(parent_node-vnode)) {
-			vput(child_node-vnode);
 			vput(parent_node-vnode);
 			return ENOENT;
 		}
 
-		/*
-		 * Push our intermediate node, we're done with it, but do
-		 * remember our parent location
-		 */
-		vput(child_node-vnode);
 		child_node = parent_node;
 	}
 }



CVS commit: src/sys/fs/udf

2013-07-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Jul 13 19:39:02 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
Rework udf_gro_rename() to be more linear instead of nesting if/else
branching.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.5 src/sys/fs/udf/udf_rename.c:1.6
--- src/sys/fs/udf/udf_rename.c:1.5	Fri Jul 12 16:14:10 2013
+++ src/sys/fs/udf/udf_rename.c	Sat Jul 13 19:39:02 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.5 2013/07/12 16:14:10 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.6 2013/07/13 19:39:02 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.5 2013/07/12 16:14:10 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.6 2013/07/13 19:39:02 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -374,22 +374,25 @@ udf_gro_rename(struct mount *mp, kauth_c
 
 	/* unlink old directory entry for the node, if failing, unattach new */
 	error = udf_dir_detach(tdnode-ump, fdnode, fnode, fcnp);
-	if (error) {
-		udf_dir_detach(tdnode-ump, tdnode, fnode, tcnp);
-	} else if ((fdnode != tdnode)  (fvp-v_type == VDIR)) {
+	if (error)
+		goto rollback_attach;
+
+	if ((fdnode != tdnode)  (fvp-v_type == VDIR)) {
 		/* update fnode's '..' entry */
 		error = udf_dir_update_rootentry(fnode-ump, fnode, tdnode);
-		if (error) {
-			/* 'try' to recover from this situation */
-			udf_dir_attach(tdnode-ump, fdnode, fnode, fvap, fcnp);
-			udf_dir_detach(tdnode-ump, tdnode, fnode, tcnp);
-		}
+		if (error)
+			goto rollback;
 	}
 
-	if (!error) {
-		VN_KNOTE(fvp, NOTE_RENAME);
-		genfs_rename_cache_purge(fdvp, fvp, tdvp, tvp);
-	}
+	VN_KNOTE(fvp, NOTE_RENAME);
+	genfs_rename_cache_purge(fdvp, fvp, tdvp, tvp);
+	return 0;
+
+rollback:
+	/* 'try' to recover from this situation */
+	udf_dir_attach(tdnode-ump, fdnode, fnode, fvap, fcnp);
+rollback_attach:
+	udf_dir_detach(tdnode-ump, tdnode, fnode, tcnp);
 
 	return error;
 }



CVS commit: src/sys/fs/udf

2013-07-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Jul 13 19:40:14 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
vp is used, so don't (void) it


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.6 src/sys/fs/udf/udf_rename.c:1.7
--- src/sys/fs/udf/udf_rename.c:1.6	Sat Jul 13 19:39:02 2013
+++ src/sys/fs/udf/udf_rename.c	Sat Jul 13 19:40:14 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.6 2013/07/13 19:39:02 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.7 2013/07/13 19:40:14 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.6 2013/07/13 19:39:02 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.7 2013/07/13 19:40:14 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -408,7 +408,6 @@ udf_gro_remove(struct mount *mp, kauth_c
 {
 	struct udf_node *dir_node, *udf_node;
 
-	(void)vp;
 	KASSERT(mp != NULL);
 	KASSERT(dvp != NULL);
 	KASSERT(cnp != NULL);



CVS commit: src/sys/fs/udf

2013-07-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Jul 13 19:42:26 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
udf_gro_genealogy() : source and destination should never be the same on call,
KASSERT it instead of checking for it.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.7 src/sys/fs/udf/udf_rename.c:1.8
--- src/sys/fs/udf/udf_rename.c:1.7	Sat Jul 13 19:40:14 2013
+++ src/sys/fs/udf/udf_rename.c	Sat Jul 13 19:42:26 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.7 2013/07/13 19:40:14 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.8 2013/07/13 19:42:26 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.7 2013/07/13 19:40:14 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.8 2013/07/13 19:42:26 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -542,8 +542,7 @@ udf_gro_genealogy(struct mount *mp, kaut
 	ump = target-ump;
 
 	/* if nodes are equal, it is no use looking */
-	if (udf_compare_icb(source-loc, target-loc) == 0)
-		return EEXIST;
+	KASSERT(udf_compare_icb(source-loc, target-loc) != 0);
 
 	child_node = target;
 	vref(child_node-vnode);



CVS commit: src/sys/fs/udf

2013-07-12 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Jul 12 16:14:10 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
In case there is trouble determining the number of entries in a directory,
return its not empty to be on the safe side.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.4 src/sys/fs/udf/udf_rename.c:1.5
--- src/sys/fs/udf/udf_rename.c:1.4	Thu Jul 11 19:41:19 2013
+++ src/sys/fs/udf/udf_rename.c	Fri Jul 12 16:14:10 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.4 2013/07/11 19:41:19 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.5 2013/07/12 16:14:10 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.4 2013/07/11 19:41:19 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.5 2013/07/12 16:14:10 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -140,7 +140,8 @@ udf_gro_directory_empty_p(struct mount *
 	error = udf_dirhash_fill(udf_node);
 	if (error) {
 		dirhash_put(udf_node-dir_hash);
-		return error;
+		/* VERY unlikely, answer its not empty */
+		return 0;
 	}
 
 	/* check to see if the directory is empty */



CVS commit: src/sys/fs/udf

2013-07-11 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jul 11 15:43:13 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
Small cleanup


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.2 src/sys/fs/udf/udf_rename.c:1.3
--- src/sys/fs/udf/udf_rename.c:1.2	Wed Jul 10 19:14:07 2013
+++ src/sys/fs/udf/udf_rename.c	Thu Jul 11 15:43:12 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.2 2013/07/10 19:14:07 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.3 2013/07/11 15:43:12 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.2 2013/07/10 19:14:07 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.3 2013/07/11 15:43:12 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -84,12 +84,10 @@ udf_sane_rename( struct vnode *fdvp, str
 struct vnode *tdvp, struct componentname *tcnp,
 kauth_cred_t cred, bool posixly_correct)
 {
-	struct dirent fdirent, tdirent;	/* XXX OK? XXX */
-
 	DPRINTF(CALL, (udf_sane_rename '%s' - '%s'\n,
 		fcnp-cn_nameptr, tcnp-cn_nameptr));
 	return genfs_sane_rename(udf_genfs_rename_ops,
-	fdvp, fcnp, fdirent, tdvp, tcnp, tdirent,
+	fdvp, fcnp, NULL, tdvp, tcnp, NULL,
 	cred, posixly_correct);
 }
 
@@ -184,8 +182,6 @@ udf_gro_rename_check_possible(struct mou
 	KASSERT((tvp == NULL) || (VOP_ISLOCKED(tvp) == LK_EXCLUSIVE));
 
 	DPRINTF(CALL, (udf_gro_rename_check_possible called\n));
-	if (mp-mnt_flag  MNT_RDONLY)
-		return EROFS;
 
 	/* flags not implemented since they are not defined (yet) in UDF */
 	return 0;
@@ -273,8 +269,6 @@ udf_gro_remove_check_possible(struct mou
 	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
 
 	DPRINTF(CALL, (udf_gro_remove_check_possible called\n));
-	if (mp-mnt_flag  MNT_RDONLY)
-		return EROFS;
 
 	/* flags not implemented since they are not defined (yet) in UDF */
 	return 0;



CVS commit: src/sys/fs/udf

2013-07-11 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jul 11 19:41:19 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
Resort to the easiest way to check if a directory is deleted: the flag that
tells that there is no FID (dirent) pointing to it anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.3 src/sys/fs/udf/udf_rename.c:1.4
--- src/sys/fs/udf/udf_rename.c:1.3	Thu Jul 11 15:43:12 2013
+++ src/sys/fs/udf/udf_rename.c	Thu Jul 11 19:41:19 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.3 2013/07/11 15:43:12 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.4 2013/07/11 19:41:19 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.3 2013/07/11 15:43:12 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.4 2013/07/11 19:41:19 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -480,23 +480,13 @@ udf_gro_lookup(struct mount *mp, struct 
 static bool
 udf_rmdired_p(struct vnode *vp)
 {
-	struct long_ad icb_loc;
-	const char *name;
-	int namelen;
-	int error, found;
-
 	DPRINTF(CALL, (udf_rmdired_p called\n));
 
 	KASSERT(vp != NULL);
 	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
 	KASSERT(vp-v_type == VDIR);
 
-	/* get our node */
-	name= ..;
-	namelen = 2;
-	error = udf_lookup_name_in_dir(vp, name, namelen,
-			icb_loc, found);
-	return (error || !found);
+	return (VTOI(vp)-i_flags  IN_DELETED);
 }
 
 



CVS commit: src/sys/fs/udf

2013-07-10 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul 10 15:10:56 UTC 2013

Modified Files:
src/sys/fs/udf: files.udf udf_vnops.c
Added Files:
src/sys/fs/udf: udf_rename.c

Log Message:
Implement udf_rename() using the new genfs_rename() framework.

Fixes PR kern/47986


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/udf/files.udf
cvs rdiff -u -r0 -r1.1 src/sys/fs/udf/udf_rename.c
cvs rdiff -u -r1.84 -r1.85 src/sys/fs/udf/udf_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/fs/udf/files.udf
diff -u src/sys/fs/udf/files.udf:1.4 src/sys/fs/udf/files.udf:1.5
--- src/sys/fs/udf/files.udf:1.4	Tue Mar  2 16:43:48 2010
+++ src/sys/fs/udf/files.udf	Wed Jul 10 15:10:56 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: files.udf,v 1.4 2010/03/02 16:43:48 pooka Exp $
+#	$NetBSD: files.udf,v 1.5 2013/07/10 15:10:56 reinoud Exp $
 
 deffs	UDF
 
@@ -12,4 +12,5 @@ file	fs/udf/udf_strat_sequential.c	udf
 file	fs/udf/udf_strat_direct.c	udf
 file	fs/udf/udf_strat_rmw.c		udf
 file	fs/udf/udf_allocation.c		udf
+file	fs/udf/udf_rename.c		udf
 

Index: src/sys/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.84 src/sys/fs/udf/udf_vnops.c:1.85
--- src/sys/fs/udf/udf_vnops.c:1.84	Mon Jul  8 08:21:12 2013
+++ src/sys/fs/udf/udf_vnops.c	Wed Jul 10 15:10:56 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.84 2013/07/08 08:21:12 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.85 2013/07/10 15:10:56 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.84 2013/07/08 08:21:12 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.85 2013/07/10 15:10:56 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -667,7 +667,8 @@ udf_lookup(void *v)
 	ump = dir_node-ump;
 	*vpp = NULL;
 
-	DPRINTF(LOOKUP, (udf_lookup called\n));
+	DPRINTF(LOOKUP, (udf_lookup called, lookup `%s`\n,
+		cnp-cn_nameptr));
 
 	/* simplify/clarification flags */
 	nameiop = cnp-cn_nameiop;
@@ -720,6 +721,11 @@ udf_lookup(void *v)
 		/* special case 2 '..' */
 		DPRINTF(LOOKUP, (\tlookup '..'\n));
 
+		if (islastcn  cnp-cn_nameiop == RENAME) {
+			error = EINVAL;
+			goto out;
+		}
+
 		/* get our node */
 		name= ..;
 		namelen = 2;
@@ -1534,11 +1540,6 @@ udf_do_link(struct vnode *dvp, struct vn
 	KASSERT(vp-v_type != VDIR);
 	KASSERT(dvp-v_mount == vp-v_mount);
 
-	/* lock node */
-	error = vn_lock(vp, LK_EXCLUSIVE);
-	if (error)
-		return error;
-
 	/* get attributes */
 	dir_node = VTOI(dvp);
 	udf_node = VTOI(vp);
@@ -1893,256 +1894,9 @@ udf_readlink(void *v)
 /* - */
 
 /*
- * 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. Modeled after UFS.
- *
- * If source is on the path from target to the root, return error.
+ * udf_rename() moved to udf_rename.c
  */
 
-static int
-udf_on_rootpath(struct udf_node *source, struct udf_node *target)
-{
-	struct udf_mount *ump = target-ump;
-	struct udf_node *res_node;
-	struct long_ad icb_loc, *root_icb;
-	const char *name;
-	int namelen;
-	int error, found;
-
-	name = ..;
-	namelen  = 2;
-	error= 0;
-	res_node = target;
-
-	root_icb   = ump-fileset_desc-rootdir_icb;
-
-	/* if nodes are equal, it is no use looking */
-	if (udf_compare_icb(source-loc, target-loc) == 0) {
-		error = EEXIST;
-		goto out;
-	}
-
-	/* nothing can exist before the root */
-	if (udf_compare_icb(root_icb, target-loc) == 0) {
-		error = 0;
-		goto out;
-	}
-
-	for (;;) {
-		DPRINTF(NODE, (udf_on_rootpath : 
-			source vp %p, looking at vp %p\n,
-			source-vnode, res_node-vnode));
-
-		/* sanity check */
-		if (res_node-vnode-v_type != VDIR) {
-			error = ENOTDIR;
-			goto out;
-		}
-
-		/* go down one level */
-		error = udf_lookup_name_in_dir(res_node-vnode, name, namelen,
-			icb_loc, found);
-		DPRINTF(NODE, (\tlookup of '..' resulted in error %d, 
-			found %d\n, error, found));
-
-		if (!found)
-			error = ENOENT;
-		if (error)
-			goto out;
-
-		/* did we encounter source node? */
-		if (udf_compare_icb(icb_loc, source-loc) == 0) {
-			error = EINVAL;
-			goto out;
-		}
-
-		/* did we encounter the root node? */
-		if (udf_compare_icb(icb_loc, root_icb) == 0) {
-			error = 0;
-			goto out;
-		}
-
-		/* push our intermediate node, we're done with it */
-		/* DPRINTF(NODE, (\tvput %p\n, target-vnode)); */
-		vput(res_node-vnode);
-
-		DPRINTF(NODE, (\tgetting the .. node\n));
-		error = udf_get_node(ump, icb_loc, res_node);
-
-		if (error) {	/* argh, bail out */
-			KASSERT(res_node == NULL);
-			// res_node = NULL;
-			goto out;
-		}
-	}
-out:
-	DPRINTF(NODE, (\tresult: %svalid, error = %d\n, error?in:, error));
-
-	/* put our last node */
-	if (res_node)
-		vput(res_node-vnode);
-
-	return 

CVS commit: src/sys/fs/udf

2013-07-10 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul 10 19:14:07 UTC 2013

Modified Files:
src/sys/fs/udf: udf_rename.c

Log Message:
Remove the dirent checks and references. UDF doesn't need/use them on rename
so just to make sure, we remove all references/checks to not trigger bugs
thats are not really ours.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/udf/udf_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/fs/udf/udf_rename.c
diff -u src/sys/fs/udf/udf_rename.c:1.1 src/sys/fs/udf/udf_rename.c:1.2
--- src/sys/fs/udf/udf_rename.c:1.1	Wed Jul 10 15:10:56 2013
+++ src/sys/fs/udf/udf_rename.c	Wed Jul 10 19:14:07 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.1 2013/07/10 15:10:56 reinoud Exp $ */
+/* $NetBSD: udf_rename.c,v 1.2 2013/07/10 19:14:07 reinoud Exp $ */
 
 /*
  * Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.1 2013/07/10 15:10:56 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_rename.c,v 1.2 2013/07/10 19:14:07 reinoud Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -329,8 +329,6 @@ udf_gro_rename(struct mount *mp, kauth_c
 struct vnode *tdvp, struct componentname *tcnp,
 void *tde, struct vnode *tvp)
 {
-	struct dirent **fdirentp = fde;
-	struct dirent **tdirentp = tde;
 	struct udf_node *fnode, *fdnode, *tnode, *tdnode;
 	struct vattr fvap;
 	int error;
@@ -342,11 +340,6 @@ udf_gro_rename(struct mount *mp, kauth_c
 	KASSERT(fvp != NULL);
 	KASSERT(tdvp != NULL);
 	KASSERT(tcnp != NULL);
-	KASSERT(fdirentp != NULL);
-	KASSERT(tdirentp != NULL);
-	KASSERT(fdirentp != tdirentp);
-	KASSERT((*fdirentp) != (*tdirentp));
-	KASSERT((*fdirentp) != NULL);
 	KASSERT(fdvp != fvp);
 	KASSERT(fdvp != tvp);
 	KASSERT(tdvp != fvp);



CVS commit: src/sys/fs/udf

2013-07-08 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Jul  8 08:21:13 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Clarify the sticky-bit check


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.83 src/sys/fs/udf/udf_vnops.c:1.84
--- src/sys/fs/udf/udf_vnops.c:1.83	Sun Jul  7 20:16:22 2013
+++ src/sys/fs/udf/udf_vnops.c	Mon Jul  8 08:21:12 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.83 2013/07/07 20:16:22 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.84 2013/07/08 08:21:12 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.83 2013/07/07 20:16:22 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.84 2013/07/08 08:21:12 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -792,7 +792,7 @@ udf_lookup(void *v)
 	if (error)
 		goto out;
 
-	/* check the permissions */
+	/* check permissions */
 	if (islastcn  (cnp-cn_nameiop == DELETE ||
 			 cnp-cn_nameiop == RENAME)  ) {
 		error = VOP_ACCESS(dvp, VWRITE, cnp-cn_cred);
@@ -801,10 +801,14 @@ udf_lookup(void *v)
 			goto out;
 		}
 
-		/* get node attributes */
+		/*
+		 * Check if the directory has its sticky bit set. If so, ask
+		 * for clearance since only the owner of a file or directory
+		 * can remove/rename from taht directory.
+		 */
 		mode = udf_getaccessmode(dir_node);
-		udf_getownership(dir_node, d_uid, d_gid);
 		if ((mode  S_ISTXT) != 0) {
+			udf_getownership(dir_node, d_uid, d_gid);
 			error = kauth_authorize_vnode(cnp-cn_cred,
 			KAUTH_VNODE_DELETE, res_node-vnode,
 			dir_node-vnode, genfs_can_sticky(cnp-cn_cred,



CVS commit: src/sys/fs/udf

2013-07-07 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Jul  7 19:49:44 UTC 2013

Modified Files:
src/sys/fs/udf: udf_subr.c udf_subr.h udf_vnops.c

Log Message:
Implement a real empty-directory checking for rmdir().

Should should fix the other part of PR kern/47987
Solves tests/vfs/t_vnops udf_dir_notempty


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.18 -r1.19 src/sys/fs/udf/udf_subr.h
cvs rdiff -u -r1.81 -r1.82 src/sys/fs/udf/udf_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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.119 src/sys/fs/udf/udf_subr.c:1.120
--- src/sys/fs/udf/udf_subr.c:1.119	Sun Apr 29 22:53:59 2012
+++ src/sys/fs/udf/udf_subr.c	Sun Jul  7 19:49:44 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.119 2012/04/29 22:53:59 chs Exp $ */
+/* $NetBSD: udf_subr.c,v 1.120 2013/07/07 19:49:44 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.119 2012/04/29 22:53:59 chs Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.120 2013/07/07 19:49:44 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -4458,8 +4458,8 @@ udf_setownership(struct udf_node *udf_no
 /* - */
 
 
-static int
-dirhash_fill(struct udf_node *dir_node)
+int
+udf_dirhash_fill(struct udf_node *dir_node)
 {
 	struct vnode *dvp = dir_node-vnode;
 	struct dirhash *dirh;
@@ -4556,7 +4556,7 @@ udf_lookup_name_in_dir(struct vnode *vp,
 
 	/* get our dirhash and make sure its read in */
 	dirhash_get(dir_node-dir_hash);
-	error = dirhash_fill(dir_node);
+	error = udf_dirhash_fill(dir_node);
 	if (error) {
 		dirhash_put(dir_node-dir_hash);
 		return error;
@@ -4789,7 +4789,7 @@ udf_dir_detach(struct udf_mount *ump, st
 
 	/* get our dirhash and make sure its read in */
 	dirhash_get(dir_node-dir_hash);
-	error = dirhash_fill(dir_node);
+	error = udf_dirhash_fill(dir_node);
 	if (error) {
 		dirhash_put(dir_node-dir_hash);
 		return error;
@@ -4938,7 +4938,7 @@ udf_dir_update_rootentry(struct udf_moun
 
 	/* get our dirhash and make sure its read in */
 	dirhash_get(dir_node-dir_hash);
-	error = dirhash_fill(dir_node);
+	error = udf_dirhash_fill(dir_node);
 	if (error) {
 		dirhash_put(dir_node-dir_hash);
 		return error;
@@ -5061,7 +5061,7 @@ udf_dir_attach(struct udf_mount *ump, st
 
 	/* get our dirhash and make sure its read in */
 	dirhash_get(dir_node-dir_hash);
-	error = dirhash_fill(dir_node);
+	error = udf_dirhash_fill(dir_node);
 	if (error) {
 		dirhash_put(dir_node-dir_hash);
 		return error;

Index: src/sys/fs/udf/udf_subr.h
diff -u src/sys/fs/udf/udf_subr.h:1.18 src/sys/fs/udf/udf_subr.h:1.19
--- src/sys/fs/udf/udf_subr.h:1.18	Thu Feb 25 16:15:58 2010
+++ src/sys/fs/udf/udf_subr.h	Sun Jul  7 19:49:44 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.h,v 1.18 2010/02/25 16:15:58 reinoud Exp $ */
+/* $NetBSD: udf_subr.h,v 1.19 2013/07/07 19:49:44 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -170,9 +170,11 @@ int udf_create_node(struct vnode *dvp, s
 void udf_delete_node(struct udf_node *udf_node);
 
 int udf_chsize(struct vnode *vp, u_quad_t newsize, kauth_cred_t cred);
+
 int udf_dir_detach(struct udf_mount *ump, struct udf_node *dir_node, struct udf_node *udf_node, struct componentname *cnp);
 int udf_dir_attach(struct udf_mount *ump, struct udf_node *dir_node, struct udf_node *udf_node, struct vattr *vap, struct componentname *cnp);
 int udf_dir_update_rootentry(struct udf_mount *ump, struct udf_node *dir_node, struct udf_node *new_parent_node);
+int udf_dirhash_fill(struct udf_node *dir_node);
 
 /* update and times */
 void udf_add_to_dirtylist(struct udf_node *udf_node);

Index: src/sys/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.81 src/sys/fs/udf/udf_vnops.c:1.82
--- src/sys/fs/udf/udf_vnops.c:1.81	Fri Jul  5 20:40:20 2013
+++ src/sys/fs/udf/udf_vnops.c	Sun Jul  7 19:49:44 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.81 2013/07/05 20:40:20 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.82 2013/07/07 19:49:44 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.81 2013/07/05 20:40:20 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.82 2013/07/07 19:49:44 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -2191,7 +2191,7 @@ udf_rmdir(void *v)
 	struct udf_node *dir_node = VTOI(dvp);
 	struct udf_node *udf_node = VTOI(vp);
 	struct udf_mount *ump = dir_node-ump;
-	int refcnt, error;
+	int error, isempty;
 
 	DPRINTF(NOTIMPL, (udf_rmdir '%s' called\n, cnp-cn_nameptr));
 
@@ -2202,15 +2202,19 @@ udf_rmdir(void *v)
 		return EINVAL;
 	}
 
-	/* check to see if the directory is empty */
-	error = 0;
-	if 

CVS commit: src/sys/fs/udf

2013-07-07 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Jul  7 20:16:22 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Pull forward the node creation returned from the lookup call. Its vnode is
used in the access determination on delete/rename of TXT files.

Thanks for joerg@ and clang for detecting this!


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.82 src/sys/fs/udf/udf_vnops.c:1.83
--- src/sys/fs/udf/udf_vnops.c:1.82	Sun Jul  7 19:49:44 2013
+++ src/sys/fs/udf/udf_vnops.c	Sun Jul  7 20:16:22 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.82 2013/07/07 19:49:44 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.83 2013/07/07 20:16:22 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.82 2013/07/07 19:49:44 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.83 2013/07/07 20:16:22 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -787,12 +787,19 @@ udf_lookup(void *v)
 	 * a link. It seems to function well without this code.
 	 */
 
+	/* try to create/reuse the node */
+	error = udf_get_node(ump, icb_loc, res_node);
+	if (error)
+		goto out;
+
 	/* check the permissions */
 	if (islastcn  (cnp-cn_nameiop == DELETE ||
 			 cnp-cn_nameiop == RENAME)  ) {
 		error = VOP_ACCESS(dvp, VWRITE, cnp-cn_cred);
-		if (error)
+		if (error) {
+			vput(res_node-vnode);
 			goto out;
+		}
 
 		/* get node attributes */
 		mode = udf_getaccessmode(dir_node);
@@ -804,14 +811,12 @@ udf_lookup(void *v)
 			d_uid, d_uid));
 			if (error) {
 error = EPERM;
+vput(res_node-vnode);
 goto out;
 			}
 		}
 	}
-	/* try to create/reuse the node */
-	error = udf_get_node(ump, icb_loc, res_node);
-	if (error)
-		goto out;
+
 	*vpp = res_node-vnode;
 
 done:



CVS commit: src/sys/fs/udf

2013-07-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Jul  5 20:04:57 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Provide additional checks to udf_lookup and restructure it a bit.

Should fix PR 47988


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.79 src/sys/fs/udf/udf_vnops.c:1.80
--- src/sys/fs/udf/udf_vnops.c:1.79	Wed Jul  3 15:39:22 2013
+++ src/sys/fs/udf/udf_vnops.c	Fri Jul  5 20:04:57 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.79 2013/07/03 15:39:22 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.80 2013/07/05 20:04:57 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.79 2013/07/03 15:39:22 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.80 2013/07/05 20:04:57 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -656,9 +656,11 @@ udf_lookup(void *v)
 	struct udf_node  *dir_node, *res_node;
 	struct udf_mount *ump;
 	struct long_adicb_loc;
+	mode_t mode;
+	uid_t d_uid;
+	gid_t d_gid;
 	const char *name;
 	int namelen, nameiop, islastcn, mounted_ro;
-	int vnodetp;
 	int error, found;
 
 	dir_node = VTOI(dvp);
@@ -706,9 +708,14 @@ udf_lookup(void *v)
 	if ((cnp-cn_namelen == 1)  (cnp-cn_nameptr[0] == '.')) {
 		DPRINTF(LOOKUP, (\tlookup '.'\n));
 		/* special case 1 '.' */
+		if (islastcn  cnp-cn_nameiop == RENAME) {
+			error = EISDIR;
+			goto out;
+		}
 		vref(dvp);
 		*vpp = dvp;
 		/* done */
+		goto done;
 	} else if (cnp-cn_flags  ISDOTDOT) {
 		/* special case 2 '..' */
 		DPRINTF(LOOKUP, (\tlookup '..'\n));
@@ -740,58 +747,74 @@ udf_lookup(void *v)
 
 		/* try to relock parent */
 		vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
-	} else {
-		DPRINTF(LOOKUP, (\tlookup file\n));
-		/* all other files */
-		/* lookup filename in the directory; location icb_loc */
-		name= cnp-cn_nameptr;
-		namelen = cnp-cn_namelen;
-		error = udf_lookup_name_in_dir(dvp, name, namelen,
-icb_loc, found);
-		if (error)
-			goto out;
-		if (!found) {
-			DPRINTF(LOOKUP, (\tNOT found\n));
-			/*
-			 * UGH, didn't find name. If we're creating or
-			 * renaming on the last name this is OK and we ought
-			 * to return EJUSTRETURN if its allowed to be created.
-			 */
-			error = ENOENT;
-			if (islastcn 
-(nameiop == CREATE || nameiop == RENAME))
-	error = 0;
-			if (!error) {
-error = VOP_ACCESS(dvp, VWRITE, cnp-cn_cred);
-if (!error) {
-	error = EJUSTRETURN;
-}
+		goto out;
+	}
+
+	/* all other files */
+	DPRINTF(LOOKUP, (\tlookup file/dir in directory\n));
+
+	/* lookup filename in the directory; location icb_loc */
+	name= cnp-cn_nameptr;
+	namelen = cnp-cn_namelen;
+	error = udf_lookup_name_in_dir(dvp, name, namelen,
+			icb_loc, found);
+	if (error)
+		goto out;
+	if (!found) {
+		DPRINTF(LOOKUP, (\tNOT found\n));
+		/*
+		 * The entry was not found in the directory.  This is
+		 * valid if we are creating or renaming an entry and
+		 * are working on the last component of the path name.
+		 */
+		if (islastcn  (cnp-cn_nameiop == CREATE ||
+ cnp-cn_nameiop == RENAME)) {
+			error = VOP_ACCESS(dvp, VWRITE, cnp-cn_cred);
+			if (error) {
+goto out;
 			}
-			/* done */
+			error = EJUSTRETURN;
 		} else {
-			/* try to create/reuse the node */
-			error = udf_get_node(ump, icb_loc, res_node);
-			if (!error) {
-/*
- * If we are not at the last path component
- * and found a non-directory or non-link entry
- * (which may itself be pointing to a
- * directory), raise an error.
- */
-vnodetp = res_node-vnode-v_type;
-if ((vnodetp != VDIR)  (vnodetp != VLNK)) {
-	if (!islastcn)
-		error = ENOTDIR;
-}
+			error = ENOENT;
+		}
+		/* done */
+		goto done;
+	}
 
-			}
-			if (!error) {
-*vpp = res_node-vnode;
+	/*
+	 * XXX NOTE tmpfs has a test here that tests that intermediate
+	 * components i.e. not the last one ought to be either a directory or
+	 * a link. It seems to function well without this code.
+	 */
+
+	/* check the permissions */
+	if (islastcn  (cnp-cn_nameiop == DELETE ||
+			 cnp-cn_nameiop == RENAME)  ) {
+		error = VOP_ACCESS(dvp, VWRITE, cnp-cn_cred);
+		if (error)
+			goto out;
+
+		/* get node attributes */
+		mode = udf_getaccessmode(dir_node);
+		udf_getownership(dir_node, d_uid, d_gid);
+		if ((mode  S_ISTXT) != 0) {
+			error = kauth_authorize_vnode(cnp-cn_cred,
+			KAUTH_VNODE_DELETE, res_node-vnode,
+			dir_node-vnode, genfs_can_sticky(cnp-cn_cred,
+			d_uid, d_uid));
+			if (error) {
+error = EPERM;
+goto out;
 			}
 		}
-	}	
+	}
+	/* try to create/reuse the node */
+	error = udf_get_node(ump, icb_loc, res_node);
+	if (error)
+		goto out;
+	*vpp = res_node-vnode;
 
-out:
+done:
 

CVS commit: src/sys/fs/udf

2013-07-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Jul  5 20:40:20 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Fixes chflags. They were silently rejected before but the VFS standard demands
it complains with EOPNOTSUPP.

Fixes chflags test case.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.80 src/sys/fs/udf/udf_vnops.c:1.81
--- src/sys/fs/udf/udf_vnops.c:1.80	Fri Jul  5 20:04:57 2013
+++ src/sys/fs/udf/udf_vnops.c	Fri Jul  5 20:40:20 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.80 2013/07/05 20:04:57 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.81 2013/07/05 20:40:20 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.80 2013/07/05 20:04:57 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.81 2013/07/05 20:40:20 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1115,9 +1115,11 @@ udf_chflags(struct vnode *vp, mode_t mod
 	if (vp-v_mount-mnt_flag  MNT_RDONLY)
 		return EROFS;
 
-	/* XXX we can't do this yet, but erroring out is enoying XXX */
+	/*
+	 * XXX we can't do this yet, as its not described in the standard yet
+	 */
 
-	return 0;
+	return EOPNOTSUPP;
 }
 
 



CVS commit: src/sys/fs/udf

2013-07-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul  3 11:50:59 UTC 2013

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
On growing a node that was recorded inside the (E)FE, don't forget to set the
size of the node to the NEW size. This was reported by the `t_io
udf_shrinkfile' testcase.

Fixes PR kern/47985


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.32 src/sys/fs/udf/udf_allocation.c:1.33
--- src/sys/fs/udf/udf_allocation.c:1.32	Thu Jun 16 09:21:02 2011
+++ src/sys/fs/udf/udf_allocation.c	Wed Jul  3 11:50:59 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.32 2011/06/16 09:21:02 hannken Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.33 2013/07/03 11:50:59 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.32 2011/06/16 09:21:02 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.33 2013/07/03 11:50:59 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -2706,8 +2706,8 @@ udf_grow_node(struct udf_node *udf_node,
 			error = 0;
 
 			/* set new size for uvm */
-			uvm_vnp_setsize(vp, old_size);
 			uvm_vnp_setwritesize(vp, new_size);
+			uvm_vnp_setsize(vp, new_size);
 
 #if 0
 			/* zero append space in buffer */



CVS commit: src/sys/fs/udf

2013-07-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul  3 12:55:34 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Typo in debug message: we are removing a directory and not a file.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.76 src/sys/fs/udf/udf_vnops.c:1.77
--- src/sys/fs/udf/udf_vnops.c:1.76	Thu Jun 27 09:38:08 2013
+++ src/sys/fs/udf/udf_vnops.c	Wed Jul  3 12:55:34 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.76 2013/06/27 09:38:08 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.77 2013/07/03 12:55:34 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.76 2013/06/27 09:38:08 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.77 2013/07/03 12:55:34 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -2196,7 +2196,7 @@ udf_rmdir(void *v)
 //		cache_purge(dvp);	/* XXX from msdosfs, why? */
 		VN_KNOTE(vp, NOTE_DELETE);
 	}
-	DPRINTFIF(NODE, error, (\tgot error removing file\n));
+	DPRINTFIF(NODE, error, (\tgot error removing dir\n));
 
 	/* unput the nodes and exit */
 	vput(dvp);



CVS commit: src/sys/fs/udf

2013-07-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul  3 14:35:29 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
On removing a directory make sure the leaf directory doesn't have a valid '..'
link anymore. In a corner case this leaf can be held by a process as a CWD. It
is guaranteed to be empty at this stage so we trunc it removing the only valid
FID, being the '..' entry.

Solves part of PR kern/47987
Solves tests/vfs/t_vnops udf_dir_rmdirdotdot


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.77 src/sys/fs/udf/udf_vnops.c:1.78
--- src/sys/fs/udf/udf_vnops.c:1.77	Wed Jul  3 12:55:34 2013
+++ src/sys/fs/udf/udf_vnops.c	Wed Jul  3 14:35:28 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.77 2013/07/03 12:55:34 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.78 2013/07/03 14:35:28 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.77 2013/07/03 12:55:34 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.78 2013/07/03 14:35:28 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -58,6 +58,8 @@ __KERNEL_RCSID(0, $NetBSD: udf_vnops.c,
 
 #include fs/udf/ecma167-udf.h
 #include fs/udf/udf_mount.h
+#include sys/dirhash.h
+
 #include udf.h
 #include udf_subr.h
 #include udf_bswap.h
@@ -2166,7 +2168,7 @@ udf_rmdir(void *v)
 	struct udf_mount *ump = dir_node-ump;
 	int refcnt, error;
 
-	DPRINTF(NOTIMPL, (udf_rmdir called\n));
+	DPRINTF(NOTIMPL, (udf_rmdir '%s' called\n, cnp-cn_nameptr));
 
 	/* don't allow '.' to be deleted */
 	if (dir_node == udf_node) {
@@ -2189,11 +2191,20 @@ udf_rmdir(void *v)
 		return ENOTEMPTY;
 	}
 
-	/* detach the node from the directory */
+	/* detach the node from the directory, udf_node is an empty dir here */
 	error = udf_dir_detach(ump, dir_node, udf_node, cnp);
 	if (error == 0) {
 		cache_purge(vp);
 //		cache_purge(dvp);	/* XXX from msdosfs, why? */
+		/*
+		 * Bug alert: we need to remove '..' from the detaching
+		 * udf_node so further lookups of this are not possible. This
+		 * prevents a process in a deleted directory from going to its
+		 * deleted parent. Since `udf_node' is garanteed to be empty
+		 * here, trunc it so no fids are there.
+		 */
+		dirhash_purge(udf_node-dir_hash);
+		udf_shrink_node(udf_node, 0);
 		VN_KNOTE(vp, NOTE_DELETE);
 	}
 	DPRINTFIF(NODE, error, (\tgot error removing dir\n));



CVS commit: src/sys/fs/udf

2013-07-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul  3 15:39:23 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Remove spurious empty line


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.78 src/sys/fs/udf/udf_vnops.c:1.79
--- src/sys/fs/udf/udf_vnops.c:1.78	Wed Jul  3 14:35:28 2013
+++ src/sys/fs/udf/udf_vnops.c	Wed Jul  3 15:39:22 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.78 2013/07/03 14:35:28 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.79 2013/07/03 15:39:22 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.78 2013/07/03 14:35:28 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.79 2013/07/03 15:39:22 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1376,7 +1376,6 @@ static int
 udf_check_permitted(struct vnode *vp, struct vattr *vap, mode_t mode,
 kauth_cred_t cred)
 {
-
 	/* ask the generic genfs_can_access to advice on security */
 	return kauth_authorize_vnode(cred, KAUTH_ACCESS_ACTION(mode,
 	vp-v_type, vap-va_mode), vp, NULL, genfs_can_access(vp-v_type,



CVS commit: src/sys/fs/udf

2013-06-27 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jun 27 09:38:08 UTC 2013

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Since UDF volumes are always mounted async, the simple UBC purging with
VOP_PUTPAGES() was never triggered resulting in far too much data in the UBC
that needed to be written out. This could result in instability on small
memory machines.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.75 src/sys/fs/udf/udf_vnops.c:1.76
--- src/sys/fs/udf/udf_vnops.c:1.75	Mon Mar 18 19:35:41 2013
+++ src/sys/fs/udf/udf_vnops.c	Thu Jun 27 09:38:08 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.75 2013/03/18 19:35:41 plunky Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.76 2013/06/27 09:38:08 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.75 2013/03/18 19:35:41 plunky Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.76 2013/06/27 09:38:08 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -276,7 +276,6 @@ udf_write(void *v)
 	struct extfile_entry *efe;
 	uint64_t file_size, old_size, old_offset;
 	vsize_t len;
-	int async = vp-v_mount-mnt_flag  MNT_ASYNC;
 	int aflag = ioflag  IO_SYNC ? B_SYNC : 0;
 	int error;
 	int resid, extended;
@@ -364,7 +363,7 @@ udf_write(void *v)
 		 * Directories are excluded since its file data that we want
 		 * to purge.
 		 */
-		if (!async  (vp-v_type != VDIR) 
+		if ((vp-v_type != VDIR) 
 		  (old_offset  16 != uio-uio_offset  16)) {
 			mutex_enter(vp-v_interlock);
 			error = VOP_PUTPAGES(vp, (old_offset  16)  16,



CVS commit: src/sys/fs/udf

2011-11-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 13 23:08:47 UTC 2011

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
use getdisksize()


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.117 src/sys/fs/udf/udf_subr.c:1.118
--- src/sys/fs/udf/udf_subr.c:1.117	Mon Sep 26 21:13:16 2011
+++ src/sys/fs/udf/udf_subr.c	Sun Nov 13 18:08:47 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.117 2011/09/27 01:13:16 christos Exp $ */
+/* $NetBSD: udf_subr.c,v 1.118 2011/11/13 23:08:47 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.117 2011/09/27 01:13:16 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.118 2011/11/13 23:08:47 christos Exp $);
 #endif /* not lint */
 
 
@@ -188,7 +188,8 @@ int
 udf_update_discinfo(struct udf_mount *ump)
 {
 	struct vnode *devvp = ump-devvp;
-	struct partinfo dpart;
+	uint64_t psize;
+	unsigned secsize;
 	struct mmc_discinfo *di;
 	int error;
 
@@ -204,9 +205,9 @@ udf_update_discinfo(struct udf_mount *um
 	}
 
 	/* disc partition support */
-	error = VOP_IOCTL(devvp, DIOCGPART, dpart, FREAD, NOCRED);
+	error = getdisksize(devvp, psize, secsize);
 	if (error)
-		return ENODEV;
+		return error;
 
 	/* set up a disc info profile for partitions */
 	di-mmc_profile		= 0x01;	/* disc type */
@@ -222,8 +223,8 @@ udf_update_discinfo(struct udf_mount *um
 	di-disc_flags = MMC_DFLAGS_UNRESTRICTED;
 
 	/* TODO problem with last_possible_lba on resizable VND; request */
-	di-last_possible_lba = dpart.part-p_size;
-	di-sector_size   = dpart.disklab-d_secsize;
+	di-last_possible_lba = psize;
+	di-sector_size   = secsize;
 
 	di-num_sessions = 1;
 	di-num_tracks   = 1;



CVS commit: src/sys/fs/udf

2011-10-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Oct 18 20:20:30 UTC 2011

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
VOP_GETATTR() needs a shared lock at least.

While here fix a typo (fvp - tvp).


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.67 src/sys/fs/udf/udf_vnops.c:1.68
--- src/sys/fs/udf/udf_vnops.c:1.67	Tue Sep 27 01:33:30 2011
+++ src/sys/fs/udf/udf_vnops.c	Tue Oct 18 20:20:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.67 2011/09/27 01:33:30 christos Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.68 2011/10/18 20:20:29 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.67 2011/09/27 01:33:30 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.68 2011/10/18 20:20:29 hannken Exp $);
 #endif /* not lint */
 
 
@@ -1978,13 +1978,15 @@ udf_rename(void *v)
 	}
 
 	/* get info about the node to be moved */
+	vn_lock(fvp, LK_SHARED | LK_RETRY);
 	error = VOP_GETATTR(fvp, fvap, FSCRED);
+	VOP_UNLOCK(fvp);
 	KASSERT(error == 0);
 
 	/* check when to delete the old already existing entry */
 	if (tvp) {
 		/* get info about the node to be moved to */
-		error = VOP_GETATTR(fvp, tvap, FSCRED);
+		error = VOP_GETATTR(tvp, tvap, FSCRED);
 		KASSERT(error == 0);
 
 		/* if both dirs, make sure the destination is empty */



CVS commit: src/sys/fs/udf

2011-09-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 27 01:13:16 UTC 2011

Modified Files:
src/sys/fs/udf: udf.h udf_subr.c udf_vfsops.c

Log Message:
- rename UDF_MAX_NAMELEN - UDF_MAXNAMLEN
- use NAME_MAX instead of MAXNAMLEN


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.116 -r1.117 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.60 -r1.61 src/sys/fs/udf/udf_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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.43 src/sys/fs/udf/udf.h:1.44
--- src/sys/fs/udf/udf.h:1.43	Fri Sep 24 21:42:40 2010
+++ src/sys/fs/udf/udf.h	Mon Sep 26 21:13:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.43 2010/09/25 01:42:40 matt Exp $ */
+/* $NetBSD: udf.h,v 1.44 2011/09/27 01:13:16 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -139,7 +139,7 @@ extern int udf_verbose;
 
 
 /* constants */
-#define UDF_MAX_NAMELEN		255			/* as per SPEC */
+#define UDF_MAXNAMLEN		255			/* as per SPEC */
 #define UDF_TRANS_ZERO		((uint64_t) -1)
 #define UDF_TRANS_UNMAPPED	((uint64_t) -2)
 #define UDF_TRANS_INTERN	((uint64_t) -3)

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.116 src/sys/fs/udf/udf_subr.c:1.117
--- src/sys/fs/udf/udf_subr.c:1.116	Tue Aug 16 10:29:16 2011
+++ src/sys/fs/udf/udf_subr.c	Mon Sep 26 21:13:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.116 2011/08/16 14:29:16 mbalmer Exp $ */
+/* $NetBSD: udf_subr.c,v 1.117 2011/09/27 01:13:16 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.116 2011/08/16 14:29:16 mbalmer Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.117 2011/09/27 01:13:16 christos Exp $);
 #endif /* not lint */
 
 
@@ -4178,7 +4178,7 @@ udf_to_unix_name(char *result, int resul
 	} else {
 		/* assume 8bit char length byte latin-1 */
 		assert(*id == 8);
-		assert(strlen((char *) (id+1)) = MAXNAMLEN);
+		assert(strlen((char *) (id+1)) = NAME_MAX);
 		strncpy((char *) result, (char *) (id+1), strlen((char *) (id+1)));
 	}
 	free(raw_name, M_UDFTEMP);
@@ -5259,7 +5259,7 @@ udf_dir_attach(struct udf_mount *ump, st
 
 	/* append to the dirhash */
 	/* NOTE do not use dirent anymore or it won't match later! */
-	udf_to_unix_name(dirent.d_name, MAXNAMLEN,
+	udf_to_unix_name(dirent.d_name, NAME_MAX,
 		(char *) fid-data + udf_rw16(fid-l_iu), fid-l_fi, osta_charspec);
 	dirent.d_namlen = strlen(dirent.d_name);
 	dirhash_enter(dirh, dirent, chosen_fid_pos,
@@ -6359,7 +6359,7 @@ brokendir:
 
 	/* create resulting dirent structure */
 	fid_name = (char *) fid-data + udf_rw16(fid-l_iu);
-	udf_to_unix_name(dirent-d_name, MAXNAMLEN,
+	udf_to_unix_name(dirent-d_name, NAME_MAX,
 		fid_name, fid-l_fi, ump-logical_vol-desc_charset);
 
 	/* '..' has no name, so provide one */

Index: src/sys/fs/udf/udf_vfsops.c
diff -u src/sys/fs/udf/udf_vfsops.c:1.60 src/sys/fs/udf/udf_vfsops.c:1.61
--- src/sys/fs/udf/udf_vfsops.c:1.60	Thu Jun 24 09:03:11 2010
+++ src/sys/fs/udf/udf_vfsops.c	Mon Sep 26 21:13:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vfsops.c,v 1.60 2010/06/24 13:03:11 hannken Exp $ */
+/* $NetBSD: udf_vfsops.c,v 1.61 2011/09/27 01:13:16 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vfsops.c,v 1.60 2010/06/24 13:03:11 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vfsops.c,v 1.61 2011/09/27 01:13:16 christos Exp $);
 #endif /* not lint */
 
 
@@ -576,7 +576,7 @@ udf_mountfs(struct vnode *devvp, struct 
 	mp-mnt_stat.f_fsidx.__fsid_val[0] = (uint32_t) devvp-v_rdev;
 	mp-mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_UDF);
 	mp-mnt_stat.f_fsid = mp-mnt_stat.f_fsidx.__fsid_val[0];
-	mp-mnt_stat.f_namemax = UDF_MAX_NAMELEN;
+	mp-mnt_stat.f_namemax = UDF_MAXNAMLEN;
 	mp-mnt_flag |= MNT_LOCAL;
 //	mp-mnt_iflag |= IMNT_MPSAFE;
 



CVS commit: src/sys/fs/udf

2011-09-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 27 01:33:30 UTC 2011

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
return UDF_MAXNAMLEN instead of NAME_MAX


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.66 src/sys/fs/udf/udf_vnops.c:1.67
--- src/sys/fs/udf/udf_vnops.c:1.66	Sat Jun 11 23:35:55 2011
+++ src/sys/fs/udf/udf_vnops.c	Mon Sep 26 21:33:30 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.66 2011/06/12 03:35:55 rmind Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.67 2011/09/27 01:33:30 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.66 2011/06/12 03:35:55 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.67 2011/09/27 01:33:30 christos Exp $);
 #endif /* not lint */
 
 
@@ -1218,7 +1218,7 @@ udf_pathconf(void *v)
 		*ap-a_retval = (116)-1;	/* 16 bits */
 		return 0;
 	case _PC_NAME_MAX:
-		*ap-a_retval = NAME_MAX;
+		*ap-a_retval = UDF_MAXNAMLEN;
 		return 0;
 	case _PC_PATH_MAX:
 		*ap-a_retval = PATH_MAX;



CVS commit: src/sys/fs/udf

2011-07-07 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jul  7 17:45:38 UTC 2011

Modified Files:
src/sys/fs/udf: ecma167-udf.h

Log Message:
English checked and corrected, courtisy of
Igor Sobrado sobr...@orion.ciencias.uniovi.es as noted in OpenBSD that has a
copy of this file.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/udf/ecma167-udf.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/fs/udf/ecma167-udf.h
diff -u src/sys/fs/udf/ecma167-udf.h:1.13 src/sys/fs/udf/ecma167-udf.h:1.14
--- src/sys/fs/udf/ecma167-udf.h:1.13	Wed Dec 23 09:17:41 2009
+++ src/sys/fs/udf/ecma167-udf.h	Thu Jul  7 17:45:38 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ecma167-udf.h,v 1.13 2009/12/23 09:17:41 mbalmer Exp $ */
+/* $NetBSD: ecma167-udf.h,v 1.14 2011/07/07 17:45:38 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2003, 2004, 2005, 2006, 2008, 2009
@@ -29,9 +29,9 @@
  *
  * 
  * Extended and adapted for UDFv2.50+ bij Reinoud Zandijk based on the
- * origional by Scott Long.
+ * original by Scott Long.
  * 
- * 20030508 Made some small typo and explainatory comments
+ * 20030508 Made some small typo and explanatory comments
  * 20030510 Added UDF 2.01 structures
  * 20030519 Added/correct comments on multi-partitioned logical volume space
  * 20050616 Added pseudo overwrite
@@ -108,7 +108,7 @@
 	TAGID_EXTATTR_HDR =	262,
 	TAGID_UNALL_SP_ENTRY =	263,
 	TAGID_SPACE_BITMAP = 	264,
-	TAGID_PART_INTEGRETY = 	265,
+	TAGID_PART_INTEGRITY = 	265,
 	TAGID_EXTFENTRY =	266,
 	TAGID_MAX =		266
 };
@@ -122,11 +122,11 @@
 
 enum {
 	UDF_ACCESSTYPE_NOT_SPECIFIED   = 0,	/* unknown*/
-	UDF_ACCESSTYPE_PSEUDO_OVERWITE = 0,	/* Pseudo overwritable, f.e. BD-R's LOW */
+	UDF_ACCESSTYPE_PSEUDO_OVERWITE = 0,	/* pseudo overwritable, e.g. BD-R's LOW */
 	UDF_ACCESSTYPE_READ_ONLY   = 1,	/* really only readable			*/
 	UDF_ACCESSTYPE_WRITE_ONCE  = 2,	/* write once and you're done		*/
 	UDF_ACCESSTYPE_REWRITEABLE = 3,	/* may need extra work to rewrite	*/
-	UDF_ACCESSTYPE_OVERWRITABLE= 4	/* no limits on rewriting; harddisc f.e.*/
+	UDF_ACCESSTYPE_OVERWRITABLE= 4	/* no limits on rewriting; e.g. harddisc*/
 };
 
 
@@ -327,7 +327,7 @@
 struct pri_vol_desc {
 	struct desc_tag		tag;
 	uint32_t		seq_num;		/* MAX prevail */
-	uint32_t		pvd_num;		/* assigned by author; 0 is special as in it may only occure once */
+	uint32_t		pvd_num;		/* assigned by author; 0 is special as in it may only occur once */
 	char			vol_id[32];		/* KEY ; main identifier of this disc */
 	uint16_t		vds_num;		/* volume descriptor number; i.e. what volume number is it */
 	uint16_t		max_vol_seq;		/* maximum volume descriptor number known */
@@ -345,7 +345,7 @@
 	struct regid		imp_id;
 	uint8_t			imp_use[64];
 	uint32_t		prev_vds_loc;		/* location of predecessor _lov ? */
-	uint16_t		flags;			/* bit 0 : if set indicates volume set name is meaningfull */
+	uint16_t		flags;			/* bit 0 : if set indicates volume set name is meaningful */
 	uint8_t			reserved[22];
 } __packed;
 
@@ -464,7 +464,7 @@
 	uint32_t		meta_mirror_file_lbn;
 	uint32_t		meta_bitmap_file_lbn;
 	uint32_t		alloc_unit_size;	/* allocation unit size in blocks */
-	uint16_t		alignment_unit_size;	/* alignment nessisary in blocks  */
+	uint16_t		alignment_unit_size;	/* alignment necessary in blocks  */
 	uint8_t			flags;
 	uint8_t			reserved1[5];
 } __packed;
@@ -545,7 +545,7 @@
 struct part_hdr_desc {
 	struct short_ad		unalloc_space_table;
 	struct short_ad		unalloc_space_bitmap;
-	struct short_ad		part_integrety_table;	/* has to be ZERO for UDF */
+	struct short_ad		part_integrity_table;	/* has to be ZERO for UDF */
 	struct short_ad		freed_space_table;
 	struct short_ad		freed_space_bitmap;
 	uint8_t			reserved[88];
@@ -700,7 +700,7 @@
 	struct extattr_entryhdr;
 	uint32_t		d_l;		/* length of times[] data following */
 	uint32_t		existence;	/* bitmask */
-	struct timestamp	times[1];	/* in order of assending bits */
+	struct timestamp	times[1];	/* in order of ascending bits */
 } __packed;
 #define UDF_FILETIMES_ATTR_NO	5
 #define UDF_FILETIMES_FILE_CREATION	1



CVS commit: src/sys/fs/udf

2011-01-22 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Jan 22 14:51:43 UTC 2011

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Lookup the physical partition backing up the logical one when searching for the
metadata partition overlap for BD-R.

Fixes a kernel panic on mounting a BD-R formatted with UDF 2.60


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.111 src/sys/fs/udf/udf_subr.c:1.112
--- src/sys/fs/udf/udf_subr.c:1.111	Fri Jan 21 20:36:53 2011
+++ src/sys/fs/udf/udf_subr.c	Sat Jan 22 14:51:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.111 2011/01/21 20:36:53 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.112 2011/01/22 14:51:43 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.111 2011/01/21 20:36:53 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.112 2011/01/22 14:51:43 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -445,7 +445,7 @@
 
 	/* get our base partition extent */
 	KASSERT(ump-node_part == ump-fids_part);
-	part = ump-partitions[ump-node_part];
+	part = ump-partitions[ump-vtop[ump-node_part]];
 	phys_part_start = udf_rw32(part-start_loc);
 	phys_part_end   = phys_part_start + udf_rw32(part-part_len);
 



CVS commit: src/sys/fs/udf

2011-01-22 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Jan 22 18:02:18 UTC 2011

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
A not rewritable disc can be pseudo-overwritable. A pseudo-overwritable disc
can overwrite its logical volume integrity sequence so no need to make it
append-only for this class of discs.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.112 src/sys/fs/udf/udf_subr.c:1.113
--- src/sys/fs/udf/udf_subr.c:1.112	Sat Jan 22 14:51:43 2011
+++ src/sys/fs/udf/udf_subr.c	Sat Jan 22 18:02:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.112 2011/01/22 14:51:43 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.113 2011/01/22 18:02:18 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.112 2011/01/22 14:51:43 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.113 2011/01/22 18:02:18 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1460,7 +1460,6 @@
 	logvol_integrity = udf_rw32(ump-logvol_integrity-integrity_type);
 	if (logvol_integrity == UDF_INTEGRITY_CLOSED) {
 		if ((space  3)  (lvflag  UDF_APPENDONLY_LVINT)) {
-			/* don't allow this logvol to be opened */
 			/* TODO extent LVINT space if possible */
 			return EROFS;
 		}
@@ -2056,7 +2055,9 @@
 		ump-lvopen  = UDF_WRITE_LVINT;
 		ump-lvclose = UDF_WRITE_LVINT;
 		if ((ump-discinfo.mmc_cur  MMC_CAP_REWRITABLE) == 0)
-			ump-lvopen  |= UDF_APPENDONLY_LVINT;
+			ump-lvopen  |=  UDF_APPENDONLY_LVINT;
+		if ((ump-discinfo.mmc_cur  MMC_CAP_PSEUDOOVERWRITE))
+			ump-lvopen  = ~UDF_APPENDONLY_LVINT;
 	}
 
 	/*



CVS commit: src/sys/fs/udf

2011-01-21 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Jan 21 20:36:53 UTC 2011

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Split out the raw to indexed partitioning code protecting against roque
implementations that use `ramdom' numbers for the physical partitions breaking
lots of implementations. Known curlpit is MicroSoft Windows 7.

Not only the partition mappings need to be protected against this but also the 
metadata partition files.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.110 src/sys/fs/udf/udf_subr.c:1.111
--- src/sys/fs/udf/udf_subr.c:1.110	Thu Jan 13 13:13:31 2011
+++ src/sys/fs/udf/udf_subr.c	Fri Jan 21 20:36:53 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.110 2011/01/13 13:13:31 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.111 2011/01/21 20:36:53 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.110 2011/01/13 13:13:31 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.111 2011/01/21 20:36:53 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -983,6 +983,28 @@
 	return vpart_num;
 }
 
+
+/* 
+ * BUGALERT: some rogue implementations use random physical partition
+ * numbers to break other implementations so lookup the number.
+ */
+
+static uint16_t
+udf_find_raw_phys(struct udf_mount *ump, uint16_t raw_phys_part)
+{
+	struct part_desc *part;
+	uint16_t phys_part;
+
+	for (phys_part = 0; phys_part  UDF_PARTITIONS; phys_part++) {
+		part = ump-partitions[phys_part];
+		if (part == NULL)
+			break;
+		if (udf_rw16(part-part_num) == raw_phys_part)
+			break;
+	}
+	return phys_part;
+}
+
 /* - */
 
 /* we dont try to be smart; we just record the parts */
@@ -994,7 +1016,6 @@
 static int
 udf_process_vds_descriptor(struct udf_mount *ump, union dscrptr *dscr)
 {
-	struct part_desc *part;
 	uint16_t phys_part, raw_phys_part;
 
 	DPRINTF(VOLUMES, (\tprocessing VDS descr %d\n,
@@ -1026,13 +1047,8 @@
 		 * the number.
 		 */
 		raw_phys_part = udf_rw16(dscr-pd.part_num);
-		for (phys_part = 0; phys_part  UDF_PARTITIONS; phys_part++) {
-			part = ump-partitions[phys_part];
-			if (part == NULL)
-break;
-			if (udf_rw16(part-part_num) == raw_phys_part)
-break;
-		}
+		phys_part = udf_find_raw_phys(ump, raw_phys_part);
+
 		if (phys_part == UDF_PARTITIONS) {
 			free(dscr, M_UDFVOLD);
 			return EINVAL;
@@ -1839,7 +1855,6 @@
 	/* struct udf_args *args = ump-mount_args; */
 	struct logvol_int_desc *lvint;
 	struct udf_logvol_info *lvinfo;
-	struct part_desc *part;
 	uint32_t n_pm, mt_l;
 	uint8_t *pmap_pos;
 	char *domain_name, *map_name;
@@ -1970,13 +1985,7 @@
 		 * partition numbers to break other implementations so lookup
 		 * the number.
 		 */
-		for (phys_part = 0; phys_part  UDF_PARTITIONS; phys_part++) {
-			part = ump-partitions[phys_part];
-			if (part == NULL)
-continue;
-			if (udf_rw16(part-part_num) == raw_phys_part)
-break;
-		}
+		phys_part = udf_find_raw_phys(ump, raw_phys_part);
 
 		DPRINTF(VOLUMES, (\t%d - %d(%d) type %d\n, log_part,
 		raw_phys_part, phys_part, pmap_type));
@@ -3116,17 +3125,28 @@
 	struct part_map_meta *pmm = mapping-pmm;
 	struct long_ad	 icb_loc;
 	struct vnode *vp;
+	uint16_t raw_phys_part, phys_part;
 	int error;
 
+	/*
+	 * BUGALERT: some rogue implementations use random physical
+	 * partition numbers to break other implementations so lookup
+	 * the number.
+	 */
+
 	/* extract our allocation parameters set up on format */
 	ump-metadata_alloc_unit_size = udf_rw32(mapping-pmm.alloc_unit_size);
 	ump-metadata_alignment_unit_size = udf_rw16(mapping-pmm.alignment_unit_size);
 	ump-metadata_flags = mapping-pmm.flags;
 
 	DPRINTF(VOLUMES, (Reading in Metadata files\n));
-	icb_loc.loc.part_num = pmm-part_num;
-	icb_loc.loc.lb_num   = pmm-meta_file_lbn;
+	raw_phys_part = udf_rw16(pmm-part_num);
+	phys_part = udf_find_raw_phys(ump, raw_phys_part);
+
+	icb_loc.loc.part_num = udf_rw16(phys_part);
+
 	DPRINTF(VOLUMES, (Metadata file\n));
+	icb_loc.loc.lb_num   = pmm-meta_file_lbn;
 	error = udf_get_node(ump, icb_loc, ump-metadata_node);
 	if (ump-metadata_node) {
 		vp = ump-metadata_node-vnode;
@@ -5309,6 +5329,7 @@
 	/* garbage check: translate udf_node_icb_loc to sectornr */
 	error = udf_translate_vtop(ump, node_icb_loc, sector, dummy);
 	if (error) {
+		DPRINTF(NODE, (\tcan't translate icb address!\n));
 		/* no use, this will fail anyway */
 		mutex_exit(ump-get_node_lock);
 		return EINVAL;



CVS commit: src/sys/fs/udf

2011-01-14 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Jan 14 09:09:18 UTC 2011

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
Metadata partition (v2.50+) bugfix commit :

* fix copying of the extents of the metadata node to the metadatamirror node;
  it was not copying all extents.

* fix truncing metadata partition:
   * fix endian conversions
   * fix information length calculation so its truncated to the right length!

* allow for setting maximum extent length in extent merging. This is needed
  since extents in the metadata partition files are only to be in allocation
  unit sizes.

* adjust grow and shrink node to set the granularity of the maximum length of
  an extent when encountering a metadatafile or metadatamirror file.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.30 src/sys/fs/udf/udf_allocation.c:1.31
--- src/sys/fs/udf/udf_allocation.c:1.30	Wed Dec 22 12:15:02 2010
+++ src/sys/fs/udf/udf_allocation.c	Fri Jan 14 09:09:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.30 2010/12/22 12:15:02 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.31 2011/01/14 09:09:18 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.30 2010/12/22 12:15:02 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.31 2011/01/14 09:09:18 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -76,15 +76,10 @@
 static void udf_collect_free_space_for_vpart(struct udf_mount *ump,
 	uint16_t vpart_num, uint32_t num_lb);
 
+static int udf_ads_merge(uint32_t max_len, uint32_t lb_size, struct long_ad *a1, struct long_ad *a2);
 static void udf_wipe_adslots(struct udf_node *udf_node);
 static void udf_count_alloc_exts(struct udf_node *udf_node);
 
-/*
- * IDEA/BUSY: Each udf_node gets its own extentwalker state for all operations;
- * this will hopefully/likely reduce O(nlog(n)) to O(1) for most functionality
- * since actions are most likely sequencial and thus seeking doesn't need
- * searching for the same or adjacent position again.
- */
 
 /* - */
 
@@ -1407,10 +1402,12 @@
  * no-op since they describe different extents on the disc.
  */
 
-void udf_synchronise_metadatamirror_node(struct udf_mount *ump)
+void
+udf_synchronise_metadatamirror_node(struct udf_mount *ump)
 {
 	struct udf_node *meta_node, *metamirror_node;
 	struct long_ad s_ad;
+	uint32_t len, flags;
 	int slot, cpy_slot;
 	int error, eof;
 
@@ -1430,11 +1427,21 @@
 		udf_get_adslot(meta_node, slot, s_ad, eof);
 		if (eof)
 			break;
+		len   = udf_rw32(s_ad.len);
+		flags = UDF_EXT_FLAGS(len);
+		len   = UDF_EXT_LEN(len);
+
+		if (flags == UDF_EXT_REDIRECT) {
+			slot++;
+			continue;
+		}
+
 		error = udf_append_adslot(metamirror_node, cpy_slot, s_ad);
 		if (error) {
 			/* WTF, this shouldn't happen, what to do now? */
 			panic(udf_synchronise_metadatamirror_node failed!);
 		}
+		cpy_slot++;
 		slot++;
 	}
 
@@ -1466,6 +1473,7 @@
  * and a metadata partition.
  */
 
+/* implementation limit: ump-datapart is the companion partition */
 static uint32_t
 udf_trunc_metadatapart(struct udf_mount *ump, uint32_t num_lb)
 {
@@ -1474,9 +1482,9 @@
 	struct space_bitmap_desc *sbd, *new_sbd;
 	struct logvol_int_desc *lvid;
 	uint64_t inf_len;
-	uint64_t meta_free_lbs, data_free_lbs;
+	uint64_t meta_free_lbs, data_free_lbs, to_trunc;
 	uint32_t *freepos, *sizepos;
-	uint32_t unit, lb_size, to_trunc;
+	uint32_t unit, lb_size;
 	uint16_t meta_vpart_num, data_vpart_num, num_vpart;
 	int err;
 
@@ -1484,6 +1492,13 @@
 	lb_size = udf_rw32(ump-logical_vol-lb_size);
 	lvid = ump-logvol_integrity;
 
+	/* XXX
+	 *
+	 * the following checks will fail for BD-R UDF 2.60! but they are
+	 * read-only for now anyway! Its even doubtfull if it is to be allowed
+	 * for these discs.
+	 */
+
 	/* lookup vpart for metadata partition */
 	meta_vpart_num = ump-node_part;
 	KASSERT(ump-vtop_alloc[meta_vpart_num] == UDF_ALLOC_METABITMAP);
@@ -1514,7 +1529,7 @@
 	if (to_trunc == 0)
 		return num_lb;
 
-	DPRINTF(RESERVE, (\ttruncating %d lbs from the metadata bitmap\n,
+	DPRINTF(RESERVE, (\ttruncating %PRIu64 lbs from the metadata bitmap\n,
 		to_trunc));
 
 	/* get length of the metadata bitmap node file */
@@ -1530,8 +1545,8 @@
 	/* as per [UDF 2.60/2.2.13.6] : */
 	/* 1) update the SBD in the metadata bitmap file */
 	sbd = (struct space_bitmap_desc *) bitmap-blob;
-	sbd-num_bits  = udf_rw32(sbd-num_bits)  - to_trunc;
-	sbd-num_bytes = udf_rw32(sbd-num_bytes) - to_trunc/8;
+	sbd-num_bits  = udf_rw32(udf_rw32(sbd-num_bits)  - to_trunc);
+	sbd-num_bytes = udf_rw32(udf_rw32(sbd-num_bytes) - to_trunc/8);
 	

CVS commit: src/sys/fs/udf

2011-01-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jan 13 13:13:32 UTC 2011

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Fix the case in where a file with a latin1 file name was created. It was then
erronously entered as thelatin1 file name in the dirhash whereas the matching
routing assumes both UTF-8. This would result in a file being created but not
stat-able since the dirhash couldn't find the entry unless it was remounted.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.109 src/sys/fs/udf/udf_subr.c:1.110
--- src/sys/fs/udf/udf_subr.c:1.109	Wed Dec 22 12:38:42 2010
+++ src/sys/fs/udf/udf_subr.c	Thu Jan 13 13:13:31 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.109 2010/12/22 12:38:42 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.110 2011/01/13 13:13:31 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.109 2010/12/22 12:38:42 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.110 2011/01/13 13:13:31 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -4568,7 +4568,15 @@
 			dirent-d_namlen, dirent-d_namlen, dirent-d_name));
 
 		/* see if its our entry */
-		KASSERT(dirent-d_namlen == namelen);
+#ifdef DIAGNOSTIC
+		if (dirent-d_namlen != namelen) {
+			printf(WARNING: dirhash_lookup() returned wrong 
+d_namelen: %d and ought to be %d\n,
+dirent-d_namlen, namelen);
+			printf(\tlooked for `%s' and got `%s'\n,
+name, dirent-d_name);
+		}
+#endif
 		if (strncmp(dirent-d_name, name, namelen) == 0) {
 			*found = 1;
 			*icb_loc = fid-icb;
@@ -5227,8 +5235,10 @@
 	}
 
 	/* append to the dirhash */
-	dirent.d_namlen = cnp-cn_namelen;
-	memcpy(dirent.d_name, cnp-cn_nameptr, cnp-cn_namelen);
+	/* NOTE do not use dirent anymore or it won't match later! */
+	udf_to_unix_name(dirent.d_name, MAXNAMLEN,
+		(char *) fid-data + udf_rw16(fid-l_iu), fid-l_fi, osta_charspec);
+	dirent.d_namlen = strlen(dirent.d_name);
 	dirhash_enter(dirh, dirent, chosen_fid_pos,
 		udf_fidsize(fid), 1);
 



CVS commit: src/sys/fs/udf

2011-01-03 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Mon Jan  3 13:12:40 UTC 2011

Modified Files:
src/sys/fs/udf: udf_strat_sequential.c

Log Message:
destroy mutex/cv before freeing the struct holding them, fixes
LOCKDEBUG panic


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/fs/udf/udf_strat_sequential.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/fs/udf/udf_strat_sequential.c
diff -u src/sys/fs/udf/udf_strat_sequential.c:1.10 src/sys/fs/udf/udf_strat_sequential.c:1.11
--- src/sys/fs/udf/udf_strat_sequential.c:1.10	Wed May 20 15:30:26 2009
+++ src/sys/fs/udf/udf_strat_sequential.c	Mon Jan  3 13:12:40 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_sequential.c,v 1.10 2009/05/20 15:30:26 reinoud Exp $ */
+/* $NetBSD: udf_strat_sequential.c,v 1.11 2011/01/03 13:12:40 drochner Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_strat_sequential.c,v 1.10 2009/05/20 15:30:26 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_strat_sequential.c,v 1.11 2011/01/03 13:12:40 drochner Exp $);
 #endif /* not lint */
 
 
@@ -671,6 +671,9 @@
 	/* destroy our pool */
 	pool_destroy(priv-desc_pool);
 
+	mutex_destroy(priv-discstrat_mutex);
+	cv_destroy(priv-discstrat_cv);
+
 	/* free our private space */
 	free(ump-strategy_private, M_UDFTEMP);
 	ump-strategy_private = NULL;



CVS commit: src/sys/fs/udf

2010-12-22 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Dec 22 12:15:02 UTC 2010

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
Growing the metadata partition is not yet implemented. Be so kind to report
this as unimplemented when the debug flag asks for it!


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.29 src/sys/fs/udf/udf_allocation.c:1.30
--- src/sys/fs/udf/udf_allocation.c:1.29	Fri Feb 26 09:57:39 2010
+++ src/sys/fs/udf/udf_allocation.c	Wed Dec 22 12:15:02 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.29 2010/02/26 09:57:39 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.30 2010/12/22 12:15:02 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.29 2010/02/26 09:57:39 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.30 2010/12/22 12:15:02 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1608,6 +1608,7 @@
 		/* try to grow the meta partition */
 		DPRINTF(RESERVE, (\ttrying to grow the meta partition\n));
 		/* as per [UDF 2.60/2.2.13.5] : extend bitmap and metadata file(s) */
+		DPRINTF(NOTIMPL, (\tgrowing meta partition not implemented yet\n));
 	} else {
 		/* try to shrink the metadata partition */
 		DPRINTF(RESERVE, (\ttrying to shrink the meta partition\n));



CVS commit: src/sys/fs/udf

2010-12-22 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Dec 22 12:38:43 UTC 2010

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Running with DEBUG again revealed locking errors previously undetected. The
VAT writeout was done locked while marked locked as were the readin and
writeout of the metadata partition space table.

While here, also protect the (vp) argument of the UDF_SET_SYSTEMFILE() macro.

Tested on UDF 1.50 sequential, UDF 2.01 RW and UDF 2.50 metadata RW meda.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.108 src/sys/fs/udf/udf_subr.c:1.109
--- src/sys/fs/udf/udf_subr.c:1.108	Fri Sep 24 22:51:50 2010
+++ src/sys/fs/udf/udf_subr.c	Wed Dec 22 12:38:42 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.108 2010/09/24 22:51:50 rmind Exp $ */
+/* $NetBSD: udf_subr.c,v 1.109 2010/12/22 12:38:42 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.108 2010/09/24 22:51:50 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.109 2010/12/22 12:38:42 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -73,8 +73,8 @@
 #define UDF_SET_SYSTEMFILE(vp) \
 	/* XXXAD Is the vnode locked? */	\
 	(vp)-v_vflag |= VV_SYSTEM;		\
-	vref(vp);			\
-	vput(vp);			\
+	vref((vp));			\
+	vput((vp));			\
 
 extern int syncer_maxdelay; /* maximum delay time */
 extern int (**udf_vnodeop_p)(void *);
@@ -1738,7 +1738,7 @@
 			dscr,
 			inflen, 0,
 			UIO_SYSSPACE,
-			IO_SYNC | IO_NODELOCKED | IO_ALTSEMANTICS, FSCRED,
+			IO_SYNC | IO_ALTSEMANTICS, FSCRED,
 			NULL, NULL);
 	if (error) {
 		DPRINTF(VOLUMES, (Error reading metadata space bitmap\n));
@@ -1810,7 +1810,7 @@
 			dscr,
 			new_inflen, 0,
 			UIO_SYSSPACE,
-			IO_NODELOCKED | IO_ALTSEMANTICS, FSCRED,
+			IO_ALTSEMANTICS, FSCRED,
 			NULL, NULL);
 
 	bitmap_node-i_flags |= IN_MODIFIED;
@@ -2815,7 +2815,7 @@
 	vat_length = ump-vat_table_len;
 	error = vn_rdwr(UIO_WRITE, vat_node-vnode,
 		ump-vat_table, ump-vat_table_len, 0,
-		UIO_SYSSPACE, IO_NODELOCKED, FSCRED, NULL, NULL);
+		UIO_SYSSPACE, 0, FSCRED, NULL, NULL);
 	if (error) {
 		printf(udf_writeout_vat: failed to write out VAT contents\n);
 		goto out;



CVS commit: src/sys/fs/udf

2010-02-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Feb 24 19:14:12 UTC 2010

Modified Files:
src/sys/fs/udf: udf.h udf_subr.c

Log Message:
Extract UDF metadata partition parameters as already done for VAT and sparable
partitions.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.101 -r1.102 src/sys/fs/udf/udf_subr.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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.38 src/sys/fs/udf/udf.h:1.39
--- src/sys/fs/udf/udf.h:1.38	Wed Aug  5 13:45:48 2009
+++ src/sys/fs/udf/udf.h	Wed Feb 24 19:14:12 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.38 2009/08/05 13:45:48 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.39 2010/02/24 19:14:12 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -330,6 +330,8 @@
 	struct udf_node 	*metadatabitmap_node;	/* system node   */
 	struct space_bitmap_desc*metadata_unalloc_dscr;
 	struct udf_bitmap	 metadata_unalloc_bits;
+	uint32_t		 alloc_unit_size;
+	uint16_t		 alignment_unit_size;
 
 	/* rb tree for lookup icb to udf_node and sorted list for sync */
 	kmutex_t	ihash_lock;

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.101 src/sys/fs/udf/udf_subr.c:1.102
--- src/sys/fs/udf/udf_subr.c:1.101	Tue Jan  5 13:30:11 2010
+++ src/sys/fs/udf/udf_subr.c	Wed Feb 24 19:14:12 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.101 2010/01/05 13:30:11 mbalmer Exp $ */
+/* $NetBSD: udf_subr.c,v 1.102 2010/02/24 19:14:12 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.101 2010/01/05 13:30:11 mbalmer Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.102 2010/02/24 19:14:12 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -3118,6 +3118,10 @@
 	struct vnode *vp;
 	int error;
 
+	/* extract our allocation parameters set up on format */
+	ump-alloc_unit_size = udf_rw32(mapping-pmm.alloc_unit_size);
+	ump-alignment_unit_size = udf_rw16(mapping-pmm.alignment_unit_size);
+
 	DPRINTF(VOLUMES, (Reading in Metadata files\n));
 	icb_loc.loc.part_num = pmm-part_num;
 	icb_loc.loc.lb_num   = pmm-meta_file_lbn;



CVS commit: src/sys/fs/udf

2010-02-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Feb 24 19:20:13 UTC 2010

Modified Files:
src/sys/fs/udf: udf.h udf_subr.c

Log Message:
Rename metadata partition parameters to be less generic and add the flags.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.102 -r1.103 src/sys/fs/udf/udf_subr.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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.39 src/sys/fs/udf/udf.h:1.40
--- src/sys/fs/udf/udf.h:1.39	Wed Feb 24 19:14:12 2010
+++ src/sys/fs/udf/udf.h	Wed Feb 24 19:20:13 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.39 2010/02/24 19:14:12 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.40 2010/02/24 19:20:13 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -330,8 +330,9 @@
 	struct udf_node 	*metadatabitmap_node;	/* system node   */
 	struct space_bitmap_desc*metadata_unalloc_dscr;
 	struct udf_bitmap	 metadata_unalloc_bits;
-	uint32_t		 alloc_unit_size;
-	uint16_t		 alignment_unit_size;
+	uint32_t		 metadata_alloc_unit_size;
+	uint16_t		 metadata_alignment_unit_size;
+	uint8_t			 metadata_flags;
 
 	/* rb tree for lookup icb to udf_node and sorted list for sync */
 	kmutex_t	ihash_lock;

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.102 src/sys/fs/udf/udf_subr.c:1.103
--- src/sys/fs/udf/udf_subr.c:1.102	Wed Feb 24 19:14:12 2010
+++ src/sys/fs/udf/udf_subr.c	Wed Feb 24 19:20:13 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.102 2010/02/24 19:14:12 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.103 2010/02/24 19:20:13 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.102 2010/02/24 19:14:12 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.103 2010/02/24 19:20:13 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -3119,8 +3119,9 @@
 	int error;
 
 	/* extract our allocation parameters set up on format */
-	ump-alloc_unit_size = udf_rw32(mapping-pmm.alloc_unit_size);
-	ump-alignment_unit_size = udf_rw16(mapping-pmm.alignment_unit_size);
+	ump-metadata_alloc_unit_size = udf_rw32(mapping-pmm.alloc_unit_size);
+	ump-metadata_alignment_unit_size = udf_rw16(mapping-pmm.alignment_unit_size);
+	ump-metadata_flags = mapping-pmm.flags;
 
 	DPRINTF(VOLUMES, (Reading in Metadata files\n));
 	icb_loc.loc.part_num = pmm-part_num;



CVS commit: src/sys/fs/udf

2009-09-14 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Sep 14 21:10:44 UTC 2009

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Rework simplistic UBC flushing. Recent changes to genfs made the old flush
system generate heaps of odd allocations since the end of write request was
overwritten by the start of the second resulting in another relocation.

Also added a full flush of the file on a VOP_CLOSE(). This automatically
flushes file tails to disc.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.54 src/sys/fs/udf/udf_vnops.c:1.55
--- src/sys/fs/udf/udf_vnops.c:1.54	Thu Jul 30 12:13:51 2009
+++ src/sys/fs/udf/udf_vnops.c	Mon Sep 14 21:10:44 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.54 2009/07/30 12:13:51 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.55 2009/09/14 21:10:44 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.54 2009/07/30 12:13:51 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.55 2009/09/14 21:10:44 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -364,16 +364,14 @@
 		 * flush what we just wrote if necessary.
 		 * XXXUBC simplistic async flushing.
 		 *
-		 * this one works on page sizes. Directories are excluded
-		 * since its file data that we want to purge.
+		 * Directories are excluded since its file data that we want
+		 * to purge.
 		 */
 		if (!async  (vp-v_type != VDIR) 
-		  (uio-uio_offset - old_offset = PAGE_SIZE)) {
+		  (old_offset  16 != uio-uio_offset  16)) {
 			mutex_enter(vp-v_interlock);
-			error = VOP_PUTPAGES(vp,
-ptoa(atop(old_offset)),
-ptoa(atop(uio-uio_offset + PAGE_SIZE-1)),
-PGO_CLEANIT);
+			error = VOP_PUTPAGES(vp, (old_offset  16)  16,
+			(uio-uio_offset  16)  16, PGO_CLEANIT);
 			old_offset = uio-uio_offset;
 		}
 	}
@@ -1297,10 +1295,19 @@
 	} */ *ap = v;
 	struct vnode *vp = ap-a_vp;
 	struct udf_node *udf_node = VTOI(vp);
+	int async = vp-v_mount-mnt_flag  MNT_ASYNC;
+	int error;
 
 	DPRINTF(CALL, (udf_close called\n));
 	udf_node = udf_node;	/* shut up gcc */
 
+	if (!async  (vp-v_type != VDIR)) {
+		mutex_enter(vp-v_interlock);
+		error = VOP_PUTPAGES(vp, 0, 0, PGO_CLEANIT);
+		if (error)
+			return error;
+	}
+
 	mutex_enter(vp-v_interlock);
 		if (vp-v_usecount  1)
 			udf_itimes(udf_node, NULL, NULL, NULL);



CVS commit: src/sys/fs/udf

2009-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Aug  5 13:45:48 UTC 2009

Modified Files:
src/sys/fs/udf: udf.h

Log Message:
Typo fix


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/fs/udf/udf.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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.37 src/sys/fs/udf/udf.h:1.38
--- src/sys/fs/udf/udf.h:1.37	Wed Jul  8 14:53:23 2009
+++ src/sys/fs/udf/udf.h	Wed Aug  5 13:45:48 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.37 2009/07/08 14:53:23 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.38 2009/08/05 13:45:48 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -331,7 +331,7 @@
 	struct space_bitmap_desc*metadata_unalloc_dscr;
 	struct udf_bitmap	 metadata_unalloc_bits;
 
-	/* hash table to lookup icb - udf_node and sorted list for sync */
+	/* rb tree for lookup icb to udf_node and sorted list for sync */
 	kmutex_t	ihash_lock;
 	kmutex_t	get_node_lock;
 	struct rb_tree	udf_node_tree;
@@ -374,7 +374,7 @@
 	char const		*lock_fname;
 	int			 lock_lineno;
 
-	/* rb_node for fast lookup and fast sequentual visiting */
+	/* rb_node for fast lookup and fast sequential visiting */
 	struct rb_node		 rbnode;
 
 	/* one of `fe' or `efe' can be set, not both (UDF file entry dscr.)  */



CVS commit: src/sys/fs/udf

2009-07-30 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jul 30 12:13:51 UTC 2009

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Fix uid/gid check; it was checking if the old values would fit in 32 bits
instead of checking if the new values would.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.53 src/sys/fs/udf/udf_vnops.c:1.54
--- src/sys/fs/udf/udf_vnops.c:1.53	Mon Jul 27 13:20:41 2009
+++ src/sys/fs/udf/udf_vnops.c	Thu Jul 30 12:13:51 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.53 2009/07/27 13:20:41 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.54 2009/07/30 12:13:51 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.53 2009/07/27 13:20:41 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.54 2009/07/30 12:13:51 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -969,9 +969,9 @@
 		new_gid = gid;
 
 	/* check if we can fit it in an 32 bits */
-	if ((uid_t) ((uint32_t) uid) != uid)
+	if ((uid_t) ((uint32_t) new_uid) != new_uid)
 		return EINVAL;
-	if ((gid_t) ((uint32_t) gid) != gid)
+	if ((gid_t) ((uint32_t) new_gid) != new_gid)
 		return EINVAL;
 
 	/* check permissions */



CVS commit: src/sys/fs/udf

2009-07-27 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Jul 27 13:13:33 UTC 2009

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Issue extra synchronise caches before closing tracks or sessions. It shouldn't
be needed as the caches should already be synchronised, but better be safe.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.98 src/sys/fs/udf/udf_subr.c:1.99
--- src/sys/fs/udf/udf_subr.c:1.98	Tue Jul  7 10:23:36 2009
+++ src/sys/fs/udf/udf_subr.c	Mon Jul 27 13:13:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.98 2009/07/07 10:23:36 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.99 2009/07/27 13:13:33 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.98 2009/07/07 10:23:36 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.99 2009/07/27 13:13:33 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -3809,6 +3809,8 @@
 		if (error)
 			return error;
 
+		(void) udf_synchronise_caches(ump);
+
 		/* close all associated tracks */
 		tracknr = ump-discinfo.first_track_last_session;
 		error = 0;



CVS commit: src/sys/fs/udf

2009-07-08 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul  8 14:46:55 UTC 2009

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Since OSTA has not defined a good set of flags to cover our flags, its not
usefull to implement chflags(). Instead ignore it for now since the error
codes might confuse esp. gui's.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.51 src/sys/fs/udf/udf_vnops.c:1.52
--- src/sys/fs/udf/udf_vnops.c:1.51	Tue Jul  7 10:23:36 2009
+++ src/sys/fs/udf/udf_vnops.c	Wed Jul  8 14:46:55 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.51 2009/07/07 10:23:36 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.52 2009/07/08 14:46:55 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.51 2009/07/07 10:23:36 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.52 2009/07/08 14:46:55 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1081,9 +1081,9 @@
 	if (vp-v_mount-mnt_flag  MNT_RDONLY)
 		return EROFS;
 
-	/* XXX we can't do this yet XXX */
+	/* XXX we can't do this yet, but erroring out is enoying XXX */
 
-	return EINVAL;
+	return 0;
 }
 
 



CVS commit: src/sys/fs/udf

2009-07-08 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul  8 14:53:23 UTC 2009

Modified Files:
src/sys/fs/udf: udf.h

Log Message:
Remove unused LIST_ENTRY()'s now replaced by the rbtree.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/fs/udf/udf.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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.36 src/sys/fs/udf/udf.h:1.37
--- src/sys/fs/udf/udf.h:1.36	Tue Jul  7 10:23:36 2009
+++ src/sys/fs/udf/udf.h	Wed Jul  8 14:53:23 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.36 2009/07/07 10:23:36 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.37 2009/07/08 14:53:23 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -402,9 +402,6 @@
 	struct udf_node		*extattr;
 	struct udf_node		*streamdir;
 	struct udf_node		*my_parent;		/* if extended attr. */
-
-	LIST_ENTRY(udf_node)	 hashchain;		/* inside hash line  */
-	LIST_ENTRY(udf_node)	 sortchain;		/* sorted udf nodes  */
 };
 
 



CVS commit: src/sys/fs/udf

2009-07-07 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Jul  7 10:23:36 UTC 2009

Modified Files:
src/sys/fs/udf: udf.h udf_subr.c udf_subr.h udf_vfsops.c udf_vnops.c

Log Message:
Replace the old hashtable and sorted list implemenation by a RB-tree.

Benefits are significant speed improvements on node creation/insertion while
keeping the lookup times low and still allowing sequential iteration over the
nodes.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.97 -r1.98 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/udf/udf_subr.h
cvs rdiff -u -r1.58 -r1.59 src/sys/fs/udf/udf_vfsops.c
cvs rdiff -u -r1.50 -r1.51 src/sys/fs/udf/udf_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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.35 src/sys/fs/udf/udf.h:1.36
--- src/sys/fs/udf/udf.h:1.35	Mon Jul  6 17:08:04 2009
+++ src/sys/fs/udf/udf.h	Tue Jul  7 10:23:36 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.35 2009/07/06 17:08:04 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.36 2009/07/07 10:23:36 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -30,6 +30,7 @@
 #define _FS_UDF_UDF_H_
 
 #include sys/queue.h
+#include sys/rb.h
 #include sys/uio.h
 #include sys/mutex.h
 
@@ -333,8 +334,7 @@
 	/* hash table to lookup icb - udf_node and sorted list for sync */
 	kmutex_t	ihash_lock;
 	kmutex_t	get_node_lock;
-	LIST_HEAD(, udf_node) udf_nodes[UDF_INODE_HASHSIZE];
-	LIST_HEAD(, udf_node) sorted_udf_nodes;		/* sorted sync list  */
+	struct rb_tree	udf_node_tree;
 
 	/* syncing */
 	int		syncing;			/* are we syncing?   */
@@ -354,6 +354,11 @@
 };
 
 
+#define RBTOUDFNODE(node) \
+	((node) ? \
+	 (void *)((uintptr_t)(node) - offsetof(struct udf_node, rbnode)) \
+	 : NULL)
+
 /*
  * UDF node describing a file/directory.
  *
@@ -369,6 +374,9 @@
 	char const		*lock_fname;
 	int			 lock_lineno;
 
+	/* rb_node for fast lookup and fast sequentual visiting */
+	struct rb_node		 rbnode;
+
 	/* one of `fe' or `efe' can be set, not both (UDF file entry dscr.)  */
 	struct file_entry	*fe;
 	struct extfile_entry	*efe;

Index: src/sys/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.97 src/sys/fs/udf/udf_subr.c:1.98
--- src/sys/fs/udf/udf_subr.c:1.97	Mon Jul  6 17:06:57 2009
+++ src/sys/fs/udf/udf_subr.c	Tue Jul  7 10:23:36 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.97 2009/07/06 17:06:57 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.98 2009/07/07 10:23:36 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.97 2009/07/06 17:06:57 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.98 2009/07/07 10:23:36 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -3366,7 +3366,7 @@
 /* To make absolutely sure we are NOT returning zero, add one :) */
 
 long
-udf_calchash(struct long_ad *icbptr)
+udf_get_node_id(const struct long_ad *icbptr)
 {
 	/* ought to be enough since each mountpoint has its own chain */
 	return udf_rw32(icbptr-loc.lb_num) + 1;
@@ -3374,120 +3374,102 @@
 
 
 int
-udf_check_icb_equal(struct long_ad *a, struct long_ad *b)
+udf_compare_icb(const struct long_ad *a, const struct long_ad *b)
 {
-	return (a-loc.lb_num   == b-loc.lb_num 
-	a-loc.part_num == b-loc.part_num);
+	if (udf_rw16(a-loc.part_num)  udf_rw16(b-loc.part_num))
+		return -1;
+	if (udf_rw16(a-loc.part_num)  udf_rw16(b-loc.part_num))
+		return 1;
+
+	if (udf_rw32(a-loc.lb_num)  udf_rw32(b-loc.lb_num))
+		return -1;
+	if (udf_rw32(a-loc.lb_num)  udf_rw32(b-loc.lb_num))
+		return 1;
+
+	return 0;
 }
 
 
-static struct udf_node *
-udf_hash_lookup(struct udf_mount *ump, struct long_ad *icbptr)
+static int
+udf_compare_rbnodes(const struct rb_node *a, const struct rb_node *b)
 {
-	struct udf_node *node;
-	struct vnode *vp;
-	uint32_t hashline;
-
-loop:
-	mutex_enter(ump-ihash_lock);
+	struct udf_node *a_node = RBTOUDFNODE(a);
+	struct udf_node *b_node = RBTOUDFNODE(b);
 
-	hashline = udf_calchash(icbptr)  UDF_INODE_HASHMASK;
-	LIST_FOREACH(node, ump-udf_nodes[hashline], hashchain) {
-		assert(node);
-		if (udf_check_icb_equal(node-loc, icbptr)) {
-			vp = node-vnode;
-			assert(vp);
-			mutex_enter(vp-v_interlock);
-			mutex_exit(ump-ihash_lock);
-			if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK))
-goto loop;
-			return node;
-		}
-	}
-	mutex_exit(ump-ihash_lock);
-
-	return NULL;
+	return udf_compare_icb(a_node-loc, b_node-loc);
 }
 
 
-static void
-udf_sorted_list_insert(struct udf_node *node)
+static int
+udf_compare_rbnode_icb(const struct rb_node *a, const void *key)
 {
-	struct udf_mount *ump;
-	struct udf_node  *s_node, *last_node;
-	uint32_t loc, s_loc;
+	struct udf_node *a_node = RBTOUDFNODE(a);
+	const struct long_ad * const icb = key;
 
-	ump = node-ump;
-	last_node = NULL;	/* XXX gcc */
+	return udf_compare_icb(a_node-loc, icb);
+}
 
-	

CVS commit: src/sys/fs/udf

2009-07-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Jul  6 17:06:57 UTC 2009

Modified Files:
src/sys/fs/udf: udf_subr.c udf_vnops.c

Log Message:
Make source prettier


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.49 -r1.50 src/sys/fs/udf/udf_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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.96 src/sys/fs/udf/udf_subr.c:1.97
--- src/sys/fs/udf/udf_subr.c:1.96	Thu Jun 25 17:16:33 2009
+++ src/sys/fs/udf/udf_subr.c	Mon Jul  6 17:06:57 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.96 2009/06/25 17:16:33 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.97 2009/07/06 17:06:57 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.96 2009/06/25 17:16:33 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.97 2009/07/06 17:06:57 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -6218,7 +6218,7 @@
 
 int
 udf_read_fid_stream(struct vnode *vp, uint64_t *offset,
-		struct fileid_desc *fid, struct dirent *dirent)
+		struct fileid_desc *fid, struct dirent *dirent)
 {
 	struct udf_node  *dir_node = VTOI(vp);
 	struct udf_mount *ump = dir_node-ump;

Index: src/sys/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.49 src/sys/fs/udf/udf_vnops.c:1.50
--- src/sys/fs/udf/udf_vnops.c:1.49	Fri Jul  3 23:14:11 2009
+++ src/sys/fs/udf/udf_vnops.c	Mon Jul  6 17:06:57 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.49 2009/07/03 23:14:11 pgoyette Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.50 2009/07/06 17:06:57 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.49 2009/07/03 23:14:11 pgoyette Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.50 2009/07/06 17:06:57 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -586,8 +586,7 @@
 		while (diroffset  file_size) {
 			DPRINTF(READDIR, (\tread in fid stream\n));
 			/* transfer a new fid/dirent */
-			error = udf_read_fid_stream(vp, diroffset,
-fid, dirent);
+			error = udf_read_fid_stream(vp, diroffset, fid, dirent);
 			DPRINTFIF(READDIR, error, (read error in read fid 
 			stream : %d\n, error));
 			if (error)



CVS commit: src/sys/fs/udf

2009-07-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Jul  6 17:13:38 UTC 2009

Modified Files:
src/sys/fs/udf: udf_strat_rmw.c

Log Message:
Re-implement read-modify-write backend strategy. This version is a lot more
clean locking-wise and will consume less CPU power on needless moving-around.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/fs/udf/udf_strat_rmw.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/fs/udf/udf_strat_rmw.c
diff -u src/sys/fs/udf/udf_strat_rmw.c:1.20 src/sys/fs/udf/udf_strat_rmw.c:1.21
--- src/sys/fs/udf/udf_strat_rmw.c:1.20	Thu Jul  2 16:56:35 2009
+++ src/sys/fs/udf/udf_strat_rmw.c	Mon Jul  6 17:13:38 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_rmw.c,v 1.20 2009/07/02 16:56:35 reinoud Exp $ */
+/* $NetBSD: udf_strat_rmw.c,v 1.21 2009/07/06 17:13:38 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_strat_rmw.c,v 1.20 2009/07/02 16:56:35 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_strat_rmw.c,v 1.21 2009/07/06 17:13:38 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -79,7 +79,7 @@
 #define UDF_SHED_READING	2
 #define UDF_SHED_WRITING	3
 #define UDF_SHED_SEQWRITING	4
-#define UDF_SHED_IDLE		5			/* resting */
+#define UDF_SHED_IDLE		5			/* refcnt'd */
 #define UDF_SHED_FREE		6			/* recycleable */
 #define UDF_SHED_MAX		6+1
 
@@ -105,6 +105,9 @@
 	uint32_t		  flags;
 	uint32_t		  start_sector;		/* physical */
 
+	const char		 *fname;
+	int			  sline;
+
 	struct buf		 *buf;
 	void			 *blob;
 
@@ -141,22 +144,29 @@
 
 /* - */
 
-#define UDF_LOCK_ECCLINE(eccline) udf_lock_eccline(eccline)
-#define UDF_UNLOCK_ECCLINE(eccline) udf_unlock_eccline(eccline)
+#define UDF_LOCK_ECCLINE(eccline) udf_lock_eccline(eccline, __FILE__, __LINE__)
+#define UDF_UNLOCK_ECCLINE(eccline) udf_unlock_eccline(eccline, __FILE__, __LINE__)
 
 /* can be called with or without discstrat lock */
 static void
-udf_lock_eccline(struct udf_eccline *eccline)
+udf_lock_eccline(struct udf_eccline *eccline, const char *fname, int sline)
 {
 	struct strat_private *priv = PRIV(eccline-ump);
 	int waslocked, ret;
 
+	KASSERT(mutex_owned(priv-discstrat_mutex));
+
 	waslocked = mutex_owned(priv-discstrat_mutex);
 	if (!waslocked)
 		mutex_enter(priv-discstrat_mutex);
 
 	/* wait until its unlocked first */
+	eccline-refcnt++;
 	while (eccline-flags  ECC_LOCKED) {
+		DPRINTF(ECCLINE, (waiting for lock at %s:%d\n,
+	fname, sline));
+		DPRINTF(ECCLINE, (was locked at %s:%d\n,
+	eccline-fname, eccline-sline));
 		eccline-flags |= ECC_WANTED;
 		ret = cv_timedwait(priv-discstrat_cv, priv-discstrat_mutex,
 			hz/8);
@@ -166,6 +176,10 @@
 	}
 	eccline-flags |= ECC_LOCKED;
 	eccline-flags = ~ECC_WANTED;
+	eccline-refcnt--;
+
+	eccline-fname = fname;
+	eccline-sline = sline;
 
 	if (!waslocked)
 		mutex_exit(priv-discstrat_mutex);
@@ -174,11 +188,13 @@
 
 /* can be called with or without discstrat lock */
 static void
-udf_unlock_eccline(struct udf_eccline *eccline)
+udf_unlock_eccline(struct udf_eccline *eccline, const char *fname, int sline)
 {
 	struct strat_private *priv = PRIV(eccline-ump);
 	int waslocked;
 
+	KASSERT(mutex_owned(priv-discstrat_mutex));
+
 	waslocked = mutex_owned(priv-discstrat_mutex);
 	if (!waslocked)
 		mutex_enter(priv-discstrat_mutex);
@@ -196,28 +212,21 @@
 udf_dispose_eccline(struct udf_eccline *eccline)
 {
 	struct strat_private *priv = PRIV(eccline-ump);
-	struct buf *ret;
 
 	KASSERT(mutex_owned(priv-discstrat_mutex));
 
-	KASSERT(eccline-refcnt == 0);
-	KASSERT(eccline-dirty  == 0);
-
 	DPRINTF(ECCLINE, (dispose eccline with start sector %d, 
 		present %0PRIx64\n, eccline-start_sector,
 		eccline-present));
 
-	if (eccline-queued_on) {
-		ret = bufq_cancel(priv-queues[eccline-queued_on], eccline-buf);
-		KASSERT(ret == eccline-buf);
-		priv-num_queued[eccline-queued_on]--;
-	}
-	LIST_REMOVE(eccline, hashchain);
+	KASSERT(eccline-refcnt == 0);
+	KASSERT(eccline-dirty  == 0);
+	KASSERT(eccline-queued_on == 0);
+	KASSERT(eccline-flags  ECC_FLOATING);
+	KASSERT(eccline-flags  ECC_LOCKED);
 
-	if (eccline-flags  ECC_FLOATING) {
-		eccline-flags = ~ECC_FLOATING;
-		priv-num_floating--;
-	}
+	LIST_REMOVE(eccline, hashchain);
+	priv-num_floating--;
 
 	putiobuf(eccline-buf);
 	pool_put(priv-ecclineblob_pool, eccline-blob);
@@ -230,72 +239,69 @@
 udf_push_eccline(struct udf_eccline *eccline, int newqueue)
 {
 	struct strat_private *priv = PRIV(eccline-ump);
-	struct buf *ret;
-	int curqueue;
 
 	KASSERT(mutex_owned(priv-discstrat_mutex));
 
 	DPRINTF(PARANOIA, (DEBUG: buf %p pushed on queue %d\n, eccline-buf, newqueue));
 
-	/* requeue */
-	curqueue = eccline-queued_on;
-	if (curqueue) {
-		ret = bufq_cancel(priv-queues[curqueue], eccline-buf);
-
-#ifdef DIAGNOSTIC
-		if (ret == NULL) {
-		

CVS commit: src/sys/fs/udf

2009-07-03 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Jul  3 23:14:11 UTC 2009

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Pass the vp arg to udf_check_possible() so we can access its v_mount
member.

XXX No idea if this is the right solution to this problem, but it does
XXX at least allow thebuild to continue.  The original committed should
XXX verify that this does what was intended!

(Hello again, Elad)


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.48 src/sys/fs/udf/udf_vnops.c:1.49
--- src/sys/fs/udf/udf_vnops.c:1.48	Fri Jul  3 21:17:41 2009
+++ src/sys/fs/udf/udf_vnops.c	Fri Jul  3 23:14:11 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.48 2009/07/03 21:17:41 elad Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.49 2009/07/03 23:14:11 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.48 2009/07/03 21:17:41 elad Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.49 2009/07/03 23:14:11 pgoyette Exp $);
 #endif /* not lint */
 
 
@@ -1311,7 +1311,7 @@
 /* - */
 
 static int
-udf_check_possible(struct vattr *vap, mode_t mode)
+udf_check_possible(struct vnode *vp, struct vattr *vap, mode_t mode)
 {
 	int flags;
 
@@ -1383,7 +1383,7 @@
 	if (error)
 		return error;
 
-	error = udf_check_possible(vap, mode);
+	error = udf_check_possible(vp, vap, mode);
 	if (error)
 		return error;
 



CVS commit: src/sys/fs/udf

2009-07-02 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jul  2 16:56:35 UTC 2009

Modified Files:
src/sys/fs/udf: udf_strat_rmw.c

Log Message:
Enhance dumping on buffer screwup. Also prevent races or invalid combinations
to exist for ecclines.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/fs/udf/udf_strat_rmw.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/fs/udf/udf_strat_rmw.c
diff -u src/sys/fs/udf/udf_strat_rmw.c:1.19 src/sys/fs/udf/udf_strat_rmw.c:1.20
--- src/sys/fs/udf/udf_strat_rmw.c:1.19	Wed May 20 15:30:26 2009
+++ src/sys/fs/udf/udf_strat_rmw.c	Thu Jul  2 16:56:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_rmw.c,v 1.19 2009/05/20 15:30:26 reinoud Exp $ */
+/* $NetBSD: udf_strat_rmw.c,v 1.20 2009/07/02 16:56:35 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_strat_rmw.c,v 1.19 2009/05/20 15:30:26 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_strat_rmw.c,v 1.20 2009/07/02 16:56:35 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -242,22 +242,26 @@
 	if (curqueue) {
 		ret = bufq_cancel(priv-queues[curqueue], eccline-buf);
 
-		DPRINTF(PARANOIA, (push_eccline bufq_cancel returned %p when 
-			requested to remove %p from queue %d\n, ret,
-			eccline-buf, curqueue));
 #ifdef DIAGNOSTIC
 		if (ret == NULL) {
 			int i;
 
 			printf(udf_push_eccline: bufq_cancel can't find 
-buffer; dumping queues\n);
+buffer %p on queue %d; 
+dumping queues\n, eccline-buf, curqueue);
 			for (i = 1; i  UDF_SHED_MAX; i++) {
 printf(queue %d\n\t, i);
 ret = bufq_get(priv-queues[i]);
 while (ret) {
 	printf(%p , ret);
+	if (BTOE(ret)-queued_on != i)
+		printf(WRONGQ );
 	if (ret == eccline-buf)
 		printf([-] );
+	if (ret == bufq_peek(priv-queues[i])) {
+		printf(LOOP );
+		break;
+	}
 	ret = bufq_get(priv-queues[i]);
 }
 printf(\n);
@@ -275,9 +279,9 @@
 	eccline-buf-b_blkno= eccline-start_sector;
 	eccline-buf-b_rawblkno = eccline-start_sector;
 
-	bufq_put(priv-queues[newqueue], eccline-buf);
 	eccline-queued_on = newqueue;
 	priv-num_queued[newqueue]++;
+	bufq_put(priv-queues[newqueue], eccline-buf);
 	vfs_timestamp(priv-last_queued[newqueue]);
 
 	if (eccline-flags  ECC_FLOATING) {
@@ -300,7 +304,7 @@
 	KASSERT(mutex_owned(priv-discstrat_mutex));
 
 	buf = bufq_get(priv-queues[queued_on]);
-	if (!buf) {
+	if (buf == NULL) {
 		KASSERT(priv-num_queued[queued_on] == 0);
 		return NULL;
 	}
@@ -390,9 +394,11 @@
 priv-discstrat_mutex, hz/8);
 			goto retry;
 		}
-		/* push back line if we're waiting for it */
-		if (eccline-flags  ECC_WANTED) {
-			udf_push_eccline(eccline, UDF_SHED_IDLE);
+
+		/* push back line if we're waiting for it or its locked */
+		if (eccline-flags  (ECC_WANTED | ECC_LOCKED)) {
+			/* XXX what were they doing on the free list anyway? */
+			udf_push_eccline(eccline, UDF_SHED_WAITING);
 			goto retry;
 		}
 
@@ -1002,6 +1008,7 @@
 	 */
 
 	udf_puteccline(eccline);
+
 	DPRINTF(ECCLINE, (read callback finished\n));
 }
 
@@ -1014,7 +1021,7 @@
 	uint64_t bit;
 	int error, i, len;
 
-	DPRINTF(ECCLINE, (write callback called\n));
+	DPRINTF(ECCLINE, (write callback called buf %p\n, buf));
 	/* post process write action */
 	error = buf-b_error;
 	for (i = 0; i  ump-packet_size; i++) {
@@ -1179,16 +1186,18 @@
 		new_queue = UDF_SHED_READING;
 }
 			}
+			if (eccline-flags  ECC_LOCKED)
+new_queue = UDF_SHED_WAITING;
 			udf_push_eccline(eccline, new_queue);
 			cnt++;
 		}
 
-		/* maintenance: free exess ecclines */
+		/* maintenance: free excess ecclines */
 		while (priv-num_queued[UDF_SHED_FREE]  UDF_ECCLINE_MAXFREE) {
 			eccline = udf_pop_eccline(priv, UDF_SHED_FREE);
 			KASSERT(eccline);
 			KASSERT(eccline-refcnt == 0);
-			if (eccline-flags  ECC_WANTED) {
+			if (eccline-flags  (ECC_WANTED | ECC_LOCKED)) {
 udf_push_eccline(eccline, UDF_SHED_IDLE);
 DPRINTF(ECCLINE, (Tried removing, pushed back to free list\n));
 			} else {



CVS commit: src/sys/fs/udf

2009-06-27 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Jun 27 13:42:06 UTC 2009

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
Fix corner-case in truncing files. It could forget to free the last block.
This would result in a free-space map with one block orphaned.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.26 src/sys/fs/udf/udf_allocation.c:1.27
--- src/sys/fs/udf/udf_allocation.c:1.26	Wed Jun 24 17:09:13 2009
+++ src/sys/fs/udf/udf_allocation.c	Sat Jun 27 13:42:06 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.26 2009/06/24 17:09:13 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.27 2009/06/27 13:42:06 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.26 2009/06/24 17:09:13 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.27 2009/06/27 13:42:06 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -2616,7 +2616,7 @@
 	uint64_t foffset, end_foffset;
 	uint64_t orig_inflen, orig_lbrec, new_inflen, new_lbrec;
 	uint32_t lb_size, dscr_size, crclen;
-	uint32_t slot_offset;
+	uint32_t slot_offset, slot_offset_lb;
 	uint32_t len, flags, max_len;
 	uint32_t num_lb, lb_num;
 	uint32_t max_l_ad, l_ad, l_ea;
@@ -2762,9 +2762,13 @@
 		vpart_num = udf_rw16(s_ad.loc.part_num);
 
 		if (flags == UDF_EXT_ALLOCATED) {
-			/* note: round DOWN on num_lb */
-			lb_num += (slot_offset + lb_size -1) / lb_size;
-			num_lb  = (len - slot_offset) / lb_size;
+			/* calculate extent in lb, and offset in lb */
+			num_lb = (len + lb_size -1) / lb_size;
+			slot_offset_lb = (slot_offset + lb_size -1) / lb_size;
+
+			/* adjust our slot */
+			lb_num += slot_offset_lb;
+			num_lb -= slot_offset_lb;
 
 			udf_free_allocated_space(ump, lb_num, vpart_num, num_lb);
 		}



CVS commit: src/sys/fs/udf

2009-06-25 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jun 25 17:16:33 UTC 2009

Modified Files:
src/sys/fs/udf: udf_subr.c udf_subr.h udf_vnops.c

Log Message:
Rewrite of udf_on_rootpath(), and vop_rename() code that calls it, after the
UFS way. The tree walking is now done the same and the code hasn't locked up
on examples that made it lockup before.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.15 -r1.16 src/sys/fs/udf/udf_subr.h
cvs rdiff -u -r1.46 -r1.47 src/sys/fs/udf/udf_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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.95 src/sys/fs/udf/udf_subr.c:1.96
--- src/sys/fs/udf/udf_subr.c:1.95	Wed Jun 24 17:09:13 2009
+++ src/sys/fs/udf/udf_subr.c	Thu Jun 25 17:16:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.95 2009/06/24 17:09:13 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.96 2009/06/25 17:16:33 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.95 2009/06/24 17:09:13 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.96 2009/06/25 17:16:33 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -3373,6 +3373,14 @@
 }
 
 
+int
+udf_check_icb_equal(struct long_ad *a, struct long_ad *b)
+{
+	return (a-loc.lb_num   == b-loc.lb_num 
+	a-loc.part_num == b-loc.part_num);
+}
+
+
 static struct udf_node *
 udf_hash_lookup(struct udf_mount *ump, struct long_ad *icbptr)
 {
@@ -3386,8 +3394,7 @@
 	hashline = udf_calchash(icbptr)  UDF_INODE_HASHMASK;
 	LIST_FOREACH(node, ump-udf_nodes[hashline], hashchain) {
 		assert(node);
-		if (node-loc.loc.lb_num   == icbptr-loc.lb_num 
-		node-loc.loc.part_num == icbptr-loc.part_num) {
+		if (udf_check_icb_equal(node-loc, icbptr)) {
 			vp = node-vnode;
 			assert(vp);
 			mutex_enter(vp-v_interlock);

Index: src/sys/fs/udf/udf_subr.h
diff -u src/sys/fs/udf/udf_subr.h:1.15 src/sys/fs/udf/udf_subr.h:1.16
--- src/sys/fs/udf/udf_subr.h:1.15	Wed Jun 24 17:09:13 2009
+++ src/sys/fs/udf/udf_subr.h	Thu Jun 25 17:16:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.h,v 1.15 2009/06/24 17:09:13 reinoud Exp $ */
+/* $NetBSD: udf_subr.h,v 1.16 2009/06/25 17:16:33 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -183,6 +183,7 @@
 
 /* helpers and converters */
 long udf_calchash(struct long_ad *icbptr);/* for `inode' numbering */
+int udf_check_icb_equal(struct long_ad *a, struct long_ad *b);
 uint32_t udf_getaccessmode(struct udf_node *node);
 void udf_setaccessmode(struct udf_node *udf_node, mode_t mode);
 void udf_getownership(struct udf_node *udf_node, uid_t *uidp, gid_t *gidp);

Index: src/sys/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.46 src/sys/fs/udf/udf_vnops.c:1.47
--- src/sys/fs/udf/udf_vnops.c:1.46	Wed Jun 24 17:09:13 2009
+++ src/sys/fs/udf/udf_vnops.c	Thu Jun 25 17:16:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.46 2009/06/24 17:09:13 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.47 2009/06/25 17:16:33 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.46 2009/06/24 17:09:13 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.47 2009/06/25 17:16:33 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1825,55 +1825,98 @@
 
 /* - */
 
+/*
+ * 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. Modeled after UFS.
+ *
+ * If source is on the path from target to the root, return error.
+ */
+
 static int
-udf_on_rootpath(struct udf_node *fnode, struct udf_node *tdnode)
+udf_on_rootpath(struct udf_node *source, struct udf_node *target)
 {
-	struct udf_mount *ump = tdnode-ump;
+	struct udf_mount *ump = target-ump;
 	struct udf_node *res_node;
-	struct long_ad icb_loc;
+	struct long_ad icb_loc, *root_icb;
 	const char *name;
 	int namelen;
 	int error, found;
 
-	/* if fnode is on the path from tdnode to the root, return error */
-	name= ..;
-	namelen = 2;
-	while (fnode != tdnode) {
-		DPRINTF(NODE, (udf_on_rootpath : fnode %p, tdnode %p\n,
-			fnode, tdnode));
-		if (tdnode-vnode-v_vflag  VV_ROOT) {
-			/* found root, accept */
-			/* DPRINTF(NODE, (\tCOUGHT, pre-vput\n)); */
-			vput(tdnode-vnode);
-			DPRINTF(NODE, (\tCOUGHT: valid\n));
-			return 0;
+	name = ..;
+	namelen  = 2;
+	error= 0;
+	res_node = target;
+
+	root_icb   = ump-fileset_desc-rootdir_icb;
+
+	/* if nodes are equal, it is no use looking */
+	if (udf_check_icb_equal(source-loc, target-loc)) {
+		error = EEXIST;
+		goto out;
+	}
+
+	/* nothing can exist before the root */
+	if 

CVS commit: src/sys/fs/udf

2009-06-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jun 24 17:09:14 UTC 2009

Modified Files:
src/sys/fs/udf: udf.h udf_allocation.c udf_subr.c udf_subr.h
udf_vfsops.c udf_vnops.c

Log Message:
Commit first stage of free-space accounting. It is estimating the underlimit
of free blocks on the device and when free blocks are getting tight it tries
to readjust/recalculate that value by syncing the FS.

Second stage will be resizing the data/metadata partitions.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/fs/udf/udf.h
cvs rdiff -u -r1.25 -r1.26 src/sys/fs/udf/udf_allocation.c
cvs rdiff -u -r1.94 -r1.95 src/sys/fs/udf/udf_subr.c
cvs rdiff -u -r1.14 -r1.15 src/sys/fs/udf/udf_subr.h
cvs rdiff -u -r1.56 -r1.57 src/sys/fs/udf/udf_vfsops.c
cvs rdiff -u -r1.45 -r1.46 src/sys/fs/udf/udf_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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.33 src/sys/fs/udf/udf.h:1.34
--- src/sys/fs/udf/udf.h:1.33	Tue Jun 23 20:13:37 2009
+++ src/sys/fs/udf/udf.h	Wed Jun 24 17:09:13 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.33 2009/06/23 20:13:37 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.34 2009/06/24 17:09:13 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -124,6 +124,7 @@
 #define UDF_VAT_CHUNKSIZE	(64*1024)		/* picked */
 #define UDF_SYMLINKBUFLEN	(64*1024)		/* picked */
 
+#define UDF_DISC_SLACK		(128)			/* picked, at least 64 kb or 128 */
 #define UDF_ISO_VRS_SIZE	(32*2048)		/* 32 ISO `sectors' */
 
 
@@ -340,7 +341,7 @@
 	kcondvar_t 	dirtynodes_cv;			/* sleeping on sync  */
 
 	/* late allocation */
-	uint32_t		 uncomitted_lb;		/* for free space*/
+	int32_t			 uncommitted_lbs[UDF_PARTITIONS];
 	struct long_ad		*la_node_ad_cpy;		/* issue buf */
 	uint64_t		*la_lmapping, *la_pmapping;	/* issue buf */
 
@@ -387,6 +388,7 @@
 	struct lockf		*lockf;			/* lock list */
 	uint32_t		 outstanding_bufs;	/* file data */
 	uint32_t		 outstanding_nodedscr;	/* node dscr */
+	int32_t			 uncommitted_lbs;	/* in UBC*/
 
 	/* references to associated nodes */
 	struct udf_node		*extattr;

Index: src/sys/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.25 src/sys/fs/udf/udf_allocation.c:1.26
--- src/sys/fs/udf/udf_allocation.c:1.25	Thu Jun 18 15:09:18 2009
+++ src/sys/fs/udf/udf_allocation.c	Wed Jun 24 17:09:13 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.25 2009/06/18 15:09:18 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.26 2009/06/24 17:09:13 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.25 2009/06/18 15:09:18 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.26 2009/06/24 17:09:13 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -367,6 +367,93 @@
 
 /* - */
 
+void
+udf_calc_freespace(struct udf_mount *ump, uint64_t *sizeblks, uint64_t *freeblks)
+{
+	struct logvol_int_desc *lvid;
+	uint32_t *pos1, *pos2;
+	int vpart, num_vpart;
+
+	lvid = ump-logvol_integrity;
+	*freeblks = *sizeblks = 0;
+
+	/*
+	 * Sequentials media report free space directly (CD/DVD/BD-R), for the
+	 * other media we need the logical volume integrity.
+	 *
+	 * We sum all free space up here regardless of type.
+	 */
+
+	KASSERT(lvid);
+	num_vpart = udf_rw32(lvid-num_part);
+
+	if (ump-discinfo.mmc_cur  MMC_CAP_SEQUENTIAL) {
+		/* use track info directly summing if there are 2 open */
+		/* XXX assumption at most two tracks open */
+		*freeblks = ump-data_track.free_blocks;
+		if (ump-data_track.tracknr != ump-metadata_track.tracknr)
+			*freeblks += ump-metadata_track.free_blocks;
+		*sizeblks = ump-discinfo.last_possible_lba;
+	} else {
+		/* free and used space for mountpoint based on logvol integrity */
+		for (vpart = 0; vpart  num_vpart; vpart++) {
+			pos1 = lvid-tables[0] + vpart;
+			pos2 = lvid-tables[0] + num_vpart + vpart;
+			if (udf_rw32(*pos1) != (uint32_t) -1) {
+*freeblks += udf_rw32(*pos1);
+*sizeblks += udf_rw32(*pos2);
+			}
+		}
+	}
+	/* adjust for accounted uncommitted blocks */
+	for (vpart = 0; vpart  num_vpart; vpart++)
+		*freeblks -= ump-uncommitted_lbs[vpart];
+
+	if (*freeblks  UDF_DISC_SLACK) {
+		*freeblks -= UDF_DISC_SLACK;
+	} else {
+		*freeblks = 0;
+	}
+}
+
+
+static void
+udf_calc_vpart_freespace(struct udf_mount *ump, uint16_t vpart_num, uint64_t *freeblks)
+{
+	struct logvol_int_desc *lvid;
+	uint32_t *pos1;
+
+	lvid = ump-logvol_integrity;
+	*freeblks = 0;
+
+	/*
+	 * Sequentials media report free space directly (CD/DVD/BD-R), for the
+	 * other media we need the logical volume integrity.
+	 *
+	 * We sum all free space up here regardless of type.
+	 */
+
+	KASSERT(lvid);
+	if (ump-discinfo.mmc_cur  MMC_CAP_SEQUENTIAL) {
+		/* XXX 

CVS commit: src/sys/fs/udf

2009-06-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jun 18 14:56:09 UTC 2009

Modified Files:
src/sys/fs/udf: udf.h

Log Message:
Remove now unused UDF_DIRHASH constants


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/fs/udf/udf.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/fs/udf/udf.h
diff -u src/sys/fs/udf/udf.h:1.30 src/sys/fs/udf/udf.h:1.31
--- src/sys/fs/udf/udf.h:1.30	Sun Feb  8 19:14:52 2009
+++ src/sys/fs/udf/udf.h	Thu Jun 18 14:56:09 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.30 2009/02/08 19:14:52 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.31 2009/06/18 14:56:09 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -116,11 +116,6 @@
 #define UDF_ECCBUF_HASHSIZE	(1UDF_ECCBUF_HASHBITS)
 #define UDF_ECCBUF_HASHMASK	(UDF_ECCBUF_HASHSIZE -1)
 
-#define UDF_DIRHASH_DEFAULTMEM	(1024*1024)
-#define UDF_DIRHASH_HASHBITS	5
-#define UDF_DIRHASH_HASHSIZE	(1UDF_DIRHASH_HASHBITS)
-#define UDF_DIRHASH_HASHMASK	(UDF_DIRHASH_HASHSIZE -1)
-
 #define UDF_ECCLINE_MAXFREE	5			/* picked, needs calculation */
 #define UDF_ECCLINE_MAXBUSY	300			/* picked, needs calculation */
 



CVS commit: src/sys/fs/udf

2009-06-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jun 18 15:01:34 UTC 2009

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
Remove unneeded wait for SYNC being finished on node disposal of deleted node;
this could interfere and lockup.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.91 src/sys/fs/udf/udf_subr.c:1.92
--- src/sys/fs/udf/udf_subr.c:1.91	Wed May 20 15:30:26 2009
+++ src/sys/fs/udf/udf_subr.c	Thu Jun 18 15:01:34 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.91 2009/05/20 15:30:26 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.92 2009/06/18 15:01:34 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.91 2009/05/20 15:30:26 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.92 2009/06/18 15:01:34 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -5494,14 +5494,6 @@
 v_numoutput = %d, udf_node, vp-v_numoutput);
 #endif
 
-	/* wait until out of sync (just in case we happen to stumble over one */
-	KASSERT(!mutex_owned(mntvnode_lock));
-	mutex_enter(mntvnode_lock);
-	while (udf_node-i_flags  IN_SYNCED) {
-		cv_timedwait(udf_node-ump-dirtynodes_cv, mntvnode_lock,
-			hz/16);
-	}
-	mutex_exit(mntvnode_lock);
 
 	/* TODO extended attributes and streamdir */
 



CVS commit: src/sys/fs/udf

2009-06-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jun 18 15:15:10 UTC 2009

Modified Files:
src/sys/fs/udf: udf_vnops.c

Log Message:
Pass-on credentials to size reversal on aborted write due to error. It could
be that in the future this credentials need to be changed to allways-allow
since its an reverting-on-error behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/fs/udf/udf_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/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.41 src/sys/fs/udf/udf_vnops.c:1.42
--- src/sys/fs/udf/udf_vnops.c:1.41	Thu May  7 19:30:30 2009
+++ src/sys/fs/udf/udf_vnops.c	Thu Jun 18 15:15:10 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.41 2009/05/07 19:30:30 elad Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.42 2009/06/18 15:15:10 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.41 2009/05/07 19:30:30 elad Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.42 2009/06/18 15:15:10 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -383,7 +383,7 @@
 	if (error) {
 		/* bring back file size to its former size */
 		/* take notice of its errors? */
-		(void) udf_chsize(vp, (u_quad_t) old_size, NOCRED);
+		(void) udf_chsize(vp, (u_quad_t) old_size, cred);
 
 		/* roll back uio */
 		uio-uio_offset -= resid - uio-uio_resid;
@@ -2155,7 +2155,6 @@
 
 /* - */
 
-
 /* Global vfs vnode data structures for udfs */
 int (**udf_vnodeop_p)(void *);
 



CVS commit: src/sys/fs/udf

2009-05-19 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue May 19 15:07:20 UTC 2009

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
A descriptor's CRC lenth is 16 bit so use udf_rw16() on tag.desc_crc_len.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.21 src/sys/fs/udf/udf_allocation.c:1.22
--- src/sys/fs/udf/udf_allocation.c:1.21	Tue Apr 21 16:19:00 2009
+++ src/sys/fs/udf/udf_allocation.c	Tue May 19 15:07:20 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.21 2009/04/21 16:19:00 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.22 2009/05/19 15:07:20 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.21 2009/04/21 16:19:00 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.22 2009/05/19 15:07:20 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1325,11 +1325,11 @@
 	if (fe) {
 		fe-l_ad = udf_rw32(0);
 		fe-logblks_rec  = udf_rw64(0);
-		fe-tag.desc_crc_len = udf_rw32(crclen);
+		fe-tag.desc_crc_len = udf_rw16(crclen);
 	} else {
 		efe-l_ad= udf_rw32(0);
 		efe-logblks_rec = udf_rw64(0);
-		efe-tag.desc_crc_len = udf_rw32(crclen);
+		efe-tag.desc_crc_len = udf_rw16(crclen);
 	}
 
 	/* wipe all allocation extent entries */
@@ -1342,7 +1342,7 @@
 		ext-l_ad = udf_rw32(0);
 
 		crclen = dscr_size - UDF_DESC_TAG_LENGTH;
-		ext-tag.desc_crc_len = udf_rw32(crclen);
+		ext-tag.desc_crc_len = udf_rw16(crclen);
 	}
 	udf_node-i_flags |= IN_NODE_REBUILD;
 }
@@ -1568,7 +1568,7 @@
 
 	/* offset is offset within the current (E)FE/AED */
 	l_ad   = udf_rw32(*l_ad_p);
-	crclen = udf_rw32(dscr-tag.desc_crc_len);
+	crclen = udf_rw16(dscr-tag.desc_crc_len);
 	logblks_rec = udf_rw64(*logblks_rec_p);
 
 	/* overwriting old piece? */
@@ -1630,7 +1630,7 @@
 			memset(ext-data, 0, max_l_ad);
 			ext-l_ad = udf_rw32(0);
 			ext-tag.desc_crc_len =
-udf_rw32(dscr_size - UDF_DESC_TAG_LENGTH);
+udf_rw16(dscr_size - UDF_DESC_TAG_LENGTH);
 
 			/* declare aed */
 			udf_node-num_extensions++;
@@ -1648,7 +1648,7 @@
 		}
 		l_ad   += adlen;
 		crclen += adlen;
-		dscr-tag.desc_crc_len = udf_rw32(crclen);
+		dscr-tag.desc_crc_len = udf_rw16(crclen);
 		*l_ad_p = udf_rw32(l_ad);
 
 		/* advance to the new extension */
@@ -1660,7 +1660,7 @@
 
 		l_ad_p = ext-l_ad;
 		l_ad   = udf_rw32(*l_ad_p);
-		crclen = udf_rw32(dscr-tag.desc_crc_len);
+		crclen = udf_rw16(dscr-tag.desc_crc_len);
 		offset = 0;
 
 		/* adjust callees slot count for link insert */
@@ -1691,7 +1691,7 @@
 	if (offset = l_ad) {
 		l_ad   += adlen;
 		crclen += adlen;
-		dscr-tag.desc_crc_len = udf_rw32(crclen);
+		dscr-tag.desc_crc_len = udf_rw16(crclen);
 		*l_ad_p = udf_rw32(l_ad);
 	}
 
@@ -2201,12 +2201,12 @@
 			if (fe) {
 fe-inf_len   = udf_rw64(inflen);
 fe-l_ad  = udf_rw32(l_ad);
-fe-tag.desc_crc_len = udf_rw32(crclen);
+fe-tag.desc_crc_len = udf_rw16(crclen);
 			} else {
 efe-inf_len  = udf_rw64(inflen);
 efe-obj_size = udf_rw64(objsize);
 efe-l_ad = udf_rw32(l_ad);
-efe-tag.desc_crc_len = udf_rw32(crclen);
+efe-tag.desc_crc_len = udf_rw16(crclen);
 			}
 			error = 0;
 
@@ -2474,12 +2474,12 @@
 		if (fe) {
 			fe-inf_len   = udf_rw64(inflen);
 			fe-l_ad  = udf_rw32(l_ad);
-			fe-tag.desc_crc_len = udf_rw32(crclen);
+			fe-tag.desc_crc_len = udf_rw16(crclen);
 		} else {
 			efe-inf_len  = udf_rw64(inflen);
 			efe-obj_size = udf_rw64(objsize);
 			efe-l_ad = udf_rw32(l_ad);
-			efe-tag.desc_crc_len = udf_rw32(crclen);
+			efe-tag.desc_crc_len = udf_rw16(crclen);
 		}
 		error = 0;
 
@@ -2635,12 +2635,12 @@
 			if (fe) {
 fe-inf_len   = udf_rw64(inflen);
 fe-l_ad  = udf_rw32(l_ad);
-fe-tag.desc_crc_len = udf_rw32(crclen);
+fe-tag.desc_crc_len = udf_rw16(crclen);
 			} else {
 efe-inf_len  = udf_rw64(inflen);
 efe-obj_size = udf_rw64(objsize);
 efe-l_ad = udf_rw32(l_ad);
-efe-tag.desc_crc_len = udf_rw32(crclen);
+efe-tag.desc_crc_len = udf_rw16(crclen);
 			}
 			/* eventually copy in evacuated piece */
 			/* set new size for uvm */



CVS commit: src/sys/fs/udf

2009-05-19 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue May 19 16:06:56 UTC 2009

Modified Files:
src/sys/fs/udf: udf_subr.c

Log Message:
On creation of a new node, don't forget to set the length of the allocated
space in the right endian!


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/fs/udf/udf_subr.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/fs/udf/udf_subr.c
diff -u src/sys/fs/udf/udf_subr.c:1.88 src/sys/fs/udf/udf_subr.c:1.89
--- src/sys/fs/udf/udf_subr.c:1.88	Tue May 19 15:08:42 2009
+++ src/sys/fs/udf/udf_subr.c	Tue May 19 16:06:56 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.88 2009/05/19 15:08:42 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.89 2009/05/19 16:06:56 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.88 2009/05/19 15:08:42 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_subr.c,v 1.89 2009/05/19 16:06:56 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -5596,7 +5596,7 @@
 
 	/* initialise pointer to location */
 	memset(node_icb_loc, 0, sizeof(struct long_ad));
-	node_icb_loc.len = lb_size;
+	node_icb_loc.len = udf_rw32(lb_size);
 	node_icb_loc.loc.lb_num   = udf_rw32(lb_num);
 	node_icb_loc.loc.part_num = udf_rw16(vpart_num);
 



CVS commit: src/sys/fs/udf

2009-05-19 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue May 19 16:24:05 UTC 2009

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
Account for the logical blocks recorded by the extent in the right endian!


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.22 src/sys/fs/udf/udf_allocation.c:1.23
--- src/sys/fs/udf/udf_allocation.c:1.22	Tue May 19 15:07:20 2009
+++ src/sys/fs/udf/udf_allocation.c	Tue May 19 16:24:05 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.22 2009/05/19 15:07:20 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.23 2009/05/19 16:24:05 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.22 2009/05/19 15:07:20 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.23 2009/05/19 16:24:05 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -1682,9 +1682,10 @@
 	}
 
 	/* adjust logblks recorded count */
-	flags = UDF_EXT_FLAGS(udf_rw32(icb-len));
+	len = udf_rw32(icb-len);
+	flags = UDF_EXT_FLAGS(len);
 	if (flags == UDF_EXT_ALLOCATED)
-		logblks_rec += (UDF_EXT_LEN(icb-len) + lb_size -1) / lb_size;
+		logblks_rec += (UDF_EXT_LEN(len) + lb_size -1) / lb_size;
 	*logblks_rec_p = udf_rw64(logblks_rec);
 
 	/* adjust l_ad and crclen when needed */



CVS commit: src/sys/fs/udf

2009-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon May 18 20:51:04 UTC 2009

Modified Files:
src/sys/fs/udf: ecma167-udf.h

Log Message:
Make ecma167 header file compilable by pcc


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/udf/ecma167-udf.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/fs/udf/ecma167-udf.h
diff -u src/sys/fs/udf/ecma167-udf.h:1.11 src/sys/fs/udf/ecma167-udf.h:1.12
--- src/sys/fs/udf/ecma167-udf.h:1.11	Fri Jul 25 15:37:56 2008
+++ src/sys/fs/udf/ecma167-udf.h	Mon May 18 20:51:03 2009
@@ -1,7 +1,8 @@
-/* $NetBSD: ecma167-udf.h,v 1.11 2008/07/25 15:37:56 reinoud Exp $ */
+/* $NetBSD: ecma167-udf.h,v 1.12 2009/05/18 20:51:03 reinoud Exp $ */
 
 /*-
- * Copyright (c) 2003, 2004, 2005, 2006, 2008 Reinoud Zandijk
+ * Copyright (c) 2003, 2004, 2005, 2006, 2008, 2009
+ * 	Reinoud Zandijk * rein...@netbsd.org
  * Copyright (c) 2001, 2002 Scott Long sco...@freebsd.org
  * All rights reserved.
  *
@@ -59,7 +60,7 @@
 */
 
 #ifndef __packed
-#define __packed __packed
+#define __packed __attribute__((packed))
 #endif
 
 
@@ -178,7 +179,7 @@
 	union {
 		uint8_t	bytes[6];
 		struct UDF_ADImp_use im_used;
-	} __packed impl;
+	} impl;
 } __packed;
 #define longad_uniqueid impl.im_used.unique_id
 
@@ -198,7 +199,7 @@
 	struct short_ad	s_ad;
 	struct long_ad	l_ad;
 	struct ext_ad	e_ad;
-} __packed;
+};
 
 
 /* short/long/ext extent have flags encoded in length */
@@ -371,7 +372,7 @@
 	union {
 		struct udf_lv_info	lv_info;
 		char			impl_use[460];
-	} __packed _impl_use;
+	} _impl_use;
 } __packed;
 
 
@@ -386,7 +387,7 @@
 	union {
 		struct long_ad	fsd_loc;		/* to fileset descriptor SEQUENCE */
 		uint8_t		logvol_content_use[16];
-	} __packed _lvd_use;
+	} _lvd_use;
 	uint32_t		mt_l;			/* Partition map length */
 	uint32_t		n_pm;			/* Number of partition maps */
 	struct regid		imp_id;
@@ -477,7 +478,7 @@
 	struct part_map_virt	pmv;
 	struct part_map_spare	pms;
 	struct part_map_meta	pmm;
-} __packed;
+};
 
 
 /* Sparing Map Entry [UDF 2.01/2.2.11] */
@@ -607,7 +608,7 @@
 	union {
 		struct logvolhdr  logvolhdr;
 		int8_t		  reserved[32];
-	} __packed _impl_use;
+	} _impl_use;
 	uint32_t		num_part;
 	uint32_t		l_iu;
 	uint32_t		tables[1];	/* Freespace table, Sizetable, Implementation use */
@@ -827,7 +828,7 @@
 	struct udf_sparing_table spt;
 	struct space_bitmap_desc sbd;
 	struct space_entry_desc	 sed;
-} __packed;
+};
 
 
 #endif /* !_FS_UDF_ECMA167_UDF_H_ */



CVS commit: src/sys/fs/udf

2009-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon May 18 21:09:54 UTC 2009

Modified Files:
src/sys/fs/udf: udf_bswap.h

Log Message:
ANSI-fy. No idea why they weren't so in the first place.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/fs/udf/udf_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/fs/udf/udf_bswap.h
diff -u src/sys/fs/udf/udf_bswap.h:1.6 src/sys/fs/udf/udf_bswap.h:1.7
--- src/sys/fs/udf/udf_bswap.h:1.6	Mon May 18 20:52:24 2009
+++ src/sys/fs/udf/udf_bswap.h	Mon May 18 21:09:54 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_bswap.h,v 1.6 2009/05/18 20:52:24 reinoud Exp $	*/
+/* $NetBSD: udf_bswap.h,v 1.7 2009/05/18 21:09:54 reinoud Exp $	*/
 
 /*
  * Copyright (c) 1998 Manuel Bouyer.
@@ -51,24 +51,21 @@
 
 
 static __inline uint16_t
-udf_rw16(a)
-	uint16_t a;
+udf_rw16(uint16_t a)
 {
 	return bswap16(a);
 }
 
 
 static __inline uint32_t
-udf_rw32(a)
-	uint32_t a;
+udf_rw32(uint32_t a)
 {
 	return bswap32(a);
 }
 
 
 static __inline uint64_t
-udf_rw64(a)
-	uint64_t a;
+udf_rw64(uint64_t a)
 {
 	return bswap64(a);
 }



CVS commit: src/sys/fs/udf

2009-04-21 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Apr 21 16:19:00 UTC 2009

Modified Files:
src/sys/fs/udf: udf_allocation.c

Log Message:
Fix endian related bug when using discs with a meta-data partition on
big-endian machines.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/fs/udf/udf_allocation.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/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.20 src/sys/fs/udf/udf_allocation.c:1.21
--- src/sys/fs/udf/udf_allocation.c:1.20	Wed Mar 25 20:04:52 2009
+++ src/sys/fs/udf/udf_allocation.c	Tue Apr 21 16:19:00 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.20 2009/03/25 20:04:52 reinoud Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.21 2009/04/21 16:19:00 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.20 2009/03/25 20:04:52 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: udf_allocation.c,v 1.21 2009/04/21 16:19:00 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -507,11 +507,8 @@
 		lb_num   = udf_rw32(s_icb_loc.loc.lb_num);
 		vpart= udf_rw16(s_icb_loc.loc.part_num);
 		lb_num  += (ext_offset + lb_size -1) / lb_size;
-		len -= ext_offset;
 		ext_offset = 0;
 
-		flags = UDF_EXT_FLAGS(s_icb_loc.len);
-
 		UDF_UNLOCK_NODE(ump-metadata_node, 0);
 		if (flags != UDF_EXT_ALLOCATED) {
 			DPRINTF(TRANSLATE, (Metadata partition translation