Module Name:    src
Committed By:   maxv
Date:           Sun Dec 28 12:13:22 UTC 2014

Modified Files:
        src/sys/fs/ntfs: ntfs_vfsops.c

Log Message:
Make this more readable (KNF).


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/fs/ntfs/ntfs_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/ntfs/ntfs_vfsops.c
diff -u src/sys/fs/ntfs/ntfs_vfsops.c:1.97 src/sys/fs/ntfs/ntfs_vfsops.c:1.98
--- src/sys/fs/ntfs/ntfs_vfsops.c:1.97	Thu Nov 13 16:51:53 2014
+++ src/sys/fs/ntfs/ntfs_vfsops.c	Sun Dec 28 12:13:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntfs_vfsops.c,v 1.97 2014/11/13 16:51:53 hannken Exp $	*/
+/*	$NetBSD: ntfs_vfsops.c,v 1.98 2014/12/28 12:13:22 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.97 2014/11/13 16:51:53 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.98 2014/12/28 12:13:22 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -79,12 +79,12 @@ static int	ntfs_mountfs(struct vnode *, 
 				  struct ntfs_args *, struct lwp *);
 static int	ntfs_vptofh(struct vnode *, struct fid *, size_t *);
 
-static void     ntfs_init(void);
-static void     ntfs_reinit(void);
-static void     ntfs_done(void);
-static int      ntfs_fhtovp(struct mount *, struct fid *,
+static void	ntfs_init(void);
+static void	ntfs_reinit(void);
+static void	ntfs_done(void);
+static int	ntfs_fhtovp(struct mount *, struct fid *,
 				struct vnode **);
-static int      ntfs_mountroot(void);
+static int	ntfs_mountroot(void);
 
 static const struct genfs_ops ntfs_genfsops = {
 	.gop_write = genfs_compat_gop_write,
@@ -160,11 +160,7 @@ ntfs_done(void)
 }
 
 static int
-ntfs_mount (
-	struct mount *mp,
-	const char *path,
-	void *data,
-	size_t *data_len)
+ntfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
 {
 	struct lwp *l = curlwp;
 	int		err = 0, flags;
@@ -209,10 +205,8 @@ ntfs_mount (
 	 */
 	err = namei_simple_user(args->fspec,
 				NSM_FOLLOW_NOEMULROOT, &devvp);
