CVS commit: src/sys/fs/hfs

2021-06-29 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Jun 29 22:37:50 UTC 2021

Modified Files:
src/sys/fs/hfs: hfs_vnops.c

Log Message:
Implement VOP_PARSEPATH() for hfs.

This checks for a following "/rsrc" at the end of the pathname (to
indicate the resource fork of a file) and assimilates it into the
component name to be looked up. Then cn_namelen will already include
this text in lookup, and it's no longer necessary to muck with
cn_consume.

Invalid uses of "/rsrc" are ignored rather than rejected, which
appears to be the same as the old behavior. It is possible that the
parsepath logic should only consume the "/rsrc" if the name names a
file and not a directory, which would require looking it up in
parsepath and be a general nuisance; I hope not. It's also possible
that the whole thing doesn't work at all now, or it didn't before, as
I don't have any way to test it.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/fs/hfs/hfs_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/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.37 src/sys/fs/hfs/hfs_vnops.c:1.38
--- src/sys/fs/hfs/hfs_vnops.c:1.37	Tue Jun 29 22:34:06 2021
+++ src/sys/fs/hfs/hfs_vnops.c	Tue Jun 29 22:37:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vnops.c,v 1.37 2021/06/29 22:34:06 dholland Exp $	*/
+/*	$NetBSD: hfs_vnops.c,v 1.38 2021/06/29 22:37:50 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.37 2021/06/29 22:34:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.38 2021/06/29 22:37:50 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -132,6 +132,7 @@ __KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,
 
 #include 
 
+int	hfs_vop_parsepath(void *);
 int	hfs_vop_lookup(void *);
 int	hfs_vop_open(void *);
 int	hfs_vop_close(void *);
@@ -331,6 +332,29 @@ const struct vnodeopv_desc hfs_fifoop_op
 	{ _fifoop_p, hfs_fifoop_entries };
 
 int
+hfs_vop_parsepath(void *v)
+{
+	struct vop_parsepath_args /* {
+		struct vnode *a_dvp;
+		const char *a_name;
+		size_t *a_retval;
+	} */ *ap = v;
+	size_t len;
+	int error;
+
+	error = genfs_parsepath(v);
+	if (error) {
+		return error;
+	}
+
+	len = *ap->a_retval;
+	if (!strcmp(ap->a_name + len, "/rsrc")) {
+		*ap->a_retval += 5;
+	}
+	return 0;
+}
+
+int
 hfs_vop_lookup(void *v)
 {
 	struct vop_lookup_v2_args /* {
@@ -346,6 +370,8 @@ hfs_vop_lookup(void *v)
 	struct vnode *vdp;		/* vnode for directory being searched */
 	hfs_catalog_key_t key;	/* hfs+ catalog search key for requested child */
 	hfs_catalog_keyed_record_t rec; /* catalog record of requested child */
+	size_t namelen;
+	int use_resource_fork = 0;
 	unichar_t* unicn;		/* name of component, in Unicode */
 	const char *pname;
 	int error;
@@ -420,12 +446,18 @@ hfs_vop_lookup(void *v)
 
 		hfslib_init_cbargs();
 
+		namelen = cnp->cn_namelen;
+		if (namelen > 5 &&
+		!strcmp(cnp->cn_nameptr + namelen - 5, "/rsrc")) {
+			namelen -= 5;
+			use_resource_fork = 1;
+		}
+
 		/* XXX: when decomposing, string could grow
 		   and we have to handle overflow */
-		unicn = malloc(cnp->cn_namelen * sizeof(unicn[0]),
-		M_TEMP, M_WAITOK);
-		len = utf8_to_utf16(unicn, cnp->cn_namelen,
-		cnp->cn_nameptr, cnp->cn_namelen, 0, NULL);
+		unicn = malloc(namelen * sizeof(unicn[0]), M_TEMP, M_WAITOK);
+		len = utf8_to_utf16(unicn, namelen,
+		cnp->cn_nameptr, namelen, 0, NULL);
 		for (ni = 0; ni < len; ni++)
 			if (unicn[ni] == (unichar_t)':')
 unicn[ni] = (unichar_t)'/';
@@ -462,13 +494,11 @@ hfs_vop_lookup(void *v)
 		}
 
 		if (rec.type == HFS_REC_FILE
-		&& strcmp(cnp->cn_nameptr+cnp->cn_namelen, "/rsrc") == 0
+		&& use_resource_fork
 		&& rec.file.rsrc_fork.logical_size > 0) {
-		/* advance namei next pointer to end of stirng */
-		cnp->cn_consume = 5;
-		cnp->cn_flags &= ~REQUIREDIR; /* XXX: needed? */
-		error = hfs_vget_internal(vdp->v_mount, rec.file.cnid,
-			HFS_RSRCFORK, );
+		/* advance namei next pointer to end of string */
+			error = hfs_vget_internal(vdp->v_mount, rec.file.cnid,
+			HFS_RSRCFORK, );
 		} else
 			error = hfs_vget_internal(vdp->v_mount, rec.file.cnid,
 			HFS_DATAFORK, );



CVS commit: src/sys/fs/hfs

2020-07-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jul 24 05:26:37 UTC 2020

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

Log Message:
Replace the */ I accidentally removed in the last commit


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/hfs/hfs.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/hfs/hfs.h
diff -u src/sys/fs/hfs/hfs.h:1.11 src/sys/fs/hfs/hfs.h:1.12
--- src/sys/fs/hfs/hfs.h:1.11	Thu Jul 23 19:26:34 2020
+++ src/sys/fs/hfs/hfs.h	Fri Jul 24 05:26:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs.h,v 1.11 2020/07/23 19:26:34 skrll Exp $	*/
+/*	$NetBSD: hfs.h,v 1.12 2020/07/24 05:26:37 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #ifdef HFS_DEBUG
 	#if defined(_KERNEL)
 		#include "opt_ddb.h"
-	#endif /* defined(_KERNEL_)
+	#endif /* defined(_KERNEL_) */
 #endif /* HFS_DEBUG */
 
 #include 



CVS commit: src/sys/fs/hfs

2020-07-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 23 19:26:34 UTC 2020

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

Log Message:
unifdef -U_LKM


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/fs/hfs/hfs.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/hfs/hfs.h
diff -u src/sys/fs/hfs/hfs.h:1.10 src/sys/fs/hfs/hfs.h:1.11
--- src/sys/fs/hfs/hfs.h:1.10	Thu Jul 23 19:26:00 2020
+++ src/sys/fs/hfs/hfs.h	Thu Jul 23 19:26:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs.h,v 1.10 2020/07/23 19:26:00 skrll Exp $	*/
+/*	$NetBSD: hfs.h,v 1.11 2020/07/23 19:26:34 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -41,9 +41,9 @@
 /*#define HFS_DEBUG*/
 
 #ifdef HFS_DEBUG
-	#if defined(_KERNEL) && !defined(_LKM)
+	#if defined(_KERNEL)
 		#include "opt_ddb.h"
-	#endif /* defined(_KERNEL_) && !defined(_LKM) */
+	#endif /* defined(_KERNEL_)
 #endif /* HFS_DEBUG */
 
 #include 



CVS commit: src/sys/fs/hfs

2020-07-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 23 19:26:00 UTC 2020

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/fs/hfs/hfs.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/hfs/hfs.h
diff -u src/sys/fs/hfs/hfs.h:1.9 src/sys/fs/hfs/hfs.h:1.10
--- src/sys/fs/hfs/hfs.h:1.9	Sun Aug 10 08:53:22 2014
+++ src/sys/fs/hfs/hfs.h	Thu Jul 23 19:26:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs.h,v 1.9 2014/08/10 08:53:22 hannken Exp $	*/
+/*	$NetBSD: hfs.h,v 1.10 2020/07/23 19:26:00 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -27,8 +27,8 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- */ 
- 
+ */
+
 #ifndef _FS_HFS_HFS_H_
 #define _FS_HFS_HFS_H_
 
@@ -87,7 +87,7 @@ struct hfsnode {
 			hfs_cnid_t		cnid;
 		} u; /* convenience for accessing common record info */
 	} h_rec; /* catalog record for this hnode */
-	
+
 	/*
 	 * We cache this vnode's parent CNID here upon vnode creation (i.e., during
 	 * hfs_vop_vget()) for quick access without needing to search the catalog.



CVS commit: src/sys/fs/hfs

2020-02-28 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Feb 28 11:27:38 UTC 2020

Modified Files:
src/sys/fs/hfs: hfs_vfsops.c

Log Message:
Avoid undefined behavior in left shift semantics

hfs_vfsops.c:477:19, left shift of 1 by 31 places cannot be represented in type 
'int'


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/fs/hfs/hfs_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/hfs/hfs_vfsops.c
diff -u src/sys/fs/hfs/hfs_vfsops.c:1.36 src/sys/fs/hfs/hfs_vfsops.c:1.37
--- src/sys/fs/hfs/hfs_vfsops.c:1.36	Fri Jan 17 20:08:07 2020
+++ src/sys/fs/hfs/hfs_vfsops.c	Fri Feb 28 11:27:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vfsops.c,v 1.36 2020/01/17 20:08:07 ad Exp $	*/
+/*	$NetBSD: hfs_vfsops.c,v 1.37 2020/02/28 11:27:38 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -99,7 +99,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.36 2020/01/17 20:08:07 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.37 2020/02/28 11:27:38 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -474,7 +474,7 @@ hfs_statvfs(struct mount *mp, struct sta
 	sbp->f_bavail = vh->free_blocks; /* blocks free for non superuser */
 	sbp->f_bresvd = 0;
 	sbp->f_files =  vh->file_count; /* total files */
-	sbp->f_ffree = (1<<31) - vh->file_count; /* free file nodes */
+	sbp->f_ffree = (1U<<31) - vh->file_count; /* free file nodes */
 	copy_statvfs_info(sbp, mp);
 
 	return 0;



CVS commit: src/sys/fs/hfs

2019-01-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jan  5 10:25:11 UTC 2019

Modified Files:
src/sys/fs/hfs: libhfs.h

Log Message:
Remove bogus code to workaround PCC limitations.

This would print stack garbage, which isn't desirable.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/fs/hfs/libhfs.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/hfs/libhfs.h
diff -u src/sys/fs/hfs/libhfs.h:1.7 src/sys/fs/hfs/libhfs.h:1.8
--- src/sys/fs/hfs/libhfs.h:1.7	Sun Jun 21 14:00:40 2015
+++ src/sys/fs/hfs/libhfs.h	Sat Jan  5 10:25:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.h,v 1.7 2015/06/21 14:00:40 maxv Exp $	*/
+/*	$NetBSD: libhfs.h,v 1.8 2019/01/05 10:25:11 maya Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -57,15 +57,9 @@
 
 
 /* Macros to handle errors in this library. Not recommended outside libhfs.c */
