Home | History | Annotate | Line # | Download | only in lfs
ulfsmount.h revision 1.2
      1  1.2  dholland /*	$NetBSD: ulfsmount.h,v 1.2 2013/06/06 00:44:41 dholland Exp $	*/
      2  1.1  dholland /*  from NetBSD: ufsmount.h,v 1.39 2012/10/19 17:09:08 drochner Exp  */
      3  1.1  dholland 
      4  1.1  dholland /*
      5  1.1  dholland  * Copyright (c) 1982, 1986, 1989, 1993
      6  1.1  dholland  *	The Regents of the University of California.  All rights reserved.
      7  1.1  dholland  *
      8  1.1  dholland  * Redistribution and use in source and binary forms, with or without
      9  1.1  dholland  * modification, are permitted provided that the following conditions
     10  1.1  dholland  * are met:
     11  1.1  dholland  * 1. Redistributions of source code must retain the above copyright
     12  1.1  dholland  *    notice, this list of conditions and the following disclaimer.
     13  1.1  dholland  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  dholland  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  dholland  *    documentation and/or other materials provided with the distribution.
     16  1.1  dholland  * 3. Neither the name of the University nor the names of its contributors
     17  1.1  dholland  *    may be used to endorse or promote products derived from this software
     18  1.1  dholland  *    without specific prior written permission.
     19  1.1  dholland  *
     20  1.1  dholland  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21  1.1  dholland  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22  1.1  dholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  1.1  dholland  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24  1.1  dholland  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25  1.1  dholland  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26  1.1  dholland  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27  1.1  dholland  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28  1.1  dholland  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29  1.1  dholland  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30  1.1  dholland  * SUCH DAMAGE.
     31  1.1  dholland  *
     32  1.1  dholland  *	@(#)ufsmount.h	8.6 (Berkeley) 3/30/95
     33  1.1  dholland  */
     34  1.1  dholland 
     35  1.1  dholland #ifndef _UFS_UFS_UFSMOUNT_H_
     36  1.1  dholland #define _UFS_UFS_UFSMOUNT_H_
     37  1.1  dholland 
     38  1.1  dholland #include <sys/mount.h> /* struct export_args30 */
     39  1.1  dholland 
     40  1.1  dholland /*
     41  1.1  dholland  * Arguments to mount UFS-based filesystems
     42  1.1  dholland  */
     43  1.1  dholland struct ufs_args {
     44  1.1  dholland 	char	*fspec;			/* block special device to mount */
     45  1.1  dholland };
     46  1.1  dholland 
     47  1.1  dholland /*
     48  1.1  dholland  * Arguments to mount MFS
     49  1.1  dholland  */
     50  1.1  dholland struct mfs_args {
     51  1.1  dholland 	char	*fspec;			/* name to export for statfs */
     52  1.1  dholland 	struct	export_args30 _pad1; /* compat with old userland tools */
     53  1.1  dholland 	void *	base;			/* base of file system in memory */
     54  1.1  dholland 	u_long	size;			/* size of file system */
     55  1.1  dholland };
     56  1.1  dholland 
     57  1.1  dholland #ifdef _KERNEL
     58  1.1  dholland 
     59  1.1  dholland #if defined(_KERNEL_OPT)
     60  1.1  dholland #include "opt_ffs.h"
     61  1.1  dholland #endif
     62  1.1  dholland 
     63  1.1  dholland #include <sys/mutex.h>
     64  1.1  dholland 
     65  1.2  dholland #include <ufs/lfs/ulfs_extattr.h>
     66  1.2  dholland #include <ufs/lfs/ulfs_quotacommon.h>
     67  1.1  dholland 
     68  1.1  dholland struct buf;
     69  1.1  dholland struct inode;
     70  1.1  dholland struct nameidata;
     71  1.1  dholland struct timeval;
     72  1.1  dholland struct uio;
     73  1.1  dholland struct vnode;
     74  1.1  dholland 
     75  1.1  dholland /* This structure describes the UFS specific mount structure data. */
     76  1.1  dholland struct ufsmount {
     77  1.1  dholland 	struct	mount *um_mountp;		/* filesystem vfs structure */
     78  1.1  dholland 	dev_t	um_dev;				/* device mounted */
     79  1.1  dholland 	struct	vnode *um_devvp;		/* block device mounted vnode */
     80  1.1  dholland 	u_long	um_fstype;
     81  1.1  dholland 	u_int32_t um_flags;			/* UFS-specific flags - see below */
     82  1.1  dholland 	union {					/* pointer to superblock */
     83  1.1  dholland 		struct	fs *fs;			/* FFS */
     84  1.1  dholland 		struct	lfs *lfs;		/* LFS */
     85  1.1  dholland 		struct  m_ext2fs *e2fs;		/* EXT2FS */
     86  1.1  dholland 		struct  chfs_mount *chfs;	/* CHFS */
     87  1.1  dholland 	} ufsmount_u;
     88  1.1  dholland #define	um_fs	ufsmount_u.fs
     89  1.1  dholland #define	um_lfs	ufsmount_u.lfs
     90  1.1  dholland #define um_e2fs	ufsmount_u.e2fs
     91  1.1  dholland #define um_e2fsb ufsmount_u.e2fs->s_es
     92  1.1  dholland #define um_chfs	ufsmount_u.chfs
     93  1.1  dholland 
     94  1.1  dholland 	/* Extended attribute information. */
     95  1.1  dholland 	struct ufs_extattr_per_mount um_extattr;
     96  1.1  dholland 
     97  1.1  dholland 	struct	vnode *um_quotas[MAXQUOTAS];	/* pointer to quota files */
     98  1.1  dholland 	kauth_cred_t   um_cred[MAXQUOTAS];	/* quota file access cred */
     99  1.1  dholland 	u_long	um_nindir;			/* indirect ptrs per block */
    100  1.1  dholland 	u_long	um_lognindir;			/* log2 of um_nindir */
    101  1.1  dholland 	u_long	um_bptrtodb;			/* indir ptr to disk block */
    102  1.1  dholland 	u_long	um_seqinc;			/* inc between seq blocks */
    103  1.1  dholland 	kmutex_t um_lock;			/* lock on global data */
    104  1.1  dholland 	union {
    105  1.1  dholland 	    struct um_q1 {
    106  1.1  dholland 		time_t	q1_btime[MAXQUOTAS];	/* block quota time limit */
    107  1.1  dholland 		time_t	q1_itime[MAXQUOTAS];	/* inode quota time limit */
    108  1.1  dholland 		char	q1_qflags[MAXQUOTAS];	/* quota specific flags */
    109  1.1  dholland 	    } um_q1;
    110  1.1  dholland 	    struct um_q2 {
    111  1.1  dholland 		uint64_t q2_bsize;		/* block size of quota file */
    112  1.1  dholland 		uint64_t q2_bmask;		/* mask for above */
    113  1.1  dholland 	    } um_q2;
    114  1.1  dholland 	} um_q;
    115  1.1  dholland #define umq1_btime  um_q.um_q1.q1_btime
    116  1.1  dholland #define umq1_itime  um_q.um_q1.q1_itime
    117  1.1  dholland #define umq1_qflags um_q.um_q1.q1_qflags
    118  1.1  dholland #define umq2_bsize  um_q.um_q2.q2_bsize
    119  1.1  dholland #define umq2_bmask  um_q.um_q2.q2_bmask
    120  1.1  dholland 
    121  1.1  dholland 	void	*um_oldfscompat;		/* save 4.2 rotbl */
    122  1.1  dholland 	int	um_maxsymlinklen;
    123  1.1  dholland 	int	um_dirblksiz;
    124  1.1  dholland 	u_int64_t um_maxfilesize;
    125  1.1  dholland 	void	*um_snapinfo;			/* snapshot private data */
    126  1.1  dholland 
    127  1.1  dholland 	const struct ufs_ops *um_ops;
    128  1.1  dholland 
    129  1.1  dholland 	void *um_discarddata;
    130  1.1  dholland };
    131  1.1  dholland 
    132  1.1  dholland struct ufs_ops {
    133  1.1  dholland 	void (*uo_itimes)(struct inode *ip, const struct timespec *,
    134  1.1  dholland 	    const struct timespec *, const struct timespec *);
    135  1.1  dholland 	int (*uo_update)(struct vnode *, const struct timespec *,
    136  1.1  dholland 	    const struct timespec *, int);
    137  1.1  dholland 	int (*uo_truncate)(struct vnode *, off_t, int, kauth_cred_t);
    138  1.1  dholland 	int (*uo_valloc)(struct vnode *, int, kauth_cred_t, struct vnode **);
    139  1.1  dholland 	int (*uo_vfree)(struct vnode *, ino_t, int);
    140  1.1  dholland 	int (*uo_balloc)(struct vnode *, off_t, int, kauth_cred_t, int,
    141  1.1  dholland 	    struct buf **);
    142  1.1  dholland         void (*uo_unmark_vnode)(struct vnode *);
    143  1.1  dholland };
    144  1.1  dholland 
    145  1.1  dholland #define	UFS_OPS(vp)	(VFSTOUFS((vp)->v_mount)->um_ops)
    146  1.1  dholland 
    147  1.1  dholland #define	UFS_ITIMES(vp, acc, mod, cre) \
    148  1.1  dholland 	(*UFS_OPS(vp)->uo_itimes)(VTOI(vp), (acc), (mod), (cre))
    149  1.1  dholland #define	UFS_UPDATE(vp, acc, mod, flags) \
    150  1.1  dholland 	(*UFS_OPS(vp)->uo_update)((vp), (acc), (mod), (flags))
    151  1.1  dholland #define	UFS_TRUNCATE(vp, off, flags, cr) \
    152  1.1  dholland 	(*UFS_OPS(vp)->uo_truncate)((vp), (off), (flags), (cr))
    153  1.1  dholland #define	UFS_VALLOC(vp, mode, cr, vpp) \
    154  1.1  dholland 	(*UFS_OPS(vp)->uo_valloc)((vp), (mode), (cr), (vpp))
    155  1.1  dholland #define	UFS_VFREE(vp, ino, mode) \
    156  1.1  dholland 	(*UFS_OPS(vp)->uo_vfree)((vp), (ino), (mode))
    157  1.1  dholland #define	UFS_BALLOC(vp, off, size, cr, flags, bpp) \
    158  1.1  dholland 	(*UFS_OPS(vp)->uo_balloc)((vp), (off), (size), (cr), (flags), (bpp))
    159  1.1  dholland #define	UFS_UNMARK_VNODE(vp) \
    160  1.1  dholland 	(*UFS_OPS(vp)->uo_unmark_vnode)((vp))
    161  1.1  dholland 
    162  1.1  dholland /* UFS-specific flags */
    163  1.1  dholland #define UFS_NEEDSWAP	0x01	/* filesystem metadata need byte-swapping */
    164  1.1  dholland #define UFS_ISAPPLEUFS	0x02	/* filesystem is Apple UFS */
    165  1.1  dholland #define UFS_QUOTA	0x04	/* filesystem has QUOTA (v1) */
    166  1.1  dholland #define UFS_QUOTA2	0x08	/* filesystem has QUOTA2 */
    167  1.1  dholland 
    168  1.1  dholland /*
    169  1.1  dholland  * Filesystem types
    170  1.1  dholland  */
    171  1.1  dholland #define UFS1  1
    172  1.1  dholland #define UFS2  2
    173  1.1  dholland 
    174  1.1  dholland 
    175  1.1  dholland /*
    176  1.1  dholland  * Flags describing the state of quotas.
    177  1.1  dholland  */
    178  1.1  dholland #define	QTF_OPENING	0x01			/* Q_QUOTAON in progress */
    179  1.1  dholland #define	QTF_CLOSING	0x02			/* Q_QUOTAOFF in progress */
    180  1.1  dholland 
    181  1.1  dholland /* Convert mount ptr to ufsmount ptr. */
    182  1.1  dholland #define VFSTOUFS(mp)	((struct ufsmount *)((mp)->mnt_data))
    183  1.1  dholland 
    184  1.1  dholland #ifdef APPLE_UFS
    185  1.1  dholland #define UFS_MPISAPPLEUFS(ump)	((ump)->um_flags & UFS_ISAPPLEUFS)
    186  1.1  dholland #else
    187  1.1  dholland #define UFS_MPISAPPLEUFS(ump)	(0)
    188  1.1  dholland #endif
    189  1.1  dholland 
    190  1.1  dholland /*
    191  1.1  dholland  * Macros to access file system parameters in the ufsmount structure.
    192  1.1  dholland  * Used by ufs_bmap.
    193  1.1  dholland  */
    194  1.1  dholland #define MNINDIR(ump)			((ump)->um_nindir)
    195  1.1  dholland #define	blkptrtodb(ump, b)		((b) << (ump)->um_bptrtodb)
    196  1.1  dholland 
    197  1.1  dholland /*
    198  1.1  dholland  * Predicate for byte-swapping support.
    199  1.1  dholland  */
    200  1.1  dholland #define	FSFMT(vp)	(((vp)->v_mount->mnt_iflag & IMNT_DTYPE) == 0)
    201  1.1  dholland 
    202  1.1  dholland #endif /* _KERNEL */
    203  1.1  dholland 
    204  1.1  dholland #endif /* !_UFS_UFS_UFSMOUNT_H_ */
    205