Cosmetic changes:
- add a ffs-like ntfs_superblock_validate function - remove unused includes - fix some comments - KNF No functional change.
This commit is contained in:
parent
13666056c3
commit
14c9669847
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ntfs_compr.c,v 1.5 2009/03/18 16:00:21 cegger Exp $ */
|
||||
/* $NetBSD: ntfs_compr.c,v 1.6 2015/02/20 17:08:13 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999 Semen Ustimenko
|
||||
@ -29,36 +29,29 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_compr.c,v 1.5 2009/03/18 16:00:21 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_compr.c,v 1.6 2015/02/20 17:08:13 maxv Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/malloc.h>
|
||||
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
|
||||
#include <fs/ntfs/ntfs.h>
|
||||
#include <fs/ntfs/ntfs_compr.h>
|
||||
|
||||
#define GET_UINT16(addr) (*((u_int16_t *)(addr)))
|
||||
|
||||
int
|
||||
ntfs_uncompblock(
|
||||
u_int8_t * dbuf,
|
||||
u_int8_t * cbuf)
|
||||
ntfs_uncompblock(u_int8_t *dbuf, u_int8_t *cbuf)
|
||||
{
|
||||
u_int32_t ctag;
|
||||
int len, dshift, lmask;
|
||||
int blen, boff;
|
||||
int i, j;
|
||||
int pos, cpos;
|
||||
u_int32_t ctag;
|
||||
int len, dshift, lmask;
|
||||
int blen, boff;
|
||||
int i, j;
|
||||
int pos, cpos;
|
||||
|
||||
len = GET_UINT16(cbuf) & 0xFFF;
|
||||
dprintf(("ntfs_uncompblock: block length: %d + 3, 0x%x,0x%04x\n",
|
||||
@ -101,14 +94,11 @@ ntfs_uncompblock(
|
||||
}
|
||||
|
||||
int
|
||||
ntfs_uncompunit(
|
||||
struct ntfsmount * ntmp,
|
||||
u_int8_t * uup,
|
||||
u_int8_t * cup)
|
||||
ntfs_uncompunit(struct ntfsmount *ntmp, u_int8_t *uup, u_int8_t *cup)
|
||||
{
|
||||
int i;
|
||||
int off = 0;
|
||||
int new;
|
||||
int i;
|
||||
int off = 0;
|
||||
int new;
|
||||
|
||||
for (i = 0; i * NTFS_COMPBLOCK_SIZE < ntfs_cntob(NTFS_COMPUNIT_CL); i++) {
|
||||
new = ntfs_uncompblock(uup + i * NTFS_COMPBLOCK_SIZE, cup + off);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ntfs_conv.c,v 1.9 2008/04/28 20:24:02 martin Exp $ */
|
||||
/* $NetBSD: ntfs_conv.c,v 1.10 2015/02/20 17:08:13 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -31,29 +31,18 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_conv.c,v 1.9 2008/04/28 20:24:02 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_conv.c,v 1.10 2015/02/20 17:08:13 maxv Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/lock.h>
|
||||
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
|
||||
#include <fs/ntfs/ntfs.h>
|
||||
#include <fs/ntfs/ntfsmount.h>
|
||||
#include <fs/ntfs/ntfs_inode.h>
|
||||
#include <fs/ntfs/ntfs_vfsops.h>
|
||||
#include <fs/ntfs/ntfs_subr.h>
|
||||
#include <fs/ntfs/ntfs_compr.h>
|
||||
#include <fs/ntfs/ntfs_ihash.h>
|
||||
|
||||
/* UTF-8 encoding stuff */
|
||||
#include <fs/unicode.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ntfs_ihash.c,v 1.10 2012/01/27 19:48:40 para Exp $ */
|
||||
/* $NetBSD: ntfs_ihash.c,v 1.11 2015/02/20 17:08:13 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995
|
||||
@ -33,14 +33,13 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_ihash.c,v 1.10 2012/01/27 19:48:40 para Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_ihash.c,v 1.11 2015/02/20 17:08:13 maxv Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/mallocvar.h>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ntfs_subr.c,v 1.59 2015/01/16 17:02:12 maxv Exp $ */
|
||||
/* $NetBSD: ntfs_subr.c,v 1.60 2015/02/20 17:08:13 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.59 2015/01/16 17:02:12 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.60 2015/02/20 17:08:13 maxv Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -1183,7 +1183,7 @@ ntfs_nttimetounix(u_int64_t nt)
|
||||
}
|
||||
|
||||
/*
|
||||
* This is one of write routine.
|
||||
* This is one of the write routines.
|
||||
*/
|
||||
int
|
||||
ntfs_writeattr_plain(struct ntfsmount *ntmp, struct ntnode *ip,
|
||||
@ -1231,7 +1231,7 @@ ntfs_writeattr_plain(struct ntfsmount *ntmp, struct ntnode *ip,
|
||||
}
|
||||
|
||||
/*
|
||||
* This is one of write routine.
|
||||
* This is one of the write routines.
|
||||
*
|
||||
* ntnode should be locked.
|
||||
*/
|
||||
@ -1333,7 +1333,7 @@ ntfs_writentvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip,
|
||||
}
|
||||
|
||||
/*
|
||||
* This is one of read routines.
|
||||
* This is one of the read routines.
|
||||
*
|
||||
* ntnode should be locked.
|
||||
*/
|
||||
@ -1460,7 +1460,7 @@ ntfs_readntvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip,
|
||||
}
|
||||
|
||||
/*
|
||||
* This is one of read routines.
|
||||
* This is one of the read routines.
|
||||
*/
|
||||
int
|
||||
ntfs_readattr_plain(struct ntfsmount *ntmp, struct ntnode *ip,
|
||||
@ -1508,7 +1508,7 @@ ntfs_readattr_plain(struct ntfsmount *ntmp, struct ntnode *ip,
|
||||
}
|
||||
|
||||
/*
|
||||
* This is one of read routines.
|
||||
* This is one of the read routines.
|
||||
*/
|
||||
int
|
||||
ntfs_readattr(struct ntfsmount *ntmp, struct ntnode *ip, u_int32_t attrnum,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ntfs_vfsops.c,v 1.102 2015/01/06 11:03:09 hannken Exp $ */
|
||||
/* $NetBSD: ntfs_vfsops.c,v 1.103 2015/02/20 17:08:13 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.102 2015/01/06 11:03:09 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.103 2015/02/20 17:08:13 maxv Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -65,6 +65,7 @@ MALLOC_JUSTDEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
|
||||
MALLOC_JUSTDEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
|
||||
MALLOC_JUSTDEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
|
||||
|
||||
static int ntfs_superblock_validate(struct ntfsmount *);
|
||||
static int ntfs_mount(struct mount *, const char *, void *, size_t *);
|
||||
static int ntfs_root(struct mount *, struct vnode **);
|
||||
static int ntfs_start(struct mount *, int);
|
||||
@ -291,6 +292,25 @@ fail:
|
||||
return (err);
|
||||
}
|
||||
|
||||
static int
|
||||
ntfs_superblock_validate(struct ntfsmount *ntmp)
|
||||
{
|
||||
/* Sanity checks. XXX: More checks are probably needed. */
|
||||
if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
|
||||
dprintf(("ntfs_superblock_validate: invalid boot block\n"));
|
||||
return EINVAL;
|
||||
}
|
||||
if (ntmp->ntm_bps == 0) {
|
||||
dprintf(("ntfs_superblock_validate: invalid bytes per sector\n"));
|
||||
return EINVAL;
|
||||
}
|
||||
if (ntmp->ntm_spc == 0) {
|
||||
dprintf(("ntfs_superblock_validate: invalid sectors per cluster\n"));
|
||||
return EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common code for mount and mountroot
|
||||
*/
|
||||
@ -324,22 +344,8 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp, str
|
||||
brelse(bp, 0);
|
||||
bp = NULL;
|
||||
|
||||
/* Sanity checks. XXX: More checks are probably needed. */
|
||||
if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
|
||||
error = EINVAL;
|
||||
dprintf(("ntfs_mountfs: invalid boot block\n"));
|
||||
if ((error = ntfs_superblock_validate(ntmp)))
|
||||
goto out;
|
||||
}
|
||||
if (ntmp->ntm_bps == 0) {
|
||||
error = EINVAL;
|
||||
dprintf(("ntfs_mountfs: invalid bytes per sector\n"));
|
||||
goto out;
|
||||
}
|
||||
if (ntmp->ntm_spc == 0) {
|
||||
error = EINVAL;
|
||||
dprintf(("ntfs_mountfs: invalid sectors per cluster\n"));
|
||||
goto out;
|
||||
}
|
||||
|
||||
{
|
||||
int8_t cpr = ntmp->ntm_mftrecsz;
|
||||
@ -349,10 +355,10 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp, str
|
||||
ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
|
||||
}
|
||||
dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
|
||||
ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
|
||||
ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
|
||||
ntmp->ntm_bps, ntmp->ntm_spc, ntmp->ntm_bootfile.bf_media,
|
||||
ntmp->ntm_mftrecsz, ntmp->ntm_bpmftrec));
|
||||
dprintf(("ntfs_mountfs(): mftcn: 0x%x|0x%x\n",
|
||||
(u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn));
|
||||
(u_int32_t)ntmp->ntm_mftcn, (u_int32_t)ntmp->ntm_mftmirrcn));
|
||||
|
||||
ntmp->ntm_mountp = mp;
|
||||
ntmp->ntm_dev = dev;
|
||||
@ -410,7 +416,7 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp, str
|
||||
struct attrdef ad;
|
||||
|
||||
/* Open $AttrDef */
|
||||
error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp );
|
||||
error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp);
|
||||
if (error)
|
||||
goto out1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user