-#ifdef __PCC__
-#define HFS_LIBERR(format, ...) \
-	do{ hfslib_error(format, __FILE__, __LINE__); \
-		goto error; } while(/*CONSTCOND*/ 0)
-#else
 #define HFS_LIBERR(format, ...) \
 	do{ hfslib_error(format, __FILE__, __LINE__, ##__VA_ARGS__); \
 		goto error; } while(/*CONSTCOND*/ 0)
-#endif
 
 #if 0
 #pragma mark Constants (on-disk)



CVS commit: src/sys/fs/hfs

2018-12-30 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Dec 30 22:40:00 UTC 2018

Modified Files:
src/sys/fs/hfs: libhfs.c

Log Message:
Fix support for case sensitive HFS.
Without this change, the wrong file is returned, if 2 file names contain a
subset of each other.

Code submitted in PR bin/52993 by Harold Gutch


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/fs/hfs/libhfs.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/hfs/libhfs.c
diff -u src/sys/fs/hfs/libhfs.c:1.14 src/sys/fs/hfs/libhfs.c:1.15
--- src/sys/fs/hfs/libhfs.c:1.14	Sun Jun 21 13:40:25 2015
+++ src/sys/fs/hfs/libhfs.c	Sun Dec 30 22:40:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.c,v 1.14 2015/06/21 13:40:25 maxv Exp $	*/
+/*	$NetBSD: libhfs.c,v 1.15 2018/12/30 22:40:00 sevan Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: libhfs.c,v 1.14 2015/06/21 13:40:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: libhfs.c,v 1.15 2018/12/30 22:40:00 sevan Exp $");
 
 #include "libhfs.h"
 
@@ -2384,37 +2384,42 @@ hfslib_compare_catalog_keys_cf (
 /* binary compare (i.e., not case folding) */
 int
 hfslib_compare_catalog_keys_bc (
-	const void *a,
-	const void *b)
+	const void *ap,
+	const void *bp)
 {
-	if (((const hfs_catalog_key_t*)a)->parent_cnid
-		== ((const hfs_catalog_key_t*)b)->parent_cnid)
+	int c;
+	const hfs_catalog_key_t *a, *b;
+
+	a = (const hfs_catalog_key_t *) ap;
+	b = (const hfs_catalog_key_t *) bp;
+
+	if (a->parent_cnid == b->parent_cnid)
 	{
-		if (((const hfs_catalog_key_t*)a)->name.length == 0 &&
-			((const hfs_catalog_key_t*)b)->name.length == 0)
+		if (a->name.length == 0 && b->name.length == 0)
 			return 0;
 
-		if (((const hfs_catalog_key_t*)a)->name.length == 0)
+		if (a->name.length == 0)
 			return -1;
-		if (((const hfs_catalog_key_t*)b)->name.length == 0)
+		if (b->name.length == 0)
 			return 1;
 
 		/* FIXME: This does a byte-per-byte comparison, whereas the HFS spec
 		 * mandates a uint16_t chunk comparison. */
-		return memcmp(((const hfs_catalog_key_t*)a)->name.unicode,
-			((const hfs_catalog_key_t*)b)->name.unicode,
-			min(((const hfs_catalog_key_t*)a)->name.length,
-((const hfs_catalog_key_t*)b)->name.length));
+		c = memcmp(a->name.unicode, b->name.unicode,
+			sizeof(unichar_t)*min(a->name.length, b->name.length));
+		if (c != 0)
+			return c;
+		else
+			return (a->name.length - b->name.length);
 	} else {
-		return (((const hfs_catalog_key_t*)a)->parent_cnid - 
-((const hfs_catalog_key_t*)b)->parent_cnid);
+		return (a->parent_cnid - b->parent_cnid);
 	}
 }
 
 int
 hfslib_compare_extent_keys (
-	const void *a,
-	const void *b)
+	const void *ap,
+	const void *bp)
 {
 	/*
 	 *	Comparison order, in descending importance:
@@ -2422,27 +2427,25 @@ hfslib_compare_extent_keys (
 	 *		CNID -> fork type -> start block
 	 */
 
-	if (((const hfs_extent_key_t*)a)->file_cnid
-		== ((const hfs_extent_key_t*)b)->file_cnid)
+	const hfs_extent_key_t *a, *b;
+	a = (const hfs_extent_key_t *) ap;
+	b = (const hfs_extent_key_t *) bp;
+
+	if (a->file_cnid == b->file_cnid)
 	{
-		if (((const hfs_extent_key_t*)a)->fork_type
-			== ((const hfs_extent_key_t*)b)->fork_type)
+		if (a->fork_type == b->fork_type)
 		{
-			if (((const hfs_extent_key_t*)a)->start_block
-== ((const hfs_extent_key_t*)b)->start_block)
+			if (a->start_block == b->start_block)
 			{
 return 0;
 			} else {
-return (((const hfs_extent_key_t*)a)->start_block - 
-		((const hfs_extent_key_t*)b)->start_block);
+return (a->start_block - b->start_block);
 			}
 		} else {
-			return (((const hfs_extent_key_t*)a)->fork_type - 
-	((const hfs_extent_key_t*)b)->fork_type);
+			return (a->fork_type - b->fork_type);
 		}
 	} else {
-		return (((const hfs_extent_key_t*)a)->file_cnid - 
-((const hfs_extent_key_t*)b)->file_cnid);
+		return (a->file_cnid - b->file_cnid);
 	}
 }
 



CVS commit: src/sys/fs/hfs

2015-06-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun 21 13:40:25 UTC 2015

Modified Files:
src/sys/fs/hfs: libhfs.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/hfs/libhfs.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/hfs/libhfs.c
diff -u src/sys/fs/hfs/libhfs.c:1.13 src/sys/fs/hfs/libhfs.c:1.14
--- src/sys/fs/hfs/libhfs.c:1.13	Mon Dec 29 17:02:39 2014
+++ src/sys/fs/hfs/libhfs.c	Sun Jun 21 13:40:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.c,v 1.13 2014/12/29 17:02:39 maxv Exp $	*/
+/*	$NetBSD: libhfs.c,v 1.14 2015/06/21 13:40:25 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.13 2014/12/29 17:02:39 maxv Exp $);
+__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.14 2015/06/21 13:40:25 maxv Exp $);
 
 #include libhfs.h
 
@@ -359,7 +359,7 @@ hfslib_open_volume(
 error:	
 	if (result != 0  isopen)
 		hfslib_close_volume(out_vol, cbargs);
-	if(buffer!=NULL)
+	if (buffer != NULL)
 		hfslib_free(buffer, cbargs);
 	return result;
 }
@@ -425,36 +425,35 @@ hfslib_path_to_cnid(hfs_volume* in_vol,
 
 		memcpy(path + path_offset, parent_thread.name.unicode,
 			parent_thread.name.length*2);
-		
-		/*	Add a forward slash. The unicode string was specified in big endian
-		 *	format, so convert to core format if necessary. */
-		path[512]=0x00;
-		path[513]=0x2F;
+
+		/* Add a forward slash. The unicode string was specified in big endian
+		 * format, so convert to core format if necessary. */
+		path[512] = 0x00;
+		path[513] = 0x2F;
 		
 		ptr = (uint16_t*)path + 256;
 		uchar = be16tohp((void*)ptr);
 		*(ptr-1) = uchar;
 
 		total_path_length += parent_thread.name.length + 1;
-
 		child_cnid = parent_cnid;
 	}
-	
+
 	/*
-	 *	At this point, 'path' holds a sequence of unicode characters which
-	 *	represent the absolute path to the given cnid. This string is missing
-	 *	a terminating null char and an initial forward slash that represents
-	 *	the root of the filesystem. It most likely also has extra space in
-	 *	the beginning, due to the fact that we reserve 512 bytes for each path
-	 *	component and won't usually use all that space. So, we allocate the
-	 *	final string based on the actual length of the absolute path, plus four
-	 *	additional bytes (two unichars) for the forward slash and the null char.
+	 * At this point, 'path' holds a sequence of unicode characters which
+	 * represent the absolute path to the given cnid. This string is missing
+	 * a terminating null char and an initial forward slash that represents
+	 * the root of the filesystem. It most likely also has extra space in
+	 * the beginning, due to the fact that we reserve 512 bytes for each path
+	 * component and won't usually use all that space. So, we allocate the
+	 * final string based on the actual length of the absolute path, plus four
+	 * additional bytes (two unichars) for the forward slash and the null char.
 	 */
-	
+
 	*out_unicode = hfslib_malloc((total_path_length+2)*2, cbargs);
-	if(*out_unicode == NULL)
+	if (*out_unicode == NULL)
 		goto exit;
-	
+
 	/* copy only the bytes that are actually used */
 	memcpy(*out_unicode + 2, path + path_offset, total_path_length*2);
 
@@ -465,15 +464,14 @@ hfslib_path_to_cnid(hfs_volume* in_vol,
 	/* insert null char at end */
 	(*out_unicode)[total_path_length*2+2] = 0x00;
 	(*out_unicode)[total_path_length*2+3] = 0x00;
-	
+
 	*out_length = total_path_length + 1 /* extra for forward slash */ ;
 
 	result = 0;
-	
+
 exit:
-	if(path!=NULL)
+	if (path != NULL)
 		hfslib_free(path, cbargs);
-		
 	return result;
 }
 
