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