Driver is now ported to NetBSD.

Submitted by:	Christos Zoulas <christos@zoulas.com>
This commit is contained in:
semenu 1999-05-12 09:43:09 +00:00
parent 92a76e707b
commit 3ce8327c89
25 changed files with 505 additions and 233 deletions

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs.h,v 1.2 1999/05/06 15:43:17 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs.h,v 1.9 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs.h,v 1.4 1999/04/20 21:06:41 semenu Exp $
*/
/*#define NTFS_DEBUG 1*/
@ -286,6 +288,32 @@ MALLOC_DECLARE(M_NTFSDIR);
MALLOC_DECLARE(M_NTFSNTHASH);
#endif
#ifdef __NetBSD__
#define MALLOC_DEFINE(a, b, c)
#define M_NTFSNTHASH M_TEMP
#define M_NTFSNTVATTR M_TEMP
#define M_NTFSRDATA M_TEMP
#define M_NTFSRUN M_TEMP
#define M_NTFSDECOMP M_TEMP
#define M_NTFSMNT M_TEMP
#define M_NTFSNTNODE M_TEMP
#define M_NTFSFNODE M_TEMP
#define M_NTFSDIR M_TEMP
typedef int (vop_t) __P((void *));
#define HASHINIT(a, b, c, d) hashinit((a), (b), (c), (d))
#define bqrelse(bp) brelse(bp)
#define VOP__LOCK(a, b, c) VOP_LOCK((a), (b) ? LK_EXCLUSIVE : LK_SHARED)
#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), 0)
#define VGET(a, b, c) vget((a), LK_EXCLUSIVE)
#define VN_LOCK(a, b, c) vn_lock((a), LK_EXCLUSIVE)
#else
#define HASHINIT(a, b, c, d) hashinit((a), (b), (d))
#define VOP__LOCK(a, b, c) VOP_LOCK((a), (b), (c))
#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), (b), (c))
#define VGET(a, b, c) vget((a), (b), (c))
#define VN_LOCK(a, b, c) vn_lock((a), (b), (c))
#endif
#if defined(NTFS_DEBUG)
#define dprintf(a) printf a
#if NTFS_DEBUG > 1

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_compr.c,v 1.2 1999/05/06 15:43:18 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_compr.c,v 1.4 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_compr.c,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
#include <sys/param.h>
@ -36,7 +38,9 @@
#include <sys/buf.h>
#include <sys/file.h>
#include <sys/malloc.h>
#ifdef __FreeBSD__
#include <machine/clock.h>
#endif
#include <miscfs/specfs/specdev.h>

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_compr.h,v 1.2 1999/05/06 15:43:18 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_compr.h,v 1.3 1999/01/28 03:56:06 semen Exp $
* $Id: ntfs_compr.h,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
#define NTFS_COMPBLOCK_SIZE 0x1000

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_ihash.c,v 1.2 1999/05/06 15:43:19 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995
* The Regents of the University of California. All rights reserved.
@ -31,7 +33,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95
* $Id: ntfs_ihash.c,v 1.3 1999/04/20 21:06:43 semenu Exp $
* $Id: ntfs_ihash.c,v 1.4 1999/05/11 19:54:50 phk Exp $
*/
#include <sys/param.h>
@ -65,7 +67,8 @@ void
ntfs_nthashinit()
{
ntfs_nthashtbl = hashinit(desiredvnodes, M_NTFSNTHASH, &ntfs_nthash);
ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK,
&ntfs_nthash);
simple_lock_init(&ntfs_nthash_slock);
}

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_ihash.h,v 1.2 1999/05/06 15:43:19 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs.h,v 1.9 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_ihash.h,v 1.2 1999/04/20 21:06:43 semenu Exp $
*/
void ntfs_nthashinit __P((void));

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_inode.h,v 1.2 1999/05/06 15:43:19 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,11 +25,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_inode.h,v 1.8 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_inode.h,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
/* These flags are kept in i_flag. */
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
#define IN_ACCESS 0x0001 /* Access time update request. */
#define IN_CHANGE 0x0002 /* Inode change time update request. */
#define IN_UPDATE 0x0004 /* Modification time update request. */
@ -35,9 +37,8 @@
#define IN_RENAME 0x0010 /* Inode is being renamed. */
#define IN_SHLOCK 0x0020 /* File has shared lock. */
#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
#define IN_HASHED 0x0080 /* Inode is on hash list */
#define IN_LAZYMOD 0x0100 /* Modified, but don't write yet. */
#else
#define IN_LAZYMOD 0x0080 /* Modified, but don't write yet. */
#else /* defined(__NetBSD__) */
#define IN_ACCESS 0x0001 /* Access time update request. */
#define IN_CHANGE 0x0002 /* Inode change time update request. */
#define IN_EXLOCK 0x0004 /* File has exclusive lock. */
@ -51,6 +52,7 @@
#define IN_RECURSE 0x0400 /* Recursion expected */
#endif
#define IN_HASHED 0x0800 /* Inode is on hash list */
#define IN_LOADED 0x8000 /* ntvattrs loaded */
#define IN_PRELOADED 0x4000 /* loaded from directory entry */
@ -64,7 +66,11 @@ struct ntnode {
u_int32_t i_flag;
int i_lock;
int i_usecount;
#if defined(__NetBSD__)
pid_t i_lockholder;
pid_t i_lockwaiter;
int i_lockcount;
#endif
LIST_HEAD(,fnode) i_fnlist;
LIST_HEAD(,ntvattr) i_valist;

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_subr.c,v 1.2 1999/05/06 15:43:19 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_subr.c,v 1.9 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_subr.c,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
#include <sys/param.h>
@ -37,7 +39,9 @@
#include <sys/buf.h>
#include <sys/file.h>
#include <sys/malloc.h>
#if defined(__FreeBSD__)
#include <machine/clock.h>
#endif
#include <miscfs/specfs/specdev.h>
@ -51,7 +55,7 @@
#include <ntfs/ntfs_compr.h>
#include <ntfs/ntfs_ihash.h>
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
MALLOC_DEFINE(M_NTFSNTVATTR, "NTFS vattr", "NTFS file attribute information");
MALLOC_DEFINE(M_NTFSRDATA, "NTFS res data", "NTFS resident data");
MALLOC_DEFINE(M_NTFSRUN, "NTFS vrun", "NTFS vrun storage");
@ -684,9 +688,9 @@ ntfs_uustricmp(
int
ntfs_uastricmp(
struct ntfsmount * ntmp,
wchar * str1,
const wchar *str1,
int str1len,
char *str2,
const char *str2,
int str2len)
{
int i;
@ -706,10 +710,10 @@ ntfs_uastricmp(
*/
int
ntfs_uastrcmp(
struct ntfsmount * ntmp,
wchar * str1,
struct ntfsmount *ntmp,
const wchar *str1,
int str1len,
char *str2,
const char *str2,
int str2len)
{
int i;
@ -810,13 +814,13 @@ ntfs_frele(
int
ntfs_ntlookupattr(
struct ntfsmount * ntmp,
char * name,
const char * name,
int namelen,
int *attrtype,
char **attrname)
{
char *sys;
int syslen,i;
const char *sys;
size_t syslen, i;
struct ntvattrdef *adp;
if (namelen == 0)
@ -882,7 +886,7 @@ ntfs_ntlookupfile(
u_int32_t rdsize; /* Length of data to read from current block */
struct attr_indexentry *iep;
int error, res, anamelen, fnamelen;
char *fname,*aname;
const char *fname,*aname;
u_int32_t aoff;
error = ntfs_ntget(ip);

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_subr.h,v 1.2 1999/05/06 15:43:20 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_subr.h,v 1.3 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_subr.h,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
#define VA_LOADED 0x0001
@ -92,8 +94,10 @@ struct timespec ntfs_nttimetounix __P(( u_int64_t ));
int ntfs_ntreaddir __P(( struct ntfsmount *, struct fnode *, u_int32_t, struct attr_indexentry **));
wchar ntfs_toupper __P(( struct ntfsmount *, wchar ));
int ntfs_uustricmp __P(( struct ntfsmount *, wchar *, int, wchar *, int ));
int ntfs_uastricmp __P(( struct ntfsmount *, wchar *, int, char *, int ));
int ntfs_uastrcmp __P(( struct ntfsmount *, wchar *, int, char *, int ));
int ntfs_uastricmp __P(( struct ntfsmount *, const wchar *, int, const char *,
int ));
int ntfs_uastrcmp __P(( struct ntfsmount *, const wchar *, int, const char *,
int ));
int ntfs_runtovrun __P(( cn_t **, cn_t **, u_long *, u_int8_t *));
int ntfs_attrtontvattr __P(( struct ntfsmount *, struct ntvattr **, struct attr * ));
void ntfs_freentvattr __P(( struct ntvattr * ));
@ -108,6 +112,6 @@ int ntfs_ntget __P((struct ntnode *));
void ntfs_ntrele __P((struct ntnode *));
void ntfs_ntput __P((struct ntnode *));
int ntfs_loadntnode __P(( struct ntfsmount *, struct ntnode * ));
int ntfs_ntlookupattr(struct ntfsmount *, char *, int, int *, char **);
int ntfs_ntlookupattr(struct ntfsmount *, const char *, int, int *, char **);
int ntfs_writentvattr_plain(struct ntfsmount *, struct ntnode *, struct ntvattr *, off_t, size_t, void *, size_t *);
int ntfs_writeattr_plain(struct ntfsmount *, struct ntnode *, u_int32_t, char *, off_t, size_t, void *, size_t *);

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_vfsops.c,v 1.2 1999/05/06 15:43:20 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_vfsops.c,v 1.4 1999/05/06 22:07:34 peter Exp $
* $Id: ntfs_vfsops.c,v 1.5 1999/05/11 19:54:52 phk Exp $
*/
@ -57,15 +59,20 @@
#include <ntfs/ntfs_extern.h>
#include <ntfs/ntfsmount.h>
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
#endif
#if defined(__FreeBSD__)
static int ntfs_mount __P((struct mount *, char *, caddr_t,
struct nameidata *, struct proc *));
#else
static int ntfs_mount __P((struct mount *, const char *, void *,
struct nameidata *, struct proc *));
#endif
static int ntfs_quotactl __P((struct mount *, int, uid_t, caddr_t,
struct proc *));
static int ntfs_root __P((struct mount *, struct vnode **));
@ -81,11 +88,20 @@ static int ntfs_mountfs __P((register struct vnode *, struct mount *,
struct ntfs_args *, struct proc *));
static int ntfs_vptofh __P((struct vnode *, struct fid *));
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
static int ntfs_init __P((struct vfsconf *));
static int ntfs_fhtovp __P((struct mount *, struct fid *,
struct sockaddr *, struct vnode **,
int *, struct ucred **));
#elif defined(__NetBSD__)
static void ntfs_init __P((void));
static int ntfs_fhtovp __P((struct mount *, struct fid *,
struct vnode **));
static int ntfs_checkexp __P((struct mount *, struct mbuf *,
int *, struct ucred **));
static int ntfs_mountroot __P((void));
static int ntfs_sysctl __P((int *, u_int, void *, size_t *, void *,
size_t, struct proc *));
#else
static int ntfs_init __P((void));
static int ntfs_fhtovp __P((struct mount *, struct fid *,
@ -93,25 +109,68 @@ static int ntfs_fhtovp __P((struct mount *, struct fid *,
int *, struct ucred **));
#endif
#if __FreeBSD_version >= 300000
#ifdef __NetBSD__
/*ARGSUSED*/
static int
ntfs_checkexp(mp, nam, exflagsp, credanonp)
register struct mount *mp;
struct mbuf *nam;
int *exflagsp;
struct ucred **credanonp;
{
return (EINVAL);
}
/*ARGSUSED*/
static int
ntfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
int *name;
u_int namelen;
void *oldp;
size_t *oldlenp;
void *newp;
size_t newlen;
struct proc *p;
{
return (EINVAL);
}
static int
ntfs_mountroot()
{
return (EINVAL);
}
#endif
#if defined(__FreeBSD__)
static int
ntfs_init (
struct vfsconf *vcp )
#elif defined(__NetBSD__)
static void
ntfs_init ()
#else
static int
ntfs_init ()
#endif
{
ntfs_nthashinit();
#if !defined(__NetBSD__)
return 0;
#endif
}
static int
ntfs_mount (
struct mount *mp,
#if defined(__FreeBSD__)
char *path,
caddr_t data,
#else
const char *path,
void *data,
#endif
struct nameidata *ndp,
struct proc *p )
{
@ -347,11 +406,13 @@ ntfs_mountfs(devvp, mp, argsp, p)
if (error)
return (error);
ncount = vcount(devvp);
#if defined(__FreeBSD__)
if (devvp->v_object)
ncount -= 1;
#endif
if (ncount > 1 && devvp != rootvp)
return (EBUSY);
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
VOP_UNLOCK(devvp, 0, p);
@ -501,14 +562,14 @@ ntfs_mountfs(devvp, mp, argsp, p)
}
mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
#else
mp->mnt_stat.f_fsid.val[1] = MOUNT_NTFS;
mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_NTFS);
#endif
mp->mnt_maxsymlinklen = 0;
mp->mnt_flag |= MNT_LOCAL;
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
devvp->v_specmountpoint = mp;
#else
devvp->v_specflags |= SI_MOUNTEDON;
@ -523,10 +584,10 @@ ntfs_mountfs(devvp, mp, argsp, p)
printf("ntfs_mountfs: vflush failed\n");
out:
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
devvp->v_specmountpoint = NULL;
#else
devvp->v_specflags |= SI_MOUNTEDON;
devvp->v_specflags &= ~SI_MOUNTEDON;
#endif
if (bp)
brelse(bp);
@ -580,14 +641,10 @@ ntfs_unmount(
if (error)
printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
ntmp->ntm_devvp->v_specmountpoint = NULL;
#else
ntmp->ntm_devvp->v_specflags &= ~SI_MOUNTEDON;
VOP_LOCK(ntmp->ntm_devvp);
vnode_pager_uncache(ntmp->ntm_devvp);
VOP_UNLOCK(ntmp->ntm_devvp);
#endif
vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, p, 0, 0);
@ -686,8 +743,10 @@ ntfs_statfs(
mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
sbp->f_type = mp->mnt_vfc->vfc_typenum;
#elif defined(__NetBSD__)
sbp->f_type = 0;
#else
sbp->f_type = MOUNT_NTFS;
#endif
@ -720,18 +779,21 @@ ntfs_sync (
return (0);
}
#if __FreeBSD_version >= 300000
/*ARGSUSED*/
static int
ntfs_fhtovp(
#if defined(__FreeBSD__)
struct mount *mp,
struct fid *fhp,
struct sockaddr *nam,
struct vnode **vpp,
int *exflagsp,
struct ucred **credanonp)
#elif defined(__NetBSD__)
struct mount *mp,
struct fid *fhp,
struct vnode **vpp)
#else
static int
ntfs_fhtovp(
struct mount *mp,
struct fid *fhp,
struct mbuf *nam,
@ -824,7 +886,7 @@ ntfs_vgetex(
}
if (FTOV(fp)) {
vget(FTOV(fp), lkflags, p);
VGET(FTOV(fp), lkflags, p);
*vpp = FTOV(fp);
ntfs_ntput(ip);
return (0);
@ -849,7 +911,7 @@ ntfs_vgetex(
ntfs_ntput(ip);
if (lkflags & LK_TYPE_MASK) {
error = vn_lock(vp, lkflags, p);
error = VN_LOCK(vp, lkflags, p);
if (error) {
vput(vp);
return (error);
@ -872,7 +934,7 @@ ntfs_vget(
LK_EXCLUSIVE, 0, curproc, vpp);
}
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
static struct vfsops ntfs_vfsops = {
ntfs_mount,
ntfs_start,
@ -888,6 +950,32 @@ static struct vfsops ntfs_vfsops = {
NULL
};
VFS_SET(ntfs_vfsops, ntfs, 0);
#elif defined(__NetBSD__)
extern struct vnodeopv_desc ntfs_vnodeop_opv_desc;
struct vnodeopv_desc *ntfs_vnodeopv_descs[] = {
&ntfs_vnodeop_opv_desc,
NULL,
};
struct vfsops ntfs_vfsops = {
MOUNT_NTFS,
ntfs_mount,
ntfs_start,
ntfs_unmount,
ntfs_root,
ntfs_quotactl,
ntfs_statfs,
ntfs_sync,
ntfs_vget,
ntfs_fhtovp,
ntfs_vptofh,
ntfs_init,
ntfs_sysctl,
ntfs_mountroot,
ntfs_checkexp,
ntfs_vnodeopv_descs,
};
#else
static struct vfsops ntfs_vfsops = {
ntfs_mount,
@ -902,7 +990,6 @@ static struct vfsops ntfs_vfsops = {
ntfs_vptofh,
ntfs_init,
};
VFS_SET(ntfs_vfsops, ntfs, MOUNT_NTFS, 0);
#endif

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_vfsops.h,v 1.2 1999/05/06 15:43:20 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_vfsops.h,v 1.1 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_vfsops.h,v 1.2 1999/04/20 21:06:43 semenu Exp $
*/
#define VG_DONTLOADIN 0x0001 /* Tells ntfs_vgetex to do not call */
/* ntfs_loadnode on ntnode, even if */

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_vnops.c,v 1.2 1999/05/06 15:43:20 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@ -33,14 +35,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_vnops.c,v 1.3 1999/04/20 21:06:43 semenu Exp $
* $Id: ntfs_vnops.c,v 1.4 1999/05/11 19:54:52 phk Exp $
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/time.h>
#include <sys/types.h>
@ -58,9 +59,13 @@
#include <vm/vm_page.h>
#include <vm/vm_object.h>
#include <vm/vm_pager.h>
#if defined(__FreeBSD__)
#include <vm/vnode_pager.h>
#endif
#include <vm/vm_extern.h>
#include <sys/sysctl.h>
/*#define NTFS_DEBUG 1*/
#include <ntfs/ntfs.h>
@ -77,7 +82,7 @@ static int ntfs_inactive __P((struct vop_inactive_args *ap));
static int ntfs_print __P((struct vop_print_args *ap));
static int ntfs_reclaim __P((struct vop_reclaim_args *ap));
static int ntfs_strategy __P((struct vop_strategy_args *ap));
#if __FreeBSD_version < 300000
#if defined(__NetBSD__)
static int ntfs_islocked __P((struct vop_islocked_args *ap));
static int ntfs_unlock __P((struct vop_unlock_args *ap));
static int ntfs_lock __P((struct vop_lock_args *ap));
@ -88,12 +93,15 @@ static int ntfs_close __P((struct vop_close_args *ap));
static int ntfs_readdir __P((struct vop_readdir_args *ap));
static int ntfs_lookup __P((struct vop_lookup_args *ap));
static int ntfs_bmap __P((struct vop_bmap_args *ap));
#if defined(__FreeBSD__)
static int ntfs_getpages __P((struct vop_getpages_args *ap));
static int ntfs_putpages __P((struct vop_putpages_args *));
#endif
static int ntfs_fsync __P((struct vop_fsync_args *ap));
int ntfs_prtactive = 1; /* 1 => print out reclaim of active vnodes */
#if defined(__FreeBSD__)
int
ntfs_getpages(ap)
struct vop_getpages_args *ap;
@ -109,6 +117,7 @@ ntfs_putpages(ap)
return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
ap->a_sync, ap->a_rtvals);
}
#endif
/*
* This is a noop, simply returning what one has been given.
@ -131,8 +140,10 @@ ntfs_bmap(ap)
*ap->a_bnp = ap->a_bn;
if (ap->a_runp != NULL)
*ap->a_runp = 0;
#if !defined(__NetBSD__)
if (ap->a_runb != NULL)
*ap->a_runb = 0;
#endif
return (0);
}
@ -256,28 +267,16 @@ ntfs_inactive(ap)
error = 0;
#if __FreeBSD_version >= 300000
VOP_UNLOCK(vp,0,ap->a_p);
#else
#ifdef DIAGNOSTIC
if (VOP_ISLOCKED(vp))
panic("ntfs_inactive: locked vnode");
if (curproc)
ip->i_lockholder = curproc->p_pid;
else
ip->i_lockholder = -1;
#endif
ip->i_flag |= IN_LOCKED;
VOP_UNLOCK(vp);
#endif
VOP__UNLOCK(vp,0,ap->a_p);
/*
* If we are done with the ntnode, reclaim it
* so that it can be reused immediately.
*/
if (vp->v_usecount == 0 && ip->i_mode == 0)
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
vrecycle(vp, (struct simplelock *)0, ap->a_p);
#else
#else /* defined(__NetBSD__) */
vgone(vp);
#endif
return (error);
@ -303,8 +302,8 @@ ntfs_reclaim(ap)
if (error)
return (error);
#if __FreeBSD_version >= 300000
VOP_UNLOCK(vp,0,ap->a_p);
#if defined(__FreeBSD__)
VOP__UNLOCK(vp,0,ap->a_p);
#endif
/* Purge old data structures associated with the inode. */
@ -467,7 +466,7 @@ ntfs_write(ap)
return (0);
}
#if __FreeBSD_version < 300000
#if defined(__NetBSD__)
/*
* Check for a locked ntnode.
*/
@ -497,7 +496,9 @@ ntfs_unlock(ap)
} */ *ap;
{
register struct ntnode *ip = VTONT(ap->a_vp);
#ifdef DIAGNOSTIC
struct proc *p = curproc;
#endif
dprintf(("ntfs_unlock %d\n",ip->i_number));
@ -729,10 +730,6 @@ ntfs_close(ap)
return (0);
}
/*
#undef dprintf
#define dprintf(a) printf a
*/
int
ntfs_readdir(ap)
struct vop_readdir_args /* {
@ -835,24 +832,25 @@ ntfs_readdir(ap)
if (!error && ap->a_ncookies != NULL) {
struct dirent* dpStart;
struct dirent* dp;
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
u_long *cookies;
u_long *cookiep;
#else
u_int *cookies;
u_int *cookiep;
#else /* defined(__NetBSD__) */
off_t *cookies;
off_t *cookiep;
#endif
printf("ntfs_readdir: %d cookies\n",ncookies);
if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
panic("ntfs_readdir: unexpected uio from NFS server");
dpStart = (struct dirent *)
(uio->uio_iov->iov_base - (uio->uio_offset - off));
#if __FreeBSD_version >= 300000
((caddr_t)uio->uio_iov->iov_base -
(uio->uio_offset - off));
#if defined(__FreeBSD__)
MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
M_TEMP, M_WAITOK);
#else
MALLOC(cookies, u_int *, ncookies * sizeof(u_int),
#else /* defined(__NetBSD__) */
MALLOC(cookies, off_t *, ncookies * sizeof(off_t),
M_TEMP, M_WAITOK);
#endif
for (dp = dpStart, cookiep = cookies, i=0;
@ -870,10 +868,6 @@ ntfs_readdir(ap)
*/
return (error);
}
/*
#undef dprintf
#define dprintf(a)
*/
int
ntfs_lookup(ap)
@ -921,11 +915,7 @@ ntfs_lookup(ap)
if(error)
return (error);
#if __FreeBSD_version >= 300000
VOP_UNLOCK(dvp,0,cnp->cn_proc);
#else
VOP_UNLOCK(dvp);
#endif
VOP__UNLOCK(dvp,0,cnp->cn_proc);
dprintf(("ntfs_lookup: parentdir: %d\n",
vap->va_a_name->n_pnumber));
@ -933,20 +923,12 @@ ntfs_lookup(ap)
vap->va_a_name->n_pnumber,ap->a_vpp);
ntfs_ntvattrrele(vap);
if(error) {
#if __FreeBSD_version >= 300000
VOP_LOCK(dvp, 0, cnp->cn_proc);
#else
VOP_LOCK(dvp);
#endif
VOP__LOCK(dvp, 0, cnp->cn_proc);
return(error);
}
if( lockparent && (cnp->cn_flags & ISLASTCN) &&
#if __FreeBSD_version >= 300000
(error = VOP_LOCK(dvp, 0, cnp->cn_proc)) ) {
#else
(error = VOP_LOCK(dvp)) ) {
#endif
(error = VOP__LOCK(dvp, 0, cnp->cn_proc)) ) {
vput( *(ap->a_vpp) );
return (error);
}
@ -960,11 +942,7 @@ ntfs_lookup(ap)
VTONT(*ap->a_vpp)->i_number));
if(!lockparent || !(cnp->cn_flags & ISLASTCN))
#if __FreeBSD_version >= 300000
VOP_UNLOCK(dvp, 0, cnp->cn_proc);
#else
VOP_UNLOCK(dvp);
#endif
VOP__UNLOCK(dvp, 0, cnp->cn_proc);
if (cnp->cn_flags & MAKEENTRY)
cache_enter(dvp, *ap->a_vpp, cnp);
@ -994,7 +972,10 @@ ntfs_fsync(ap)
* Global vfs data structures
*/
vop_t **ntfs_vnodeop_p;
static struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
#if defined(__FreeBSD__)
static
#endif
struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
{ &vop_default_desc, (vop_t *)ntfs_bypass },
{ &vop_getattr_desc, (vop_t *)ntfs_getattr },
@ -1002,7 +983,7 @@ static struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
{ &vop_reclaim_desc, (vop_t *)ntfs_reclaim },
{ &vop_print_desc, (vop_t *)ntfs_print },
#if __FreeBSD_version >= 30000
#if defined(__FreeBSD__)
{ &vop_islocked_desc, (vop_t *)vop_stdislocked },
{ &vop_unlock_desc, (vop_t *)vop_stdunlock },
{ &vop_lock_desc, (vop_t *)vop_stdlock },
@ -1022,18 +1003,28 @@ static struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
{ &vop_fsync_desc, (vop_t *)ntfs_fsync },
{ &vop_bmap_desc, (vop_t *)ntfs_bmap },
{ &vop_getpages_desc, (vop_t *)ntfs_getpages },
#if defined(__FreeBSD__)
{ &vop_getpages_desc, (vop_t *) ntfs_getpages },
{ &vop_putpages_desc, (vop_t *) ntfs_putpages },
#endif
{ &vop_strategy_desc, (vop_t *)ntfs_strategy },
#if defined(__FreeBSD__)
{ &vop_bwrite_desc, (vop_t *)vop_stdbwrite },
#else /* defined(__NetBSD__) */
{ &vop_bwrite_desc, (vop_t *)vn_bwrite },
#endif
{ &vop_read_desc, (vop_t *)ntfs_read },
{ &vop_write_desc, (vop_t *)ntfs_write },
{ NULL, NULL }
};
static struct vnodeopv_desc ntfs_vnodeop_opv_desc =
#if defined(__FreeBSD__)
static
#endif
struct vnodeopv_desc ntfs_vnodeop_opv_desc =
{ &ntfs_vnodeop_p, ntfs_vnodeop_entries };
#if defined(__FreeBSD__)
VNODEOP_SET(ntfs_vnodeop_opv_desc);
#endif

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfsmount.h,v 1.2 1999/05/06 15:43:21 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfsmount.h,v 1.7 1999/01/28 03:56:07 semen Exp $
* $Id: ntfsmount.h,v 1.3 1999/04/20 21:06:44 semenu Exp $
*/
#define NTFS_MFLAG_CASEINS 0x00000001

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs.h,v 1.2 1999/05/06 15:43:17 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs.h,v 1.9 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs.h,v 1.4 1999/04/20 21:06:41 semenu Exp $
*/
/*#define NTFS_DEBUG 1*/
@ -286,6 +288,32 @@ MALLOC_DECLARE(M_NTFSDIR);
MALLOC_DECLARE(M_NTFSNTHASH);
#endif
#ifdef __NetBSD__
#define MALLOC_DEFINE(a, b, c)
#define M_NTFSNTHASH M_TEMP
#define M_NTFSNTVATTR M_TEMP
#define M_NTFSRDATA M_TEMP
#define M_NTFSRUN M_TEMP
#define M_NTFSDECOMP M_TEMP
#define M_NTFSMNT M_TEMP
#define M_NTFSNTNODE M_TEMP
#define M_NTFSFNODE M_TEMP
#define M_NTFSDIR M_TEMP
typedef int (vop_t) __P((void *));
#define HASHINIT(a, b, c, d) hashinit((a), (b), (c), (d))
#define bqrelse(bp) brelse(bp)
#define VOP__LOCK(a, b, c) VOP_LOCK((a), (b) ? LK_EXCLUSIVE : LK_SHARED)
#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), 0)
#define VGET(a, b, c) vget((a), LK_EXCLUSIVE)
#define VN_LOCK(a, b, c) vn_lock((a), LK_EXCLUSIVE)
#else
#define HASHINIT(a, b, c, d) hashinit((a), (b), (d))
#define VOP__LOCK(a, b, c) VOP_LOCK((a), (b), (c))
#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), (b), (c))
#define VGET(a, b, c) vget((a), (b), (c))
#define VN_LOCK(a, b, c) vn_lock((a), (b), (c))
#endif
#if defined(NTFS_DEBUG)
#define dprintf(a) printf a
#if NTFS_DEBUG > 1

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_compr.c,v 1.2 1999/05/06 15:43:18 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_compr.c,v 1.4 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_compr.c,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
#include <sys/param.h>
@ -36,7 +38,9 @@
#include <sys/buf.h>
#include <sys/file.h>
#include <sys/malloc.h>
#ifdef __FreeBSD__
#include <machine/clock.h>
#endif
#include <miscfs/specfs/specdev.h>

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_compr.h,v 1.2 1999/05/06 15:43:18 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_compr.h,v 1.3 1999/01/28 03:56:06 semen Exp $
* $Id: ntfs_compr.h,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
#define NTFS_COMPBLOCK_SIZE 0x1000

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_extern.h,v 1.2 1999/05/06 15:43:18 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_extern.h,v 1.3 1999/01/28 03:56:06 semen Exp $
* $Id: ntfs_extern.h,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
struct sockaddr;

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_ihash.c,v 1.2 1999/05/06 15:43:19 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995
* The Regents of the University of California. All rights reserved.
@ -31,7 +33,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95
* $Id: ntfs_ihash.c,v 1.3 1999/04/20 21:06:43 semenu Exp $
* $Id: ntfs_ihash.c,v 1.4 1999/05/11 19:54:50 phk Exp $
*/
#include <sys/param.h>
@ -65,7 +67,8 @@ void
ntfs_nthashinit()
{
ntfs_nthashtbl = hashinit(desiredvnodes, M_NTFSNTHASH, &ntfs_nthash);
ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK,
&ntfs_nthash);
simple_lock_init(&ntfs_nthash_slock);
}

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_ihash.h,v 1.2 1999/05/06 15:43:19 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs.h,v 1.9 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_ihash.h,v 1.2 1999/04/20 21:06:43 semenu Exp $
*/
void ntfs_nthashinit __P((void));

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_inode.h,v 1.2 1999/05/06 15:43:19 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,11 +25,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_inode.h,v 1.8 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_inode.h,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
/* These flags are kept in i_flag. */
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
#define IN_ACCESS 0x0001 /* Access time update request. */
#define IN_CHANGE 0x0002 /* Inode change time update request. */
#define IN_UPDATE 0x0004 /* Modification time update request. */
@ -35,9 +37,8 @@
#define IN_RENAME 0x0010 /* Inode is being renamed. */
#define IN_SHLOCK 0x0020 /* File has shared lock. */
#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
#define IN_HASHED 0x0080 /* Inode is on hash list */
#define IN_LAZYMOD 0x0100 /* Modified, but don't write yet. */
#else
#define IN_LAZYMOD 0x0080 /* Modified, but don't write yet. */
#else /* defined(__NetBSD__) */
#define IN_ACCESS 0x0001 /* Access time update request. */
#define IN_CHANGE 0x0002 /* Inode change time update request. */
#define IN_EXLOCK 0x0004 /* File has exclusive lock. */
@ -51,6 +52,7 @@
#define IN_RECURSE 0x0400 /* Recursion expected */
#endif
#define IN_HASHED 0x0800 /* Inode is on hash list */
#define IN_LOADED 0x8000 /* ntvattrs loaded */
#define IN_PRELOADED 0x4000 /* loaded from directory entry */
@ -64,7 +66,11 @@ struct ntnode {
u_int32_t i_flag;
int i_lock;
int i_usecount;
#if defined(__NetBSD__)
pid_t i_lockholder;
pid_t i_lockwaiter;
int i_lockcount;
#endif
LIST_HEAD(,fnode) i_fnlist;
LIST_HEAD(,ntvattr) i_valist;

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_subr.c,v 1.2 1999/05/06 15:43:19 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_subr.c,v 1.9 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_subr.c,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
#include <sys/param.h>
@ -37,7 +39,9 @@
#include <sys/buf.h>
#include <sys/file.h>
#include <sys/malloc.h>
#if defined(__FreeBSD__)
#include <machine/clock.h>
#endif
#include <miscfs/specfs/specdev.h>
@ -51,7 +55,7 @@
#include <ntfs/ntfs_compr.h>
#include <ntfs/ntfs_ihash.h>
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
MALLOC_DEFINE(M_NTFSNTVATTR, "NTFS vattr", "NTFS file attribute information");
MALLOC_DEFINE(M_NTFSRDATA, "NTFS res data", "NTFS resident data");
MALLOC_DEFINE(M_NTFSRUN, "NTFS vrun", "NTFS vrun storage");
@ -684,9 +688,9 @@ ntfs_uustricmp(
int
ntfs_uastricmp(
struct ntfsmount * ntmp,
wchar * str1,
const wchar *str1,
int str1len,
char *str2,
const char *str2,
int str2len)
{
int i;
@ -706,10 +710,10 @@ ntfs_uastricmp(
*/
int
ntfs_uastrcmp(
struct ntfsmount * ntmp,
wchar * str1,
struct ntfsmount *ntmp,
const wchar *str1,
int str1len,
char *str2,
const char *str2,
int str2len)
{
int i;
@ -810,13 +814,13 @@ ntfs_frele(
int
ntfs_ntlookupattr(
struct ntfsmount * ntmp,
char * name,
const char * name,
int namelen,
int *attrtype,
char **attrname)
{
char *sys;
int syslen,i;
const char *sys;
size_t syslen, i;
struct ntvattrdef *adp;
if (namelen == 0)
@ -882,7 +886,7 @@ ntfs_ntlookupfile(
u_int32_t rdsize; /* Length of data to read from current block */
struct attr_indexentry *iep;
int error, res, anamelen, fnamelen;
char *fname,*aname;
const char *fname,*aname;
u_int32_t aoff;
error = ntfs_ntget(ip);

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_subr.h,v 1.2 1999/05/06 15:43:20 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_subr.h,v 1.3 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_subr.h,v 1.3 1999/04/20 21:06:43 semenu Exp $
*/
#define VA_LOADED 0x0001
@ -92,8 +94,10 @@ struct timespec ntfs_nttimetounix __P(( u_int64_t ));
int ntfs_ntreaddir __P(( struct ntfsmount *, struct fnode *, u_int32_t, struct attr_indexentry **));
wchar ntfs_toupper __P(( struct ntfsmount *, wchar ));
int ntfs_uustricmp __P(( struct ntfsmount *, wchar *, int, wchar *, int ));
int ntfs_uastricmp __P(( struct ntfsmount *, wchar *, int, char *, int ));
int ntfs_uastrcmp __P(( struct ntfsmount *, wchar *, int, char *, int ));
int ntfs_uastricmp __P(( struct ntfsmount *, const wchar *, int, const char *,
int ));
int ntfs_uastrcmp __P(( struct ntfsmount *, const wchar *, int, const char *,
int ));
int ntfs_runtovrun __P(( cn_t **, cn_t **, u_long *, u_int8_t *));
int ntfs_attrtontvattr __P(( struct ntfsmount *, struct ntvattr **, struct attr * ));
void ntfs_freentvattr __P(( struct ntvattr * ));
@ -108,6 +112,6 @@ int ntfs_ntget __P((struct ntnode *));
void ntfs_ntrele __P((struct ntnode *));
void ntfs_ntput __P((struct ntnode *));
int ntfs_loadntnode __P(( struct ntfsmount *, struct ntnode * ));
int ntfs_ntlookupattr(struct ntfsmount *, char *, int, int *, char **);
int ntfs_ntlookupattr(struct ntfsmount *, const char *, int, int *, char **);
int ntfs_writentvattr_plain(struct ntfsmount *, struct ntnode *, struct ntvattr *, off_t, size_t, void *, size_t *);
int ntfs_writeattr_plain(struct ntfsmount *, struct ntnode *, u_int32_t, char *, off_t, size_t, void *, size_t *);

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_vfsops.c,v 1.2 1999/05/06 15:43:20 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_vfsops.c,v 1.4 1999/05/06 22:07:34 peter Exp $
* $Id: ntfs_vfsops.c,v 1.5 1999/05/11 19:54:52 phk Exp $
*/
@ -57,15 +59,20 @@
#include <ntfs/ntfs_extern.h>
#include <ntfs/ntfsmount.h>
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
#endif
#if defined(__FreeBSD__)
static int ntfs_mount __P((struct mount *, char *, caddr_t,
struct nameidata *, struct proc *));
#else
static int ntfs_mount __P((struct mount *, const char *, void *,
struct nameidata *, struct proc *));
#endif
static int ntfs_quotactl __P((struct mount *, int, uid_t, caddr_t,
struct proc *));
static int ntfs_root __P((struct mount *, struct vnode **));
@ -81,11 +88,20 @@ static int ntfs_mountfs __P((register struct vnode *, struct mount *,
struct ntfs_args *, struct proc *));
static int ntfs_vptofh __P((struct vnode *, struct fid *));
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
static int ntfs_init __P((struct vfsconf *));
static int ntfs_fhtovp __P((struct mount *, struct fid *,
struct sockaddr *, struct vnode **,
int *, struct ucred **));
#elif defined(__NetBSD__)
static void ntfs_init __P((void));
static int ntfs_fhtovp __P((struct mount *, struct fid *,
struct vnode **));
static int ntfs_checkexp __P((struct mount *, struct mbuf *,
int *, struct ucred **));
static int ntfs_mountroot __P((void));
static int ntfs_sysctl __P((int *, u_int, void *, size_t *, void *,
size_t, struct proc *));
#else
static int ntfs_init __P((void));
static int ntfs_fhtovp __P((struct mount *, struct fid *,
@ -93,25 +109,68 @@ static int ntfs_fhtovp __P((struct mount *, struct fid *,
int *, struct ucred **));
#endif
#if __FreeBSD_version >= 300000
#ifdef __NetBSD__
/*ARGSUSED*/
static int
ntfs_checkexp(mp, nam, exflagsp, credanonp)
register struct mount *mp;
struct mbuf *nam;
int *exflagsp;
struct ucred **credanonp;
{
return (EINVAL);
}
/*ARGSUSED*/
static int
ntfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
int *name;
u_int namelen;
void *oldp;
size_t *oldlenp;
void *newp;
size_t newlen;
struct proc *p;
{
return (EINVAL);
}
static int
ntfs_mountroot()
{
return (EINVAL);
}
#endif
#if defined(__FreeBSD__)
static int
ntfs_init (
struct vfsconf *vcp )
#elif defined(__NetBSD__)
static void
ntfs_init ()
#else
static int
ntfs_init ()
#endif
{
ntfs_nthashinit();
#if !defined(__NetBSD__)
return 0;
#endif
}
static int
ntfs_mount (
struct mount *mp,
#if defined(__FreeBSD__)
char *path,
caddr_t data,
#else
const char *path,
void *data,
#endif
struct nameidata *ndp,
struct proc *p )
{
@ -347,11 +406,13 @@ ntfs_mountfs(devvp, mp, argsp, p)
if (error)
return (error);
ncount = vcount(devvp);
#if defined(__FreeBSD__)
if (devvp->v_object)
ncount -= 1;
#endif
if (ncount > 1 && devvp != rootvp)
return (EBUSY);
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
VOP_UNLOCK(devvp, 0, p);
@ -501,14 +562,14 @@ ntfs_mountfs(devvp, mp, argsp, p)
}
mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
#else
mp->mnt_stat.f_fsid.val[1] = MOUNT_NTFS;
mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_NTFS);
#endif
mp->mnt_maxsymlinklen = 0;
mp->mnt_flag |= MNT_LOCAL;
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
devvp->v_specmountpoint = mp;
#else
devvp->v_specflags |= SI_MOUNTEDON;
@ -523,10 +584,10 @@ ntfs_mountfs(devvp, mp, argsp, p)
printf("ntfs_mountfs: vflush failed\n");
out:
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
devvp->v_specmountpoint = NULL;
#else
devvp->v_specflags |= SI_MOUNTEDON;
devvp->v_specflags &= ~SI_MOUNTEDON;
#endif
if (bp)
brelse(bp);
@ -580,14 +641,10 @@ ntfs_unmount(
if (error)
printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
ntmp->ntm_devvp->v_specmountpoint = NULL;
#else
ntmp->ntm_devvp->v_specflags &= ~SI_MOUNTEDON;
VOP_LOCK(ntmp->ntm_devvp);
vnode_pager_uncache(ntmp->ntm_devvp);
VOP_UNLOCK(ntmp->ntm_devvp);
#endif
vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, p, 0, 0);
@ -686,8 +743,10 @@ ntfs_statfs(
mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
sbp->f_type = mp->mnt_vfc->vfc_typenum;
#elif defined(__NetBSD__)
sbp->f_type = 0;
#else
sbp->f_type = MOUNT_NTFS;
#endif
@ -720,18 +779,21 @@ ntfs_sync (
return (0);
}
#if __FreeBSD_version >= 300000
/*ARGSUSED*/
static int
ntfs_fhtovp(
#if defined(__FreeBSD__)
struct mount *mp,
struct fid *fhp,
struct sockaddr *nam,
struct vnode **vpp,
int *exflagsp,
struct ucred **credanonp)
#elif defined(__NetBSD__)
struct mount *mp,
struct fid *fhp,
struct vnode **vpp)
#else
static int
ntfs_fhtovp(
struct mount *mp,
struct fid *fhp,
struct mbuf *nam,
@ -824,7 +886,7 @@ ntfs_vgetex(
}
if (FTOV(fp)) {
vget(FTOV(fp), lkflags, p);
VGET(FTOV(fp), lkflags, p);
*vpp = FTOV(fp);
ntfs_ntput(ip);
return (0);
@ -849,7 +911,7 @@ ntfs_vgetex(
ntfs_ntput(ip);
if (lkflags & LK_TYPE_MASK) {
error = vn_lock(vp, lkflags, p);
error = VN_LOCK(vp, lkflags, p);
if (error) {
vput(vp);
return (error);
@ -872,7 +934,7 @@ ntfs_vget(
LK_EXCLUSIVE, 0, curproc, vpp);
}
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
static struct vfsops ntfs_vfsops = {
ntfs_mount,
ntfs_start,
@ -888,6 +950,32 @@ static struct vfsops ntfs_vfsops = {
NULL
};
VFS_SET(ntfs_vfsops, ntfs, 0);
#elif defined(__NetBSD__)
extern struct vnodeopv_desc ntfs_vnodeop_opv_desc;
struct vnodeopv_desc *ntfs_vnodeopv_descs[] = {
&ntfs_vnodeop_opv_desc,
NULL,
};
struct vfsops ntfs_vfsops = {
MOUNT_NTFS,
ntfs_mount,
ntfs_start,
ntfs_unmount,
ntfs_root,
ntfs_quotactl,
ntfs_statfs,
ntfs_sync,
ntfs_vget,
ntfs_fhtovp,
ntfs_vptofh,
ntfs_init,
ntfs_sysctl,
ntfs_mountroot,
ntfs_checkexp,
ntfs_vnodeopv_descs,
};
#else
static struct vfsops ntfs_vfsops = {
ntfs_mount,
@ -902,7 +990,6 @@ static struct vfsops ntfs_vfsops = {
ntfs_vptofh,
ntfs_init,
};
VFS_SET(ntfs_vfsops, ntfs, MOUNT_NTFS, 0);
#endif

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_vfsops.h,v 1.2 1999/05/06 15:43:20 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_vfsops.h,v 1.1 1999/02/02 01:54:54 semen Exp $
* $Id: ntfs_vfsops.h,v 1.2 1999/04/20 21:06:43 semenu Exp $
*/
#define VG_DONTLOADIN 0x0001 /* Tells ntfs_vgetex to do not call */
/* ntfs_loadnode on ntnode, even if */

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfs_vnops.c,v 1.2 1999/05/06 15:43:20 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@ -33,14 +35,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfs_vnops.c,v 1.3 1999/04/20 21:06:43 semenu Exp $
* $Id: ntfs_vnops.c,v 1.4 1999/05/11 19:54:52 phk Exp $
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/time.h>
#include <sys/types.h>
@ -58,9 +59,13 @@
#include <vm/vm_page.h>
#include <vm/vm_object.h>
#include <vm/vm_pager.h>
#if defined(__FreeBSD__)
#include <vm/vnode_pager.h>
#endif
#include <vm/vm_extern.h>
#include <sys/sysctl.h>
/*#define NTFS_DEBUG 1*/
#include <ntfs/ntfs.h>
@ -77,7 +82,7 @@ static int ntfs_inactive __P((struct vop_inactive_args *ap));
static int ntfs_print __P((struct vop_print_args *ap));
static int ntfs_reclaim __P((struct vop_reclaim_args *ap));
static int ntfs_strategy __P((struct vop_strategy_args *ap));
#if __FreeBSD_version < 300000
#if defined(__NetBSD__)
static int ntfs_islocked __P((struct vop_islocked_args *ap));
static int ntfs_unlock __P((struct vop_unlock_args *ap));
static int ntfs_lock __P((struct vop_lock_args *ap));
@ -88,12 +93,15 @@ static int ntfs_close __P((struct vop_close_args *ap));
static int ntfs_readdir __P((struct vop_readdir_args *ap));
static int ntfs_lookup __P((struct vop_lookup_args *ap));
static int ntfs_bmap __P((struct vop_bmap_args *ap));
#if defined(__FreeBSD__)
static int ntfs_getpages __P((struct vop_getpages_args *ap));
static int ntfs_putpages __P((struct vop_putpages_args *));
#endif
static int ntfs_fsync __P((struct vop_fsync_args *ap));
int ntfs_prtactive = 1; /* 1 => print out reclaim of active vnodes */
#if defined(__FreeBSD__)
int
ntfs_getpages(ap)
struct vop_getpages_args *ap;
@ -109,6 +117,7 @@ ntfs_putpages(ap)
return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
ap->a_sync, ap->a_rtvals);
}
#endif
/*
* This is a noop, simply returning what one has been given.
@ -131,8 +140,10 @@ ntfs_bmap(ap)
*ap->a_bnp = ap->a_bn;
if (ap->a_runp != NULL)
*ap->a_runp = 0;
#if !defined(__NetBSD__)
if (ap->a_runb != NULL)
*ap->a_runb = 0;
#endif
return (0);
}
@ -256,28 +267,16 @@ ntfs_inactive(ap)
error = 0;
#if __FreeBSD_version >= 300000
VOP_UNLOCK(vp,0,ap->a_p);
#else
#ifdef DIAGNOSTIC
if (VOP_ISLOCKED(vp))
panic("ntfs_inactive: locked vnode");
if (curproc)
ip->i_lockholder = curproc->p_pid;
else
ip->i_lockholder = -1;
#endif
ip->i_flag |= IN_LOCKED;
VOP_UNLOCK(vp);
#endif
VOP__UNLOCK(vp,0,ap->a_p);
/*
* If we are done with the ntnode, reclaim it
* so that it can be reused immediately.
*/
if (vp->v_usecount == 0 && ip->i_mode == 0)
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
vrecycle(vp, (struct simplelock *)0, ap->a_p);
#else
#else /* defined(__NetBSD__) */
vgone(vp);
#endif
return (error);
@ -303,8 +302,8 @@ ntfs_reclaim(ap)
if (error)
return (error);
#if __FreeBSD_version >= 300000
VOP_UNLOCK(vp,0,ap->a_p);
#if defined(__FreeBSD__)
VOP__UNLOCK(vp,0,ap->a_p);
#endif
/* Purge old data structures associated with the inode. */
@ -467,7 +466,7 @@ ntfs_write(ap)
return (0);
}
#if __FreeBSD_version < 300000
#if defined(__NetBSD__)
/*
* Check for a locked ntnode.
*/
@ -497,7 +496,9 @@ ntfs_unlock(ap)
} */ *ap;
{
register struct ntnode *ip = VTONT(ap->a_vp);
#ifdef DIAGNOSTIC
struct proc *p = curproc;
#endif
dprintf(("ntfs_unlock %d\n",ip->i_number));
@ -729,10 +730,6 @@ ntfs_close(ap)
return (0);
}
/*
#undef dprintf
#define dprintf(a) printf a
*/
int
ntfs_readdir(ap)
struct vop_readdir_args /* {
@ -835,24 +832,25 @@ ntfs_readdir(ap)
if (!error && ap->a_ncookies != NULL) {
struct dirent* dpStart;
struct dirent* dp;
#if __FreeBSD_version >= 300000
#if defined(__FreeBSD__)
u_long *cookies;
u_long *cookiep;
#else
u_int *cookies;
u_int *cookiep;
#else /* defined(__NetBSD__) */
off_t *cookies;
off_t *cookiep;
#endif
printf("ntfs_readdir: %d cookies\n",ncookies);
if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
panic("ntfs_readdir: unexpected uio from NFS server");
dpStart = (struct dirent *)
(uio->uio_iov->iov_base - (uio->uio_offset - off));
#if __FreeBSD_version >= 300000
((caddr_t)uio->uio_iov->iov_base -
(uio->uio_offset - off));
#if defined(__FreeBSD__)
MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
M_TEMP, M_WAITOK);
#else
MALLOC(cookies, u_int *, ncookies * sizeof(u_int),
#else /* defined(__NetBSD__) */
MALLOC(cookies, off_t *, ncookies * sizeof(off_t),
M_TEMP, M_WAITOK);
#endif
for (dp = dpStart, cookiep = cookies, i=0;
@ -870,10 +868,6 @@ ntfs_readdir(ap)
*/
return (error);
}
/*
#undef dprintf
#define dprintf(a)
*/
int
ntfs_lookup(ap)
@ -921,11 +915,7 @@ ntfs_lookup(ap)
if(error)
return (error);
#if __FreeBSD_version >= 300000
VOP_UNLOCK(dvp,0,cnp->cn_proc);
#else
VOP_UNLOCK(dvp);
#endif
VOP__UNLOCK(dvp,0,cnp->cn_proc);
dprintf(("ntfs_lookup: parentdir: %d\n",
vap->va_a_name->n_pnumber));
@ -933,20 +923,12 @@ ntfs_lookup(ap)
vap->va_a_name->n_pnumber,ap->a_vpp);
ntfs_ntvattrrele(vap);
if(error) {
#if __FreeBSD_version >= 300000
VOP_LOCK(dvp, 0, cnp->cn_proc);
#else
VOP_LOCK(dvp);
#endif
VOP__LOCK(dvp, 0, cnp->cn_proc);
return(error);
}
if( lockparent && (cnp->cn_flags & ISLASTCN) &&
#if __FreeBSD_version >= 300000
(error = VOP_LOCK(dvp, 0, cnp->cn_proc)) ) {
#else
(error = VOP_LOCK(dvp)) ) {
#endif
(error = VOP__LOCK(dvp, 0, cnp->cn_proc)) ) {
vput( *(ap->a_vpp) );
return (error);
}
@ -960,11 +942,7 @@ ntfs_lookup(ap)
VTONT(*ap->a_vpp)->i_number));
if(!lockparent || !(cnp->cn_flags & ISLASTCN))
#if __FreeBSD_version >= 300000
VOP_UNLOCK(dvp, 0, cnp->cn_proc);
#else
VOP_UNLOCK(dvp);
#endif
VOP__UNLOCK(dvp, 0, cnp->cn_proc);
if (cnp->cn_flags & MAKEENTRY)
cache_enter(dvp, *ap->a_vpp, cnp);
@ -994,7 +972,10 @@ ntfs_fsync(ap)
* Global vfs data structures
*/
vop_t **ntfs_vnodeop_p;
static struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
#if defined(__FreeBSD__)
static
#endif
struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
{ &vop_default_desc, (vop_t *)ntfs_bypass },
{ &vop_getattr_desc, (vop_t *)ntfs_getattr },
@ -1002,7 +983,7 @@ static struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
{ &vop_reclaim_desc, (vop_t *)ntfs_reclaim },
{ &vop_print_desc, (vop_t *)ntfs_print },
#if __FreeBSD_version >= 30000
#if defined(__FreeBSD__)
{ &vop_islocked_desc, (vop_t *)vop_stdislocked },
{ &vop_unlock_desc, (vop_t *)vop_stdunlock },
{ &vop_lock_desc, (vop_t *)vop_stdlock },
@ -1022,18 +1003,28 @@ static struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
{ &vop_fsync_desc, (vop_t *)ntfs_fsync },
{ &vop_bmap_desc, (vop_t *)ntfs_bmap },
{ &vop_getpages_desc, (vop_t *)ntfs_getpages },
#if defined(__FreeBSD__)
{ &vop_getpages_desc, (vop_t *) ntfs_getpages },
{ &vop_putpages_desc, (vop_t *) ntfs_putpages },
#endif
{ &vop_strategy_desc, (vop_t *)ntfs_strategy },
#if defined(__FreeBSD__)
{ &vop_bwrite_desc, (vop_t *)vop_stdbwrite },
#else /* defined(__NetBSD__) */
{ &vop_bwrite_desc, (vop_t *)vn_bwrite },
#endif
{ &vop_read_desc, (vop_t *)ntfs_read },
{ &vop_write_desc, (vop_t *)ntfs_write },
{ NULL, NULL }
};
static struct vnodeopv_desc ntfs_vnodeop_opv_desc =
#if defined(__FreeBSD__)
static
#endif
struct vnodeopv_desc ntfs_vnodeop_opv_desc =
{ &ntfs_vnodeop_p, ntfs_vnodeop_entries };
#if defined(__FreeBSD__)
VNODEOP_SET(ntfs_vnodeop_opv_desc);
#endif

View File

@ -1,3 +1,5 @@
/* $NetBSD: ntfsmount.h,v 1.2 1999/05/06 15:43:21 christos Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ntfsmount.h,v 1.7 1999/01/28 03:56:07 semen Exp $
* $Id: ntfsmount.h,v 1.3 1999/04/20 21:06:44 semenu Exp $
*/
#define NTFS_MFLAG_CASEINS 0x00000001