@@ -486,16 +484,16 @@ hfslib_find_parent_thread(
 {	
 	hfs_catalog_key_t	childkey;
 
-	if(in_vol==NULL || in_child==0 || out_thread==NULL)
+	if (in_vol == NULL || in_child == 0 || out_thread == NULL)
 		return 0;
-	
-	if(hfslib_make_catalog_key(in_child, 0, NULL, childkey)==0)
+
+	if (hfslib_make_catalog_key(in_child, 0, NULL, childkey) == 0)
 		return 0;
-	
-	if(hfslib_find_catalog_record_with_key(in_vol, childkey,
-		(hfs_catalog_keyed_record_t*)out_thread, cbargs)!=0)
+
+	if (hfslib_find_catalog_record_with_key(in_vol, childkey,
+		(hfs_catalog_keyed_record_t*)out_thread, cbargs) != 0)
 		return 0;
-		
+
 	return out_thread-parent_cnid;
 }
 
@@ -517,24 +515,24 @@ hfslib_find_catalog_record_with_cnid(
 	hfs_cnid_t	parentcnid;
 	hfs_thread_record_t		parentthread;
 	hfs_catalog_key_t			key;
-	
-	if(in_vol==NULL || in_cnid==0 || out_rec==NULL)
+
+	if (in_vol == NULL || in_cnid == 0 || out_rec == NULL)
 		return 0;
 
 	parentcnid =
 		hfslib_find_parent_thread(in_vol, in_cnid, parentthread, cbargs);
-	if(parentcnid == 0)
+	if (parentcnid == 0)
 		HFS_LIBERR(could not find parent thread for cnid %i, in_cnid);
 
-	if(hfslib_make_catalog_key(parentthread.parent_cnid,
+	if 

CVS commit: src/sys/fs/hfs

2015-06-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun 21 14:09:48 UTC 2015

Modified Files:
src/sys/fs/hfs: unicode.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/fs/hfs/unicode.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/hfs/unicode.c
diff -u src/sys/fs/hfs/unicode.c:1.2 src/sys/fs/hfs/unicode.c:1.3
--- src/sys/fs/hfs/unicode.c:1.2	Tue Dec 11 12:04:24 2007
+++ src/sys/fs/hfs/unicode.c	Sun Jun 21 14:09:47 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: unicode.c,v 1.2 2007/12/11 12:04:24 lukem Exp $ */
+/* $NetBSD: unicode.c,v 1.3 2015/06/21 14:09:47 maxv Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: unicode.c,v 1.2 2007/12/11 12:04:24 lukem Exp $);
+__KERNEL_RCSID(0, $NetBSD: unicode.c,v 1.3 2015/06/21 14:09:47 maxv Exp $);
 
 #include sys/null.h
 
@@ -41,97 +41,90 @@ utf8_to_utf16(uint16_t *dst, size_t dst_
 	  const char *src, size_t src_len,
 	  int flags, int *errp)
 {
-const unsigned char *s;
-size_t spos, dpos;
-int error;
-uint16_t c;
+	const unsigned char *s;
+	size_t spos, dpos;
+	int error;
+	uint16_t c;
 
 #define IS_CONT(c)	(((c)0xc0) == 0x80)
 
-error = 0;
-s = (const unsigned char *)src;
-spos = dpos = 0;
-while (spossrc_len) {
-	if (s[spos]  0x80)
-	c = s[spos++];
-	else if ((flags  UNICODE_UTF8_LATIN1_FALLBACK)
-		  (spos = src_len || !IS_CONT(s[spos+1]))
-		  s[spos]=0xa0) {
-	/* not valid UTF-8, assume ISO 8859-1 */
-	c = s[spos++];
-	}
-	else if (s[spos]  0xc0 || s[spos] = 0xf5) {
-	/* continuation byte without lead byte
-	   or lead byte for codepoint above 0x10 */
-	error++;
-	spos++;
-	continue;
-	}
-	else if (s[spos]  0xe0) {
-	if (spos = src_len || !IS_CONT(s[spos+1])) {
-		spos++;
-		error++;
-		continue;
-	}
-	c = ((s[spos]  0x3f)  6) | (s[spos+1]  0x3f);
-	spos += 2;
-	if (c  0x80) {
-		/* overlong encoding */
-		error++;
-		continue;
-	}
-	}
-	else if (s[spos]  0xf0) {
-	if (spos = src_len-2
-		|| !IS_CONT(s[spos+1]) || !IS_CONT(s[spos+2])) {
-		spos++;
-		error++;
-		continue;
-	}
-	c = ((s[spos]  0x0f)  12) | ((s[spos+1]  0x3f)  6)
-		| (s[spos+2]  0x3f);
-	spos += 3;
-	if (c  0x800 || (c  0xdf00) == 0xd800 ) {
-		/* overlong encoding or encoded surrogate */
-		error++;
-		continue;
-	}
-	}
-	else {
-	uint32_t cc;
-	/* UTF-16 surrogate pair */
-
-	if (spos = src_len-3 || !IS_CONT(s[spos+1])
-		|| !IS_CONT(s[spos+2]) || !IS_CONT(s[spos+3])) {
-		spos++;
-		error++;
-		
-		continue;
-	}
-	cc = ((s[spos]  0x03)  18) | ((s[spos+1]  0x3f)  12)
-		 | ((s[spos+2]  0x3f)  6) | (s[spos+3]  0x3f);
-	spos += 4;
-	if (cc  0x1) {
-		/* overlong encoding */
-		error++;
-		continue;
-	}
-	if (dst  dpos  dst_len)
-		dst[dpos] = (0xd800 | ((cc-0x1)10));
-	dpos++;
-	c = 0xdc00 | ((cc-0x1)  0x3);
-	}
-
-	if (dst  dpos  dst_len)
-	dst[dpos] = c;
-	dpos++;
-}
-
-if (errp)
-	*errp = error;
-
-return dpos;
-
+	error = 0;
+	s = (const unsigned char *)src;
+	spos = dpos = 0;
+	while (spos  src_len) {
+		if (s[spos]  0x80) {
+			c = s[spos++];
+		} else if ((flags  UNICODE_UTF8_LATIN1_FALLBACK)
+			  (spos = src_len || !IS_CONT(s[spos+1]))
+			  s[spos]=0xa0) {
+			/* not valid UTF-8, assume ISO 8859-1 */
+			c = s[spos++];
+		} else if (s[spos]  0xc0 || s[spos] = 0xf5) {
+			/* continuation byte without lead byte
+			 * or lead byte for codepoint above 0x10 */
+			error++;
+			spos++;
+			continue;
+		} else if (s[spos]  0xe0) {
+			if (spos = src_len || !IS_CONT(s[spos+1])) {
+spos++;
+error++;
+continue;
+			}
+			c = ((s[spos]  0x3f)  6) | (s[spos+1]  0x3f);
+			spos += 2;
+			if (c  0x80) {
+/* overlong encoding */
+error++;
+continue;
+			}
+		} else if (s[spos]  0xf0) {
+			if (spos = src_len-2 ||
+			!IS_CONT(s[spos+1]) || !IS_CONT(s[spos+2])) {
+spos++;
+error++;
+continue;
+			}
+			c = ((s[spos]  0x0f)  12) | ((s[spos+1]  0x3f)  6)
+			| (s[spos+2]  0x3f);
+			spos += 3;
+			if (c  0x800 || (c  0xdf00) == 0xd800 ) {
+/* overlong encoding or encoded surrogate */
+error++;
+continue;
+			}
+		} else {
+			uint32_t cc;
+			/* UTF-16 surrogate pair */
+
+			if (spos = src_len-3 || !IS_CONT(s[spos+1])
+			|| !IS_CONT(s[spos+2]) || !IS_CONT(s[spos+3])) {
+spos++;
+error++;
+continue;
+			}
+			cc = ((s[spos]  0x03)  18) | ((s[spos+1]  0x3f)  12)
+			| ((s[spos+2]  0x3f)  6) | (s[spos+3]  0x3f);
+			spos += 4;
+			if (cc  0x1) {
+/* overlong encoding */
+error++;
+continue;
+			}
+			if (dst  dpos  dst_len)
+dst[dpos] = (0xd800 | ((cc-0x1)10));
+			dpos++;
+			c = 0xdc00 | ((cc-0x1)  0x3);
+		}
+
+		if (dst  dpos  dst_len)
+			dst[dpos] = c;

CVS commit: src/sys/fs/hfs

2015-06-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun 21 14:00:40 UTC 2015

Modified Files:
src/sys/fs/hfs: libhfs.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/fs/hfs/libhfs.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/hfs/libhfs.h
diff -u src/sys/fs/hfs/libhfs.h:1.6 src/sys/fs/hfs/libhfs.h:1.7
--- src/sys/fs/hfs/libhfs.h:1.6	Sat Jul 28 00:43:23 2012
+++ src/sys/fs/hfs/libhfs.h	Sun Jun 21 14:00:40 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.h,v 1.6 2012/07/28 00:43:23 matt Exp $	*/
+/*	$NetBSD: libhfs.h,v 1.7 2015/06/21 14:00:40 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- */ 
+ */
 
 #ifndef _FS_HFS_LIBHFS_H_
 #define _FS_HFS_LIBHFS_H_
@@ -72,15 +72,13 @@
 #endif
 
 
-enum
-{
+enum {
 	HFS_SIG_HFSP	= 0x482B,	/* 'H+' */
 	HFS_SIG_HFSX	= 0x4858,	/* 'HX' */
 	HFS_SIG_HFS	= 0x4244	/* 'BD' */
 }; /* volume signatures */
 
-typedef enum
-{
+typedef enum {
 			/* bits 0-6 are reserved */
 	HFS_VOL_HWLOCK			= 7,
 	HFS_VOL_UNMOUNTED		= 8,
@@ -94,23 +92,20 @@ typedef enum
 			/* bits 16-31 are reserved */
 } hfs_volume_attribute_bit; /* volume header attribute bits */
 
-typedef enum
-{
+typedef enum {
 	HFS_LEAFNODE	= -1,
 	HFS_INDEXNODE	= 0,
 	HFS_HEADERNODE	= 1,
 	HFS_MAPNODE	= 2
 } hfs_node_kind; /* btree node kinds */
 
-enum
-{
+enum {
 	HFS_BAD_CLOSE_MASK			= 0x0001,
 	HFS_BIG_KEYS_MASK			= 0x0002,
 	HFS_VAR_INDEX_KEYS_MASK	= 0x0004
 }; /* btree header attribute masks */
 
-typedef enum
-{
+typedef enum {
 	HFS_CNID_ROOT_PARENT	= 1,
 	HFS_CNID_ROOT_FOLDER	= 2,
 	HFS_CNID_EXTENTS		= 3,
@@ -125,49 +120,43 @@ typedef enum
 	HFS_CNID_USER			= 16
 } hfs_special_cnid; /* special CNID values */
 
-typedef enum
-{
+typedef enum {
 	HFS_REC_FLDR			= 0x0001,
 	HFS_REC_FILE			= 0x0002,
 	HFS_REC_FLDR_THREAD	= 0x0003,
 	HFS_REC_FILE_THREAD	= 0x0004
 } hfs_catalog_rec_kind; /* catalog record types */
 
-enum
-{
-HFS_JOURNAL_ON_DISK_MASK		= 0x0001, /* journal on same volume */
-HFS_JOURNAL_ON_OTHER_MASK		= 0x0002, /* journal elsewhere */
-HFS_JOURNAL_NEEDS_INIT_MASK	= 0x0004
+enum {
+	HFS_JOURNAL_ON_DISK_MASK		= 0x0001, /* journal on same volume */
+	HFS_JOURNAL_ON_OTHER_MASK		= 0x0002, /* journal elsewhere */
+	HFS_JOURNAL_NEEDS_INIT_MASK	= 0x0004
 }; /* journal flag masks */
 
-enum
-{
+enum {
 	HFS_JOURNAL_HEADER_MAGIC	= 0x4a4e4c78,
 	HFS_JOURNAL_ENDIAN_MAGIC	= 0x12345678
 }; /* journal magic numbers */
 
-enum
-{
+enum {
 	HFS_DATAFORK	= 0x00,
 	HFS_RSRCFORK	= 0xFF
 }; /* common fork types */
 
-enum
-{
+enum {
 	HFS_KEY_CASEFOLD	= 0xCF,
 	HFS_KEY_BINARY		= 0XBC
 }; /* catalog key comparison method types */
 
-enum
-{
+enum {
 	HFS_MIN_CAT_KEY_LEN	= 6,
 	HFS_MAX_CAT_KEY_LEN	= 516,
 	HFS_MAX_EXT_KEY_LEN	= 10
 };
 
 enum {
-HFS_HARD_LINK_FILE_TYPE = 0x686C6E6B,  /* 'hlnk' */
-HFS_HFSLUS_CREATOR = 0x6866732B   /* 'hfs+' */
+	HFS_HARD_LINK_FILE_TYPE = 0x686C6E6B,  /* 'hlnk' */
+	HFS_HFSLUS_CREATOR = 0x6866732B   /* 'hfs+' */
 };
 
 
@@ -180,8 +169,7 @@ enum {
 /* number of bytes between start of volume and volume header */
 #define HFS_VOLUME_HEAD_RESERVE_SIZE	1024
 
-typedef enum
-{
+typedef enum {
 	HFS_CATALOG_FILE = 1,
 	HFS_EXTENTS_FILE = 2,
 	HFS_ATTRIBUTES_FILE = 3
@@ -195,52 +183,46 @@ typedef enum
 
 typedef uint32_t	hfs_macos_type_code; /* four 1-byte char field */
 
-typedef struct
-{
-  int16_t	v;
-  int16_t	h;
+typedef struct {
+	int16_t	v;
+	int16_t	h;
 } hfs_macos_point_t;
 
-typedef struct
-{
-  int16_t	t;	/* top */
-  int16_t	l;	/* left */
-  int16_t	b;	/* bottom */
-  int16_t	r;	/* right */
+typedef struct {
+	int16_t	t;	/* top */
+	int16_t	l;	/* left */
+	int16_t	b;	/* bottom */
+	int16_t	r;	/* right */
 } hfs_macos_rect_t;
 
-typedef struct
-{
-  hfs_macos_type_code	file_type;
-  hfs_macos_type_code	file_creator;
-  uint16_tfinder_flags;
-  hfs_macos_point_t	location;
-  uint16_treserved;
+typedef struct {
+	hfs_macos_type_code	file_type;
+	hfs_macos_type_code	file_creator;
+	uint16_tfinder_flags;
+	hfs_macos_point_t	location;
+	uint16_treserved;
 } hfs_macos_file_info_t;
 
-typedef struct
-{
-  int16_t	reserved[4];
-  uint16_t	extended_finder_flags;
-  int16_t	reserved2;
-  int32_t	put_away_folder_cnid;
+typedef struct {
+	int16_t	reserved[4];
+	uint16_t	extended_finder_flags;
+	int16_t	reserved2;
+	int32_t	put_away_folder_cnid;
 } hfs_macos_extended_file_info_t;
 
-typedef struct
-{
-  hfs_macos_rect_t		window_bounds;
-  uint16_tfinder_flags;
-  hfs_macos_point_t	location;
-  uint16_treserved;
+typedef struct {
+	hfs_macos_rect_t		window_bounds;
+	uint16_t

CVS commit: src/sys/fs/hfs

2015-06-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun 21 13:43:58 UTC 2015

Modified Files:
src/sys/fs/hfs: hfs_subr.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/fs/hfs/hfs_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/hfs/hfs_subr.c
diff -u src/sys/fs/hfs/hfs_subr.c:1.18 src/sys/fs/hfs/hfs_subr.c:1.19
--- src/sys/fs/hfs/hfs_subr.c:1.18	Sat Mar 28 19:24:05 2015
+++ src/sys/fs/hfs/hfs_subr.c	Sun Jun 21 13:43:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_subr.c,v 1.18 2015/03/28 19:24:05 maxv Exp $	*/
+/*	$NetBSD: hfs_subr.c,v 1.19 2015/06/21 13:43:58 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */ 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_subr.c,v 1.18 2015/03/28 19:24:05 maxv Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_subr.c,v 1.19 2015/06/21 13:43:58 maxv Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -173,9 +173,9 @@ hfs_libcb_opendev(
 		goto error;
 	}
 	vol-cbdata = cbdata;
-	
+
 	cbdata-devvp = NULL;
-	
+
 	/* Open the device node. */
 	mode = vol-readonly ? FREAD : FREAD|FWRITE;
 	vn_lock(args-devvp, LK_EXCLUSIVE | LK_RETRY);
@@ -200,7 +200,7 @@ hfs_libcb_opendev(
 		cbdata-devblksz = DEV_BSIZE;
 	else
 		cbdata-devblksz = secsize;
-		
+
 	return 0;
 
 error:
@@ -222,10 +222,10 @@ void
 hfs_libcb_closedev(hfs_volume* in_vol, hfs_callback_args* cbargs)
 {
 	struct vnode *devvp;
-	
+
 	if (in_vol == NULL)
 		return;
-	
+
 	if (in_vol-cbdata != NULL) {
 		devvp = ((hfs_libcb_data*)in_vol-cbdata)-devvp;
 		if (devvp != NULL) {
@@ -252,10 +252,10 @@ hfs_libcb_read(
 	hfs_libcb_argsread* argsread;
 	kauth_cred_t cred;
 	uint64_t physoffset; /* physical offset from start of device(?) */
-	
+
 	if (vol == NULL || outbytes == NULL)
 		return -1;
-	
+
 	cbdata = (hfs_libcb_data*)vol-cbdata;
 
 	if (cbargs != NULL
@@ -264,7 +264,7 @@ hfs_libcb_read(
 		cred = argsread-cred;
 	else
 		cred = NOCRED;
-		
+
 	/*
 	 * Since bread() only reads data in terms of integral blocks, it may have
 	 * read some data before and/or after our desired offset  length. So when
@@ -293,13 +293,13 @@ hfs_pread(struct vnode *vp, void *buf, s
 	uint64_t curoff; /* relative to 'start' variable */
 	uint64_t start;
 	int error;
-	
+
 	if (vp == NULL || buf == NULL)
 		return EINVAL;
-	
+
 	if (len == 0)
 		return 0;
-		
+
 	curoff = 0;
 	error = 0;
 
@@ -324,12 +324,12 @@ hfs_pread(struct vnode *vp, void *buf, s
 		if (error == 0)
 			memcpy((uint8_t*)buf + curoff, (uint8_t*)bp-b_data +
 (off - start), min(len - curoff, MAXBSIZE - (off - start)));
-		
+
 		if (bp != NULL)
 			brelse(bp, 0);
 		if (error != 0)
 			return error;
-			
+
 		curoff += MAXBSIZE;
 	}
 #undef ABSZ
@@ -352,12 +352,12 @@ hfs_time_to_timespec(uint32_t hfstime, s
 	 * precisely a 66 year difference between them, which is equal to
 	 * 2,082,844,800 seconds. No, I didn't count them by hand.
 	 */
-	
+
 	if (hfstime  2082844800)
 		unixtime-tv_sec = 0; /* dates before 1970 are bs anyway, so use epoch*/
 	else
 		unixtime-tv_sec = hfstime - 2082844800;
-	
+
 	unixtime-tv_nsec = 0; /* we don't have nanosecond resolution */
 }
 
@@ -368,21 +368,20 @@ hfs_time_to_timespec(uint32_t hfstime, s
 uint16_t be16tohp(void** inout_ptr)
 {
 	uint16_t	result;
-	
-	if(inout_ptr == NULL)
+
+	if (inout_ptr == NULL)
 		return 0;
-		
+
 	memcpy(result, *inout_ptr, sizeof(result));
 	*inout_ptr = (char *)*inout_ptr + sizeof(result);
-	
 	return be16toh(result);
 }
 
 uint32_t be32tohp(void** inout_ptr)
 {
 	uint32_t	result;
-	
-	if(inout_ptr == NULL)
+
+	if (inout_ptr == NULL)
 		return 0;
 
 	memcpy(result, *inout_ptr, sizeof(result));
@@ -393,8 +392,8 @@ uint32_t be32tohp(void** inout_ptr)
 uint64_t be64tohp(void** inout_ptr)
 {
 	uint64_t	result;
-	
-	if(inout_ptr == NULL)
+
+	if (inout_ptr == NULL)
 		return 0;
 
 	memcpy(result, *inout_ptr, sizeof(result));
@@ -405,7 +404,7 @@ uint64_t be64tohp(void** inout_ptr)
 enum vtype
 hfs_catalog_keyed_record_vtype(const hfs_catalog_keyed_record_t *rec)
 {
-	if (rec-type == HFS_REC_FILE) {
+	if (rec-type == HFS_REC_FILE) {
 		uint32_t mode;
 
 		mode = ((const hfs_file_record_t *)rec)-bsd.file_mode;
@@ -413,7 +412,6 @@ hfs_catalog_keyed_record_vtype(const hfs
 			return IFTOVT(mode);
 		else
 			return VREG;
-	}
-	else
+	} else
 		return VDIR;
 }



CVS commit: src/sys/fs/hfs

2015-06-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun 21 13:50:34 UTC 2015

Modified Files:
src/sys/fs/hfs: hfs_vnops.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/fs/hfs/hfs_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/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.31 src/sys/fs/hfs/hfs_vnops.c:1.32
--- src/sys/fs/hfs/hfs_vnops.c:1.31	Sun Aug 10 08:53:22 2014
+++ src/sys/fs/hfs/hfs_vnops.c	Sun Jun 21 13:50:34 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vnops.c,v 1.31 2014/08/10 08:53:22 hannken Exp $	*/
+/*	$NetBSD: hfs_vnops.c,v 1.32 2015/06/21 13:50:34 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- */ 
+ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.31 2014/08/10 08:53:22 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.32 2015/06/21 13:50:34 maxv Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ipsec.h
@@ -463,8 +463,7 @@ hfs_vop_lookup(void *v)
 		cnp-cn_flags = ~REQUIREDIR; /* XXX: needed? */
 		error = hfs_vget_internal(vdp-v_mount, rec.file.cnid,
 			HFS_RSRCFORK, tdp);
-		}
-		else
+		} else
 			error = hfs_vget_internal(vdp-v_mount, rec.file.cnid,
 			HFS_DATAFORK, tdp);
 		if (error != 0)
@@ -630,8 +629,7 @@ hfs_vop_getattr(void *v)
 		hfs_time_to_timespec(f-date_content_mod, vap-va_mtime);
 		hfs_time_to_timespec(f-date_accessed, vap-va_atime);
 		vap-va_nlink = 1;
-	}
-	else if (hp-h_rec.u.rec_type == HFS_REC_FLDR) {
+	} else if (hp-h_rec.u.rec_type == HFS_REC_FLDR) {
 		hfs_folder_record_t *f = hp-h_rec.folder;
 		vap-va_fileid = hp-h_rec.folder.cnid;
 		bsd = f-bsd;
@@ -641,8 +639,7 @@ hfs_vop_getattr(void *v)
 		hfs_time_to_timespec(f-date_content_mod,vap-va_mtime);
 		hfs_time_to_timespec(f-date_accessed, vap-va_atime);
 		vap-va_nlink = 2; /* XXX */
-	}
-	else {
+	} else {
 		DPRINTF((hfs+: hfs_vop_getattr(): invalid record type %i,
 		hp-h_rec.u.rec_type));
 		return EINVAL;
@@ -656,8 +653,7 @@ hfs_vop_getattr(void *v)
 			vap-va_mode = (S_IFDIR | HFS_DEFAULT_DIR_MODE);
 		vap-va_uid = HFS_DEFAULT_UID;
 		vap-va_gid = HFS_DEFAULT_GID;
-	}
-	else {
+	} else {
 		vap-va_mode = bsd-file_mode;
 		vap-va_uid = bsd-owner_id;
 		vap-va_gid = bsd-group_id;
@@ -805,7 +801,6 @@ hfs_vop_bmap(void *v)
 			*ap-a_runp = (MAXBSIZE  bshift) - 1;
 		else
 			*ap-a_runp = nblk;
-
 	}
 
 	free(extents, M_TEMP);
@@ -827,7 +822,7 @@ hfs_vop_read(void *v)
 	struct uio *uio;
 	uint64_t fsize; /* logical size of file */
 	int advice;
-int error;
+	int error;
 
 	vp = ap-a_vp;
 	hp = VTOH(vp);
@@ -839,13 +834,13 @@ hfs_vop_read(void *v)
 	error = 0;
 	advice = IO_ADV_DECODE(ap-a_ioflag);
 
-if (uio-uio_offset  0)
-return EINVAL;
+	if (uio-uio_offset  0)
+		return EINVAL;
 
-if (uio-uio_resid == 0 || uio-uio_offset = fsize)
-return 0;
+	if (uio-uio_resid == 0 || uio-uio_offset = fsize)
+		return 0;
 
-if (vp-v_type != VREG  vp-v_type != VLNK)
+	if (vp-v_type != VREG  vp-v_type != VLNK)
 		return EINVAL;
 
 	error = 0;
@@ -860,13 +855,13 @@ hfs_vop_read(void *v)
 		UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
 	}
 
-return error;
+	return error;
 }
 
 int
 hfs_vop_readdir(void *v)
 {
-struct vop_readdir_args /* {
+	struct vop_readdir_args /* {
 		struct vnode *a_vp;
 		struct uio *a_uio;
 		kauth_cred_t a_cred;
@@ -890,14 +885,14 @@ struct vop_readdir_args /* {
 	size_t namlen, ni;
 	int error;
 	int i; /* dummy variable */
-	
+
 	bufoff = 0;
 	children = NULL;
 	error = 0;
 	numchildren = 0;
 	hp = VTOH(ap-a_vp);
 	uio = ap-a_uio;
-	
+
 	if (uio-uio_offset  0)
 		return EINVAL;
 	if (ap-a_eofflag != NULL)
@@ -915,7 +910,7 @@ struct vop_readdir_args /* {
 	argsread.cred = ap-a_cred;
 	argsread.l = NULL;
 	cbargs.read = argsread;
-	
+
 	/* XXX Should we cache this? */
 	if (hfslib_get_directory_contents(hp-h_hmp-hm_vol, hp-h_rec.u.cnid,
 	children, childnames, numchildren, cbargs) != 0) {
@@ -940,7 +935,7 @@ struct vop_readdir_args /* {
 curent.d_name[ni] = ':';
 		curent.d_namlen = namlen;
 		curent.d_reclen = _DIRENT_SIZE(curent);
-		
+
 		/* Skip to desired dirent. */
 		bufoff += curent.d_reclen;
 		if (bufoff - curent.d_reclen  uio-uio_offset)
@@ -953,7 +948,7 @@ struct vop_readdir_args /* {
 *ap-a_eofflag = 1;
 			break;
 		}
-			
+
 		curent.d_fileno = children[curchild].file.cnid;
 		switch (hfs_catalog_keyed_record_vtype(children+curchild)) {
 		case VREG:
@@ -983,19 +978,18 @@ struct vop_readdir_args /* {
 		}
 		DPRINTF((curchildname = %s\t\t, curchildname));
 		/* 

CVS commit: src/sys/fs/hfs

2014-12-29 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Dec 29 17:02:39 UTC 2014

Modified Files:
src/sys/fs/hfs: libhfs.c

Log Message:
I started to KNF this file but quickly ended up figuring out I was not
courageous enough for such ugliness. So I only KNF'ed the first 300
lines.

I'll come back later.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/fs/hfs/libhfs.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/hfs/libhfs.c
diff -u src/sys/fs/hfs/libhfs.c:1.12 src/sys/fs/hfs/libhfs.c:1.13
--- src/sys/fs/hfs/libhfs.c:1.12	Sat Jul 28 00:43:23 2012
+++ src/sys/fs/hfs/libhfs.c	Mon Dec 29 17:02:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.c,v 1.12 2012/07/28 00:43:23 matt Exp $	*/
+/*	$NetBSD: libhfs.c,v 1.13 2014/12/29 17:02:39 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.12 2012/07/28 00:43:23 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.13 2014/12/29 17:02:39 maxv Exp $);
 
 #include libhfs.h
 
@@ -59,7 +59,8 @@ hfs_catalog_key_t* hfs_gPrivateObjectKey
 	hfs_gMetadataDirectoryKey,
 	hfs_gJournalInfoBlockFileKey,
 	hfs_gJournalBufferFileKey,
-	NULL};
+	NULL
+};
 
 
 extern uint16_t be16tohp(void** inout_ptr);
@@ -100,21 +101,21 @@ void
 hfslib_init(hfs_callbacks* in_callbacks)
 {
 	unichar_t	temp[256];
-	
-	if(in_callbacks!=NULL)
+
+	if (in_callbacks != NULL)
 		memcpy(hfs_gcb, in_callbacks, sizeof(hfs_callbacks));
-	
+
 	hfs_gcft = NULL;
-	
+
 	/*
 	 * Create keys for the HFS+ private files so we can reuse them whenever
 	 * we perform a user-visible operation, such as listing directory contents.
 	 */
-		
+
 #define ATOU(str, len) /* quick  dirty ascii-to-unicode conversion */ \
 	do{ int i; for(i=0; ilen; i++) temp[i]=str[i]; } \
 	while( /*CONSTCOND*/ 0)
-	
+
 	ATOU(\0\0\0\0HFS+ Private Data, 21);
 	hfslib_make_catalog_key(HFS_CNID_ROOT_FOLDER, 21, temp, 
 		hfs_gMetadataDirectoryKey);
@@ -134,8 +135,8 @@ void
 hfslib_done(void)
 {
 	hfs_callback_args	cbargs;
-	
-	if(hfs_gcft!=NULL) {
+
+	if (hfs_gcft != NULL) {
 		hfslib_init_cbargs(cbargs);
 		hfslib_free(hfs_gcft, cbargs);
 		hfs_gcft = NULL;
@@ -175,102 +176,97 @@ hfslib_open_volume(
 	result = 1;
 	buffer = NULL;
 
-	if(in_device==NULL || out_vol==NULL)
+	if (in_device == NULL || out_vol == NULL)
 		return 1;
 
 	out_vol-readonly = in_readonly;
 	out_vol-offset = 0;
 
-	if(hfslib_openvoldevice(out_vol, in_device, cbargs) != 0)
+	if (hfslib_openvoldevice(out_vol, in_device, cbargs) != 0)
 		HFS_LIBERR(could not open device);
 	isopen = 1;
 
 	/*
-	 *	Read the volume header.
+	 * Read the volume header.
 	 */
 	buffer = hfslib_malloc(max(sizeof(hfs_volume_header_t),
 		sizeof(hfs_hfs_master_directory_block_t)), cbargs);
-	if(buffer==NULL)
+	if (buffer == NULL)
 		HFS_LIBERR(could not allocate volume header);
-	if(hfslib_readd(out_vol, buffer, max(sizeof(hfs_volume_header_t),
-			sizeof(hfs_hfs_master_directory_block_t)),
-	   HFS_VOLUME_HEAD_RESERVE_SIZE, cbargs)!=0)
+	if (hfslib_readd(out_vol, buffer, max(sizeof(hfs_volume_header_t),
+	sizeof(hfs_hfs_master_directory_block_t)),
+	HFS_VOLUME_HEAD_RESERVE_SIZE, cbargs) != 0)
 		HFS_LIBERR(could not read volume header);
 
 	if (be16toh(*((uint16_t *)buffer)) == HFS_SIG_HFS) {
 		if (hfslib_read_master_directory_block(buffer, mdb) == 0)
 			HFS_LIBERR(could not parse master directory block);
-		if (mdb.embedded_signature == HFS_SIG_HFSP)
-		{
+		if (mdb.embedded_signature == HFS_SIG_HFSP) {
 			/* XXX: is 512 always correct? */
 			out_vol-offset =
 			mdb.first_block * 512
 			+ mdb.embedded_extent.start_block
 			* (uint64_t)mdb.block_size;
 
-			if(hfslib_readd(out_vol, buffer,
-			   sizeof(hfs_volume_header_t),
-			   HFS_VOLUME_HEAD_RESERVE_SIZE, cbargs)!=0)
+			if (hfslib_readd(out_vol, buffer,
+			sizeof(hfs_volume_header_t),
+			HFS_VOLUME_HEAD_RESERVE_SIZE, cbargs) != 0)
 HFS_LIBERR(could not read volume header);
-		}
-		else
+		} else
 			HFS_LIBERR(Plain HFS volumes not currently supported);
 	}
 
-	if(hfslib_read_volume_header(buffer, (out_vol-vh))==0)
+	if (hfslib_read_volume_header(buffer, (out_vol-vh)) == 0)
 		HFS_LIBERR(could not parse volume header);
-	
+
 	/*
 	 * Check the volume signature to see if this is a legitimate HFS+ or HFSX
 	 * volume. If so, set the key comparison function pointers appropriately.
 	 */
-	switch(out_vol-vh.signature)
-	{
+	switch(out_vol-vh.signature) {
 		case HFS_SIG_HFSP:
 			out_vol-keycmp = hfslib_compare_catalog_keys_cf;
 			break;
-		
 		case HFS_SIG_HFSX:
 			out_vol-keycmp = NULL; /* will be set below */
 			break;
-			
 		default:
 			/* HFS_LIBERR(unrecognized volume format); */
 			goto error;
 			break;
 	}
 
-
 	/*
-	 *	Read the catalog header.
+	 * Read the catalog header.
 	 */
 	buffer2 = hfslib_realloc(buffer, 512, cbargs);
-	

CVS commit: src/sys/fs/hfs

2014-12-29 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Dec 29 17:17:54 UTC 2014

Modified Files:
src/sys/fs/hfs: hfs_vfsops.c

Log Message:
Small cleanup:
 - KNF
 - malloc + memset - malloc(|M_ZERO)
 - no need to check data == NULL


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/fs/hfs/hfs_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/hfs/hfs_vfsops.c
diff -u src/sys/fs/hfs/hfs_vfsops.c:1.32 src/sys/fs/hfs/hfs_vfsops.c:1.33
--- src/sys/fs/hfs/hfs_vfsops.c:1.32	Sun Aug 10 08:53:22 2014
+++ src/sys/fs/hfs/hfs_vfsops.c	Mon Dec 29 17:17:54 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vfsops.c,v 1.32 2014/08/10 08:53:22 hannken Exp $	*/
+/*	$NetBSD: hfs_vfsops.c,v 1.33 2014/12/29 17:17:54 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -99,7 +99,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vfsops.c,v 1.32 2014/08/10 08:53:22 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vfsops.c,v 1.33 2014/12/29 17:17:54 maxv Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_compat_netbsd.h
@@ -174,13 +174,12 @@ struct vfsops hfs_vfsops = {
 };
 
 static const struct genfs_ops hfs_genfsops = {
-.gop_size = genfs_size,
+	.gop_size = genfs_size,
 };
 
 static int
 hfs_modcmd(modcmd_t cmd, void *arg)
 {
-
 	switch (cmd) {
 	case MODULE_CMD_INIT:
 		return vfs_attach(hfs_vfsops);
@@ -207,10 +206,10 @@ hfs_mount(struct mount *mp, const char *
 	if (*data_len  sizeof *args)
 		return EINVAL;
 
-#ifdef HFS_DEBUG	
+#ifdef HFS_DEBUG
 	printf(vfsop = hfs_mount()\n);
 #endif /* HFS_DEBUG */
-	
+
 	if (mp-mnt_flag  MNT_GETARGS) {
 		hmp = VFSTOHFS(mp);
 		if (hmp == NULL)
@@ -220,9 +219,6 @@ hfs_mount(struct mount *mp, const char *
 		return 0;
 	}
 
-	if (data == NULL)
-		return EINVAL;
-
 /* FIXME: For development ONLY - disallow remounting for now */
 #if 0
 	update = mp-mnt_flag  MNT_UPDATE;
@@ -239,7 +235,7 @@ hfs_mount(struct mount *mp, const char *
 	NSM_FOLLOW_NOEMULROOT, devvp);
 		if (error != 0)
 			return error;
-	
+
 		if (!update) {
 			/*
 			 * Be sure this is a valid block device
@@ -269,7 +265,6 @@ hfs_mount(struct mount *mp, const char *
 		}
 	}
 
-	
 	/*
 	 * If mount by non-root, then verify that user has necessary
 	 * permissions on the device.
@@ -302,14 +297,14 @@ hfs_mount(struct mount *mp, const char *
 
 	if ((error = hfs_mountfs(devvp, mp, l, args-fspec)) != 0)
 		goto error;
-	
+
 	error = set_statvfs_info(path, UIO_USERSPACE, args-fspec, UIO_USERSPACE,
 		mp-mnt_op-vfs_name, mp, l);
 
 #ifdef HFS_DEBUG
 	if(!update) {
 		char* volname;
-		
+
 		hmp = VFSTOHFS(mp);
 		volname = malloc(hmp-hm_vol.name.length + 1, M_TEMP, M_WAITOK);
 		if (volname == NULL)
@@ -324,9 +319,9 @@ hfs_mount(struct mount *mp, const char *
 		}
 	}
 #endif /* HFS_DEBUG */
-		
+
 	return error;
-	
+
 error:
 	vrele(devvp);
 	return error;
@@ -335,8 +330,7 @@ error:
 int
 hfs_start(struct mount *mp, int flags)
 {
-
-#ifdef HFS_DEBUG	
+#ifdef HFS_DEBUG
 	printf(vfsop = hfs_start()\n);
 #endif /* HFS_DEBUG */
 
@@ -353,20 +347,18 @@ hfs_mountfs(struct vnode *devvp, struct 
 	struct hfsmount *hmp;
 	kauth_cred_t cred;
 	int error;
-	
+
 	cred = l ? l-l_cred : NOCRED;
 	error = 0;
 	hmp = NULL;
 
 	/* Create mounted volume structure. */
-	hmp = (struct hfsmount*)malloc(sizeof(struct hfsmount),
-M_HFSMNT, M_WAITOK);
+	hmp = malloc(sizeof(struct hfsmount), M_HFSMNT, M_WAITOK|M_ZERO);
 	if (hmp == NULL) {
 		error = ENOMEM;
 		goto error;
 	}
-	memset(hmp, 0, sizeof(struct hfsmount));
-	
+
 	mp-mnt_data = hmp;
 	mp-mnt_flag |= MNT_LOCAL;
 	vfs_getnewfsid(mp);
@@ -374,12 +366,12 @@ hfs_mountfs(struct vnode *devvp, struct 
 	hmp-hm_mountp = mp;
 	hmp-hm_dev = devvp-v_rdev;
 	hmp-hm_devvp = devvp;
-	
+
 	/*
 	 * Use libhfs to open the volume and read the volume header and other
 	 * useful information.
 	 */
-	 
+
 	hfslib_init_cbargs(cbargs);
 	argsopen.cred = argsread.cred = cred;
 	argsopen.l = argsread.l = l;
@@ -390,7 +382,7 @@ hfs_mountfs(struct vnode *devvp, struct 
 	if ((error = hfslib_open_volume(devpath, mp-mnt_flag  MNT_RDONLY,
 		hmp-hm_vol, cbargs)) != 0)
 		goto error;
-		
+
 	/* Make sure this is not a journaled volume whose journal is dirty. */
 	if (!hfslib_is_journal_clean(hmp-hm_vol)) {
 		printf(volume journal is dirty; not mounting\n);
@@ -399,16 +391,15 @@ hfs_mountfs(struct vnode *devvp, struct 
 	}
 
 	mp-mnt_fs_bshift = 0;
-while ((1  mp-mnt_fs_bshift)  hmp-hm_vol.vh.block_size)
+	while ((1  mp-mnt_fs_bshift)  hmp-hm_vol.vh.block_size)
 		mp-mnt_fs_bshift++;
 	mp-mnt_dev_bshift = DEV_BSHIFT;
 
 	return 0;
-	
+
 error:
 	if (hmp != NULL)
 		free(hmp, M_HFSMNT);
-		
 	return error;
 }
 
@@ -420,17 +411,17 @@ hfs_unmount(struct mount *mp, int mntfla
 	struct hfsmount* hmp;
 	int error;
 	int flags;
-	
-#ifdef HFS_DEBUG	
+
+#ifdef HFS_DEBUG
 	printf(vfsop = hfs_unmount()\n);
 #endif /* HFS_DEBUG */
 
 	

CVS commit: src/sys/fs/hfs

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

Modified Files:
src/sys/fs/hfs: hfs_vnops.c

Log Message:
remove unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/fs/hfs/hfs_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/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.27 src/sys/fs/hfs/hfs_vnops.c:1.28
--- src/sys/fs/hfs/hfs_vnops.c:1.27	Mon Mar 18 15:35:37 2013
+++ src/sys/fs/hfs/hfs_vnops.c	Fri Oct 18 15:58:11 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vnops.c,v 1.27 2013/03/18 19:35:37 plunky Exp $	*/
+/*	$NetBSD: hfs_vnops.c,v 1.28 2013/10/18 19:58:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.27 2013/03/18 19:35:37 plunky Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.28 2013/10/18 19:58:11 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ipsec.h
@@ -325,7 +325,6 @@ hfs_vop_lookup(void *v)
 		struct vnode ** a_vpp;
 		struct componentname * a_cnp;
 	} */ *ap = v;
-	struct buf *bp;			/* a buffer of directory entries */
 	struct componentname *cnp;
 	struct hfsnode *dp;	/* hfsnode for directory being searched */
 	kauth_cred_t cred;
@@ -343,7 +342,6 @@ hfs_vop_lookup(void *v)
 
 	DPRINTF((VOP = hfs_vop_lookup()\n));
 
-	bp = NULL;
 	cnp = ap-a_cnp;
 	cred = cnp-cn_cred;
 	vdp = ap-a_dvp;
@@ -1027,13 +1025,11 @@ hfs_vop_reclaim(void *v)
 	} */ *ap = v;
 	struct vnode *vp;
 	struct hfsnode *hp;
-	struct hfsmount *hmp;
 	
 	DPRINTF((VOP = hfs_vop_reclaim()\n));
 
 	vp = ap-a_vp;
 	hp = VTOH(vp);
-	hmp = hp-h_hmp;
 
 	/* Remove the hfsnode from its hash chain. */
 	hfs_nhashremove(hp);



CVS commit: src/sys/fs/hfs

2012-06-15 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Jun 15 21:59:40 UTC 2012

Modified Files:
src/sys/fs/hfs: libhfs.c

Log Message:
Assert that out_hr is not NULL in hfslib_read_header_node


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/fs/hfs/libhfs.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/hfs/libhfs.c
diff -u src/sys/fs/hfs/libhfs.c:1.10 src/sys/fs/hfs/libhfs.c:1.11
--- src/sys/fs/hfs/libhfs.c:1.10	Thu Feb 24 23:49:26 2011
+++ src/sys/fs/hfs/libhfs.c	Fri Jun 15 21:59:39 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.c,v 1.10 2011/02/24 23:49:26 christos Exp $	*/
+/*	$NetBSD: libhfs.c,v 1.11 2012/06/15 21:59:39 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.10 2011/02/24 23:49:26 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.11 2012/06/15 21:59:39 joerg Exp $);
 
 #include libhfs.h
 
@@ -1658,34 +1658,32 @@ hfslib_read_header_node(void** in_recs,
 {
 	void*	ptr;
 	int		i;
-	
+
+	KASSERT(out_hr != NULL);
+
 	if(in_recs==NULL || in_rec_sizes==NULL)
 		return 0;
 	
-	if(out_hr!=NULL)
-	{
-		ptr = in_recs[0];
-		
-		out_hr-tree_depth = be16tohp(ptr);
-		out_hr-root_node = be32tohp(ptr);
-		out_hr-leaf_recs = be32tohp(ptr);
-		out_hr-first_leaf = be32tohp(ptr);
-		out_hr-last_leaf = be32tohp(ptr);
-		out_hr-node_size = be16tohp(ptr);
-		out_hr-max_key_len = be16tohp(ptr);
-		out_hr-total_nodes = be32tohp(ptr);
-		out_hr-free_nodes = be32tohp(ptr);
-		out_hr-reserved = be16tohp(ptr);
-		out_hr-clump_size = be32tohp(ptr);
-		out_hr-btree_type = *(((uint8_t*)ptr));
-		ptr = (uint8_t*)ptr + 1;
-		out_hr-keycomp_type = *(((uint8_t*)ptr));
-		ptr = (uint8_t*)ptr + 1;
-		out_hr-attributes = be32tohp(ptr);
-		for(i=0;i16;i++)
-			out_hr-reserved2[i] = be32tohp(ptr);
-	}
-	
+	ptr = in_recs[0];
+	out_hr-tree_depth = be16tohp(ptr);
+	out_hr-root_node = be32tohp(ptr);
+	out_hr-leaf_recs = be32tohp(ptr);
+	out_hr-first_leaf = be32tohp(ptr);
+	out_hr-last_leaf = be32tohp(ptr);
+	out_hr-node_size = be16tohp(ptr);
+	out_hr-max_key_len = be16tohp(ptr);
+	out_hr-total_nodes = be32tohp(ptr);
+	out_hr-free_nodes = be32tohp(ptr);
+	out_hr-reserved = be16tohp(ptr);
+	out_hr-clump_size = be32tohp(ptr);
+	out_hr-btree_type = *(((uint8_t*)ptr));
+	ptr = (uint8_t*)ptr + 1;
+	out_hr-keycomp_type = *(((uint8_t*)ptr));
+	ptr = (uint8_t*)ptr + 1;
+	out_hr-attributes = be32tohp(ptr);
+	for(i=0;i16;i++)
+		out_hr-reserved2[i] = be32tohp(ptr);
+
 	if(out_userdata!=NULL)
 	{
 		memcpy(out_userdata, in_recs[1], in_rec_sizes[1]);



CVS commit: src/sys/fs/hfs

2012-01-28 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Jan 28 16:24:35 UTC 2012

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

Log Message:
Include sys/malloc.h for MALLOC_DECLARE.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/fs/hfs/hfs.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/hfs/hfs.h
diff -u src/sys/fs/hfs/hfs.h:1.7 src/sys/fs/hfs/hfs.h:1.8
--- src/sys/fs/hfs/hfs.h:1.7	Wed Sep  3 22:57:46 2008
+++ src/sys/fs/hfs/hfs.h	Sat Jan 28 16:24:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs.h,v 1.7 2008/09/03 22:57:46 gmcgarry Exp $	*/
+/*	$NetBSD: hfs.h,v 1.8 2012/01/28 16:24:35 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -118,6 +118,7 @@ typedef struct {
 } hfs_libcb_argsread;
 
 #ifdef _KERNEL
+#include sys/malloc.h
 
 MALLOC_DECLARE(M_HFSMNT);	/* defined in hfs_vfsops.c */
 



CVS commit: src/sys/fs/hfs

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

Modified Files:
src/sys/fs/hfs: hfs_subr.c

Log Message:
use getdisksize()


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/fs/hfs/hfs_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/hfs/hfs_subr.c
diff -u src/sys/fs/hfs/hfs_subr.c:1.15 src/sys/fs/hfs/hfs_subr.c:1.16
--- src/sys/fs/hfs/hfs_subr.c:1.15	Thu Feb 24 18:48:59 2011
+++ src/sys/fs/hfs/hfs_subr.c	Sun Nov 13 18:03:55 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_subr.c,v 1.15 2011/02/24 23:48:59 christos Exp $	*/
+/*	$NetBSD: hfs_subr.c,v 1.16 2011/11/13 23:03:55 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */ 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_subr.c,v 1.15 2011/02/24 23:48:59 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_subr.c,v 1.16 2011/11/13 23:03:55 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, $NetBSD: hfs_subr.c,v
 #include sys/file.h
 #include sys/filedesc.h
 #include sys/mount.h
-#include sys/disklabel.h
+#include sys/device.h
 #include sys/conf.h
 #include sys/kauth.h
 #include sys/buf.h
@@ -155,8 +155,9 @@ hfs_libcb_opendev(
 {
 	hfs_libcb_data* cbdata = NULL;
 	hfs_libcb_argsopen* args;
-	struct partinfo dpart;
 	int result, mode;
+	uint64_t psize;
+	unsigned secsize;
 
 	result = 0;
 	args = (hfs_libcb_argsopen*)(cbargs-openvol);
@@ -193,11 +194,10 @@ hfs_libcb_opendev(
 	cbdata-devvp = args-devvp;
 
 	/* Determine the device's block size. Default to DEV_BSIZE if unavailable.*/
-	if (VOP_IOCTL(args-devvp, DIOCGPART, dpart, FREAD, args-cred)
-		!= 0)
+	if (getdisksize(args-devvp, psize, secsize) != 0)
 		cbdata-devblksz = DEV_BSIZE;
 	else
-		cbdata-devblksz = dpart.disklab-d_secsize;
+		cbdata-devblksz = secsize;
 		
 	return 0;
 



CVS commit: src/sys/fs/hfs

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

Modified Files:
src/sys/fs/hfs: hfs_vnops.c

Log Message:
use NAME_MAX instead of MAXNAMLEN


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/fs/hfs/hfs_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/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.23 src/sys/fs/hfs/hfs_vnops.c:1.24
--- src/sys/fs/hfs/hfs_vnops.c:1.23	Wed May 18 23:11:56 2011
+++ src/sys/fs/hfs/hfs_vnops.c	Mon Sep 26 21:14:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vnops.c,v 1.23 2011/05/19 03:11:56 rmind Exp $	*/
+/*	$NetBSD: hfs_vnops.c,v 1.24 2011/09/27 01:14:47 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.23 2011/05/19 03:11:56 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.24 2011/09/27 01:14:47 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ipsec.h
@@ -923,11 +923,11 @@ struct vop_readdir_args /* {
 	DPRINTF((numchildren = %u\n, numchildren));
 	for (curchild = 0; curchild  numchildren  uio-uio_resid  0;
 	curchild++) {
-		namlen = utf16_to_utf8(curent.d_name, MAXNAMLEN, 
+		namlen = utf16_to_utf8(curent.d_name, NAME_MAX, 
 		childnames[curchild].unicode, childnames[curchild].length,
 		0, NULL);
 		/* XXX: check conversion errors? */
-		if (namlen  MAXNAMLEN) {
+		if (namlen  NAME_MAX) {
 			/* XXX: how to handle name too long? */
 			continue;
 		}



CVS commit: src/sys/fs/hfs

2011-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 24 23:48:59 UTC 2011

Modified Files:
src/sys/fs/hfs: hfs_subr.c

Log Message:
simplify and handle unaligned pointer access.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/fs/hfs/hfs_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/hfs/hfs_subr.c
diff -u src/sys/fs/hfs/hfs_subr.c:1.14 src/sys/fs/hfs/hfs_subr.c:1.15
--- src/sys/fs/hfs/hfs_subr.c:1.14	Thu Jun 24 09:03:09 2010
+++ src/sys/fs/hfs/hfs_subr.c	Thu Feb 24 18:48:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_subr.c,v 1.14 2010/06/24 13:03:09 hannken Exp $	*/
+/*	$NetBSD: hfs_subr.c,v 1.15 2011/02/24 23:48:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */ 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_subr.c,v 1.14 2010/06/24 13:03:09 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_subr.c,v 1.15 2011/02/24 23:48:59 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -366,55 +366,38 @@
 uint16_t be16tohp(void** inout_ptr)
 {
 	uint16_t	result;
-	uint16_t *ptr;
 	
-	if(inout_ptr==NULL)
+	if(inout_ptr == NULL)
 		return 0;
 		
-	ptr = *inout_ptr;
-
-	result = be16toh(*ptr);
-
-	ptr++;
-	*inout_ptr = ptr;
+	memcpy(result, *inout_ptr, sizeof(result));
+	*inout_ptr = (char *)*inout_ptr + sizeof(result);
 	
-	return result;
+	return be16toh(result);
 }
 
 uint32_t be32tohp(void** inout_ptr)
 {
 	uint32_t	result;
-	uint32_t *ptr;
 	
-	if(inout_ptr==NULL)
+	if(inout_ptr == NULL)
 		return 0;
 
-	ptr = *inout_ptr;
-
-	result = be32toh(*ptr);
-
-	ptr++;
-	*inout_ptr = ptr;
-	
-	return result;
+	memcpy(result, *inout_ptr, sizeof(result));
+	*inout_ptr = (char *)*inout_ptr + sizeof(result);
+	return be32toh(result);
 }
 
 uint64_t be64tohp(void** inout_ptr)
 {
 	uint64_t	result;
-	uint64_t *ptr;
 	
-	if(inout_ptr==NULL)
+	if(inout_ptr == NULL)
 		return 0;
 
-	ptr = *inout_ptr;
-
-	result = be64toh(*ptr);
-
-	ptr++;
-	*inout_ptr = ptr;
-	
-	return result;
+	memcpy(result, *inout_ptr, sizeof(result));
+	*inout_ptr = (char *)*inout_ptr + sizeof(result);
+	return be64toh(result);
 }
 
 enum vtype



CVS commit: src/sys/fs/hfs

2011-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 24 23:49:26 UTC 2011

Modified Files:
src/sys/fs/hfs: libhfs.c

Log Message:
simplify and avoid pointer gymnastics


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/fs/hfs/libhfs.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/hfs/libhfs.c
diff -u src/sys/fs/hfs/libhfs.c:1.9 src/sys/fs/hfs/libhfs.c:1.10
--- src/sys/fs/hfs/libhfs.c:1.9	Fri Nov 27 10:58:39 2009
+++ src/sys/fs/hfs/libhfs.c	Thu Feb 24 18:49:26 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.c,v 1.9 2009/11/27 15:58:39 pooka Exp $	*/
+/*	$NetBSD: libhfs.c,v 1.10 2011/02/24 23:49:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.9 2009/11/27 15:58:39 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.10 2011/02/24 23:49:26 christos Exp $);
 
 #include libhfs.h
 
@@ -460,14 +460,11 @@
 		goto exit;
 	
 	/* copy only the bytes that are actually used */
-	memcpy(*out_unicode+2, path + path_offset, total_path_length*2);
+	memcpy(*out_unicode + 2, path + path_offset, total_path_length*2);
 
 	/* insert forward slash at start */
-	(*out_unicode)[0] = 0x00;
-	(*out_unicode)[1] = 0x2F;
-	ptr = (uint16_t*)*out_unicode;
-	uchar = be16tohp((void*)ptr);
-	*(ptr-1) = uchar;
+	uchar = be16toh(0x2F);
+	memcpy(*out_unicode, uchar, sizeof(uchar));
 
 	/* insert null char at end */
 	(*out_unicode)[total_path_length*2+2] = 0x00;



CVS commit: src/sys/fs/hfs

2011-02-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 10 01:49:52 UTC 2011

Modified Files:
src/sys/fs/hfs: hfs_vnops.c

Log Message:
PR/44523: Taylor R Campbell: mount_hfs badly handles file names with slashes
in them, encode them as colons. XXX: Should encode : as :: too?


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/fs/hfs/hfs_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/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.20 src/sys/fs/hfs/hfs_vnops.c:1.21
--- src/sys/fs/hfs/hfs_vnops.c:1.20	Sun Feb  6 22:03:16 2011
+++ src/sys/fs/hfs/hfs_vnops.c	Wed Feb  9 20:49:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vnops.c,v 1.20 2011/02/07 03:03:16 jakllsch Exp $	*/
+/*	$NetBSD: hfs_vnops.c,v 1.21 2011/02/10 01:49:51 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.20 2011/02/07 03:03:16 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.21 2011/02/10 01:49:51 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ipsec.h
@@ -408,15 +408,20 @@
 		*vpp = vdp;
 	} else {
 		hfs_callback_args cbargs;
-		uint8_t len;
+		uint8_t len, ni;
 
 		hfslib_init_cbargs(cbargs);
 
 		/* XXX: when decomposing, string could grow
 		   and we have to handle overflow */
-		unicn = malloc(cnp-cn_namelen*sizeof(unicn[0]), M_TEMP, M_WAITOK);
+		unicn = malloc(cnp-cn_namelen * sizeof(unicn[0]),
+		M_TEMP, M_WAITOK);
 		len = utf8_to_utf16(unicn, cnp-cn_namelen,
 		cnp-cn_nameptr, cnp-cn_namelen, 0, NULL);
+		/* XXX: perhaps check for colons too, and encode them? */
+		for (ni = 0; ni  len; ni++)
+			if (unicn[ni] == (unichar_t)'/')
+unicn[ni] = (unichar_t)':';
 		/* XXX: check conversion errors? */
 		if (hfslib_make_catalog_key(VTOH(vdp)-h_rec.u.cnid, len, unicn,
 		key) == 0) {
@@ -879,7 +884,7 @@
 	off_t bufoff; /* offset in buffer relative to start of dirents */
 	uint32_t numchildren;
 	uint32_t curchild; /* index of child we are stuffing into dirent */
-	size_t namlen;
+	size_t namlen, ni;
 	int error;
 	int i; /* dummy variable */
 	
@@ -927,6 +932,10 @@
 			/* XXX: how to handle name too long? */
 			continue;
 		}
+		/* XXX: perhaps check for colons too, and encode them? */
+		for (ni = 0; ni  namlen; ni++)
+			if (curent.d_name[ni] == '/')
+curent.d_name[ni] = ':';
 		curent.d_namlen = namlen;
 		curent.d_reclen = _DIRENT_SIZE(curent);
 		



CVS commit: src/sys/fs/hfs

2011-02-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 10 03:30:30 UTC 2011

Modified Files:
src/sys/fs/hfs: hfs_vnops.c

Log Message:
remove comments about needing to encode : since the on disk format does
not allow them. Also fix reversed encoding in lookup. From Taylor R Campbell.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/fs/hfs/hfs_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/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.21 src/sys/fs/hfs/hfs_vnops.c:1.22
--- src/sys/fs/hfs/hfs_vnops.c:1.21	Wed Feb  9 20:49:51 2011
+++ src/sys/fs/hfs/hfs_vnops.c	Wed Feb  9 22:30:29 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vnops.c,v 1.21 2011/02/10 01:49:51 christos Exp $	*/
+/*	$NetBSD: hfs_vnops.c,v 1.22 2011/02/10 03:30:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.21 2011/02/10 01:49:51 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.22 2011/02/10 03:30:29 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ipsec.h
@@ -418,10 +418,9 @@
 		M_TEMP, M_WAITOK);
 		len = utf8_to_utf16(unicn, cnp-cn_namelen,
 		cnp-cn_nameptr, cnp-cn_namelen, 0, NULL);
-		/* XXX: perhaps check for colons too, and encode them? */
 		for (ni = 0; ni  len; ni++)
-			if (unicn[ni] == (unichar_t)'/')
-unicn[ni] = (unichar_t)':';
+			if (unicn[ni] == (unichar_t)':')
+unicn[ni] = (unichar_t)'/';
 		/* XXX: check conversion errors? */
 		if (hfslib_make_catalog_key(VTOH(vdp)-h_rec.u.cnid, len, unicn,
 		key) == 0) {
@@ -932,7 +931,6 @@
 			/* XXX: how to handle name too long? */
 			continue;
 		}
-		/* XXX: perhaps check for colons too, and encode them? */
 		for (ni = 0; ni  namlen; ni++)
 			if (curent.d_name[ni] == '/')
 curent.d_name[ni] = ':';



CVS commit: src/sys/fs/hfs

2011-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb  7 02:06:21 UTC 2011

Modified Files:
src/sys/fs/hfs: hfs_vnops.c

Log Message:
KNF, no functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/fs/hfs/hfs_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/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.18 src/sys/fs/hfs/hfs_vnops.c:1.19
--- src/sys/fs/hfs/hfs_vnops.c:1.18	Thu Jun 24 09:03:09 2010
+++ src/sys/fs/hfs/hfs_vnops.c	Sun Feb  6 21:06:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vnops.c,v 1.18 2010/06/24 13:03:09 hannken Exp $	*/
+/*	$NetBSD: hfs_vnops.c,v 1.19 2011/02/07 02:06:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.18 2010/06/24 13:03:09 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.19 2011/02/07 02:06:20 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ipsec.h
@@ -131,18 +131,24 @@
 
 #include miscfs/genfs/genfs.h
 
-int	hfs_vop_lookup		(void *);
-int	hfs_vop_open		(void *);
-int	hfs_vop_close		(void *);
-int	hfs_vop_access		(void *);
-int	hfs_vop_getattr	(void *);
-int	hfs_vop_setattr	(void *);
-int	hfs_vop_bmap		(void *);
-int	hfs_vop_read		(void *);
-int	hfs_vop_readdir	(void *);
-int	hfs_vop_readlink	(void *);
-int	hfs_vop_reclaim	(void *);
-int	hfs_vop_print		(void *);
+int	hfs_vop_lookup(void *);
+int	hfs_vop_open(void *);
+int	hfs_vop_close(void *);
+int	hfs_vop_access(void *);
+int	hfs_vop_getattr(void *);
+int	hfs_vop_setattr(void *);
+int	hfs_vop_bmap(void *);
+int	hfs_vop_read(void *);
+int	hfs_vop_readdir(void *);
+int	hfs_vop_readlink(void *);
+int	hfs_vop_reclaim(void *);
+int	hfs_vop_print(void *);
+
+#ifdef HFS_DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
 
 
 int (**hfs_vnodeop_p) (void *);
@@ -155,8 +161,8 @@
 	{ vop_open_desc, hfs_vop_open },		/* open */
 	{ vop_close_desc, hfs_vop_close },		/* close */
 	{ vop_access_desc, hfs_vop_access },		/* access */
-	{ vop_getattr_desc, hfs_vop_getattr },	/* getattr */
-	{ vop_setattr_desc, hfs_vop_setattr },	/* setattr */
+	{ vop_getattr_desc, hfs_vop_getattr },		/* getattr */
+	{ vop_setattr_desc, hfs_vop_setattr },		/* setattr */
 	{ vop_read_desc, hfs_vop_read },		/* read */
 	{ vop_write_desc, genfs_eopnotsupp },		/* write */
 	{ vop_ioctl_desc, genfs_eopnotsupp },		/* ioctl */
@@ -173,11 +179,11 @@
 	{ vop_mkdir_desc, genfs_eopnotsupp },		/* mkdir */
 	{ vop_rmdir_desc, genfs_eopnotsupp },		/* rmdir */
 	{ vop_symlink_desc, genfs_eopnotsupp },	/* symlink */
-	{ vop_readdir_desc, hfs_vop_readdir },	/* readdir */
+	{ vop_readdir_desc, hfs_vop_readdir },		/* readdir */
 	{ vop_readlink_desc, hfs_vop_readlink },	/* readlink */
 	{ vop_abortop_desc, genfs_abortop },		/* abortop */
 	{ vop_inactive_desc, genfs_eopnotsupp },	/* inactive */
-	{ vop_reclaim_desc, hfs_vop_reclaim },	/* reclaim */
+	{ vop_reclaim_desc, hfs_vop_reclaim },		/* reclaim */
 	{ vop_lock_desc, genfs_lock },			/* lock */
 	{ vop_unlock_desc, genfs_unlock },		/* unlock */
 	{ vop_bmap_desc, hfs_vop_bmap },		/* bmap */
@@ -209,8 +215,8 @@
 	{ vop_open_desc, spec_open },			/* open */
 	{ vop_close_desc, spec_close },		/* close */
 	{ vop_access_desc, hfs_vop_access },		/* access */
-	{ vop_getattr_desc, hfs_vop_getattr },	/* getattr */
-	{ vop_setattr_desc, hfs_vop_setattr },	/* setattr */
+	{ vop_getattr_desc, hfs_vop_getattr },		/* getattr */
+	{ vop_setattr_desc, hfs_vop_setattr },		/* setattr */
 	{ vop_read_desc, spec_read },			/* read */
 	{ vop_write_desc, spec_write },		/* write */
 	{ vop_ioctl_desc, spec_ioctl },		/* ioctl */
@@ -231,7 +237,7 @@
 	{ vop_readlink_desc, spec_readlink },		/* readlink */
 	{ vop_abortop_desc, spec_abortop },		/* abortop */
 	{ vop_inactive_desc, genfs_eopnotsupp },	/* inactive */
-	{ vop_reclaim_desc, hfs_vop_reclaim },	/* reclaim */
+	{ vop_reclaim_desc, hfs_vop_reclaim },		/* reclaim */
 	{ vop_lock_desc, genfs_lock },			/* lock */
 	{ vop_unlock_desc, genfs_unlock },		/* unlock */
 	{ vop_bmap_desc, spec_bmap },			/* bmap */
@@ -333,11 +339,9 @@
 	const char *pname;
 	int error;
 	int flags;
-	int result;/* result of libhfs operations */
+	int result;			/* result of libhfs operations */
 
-#ifdef HFS_DEBUG
-	printf(VOP = hfs_vop_lookup()\n);
-#endif /* HFS_DEBUG */
+	DPRINTF((VOP = hfs_vop_lookup()\n));
 
 	bp = NULL;
 	cnp = ap-a_cnp;
@@ -372,28 +376,34 @@
 	 * we are looking for is known already.
 	 */
 /* XXX Cache disabled until we can make sure it works. */
-/*	if ((error = cache_lookup(vdp, vpp, cnp)) = 0)
-		return error; */
+#if 0
+	if ((error = cache_lookup(vdp, vpp, cnp)) = 0)
+		return error;
+#endif
 
 
-/*	if (cnp-cn_namelen == 1  *pname == '.') {
+#if 0
+	if (cnp-cn_namelen == 1  *pname == '.') {
 		*vpp = vdp;
 		vref(vdp);
-		return (0);
-	}*/
+		

CVS commit: src/sys/fs/hfs

2011-02-06 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Feb  7 03:03:16 UTC 2011

Modified Files:
src/sys/fs/hfs: hfs_vnops.c

Log Message:
Make this build.

Also, the previous commit contanined unintended functional changes I'm
going to ignore.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/fs/hfs/hfs_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/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.19 src/sys/fs/hfs/hfs_vnops.c:1.20
--- src/sys/fs/hfs/hfs_vnops.c:1.19	Mon Feb  7 02:06:20 2011
+++ src/sys/fs/hfs/hfs_vnops.c	Mon Feb  7 03:03:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vnops.c,v 1.19 2011/02/07 02:06:20 christos Exp $	*/
+/*	$NetBSD: hfs_vnops.c,v 1.20 2011/02/07 03:03:16 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.19 2011/02/07 02:06:20 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vnops.c,v 1.20 2011/02/07 03:03:16 jakllsch Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_ipsec.h
@@ -993,8 +993,10 @@
 			free(childnames, M_TEMP);
 	}
 
-	if (error)
+	if (error) {
 		DPRINTF((ERROR = %i\n, error));
+	}
+
 	return error;
 }
 



CVS commit: src/sys/fs/hfs

2009-12-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Dec  3 14:29:04 UTC 2009

Modified Files:
src/sys/fs/hfs: hfs_vfsops.c

Log Message:
vrele, not vput for unlocked devvp


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/fs/hfs/hfs_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/hfs/hfs_vfsops.c
diff -u src/sys/fs/hfs/hfs_vfsops.c:1.23 src/sys/fs/hfs/hfs_vfsops.c:1.24
--- src/sys/fs/hfs/hfs_vfsops.c:1.23	Fri Nov 27 16:11:35 2009
+++ src/sys/fs/hfs/hfs_vfsops.c	Thu Dec  3 14:29:04 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hfs_vfsops.c,v 1.23 2009/11/27 16:11:35 pooka Exp $	*/
+/*	$NetBSD: hfs_vfsops.c,v 1.24 2009/12/03 14:29:04 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -99,7 +99,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hfs_vfsops.c,v 1.23 2009/11/27 16:11:35 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: hfs_vfsops.c,v 1.24 2009/12/03 14:29:04 pooka Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_compat_netbsd.h
@@ -438,7 +438,7 @@
 	cbargs.closevol = (void*)argsclose;
 	hfslib_close_volume(hmp-hm_vol, cbargs);
 	
-	vput(hmp-hm_devvp);
+	vrele(hmp-hm_devvp);
 
 	free(hmp, M_HFSMNT);
 	mp-mnt_data = NULL;



CVS commit: src/sys/fs/hfs

2009-11-27 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Nov 27 15:58:39 UTC 2009

Modified Files:
src/sys/fs/hfs: libhfs.c

Log Message:
Don't spam if mount fails due to invalid file system.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/fs/hfs/libhfs.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/hfs/libhfs.c
diff -u src/sys/fs/hfs/libhfs.c:1.8 src/sys/fs/hfs/libhfs.c:1.9
--- src/sys/fs/hfs/libhfs.c:1.8	Tue Jul 14 21:12:18 2009
+++ src/sys/fs/hfs/libhfs.c	Fri Nov 27 15:58:39 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.c,v 1.8 2009/07/14 21:12:18 apb Exp $	*/
+/*	$NetBSD: libhfs.c,v 1.9 2009/11/27 15:58:39 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.8 2009/07/14 21:12:18 apb Exp $);
+__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.9 2009/11/27 15:58:39 pooka Exp $);
 
 #include libhfs.h
 
@@ -226,7 +226,9 @@
 			break;
 			
 		default:
-			HFS_LIBERR(unrecognized volume format);
+			/* HFS_LIBERR(unrecognized volume format); */
+			goto error;
+			break;
 	}
 
 



CVS commit: src/sys/fs/hfs

2009-07-14 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Jul 14 21:12:18 UTC 2009

Modified Files:
src/sys/fs/hfs: libhfs.c

Log Message:
Initialise the fork local variable in hfslib_get_file_extents().
This variable was not actually used uninitialised, but some compilers
(e.g. gcc-4.3.3) warned that the variable might be used uninitialised.
Inspired by PR 41255 from Kurt Lidl.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/fs/hfs/libhfs.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/hfs/libhfs.c
diff -u src/sys/fs/hfs/libhfs.c:1.7 src/sys/fs/hfs/libhfs.c:1.8
--- src/sys/fs/hfs/libhfs.c:1.7	Fri Mar 27 06:35:10 2009
+++ src/sys/fs/hfs/libhfs.c	Tue Jul 14 21:12:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: libhfs.c,v 1.7 2009/03/27 06:35:10 pooka Exp $	*/
+/*	$NetBSD: libhfs.c,v 1.8 2009/07/14 21:12:18 apb Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.7 2009/03/27 06:35:10 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: libhfs.c,v 1.8 2009/07/14 21:12:18 apb Exp $);
 
 #include libhfs.h
 
@@ -813,7 +813,7 @@
 	hfs_file_record_t		file;
 	hfs_catalog_key_t		filekey;
 	hfs_thread_record_t	fileparent;
-	hfs_fork_tfork;
+	hfs_fork_t		fork = {.logical_size = 0};
 	hfs_extent_record_t	nextextentrec;
 	uint32_t	numblocks;
 	uint16_t	numextents, n;