Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/ntfs Make this more readable (KNF).
details: https://anonhg.NetBSD.org/src/rev/763c94cf3430
branches: trunk
changeset: 335160:763c94cf3430
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Dec 28 12:13:22 2014 +0000
description:
Make this more readable (KNF).
diffstat:
sys/fs/ntfs/ntfs_vfsops.c | 151 ++++++++++++++++++---------------------------
1 files changed, 60 insertions(+), 91 deletions(-)
diffs (truncated from 363 to 300 lines):
diff -r 2d5812aeeac6 -r 763c94cf3430 sys/fs/ntfs/ntfs_vfsops.c
--- a/sys/fs/ntfs/ntfs_vfsops.c Sun Dec 28 12:05:27 2014 +0000
+++ b/sys/fs/ntfs/ntfs_vfsops.c Sun Dec 28 12:13:22 2014 +0000
@@ -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 @@
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 @@
}
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 @@
*/
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 @@
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 @@
{
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 @@
*/
{
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 @@
* Scan $BitMap and count free clusters
*/
error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
- if(error)
+ if (error)
goto out1;
/*
@@ -406,11 +400,11 @@
/* 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 @@
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 @@
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 @@
}
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 @@
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 @@
}
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 @@
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 @@
}
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 @@
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 @@
}
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 @@
/*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 @@
}
static int
-ntfs_vptofh(
Home |
Main Index |
Thread Index |
Old Index