-	if (err) {
-		/* can't get devvp!*/
+	if (err)
 		return (err);
-	}
 
 	if (devvp->v_type != VBLK) {
 		err = ENOTBLK;
@@ -325,9 +319,9 @@ ntfs_mountfs(struct vnode *devvp, struct
 	error = bread(devvp, BBLOCK, BBSIZE, NOCRED, 0, &bp);
 	if (error)
 		goto out;
-	ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK|M_ZERO);
-	memcpy( &ntmp->ntm_bootfile,  bp->b_data, sizeof(struct bootfile) );
-	brelse( bp , 0 );
+	ntmp = malloc(sizeof(*ntmp), M_NTFSMNT, M_WAITOK|M_ZERO);
+	memcpy(&ntmp->ntm_bootfile, bp->b_data, sizeof(struct bootfile));
+	brelse(bp, 0);
 	bp = NULL;
 
 	if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
@@ -338,7 +332,7 @@ ntfs_mountfs(struct vnode *devvp, struct
 
 	{
 		int8_t cpr = ntmp->ntm_mftrecsz;
-		if( cpr > 0 )
+		if (cpr > 0)
 			ntmp->ntm_bpmftrec = ntmp->ntm_spc * cpr;
 		else
 			ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
@@ -374,9 +368,9 @@ ntfs_mountfs(struct vnode *devvp, struct
 	 */
 	{
 		int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO };
-		for (i=0; i<3; i++) {
+		for (i = 0; i < 3; i++) {
 			error = VFS_VGET(mp, pi[i], &(ntmp->ntm_sysvn[pi[i]]));
-			if(error)
+			if (error)
 				goto out1;
 			ntmp->ntm_sysvn[pi[i]]->v_vflag |= VV_SYSTEM;
 			vref(ntmp->ntm_sysvn[pi[i]]);
@@ -393,7 +387,7 @@ ntfs_mountfs(struct vnode *devvp, struct
 	 * Scan $BitMap and count free clusters
 	 */
 	error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
-	if(error)
+	if (error)
 		goto out1;
 
 	/*
@@ -406,11 +400,11 @@ ntfs_mountfs(struct vnode *devvp, struct
 
 		/* Open $AttrDef */
 		error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp );
-		if(error)
+		if (error)
 			goto out1;
 
 		/* Count valid entries */
-		for(num=0;;num++) {
+		for (num = 0; ; num++) {
 			error = ntfs_readattr(ntmp, VTONT(vp),
 					NTFS_A_DATA, NULL,
 					num * sizeof(ad), sizeof(ad),
@@ -429,7 +423,7 @@ ntfs_mountfs(struct vnode *devvp, struct
 		ntmp->ntm_adnum = num;
 
 		/* Read them and translate */
-		for(i=0;i<num;i++){
+		for (i = 0; i < num; i++) {
 			error = ntfs_readattr(ntmp, VTONT(vp),
 					NTFS_A_DATA, NULL,
 					i * sizeof(ad), sizeof(ad),
@@ -456,10 +450,11 @@ ntfs_mountfs(struct vnode *devvp, struct
 	return (0);
 
 out1:
-	for(i=0;i<NTFS_SYSNODESNUM;i++)
-		if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
+	for (i = 0; i < NTFS_SYSNODESNUM; i++)
+		if (ntmp->ntm_sysvn[i])
+			vrele(ntmp->ntm_sysvn[i]);
 
-	if (vflush(mp,NULLVP,0)) {
+	if (vflush(mp, NULLVP, 0)) {
 		dprintf(("ntfs_mountfs: vflush failed\n"));
 	}
 out:
@@ -479,17 +474,13 @@ out:
 }
 
 static int
-ntfs_start (
-	struct mount *mp,
-	int flags)
+ntfs_start(struct mount *mp, int flags)
 {
 	return (0);
 }
 
 static int
-ntfs_unmount(
-	struct mount *mp,
-	int mntflags)
+ntfs_unmount(struct mount *mp, int mntflags)
 {
 	struct lwp *l = curlwp;
 	struct ntfsmount *ntmp;
@@ -499,27 +490,29 @@ ntfs_unmount(
 	ntmp = VFSTONTFS(mp);
 
 	flags = 0;
-	if(mntflags & MNT_FORCE)
+	if (mntflags & MNT_FORCE)
 		flags |= FORCECLOSE;
 
 	dprintf(("ntfs_unmount: vflushing...\n"));
-	error = vflush(mp,NULLVP,flags | SKIPSYSTEM);
+	error = vflush(mp, NULLVP, flags | SKIPSYSTEM);
 	if (error) {
 		dprintf(("ntfs_unmount: vflush failed: %d\n",error));
 		return (error);
 	}
 
 	/* Check if only system vnodes are rest */
-	for(i=0;i<NTFS_SYSNODESNUM;i++)
-		 if((ntmp->ntm_sysvn[i]) &&
-		    (ntmp->ntm_sysvn[i]->v_usecount > 1)) return (EBUSY);
+	for (i = 0; i < NTFS_SYSNODESNUM; i++)
+		if ((ntmp->ntm_sysvn[i]) &&
+		    (ntmp->ntm_sysvn[i]->v_usecount > 1))
+			return (EBUSY);
 
 	/* Dereference all system vnodes */
-	for(i=0;i<NTFS_SYSNODESNUM;i++)
-		 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
+	for (i = 0; i < NTFS_SYSNODESNUM; i++)
+		if (ntmp->ntm_sysvn[i])
+			vrele(ntmp->ntm_sysvn[i]);
 
 	/* vflush system vnodes */
-	error = vflush(mp,NULLVP,flags);
+	error = vflush(mp, NULLVP, flags);
 	if (error) {
 		panic("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
 	}
@@ -555,9 +548,7 @@ ntfs_unmount(
 }
 
 static int
-ntfs_root(
-	struct mount *mp,
-	struct vnode **vpp)
+ntfs_root(struct mount *mp, struct vnode **vpp)
 {
 	struct vnode *nvp;
 	int error = 0;
@@ -565,8 +556,8 @@ ntfs_root(
 	dprintf(("ntfs_root(): sysvn: %p\n",
 		VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO]));
 	error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, &nvp);
-	if(error) {
-		printf("ntfs_root: VFS_VGET failed: %d\n",error);
+	if (error) {
+		printf("ntfs_root: VFS_VGET failed: %d\n", error);
 		return (error);
 	}
 
@@ -575,9 +566,7 @@ ntfs_root(
 }
 
 int
-ntfs_calccfree(
-	struct ntfsmount *ntmp,
-	cn_t *cfreep)
+ntfs_calccfree(struct ntfsmount *ntmp, cn_t *cfreep)
 {
 	struct vnode *vp;
 	u_int8_t *tmp;
@@ -586,30 +575,27 @@ ntfs_calccfree(
 	size_t bmsize, i;
 
 	vp = ntmp->ntm_sysvn[NTFS_BITMAPINO];
-
 	bmsize = VTOF(vp)->f_size;
-
 	tmp = (u_int8_t *) malloc(bmsize, M_TEMP, M_WAITOK);
 
 	error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
-			       0, bmsize, tmp, NULL);
+	    0, bmsize, tmp, NULL);
 	if (error)
 		goto out;
 
-	for(i=0;i<bmsize;i++)
-		for(j=0;j<8;j++)
-			if(~tmp[i] & (1 << j)) cfree++;
+	for (i = 0; i < bmsize; i++)
+		for (j = 0; j < 8; j++)
+			if (~tmp[i] & (1 << j))
+				cfree++;
 	*cfreep = cfree;
 
-    out:
+out:
 	free(tmp, M_TEMP);
 	return(error);
 }
 
 static int
-ntfs_statvfs(
-	struct mount *mp,
-	struct statvfs *sbp)
+ntfs_statvfs(struct mount *mp, struct statvfs *sbp)
 {
 	struct ntfsmount *ntmp = VFSTONTFS(mp);
 	u_int64_t mftallocated;
@@ -633,10 +619,7 @@ ntfs_statvfs(
 }
 
 static int
-ntfs_sync (
-	struct mount *mp,
-	int waitfor,
-	kauth_cred_t cred)
+ntfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
 {
 	/*dprintf(("ntfs_sync():\n"));*/
 	return (0);
@@ -644,10 +627,7 @@ ntfs_sync (
 
 /*ARGSUSED*/
 static int
-ntfs_fhtovp(
-	struct mount *mp,
-	struct fid *fhp,
-	struct vnode **vpp)
+ntfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
 {
 	struct ntfid ntfh;
 	int error;
@@ -671,10 +651,7 @@ ntfs_fhtovp(
 }
 
 static int
-ntfs_vptofh(
-	struct vnode *vp,
-	struct fid *fhp,
-	size_t *fh_size)
+ntfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
 {
 	struct ntnode *ntp;
 	struct ntfid ntfh;
@@ -734,13 +711,13 @@ ntfs_loadvnode(struct mount *mp, struct 
 	}
 	/* It may be not initialized fully, so force load it */
 	if (!(ip->i_flag & IN_LOADED)) {
-	       error = ntfs_loadntnode(ntmp, ip);
-	       if(error) {
-		       printf("ntfs_loadvnode: CAN'T LOAD ATTRIBUTES FOR INO:"
-			   " %llu\n", (unsigned long long)ip->i_number);
-		       ntfs_ntput(ip);
-		       goto out;
-	       }
+		error = ntfs_loadntnode(ntmp, ip);
+		if (error) {
+			printf("ntfs_loadvnode: CAN'T LOAD ATTRIBUTES FOR INO:"
+			    " %llu\n", (unsigned long long)ip->i_number);
+			ntfs_ntput(ip);
+			goto out;
+		}
 	}
 
 	/* Setup fnode */
@@ -760,7 +737,7 @@ ntfs_loadvnode(struct mount *mp, struct 
 	if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
 	    (ntkey->k_attrtype == NTFS_A_DATA &&
 	    strcmp(ntkey->k_attrname, "") == 0)) {
-                        f_type = VDIR;
+		f_type = VDIR;
 	} else {
 		f_type = VREG;
 		error = ntfs_ntvattrget(ntmp, ip,
@@ -817,22 +794,14 @@ out:
 }
 
 static int
-ntfs_vget(
-	struct mount *mp,
-	ino_t ino,
-	struct vnode **vpp)
+ntfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
 {
 	return ntfs_vgetex(mp, ino, NTFS_A_DATA, "", LK_EXCLUSIVE, vpp);
 }
 
 int
-ntfs_vgetex(
-	struct mount *mp,
-	ino_t ino,
-	u_int32_t attrtype,
-	const char *attrname,
-	u_long lkflags,
-	struct vnode **vpp)
+ntfs_vgetex(struct mount *mp, ino_t ino, u_int32_t attrtype,
+    const char *attrname, u_long lkflags, struct vnode **vpp)
 {
 	const int attrlen = strlen(attrname);
 	int error;

Reply via email to