Home | History | Annotate | Line # | Download | only in lfs
ulfsmount.h revision 1.6
      1 /*	$NetBSD: ulfsmount.h,v 1.6 2013/06/06 01:25:25 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_LFS_ULFSMOUNT_H_
     36 #define _UFS_LFS_ULFSMOUNT_H_
     37 
     38 #include <sys/mount.h> /* struct export_args30 */
     39 
     40 /*
     41  * Arguments to mount ULFS-based filesystems
     42  */
     43 struct ulfs_args {
     44 	char	*fspec;			/* block special device to mount */
     45 };
     46 
     47 #ifdef _KERNEL
     48 
     49 #if defined(_KERNEL_OPT)
     50 #include "opt_lfs.h"
     51 #endif
     52 
     53 #include <sys/mutex.h>
     54 
     55 #include <ufs/lfs/ulfs_extattr.h>
     56 #include <ufs/lfs/ulfs_quotacommon.h>
     57 
     58 struct buf;
     59 struct inode;
     60 struct nameidata;
     61 struct timeval;
     62 struct uio;
     63 struct vnode;
     64 
     65 /* This structure describes the ULFS specific mount structure data. */
     66 struct ulfsmount {
     67 	struct	mount *um_mountp;		/* filesystem vfs structure */
     68 	dev_t	um_dev;				/* device mounted */
     69 	struct	vnode *um_devvp;		/* block device mounted vnode */
     70 	u_long	um_fstype;
     71 	u_int32_t um_flags;			/* ULFS-specific flags - see below */
     72 	union {					/* pointer to superblock */
     73 		struct	lfs *lfs;		/* LFS */
     74 	} ulfsmount_u;
     75 #define	um_lfs	ulfsmount_u.lfs
     76 
     77 	/* Extended attribute information. */
     78 	struct ulfs_extattr_per_mount um_extattr;
     79 
     80 	struct	vnode *um_quotas[ULFS_MAXQUOTAS];	/* pointer to quota files */
     81 	kauth_cred_t   um_cred[ULFS_MAXQUOTAS];	/* quota file access cred */
     82 	u_long	um_nindir;			/* indirect ptrs per block */
     83 	u_long	um_lognindir;			/* log2 of um_nindir */
     84 	u_long	um_bptrtodb;			/* indir ptr to disk block */
     85 	u_long	um_seqinc;			/* inc between seq blocks */
     86 	kmutex_t um_lock;			/* lock on global data */
     87 	union {
     88 	    struct um_q1 {
     89 		time_t	q1_btime[ULFS_MAXQUOTAS];	/* block quota time limit */
     90 		time_t	q1_itime[ULFS_MAXQUOTAS];	/* inode quota time limit */
     91 		char	q1_qflags[ULFS_MAXQUOTAS];	/* quota specific flags */
     92 	    } um_q1;
     93 	    struct um_q2 {
     94 		uint64_t q2_bsize;		/* block size of quota file */
     95 		uint64_t q2_bmask;		/* mask for above */
     96 	    } um_q2;
     97 	} um_q;
     98 #define umq1_btime  um_q.um_q1.q1_btime
     99 #define umq1_itime  um_q.um_q1.q1_itime
    100 #define umq1_qflags um_q.um_q1.q1_qflags
    101 #define umq2_bsize  um_q.um_q2.q2_bsize
    102 #define umq2_bmask  um_q.um_q2.q2_bmask
    103 
    104 	void	*um_oldfscompat;		/* save 4.2 rotbl */
    105 	int	um_maxsymlinklen;
    106 	int	um_dirblksiz;
    107 	u_int64_t um_maxfilesize;
    108 	void	*um_snapinfo;			/* snapshot private data */
    109 
    110 	const struct ulfs_ops *um_ops;
    111 
    112 	void *um_discarddata;
    113 };
    114 
    115 struct ulfs_ops {
    116 	void (*uo_itimes)(struct inode *ip, const struct timespec *,
    117 	    const struct timespec *, const struct timespec *);
    118 	int (*uo_update)(struct vnode *, const struct timespec *,
    119 	    const struct timespec *, int);
    120 	int (*uo_truncate)(struct vnode *, off_t, int, kauth_cred_t);
    121 	int (*uo_valloc)(struct vnode *, int, kauth_cred_t, struct vnode **);
    122 	int (*uo_vfree)(struct vnode *, ino_t, int);
    123 	int (*uo_balloc)(struct vnode *, off_t, int, kauth_cred_t, int,
    124 	    struct buf **);
    125         void (*uo_unmark_vnode)(struct vnode *);
    126 };
    127 
    128 #define	ULFS_OPS(vp)	(VFSTOULFS((vp)->v_mount)->um_ops)
    129 
    130 #define	ULFS_ITIMES(vp, acc, mod, cre) \
    131 	(*ULFS_OPS(vp)->uo_itimes)(VTOI(vp), (acc), (mod), (cre))
    132 #define	ULFS_UPDATE(vp, acc, mod, flags) \
    133 	(*ULFS_OPS(vp)->uo_update)((vp), (acc), (mod), (flags))
    134 #define	ULFS_TRUNCATE(vp, off, flags, cr) \
    135 	(*ULFS_OPS(vp)->uo_truncate)((vp), (off), (flags), (cr))
    136 #define	ULFS_VALLOC(vp, mode, cr, vpp) \
    137 	(*ULFS_OPS(vp)->uo_valloc)((vp), (mode), (cr), (vpp))
    138 #define	ULFS_VFREE(vp, ino, mode) \
    139 	(*ULFS_OPS(vp)->uo_vfree)((vp), (ino), (mode))
    140 #define	ULFS_BALLOC(vp, off, size, cr, flags, bpp) \
    141 	(*ULFS_OPS(vp)->uo_balloc)((vp), (off), (size), (cr), (flags), (bpp))
    142 #define	ULFS_UNMARK_VNODE(vp) \
    143 	(*ULFS_OPS(vp)->uo_unmark_vnode)((vp))
    144 
    145 /* ULFS-specific flags */
    146 #define ULFS_NEEDSWAP	0x01	/* filesystem metadata need byte-swapping */
    147 /*	unused		0x02	   */
    148 #define ULFS_QUOTA	0x04	/* filesystem has QUOTA (v1) */
    149 #define ULFS_QUOTA2	0x08	/* filesystem has QUOTA2 */
    150 
    151 /*
    152  * Filesystem types
    153  */
    154 #define ULFS1  1
    155 #define ULFS2  2
    156 
    157 
    158 /*
    159  * Flags describing the state of quotas.
    160  */
    161 #define	QTF_OPENING	0x01			/* Q_QUOTAON in progress */
    162 #define	QTF_CLOSING	0x02			/* Q_QUOTAOFF in progress */
    163 
    164 /* Convert mount ptr to ulfsmount ptr. */
    165 #define VFSTOULFS(mp)	((struct ulfsmount *)((mp)->mnt_data))
    166 
    167 /*
    168  * Macros to access file system parameters in the ulfsmount structure.
    169  * Used by ulfs_bmap.
    170  */
    171 #define MNINDIR(ump)			((ump)->um_nindir)
    172 #define	blkptrtodb(ump, b)		((b) << (ump)->um_bptrtodb)
    173 
    174 /*
    175  * Predicate for byte-swapping support.
    176  */
    177 #define	FSFMT(vp)	(((vp)->v_mount->mnt_iflag & IMNT_DTYPE) == 0)
    178 
    179 #endif /* _KERNEL */
    180 
    181 #endif /* !_UFS_LFS_ULFSMOUNT_H_ */
    182