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