xref: /dragonfly/usr.sbin/makefs/ffs.h (revision 0de61e28)
1 /*	$NetBSD: ffs.h,v 1.2 2004/12/20 20:51:42 jmc Exp $	*/
2 
3 /*-
4  * SPDX-License-Identifier: BSD-4-Clause
5  *
6  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
7  * All rights reserved.
8  *
9  * Written by Luke Mewburn for Wasabi Systems, Inc.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *      This product includes software developed for the NetBSD Project by
22  *      Wasabi Systems, Inc.
23  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
24  *    or promote products derived from this software without specific prior
25  *    written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  *
39  * $FreeBSD: head/usr.sbin/makefs/ffs.h 326276 2017-11-27 15:37:16Z pfg $
40  */
41 
42 #ifndef _FFS_H
43 #define _FFS_H
44 
45 #include <vfs/ufs/dinode.h>
46 #include <vfs/ufs/fs.h>
47 
48 typedef struct {
49 	char	label[MAXVOLLEN];	/* volume name/label */
50 	int	bsize;		/* block size */
51 	int	fsize;		/* fragment size */
52 	int	cpg;		/* cylinders per group */
53 	int	cpgflg;		/* cpg was specified by user */
54 	int	density;	/* bytes per inode */
55 	int	ntracks;	/* number of tracks */
56 	int	nsectors;	/* number of sectors */
57 	int	rpm;		/* rpm */
58 	int	minfree;	/* free space threshold */
59 	int	optimization;	/* optimization (space or time) */
60 	int	maxcontig;	/* max contiguous blocks to allocate */
61 	int	rotdelay;	/* rotational delay between blocks */
62 	int	maxbpg;		/* maximum blocks per file in a cyl group */
63 	int	nrpos;		/* # of distinguished rotational positions */
64 	int	avgfilesize;	/* expected average file size */
65 	int	avgfpdir;	/* expected # of files per directory */
66 	int	version;	/* filesystem version (1 = FFS, 2 = UFS2) */
67 #ifndef __DragonFly__
68 	int	maxbsize;	/* maximum extent size */
69 #endif
70 	int	maxblkspercg;	/* max # of blocks per cylinder group */
71 	int	softupdates;	/* soft updates */
72 		/* XXX: support `old' file systems ? */
73 } ffs_opt_t;
74 
75 #ifdef __DragonFly__
76 #define	SBLOCK_UFS1		8192
77 #define	SBLOCKSIZE		SBSIZE
78 #define	FS_UFS1_MAGIC		FS_MAGIC
79 
80 #define	csum_total		csum
81 #define	ufs1_daddr_t		ufs_daddr_t
82 
83 #define	fs_old_cgmask		fs_cgmask
84 #define	fs_old_cgoffset		fs_cgoffset
85 #define	fs_old_cpc		fs_cpc
86 #define	fs_old_cpg		fs_cpg
87 #define	fs_old_flags		fs_flags
88 #define	fs_old_inodefmt		fs_inodefmt
89 #define	fs_old_interleave	fs_interleave
90 #define	fs_old_ncyl		fs_ncyl
91 #define	fs_old_npsect		fs_npsect
92 #define	fs_old_nrpos		fs_nrpos
93 #define	fs_old_nsect		fs_nsect
94 #define	fs_old_nspf		fs_nspf
95 #define	fs_old_postblformat	fs_postblformat
96 #define	fs_old_postbloff	fs_postbloff
97 #define	fs_old_rotbloff		fs_rotbloff
98 #define	fs_old_rotdelay		fs_rotdelay
99 #define	fs_old_rps		fs_rps
100 #define	fs_old_spc		fs_spc
101 #define	fs_old_trackskew	fs_trackskew
102 
103 #define	cg_old_boff		cg_boff
104 #define	cg_old_btotoff		cg_btotoff
105 #define	cg_old_ncyl		cg_ncyl
106 #define	cg_old_niblk		cg_niblk
107 #define	cg_old_time		cg_time
108 
109 typedef	__int64_t	makefs_daddr_t;	/* XXX swildner: ours is 32 bits?! */
110 
111 /*
112  * The size of a cylinder group is calculated by CGSIZE. The maximum size
113  * is limited by the fact that cylinder groups are at most one block.
114  * Its size is derived from the size of the maps maintained in the
115  * cylinder group and the (struct cg) size.
116  */
117 
118 /*
119  * XXX swildner: go with FreeBSD's CGSIZE macro until I've figured out
120  *               what's wrong with ours
121  */
122 #define	FBSD_CGSIZE(fs) \
123     /* base cg */	(sizeof(struct cg) + sizeof(int32_t) + \
124     /* old btotoff */	(fs)->fs_cpg * sizeof(int32_t) + \
125     /* old boff */	(fs)->fs_cpg * sizeof(u_int16_t) + \
126     /* inode map */	howmany((fs)->fs_ipg, NBBY) + \
127     /* block map */	howmany((fs)->fs_fpg, NBBY) +\
128     /* if present */	((fs)->fs_contigsumsize <= 0 ? 0 : \
129     /* cluster sum */	(fs)->fs_contigsumsize * sizeof(int32_t) + \
130     /* cluster map */	howmany(fragstoblks(fs, (fs)->fs_fpg), NBBY)))
131 #endif
132 
133 #endif /* _FFS_H */
134