]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/tools/find-sb/mini_ufs.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / tools / find-sb / mini_ufs.h
1 /*
2  * This program, created 2002-10-03 by Garrett A. Wollman
3  * <wollman@FreeBSD.org>, is in the public domain.  Use at your own risk.
4  *
5  * $FreeBSD$
6  */
7
8 /*
9  * Small extract from ufs/ffs/fs.h to get definition of superblock
10  * in order to make this tool portable to other unix-like systems.
11  *
12  * Based upon:
13  *
14  * FreeBSD: src/sys/ufs/ffs/fs.h,v 1.48 2005/02/20 08:02:15 delphij
15  * FreeBSD: src/sys/ufs/ufs/dinode.h,v 1.15 2005/01/07 02:29:26 imp
16  */
17
18 #include <sys/types.h>
19
20 #define SBLOCKSIZE      8192
21 #define DEV_BSIZE       (1<<9)
22 #define FS_UFS1_MAGIC   0x011954
23 #define FS_UFS2_MAGIC   0x19540119
24 #define SBLOCK_UFS1     8192
25 #define SBLOCK_UFS2     65536
26 #define MAXMNTLEN       468
27 #define MAXVOLLEN       32
28 #define NOCSPTRS        ((128 / sizeof(void *)) - 4)
29 #define FSMAXSNAP       20
30
31 typedef int64_t ufs_time_t;
32 typedef int64_t ufs2_daddr_t;
33
34 struct csum {
35         int32_t cs_ndir;                /* number of directories */
36         int32_t cs_nbfree;              /* number of free blocks */
37         int32_t cs_nifree;              /* number of free inodes */
38         int32_t cs_nffree;              /* number of free frags */
39 };
40
41 struct csum_total {
42         int64_t cs_ndir;                /* number of directories */
43         int64_t cs_nbfree;              /* number of free blocks */
44         int64_t cs_nifree;              /* number of free inodes */
45         int64_t cs_nffree;              /* number of free frags */
46         int64_t cs_numclusters;         /* number of free clusters */
47         int64_t cs_spare[3];            /* future expansion */
48 };
49
50 /*
51  * Super block for an FFS filesystem.
52  */
53 struct fs {
54         int32_t  fs_firstfield;         /* historic filesystem linked list, */
55         int32_t  fs_unused_1;           /*     used for incore super blocks */
56         int32_t  fs_sblkno;             /* offset of super-block in filesys */
57         int32_t  fs_cblkno;             /* offset of cyl-block in filesys */
58         int32_t  fs_iblkno;             /* offset of inode-blocks in filesys */
59         int32_t  fs_dblkno;             /* offset of first data after cg */
60         int32_t  fs_old_cgoffset;       /* cylinder group offset in cylinder */
61         int32_t  fs_old_cgmask;         /* used to calc mod fs_ntrak */
62         int32_t  fs_old_time;           /* last time written */
63         int32_t  fs_old_size;           /* number of blocks in fs */
64         int32_t  fs_old_dsize;          /* number of data blocks in fs */
65         int32_t  fs_ncg;                /* number of cylinder groups */
66         int32_t  fs_bsize;              /* size of basic blocks in fs */
67         int32_t  fs_fsize;              /* size of frag blocks in fs */
68         int32_t  fs_frag;               /* number of frags in a block in fs */
69 /* these are configuration parameters */
70         int32_t  fs_minfree;            /* minimum percentage of free blocks */
71         int32_t  fs_old_rotdelay;       /* num of ms for optimal next block */
72         int32_t  fs_old_rps;            /* disk revolutions per second */
73 /* these fields can be computed from the others */
74         int32_t  fs_bmask;              /* ``blkoff'' calc of blk offsets */
75         int32_t  fs_fmask;              /* ``fragoff'' calc of frag offsets */
76         int32_t  fs_bshift;             /* ``lblkno'' calc of logical blkno */
77         int32_t  fs_fshift;             /* ``numfrags'' calc number of frags */
78 /* these are configuration parameters */
79         int32_t  fs_maxcontig;          /* max number of contiguous blks */
80         int32_t  fs_maxbpg;             /* max number of blks per cyl group */
81 /* these fields can be computed from the others */
82         int32_t  fs_fragshift;          /* block to frag shift */
83         int32_t  fs_fsbtodb;            /* fsbtodb and dbtofsb shift constant */
84         int32_t  fs_sbsize;             /* actual size of super block */
85         int32_t  fs_spare1[2];          /* old fs_csmask */
86                                         /* old fs_csshift */
87         int32_t  fs_nindir;             /* value of NINDIR */
88         int32_t  fs_inopb;              /* value of INOPB */
89         int32_t  fs_old_nspf;           /* value of NSPF */
90 /* yet another configuration parameter */
91         int32_t  fs_optim;              /* optimization preference, see below */
92         int32_t  fs_old_npsect;         /* # sectors/track including spares */
93         int32_t  fs_old_interleave;     /* hardware sector interleave */
94         int32_t  fs_old_trackskew;      /* sector 0 skew, per track */
95         int32_t  fs_id[2];              /* unique filesystem id */
96 /* sizes determined by number of cylinder groups and their sizes */
97         int32_t  fs_old_csaddr;         /* blk addr of cyl grp summary area */
98         int32_t  fs_cssize;             /* size of cyl grp summary area */
99         int32_t  fs_cgsize;             /* cylinder group size */
100         int32_t  fs_spare2;             /* old fs_ntrak */
101         int32_t  fs_old_nsect;          /* sectors per track */
102         int32_t  fs_old_spc;            /* sectors per cylinder */
103         int32_t  fs_old_ncyl;           /* cylinders in filesystem */
104         int32_t  fs_old_cpg;            /* cylinders per group */
105         int32_t  fs_ipg;                /* inodes per group */
106         int32_t  fs_fpg;                /* blocks per group * fs_frag */
107 /* this data must be re-computed after crashes */
108         struct  csum fs_old_cstotal;    /* cylinder summary information */
109 /* these fields are cleared at mount time */
110         int8_t   fs_fmod;               /* super block modified flag */
111         int8_t   fs_clean;              /* filesystem is clean flag */
112         int8_t   fs_ronly;              /* mounted read-only flag */
113         int8_t   fs_old_flags;          /* old FS_ flags */
114         u_char   fs_fsmnt[MAXMNTLEN];   /* name mounted on */
115         u_char   fs_volname[MAXVOLLEN]; /* volume name */
116         u_int64_t fs_swuid;             /* system-wide uid */
117         int32_t  fs_pad;                /* due to alignment of fs_swuid */
118 /* these fields retain the current block allocation info */
119         int32_t  fs_cgrotor;            /* last cg searched */
120         void    *fs_ocsp[NOCSPTRS];     /* padding; was list of fs_cs buffers */
121         u_int8_t *fs_contigdirs;        /* (u) # of contig. allocated dirs */
122         struct  csum *fs_csp;           /* (u) cg summary info buffer */
123         int32_t *fs_maxcluster;         /* (u) max cluster in each cyl group */
124         u_int   *fs_active;             /* (u) used by snapshots to track fs */
125         int32_t  fs_old_cpc;            /* cyl per cycle in postbl */
126         int32_t  fs_maxbsize;           /* maximum blocking factor permitted */
127         int64_t  fs_unrefs;             /* number of unreferenced inodes */
128         int64_t  fs_sparecon64[16];     /* old rotation block list head */
129         int64_t  fs_sblockloc;          /* byte offset of standard superblock */
130         struct  csum_total fs_cstotal;  /* (u) cylinder summary information */
131         ufs_time_t fs_time;             /* last time written */
132         int64_t  fs_size;               /* number of blocks in fs */
133         int64_t  fs_dsize;              /* number of data blocks in fs */
134         ufs2_daddr_t fs_csaddr;         /* blk addr of cyl grp summary area */
135         int64_t  fs_pendingblocks;      /* (u) blocks being freed */
136         int32_t  fs_pendinginodes;      /* (u) inodes being freed */
137         int32_t  fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
138         int32_t  fs_avgfilesize;        /* expected average file size */
139         int32_t  fs_avgfpdir;           /* expected # of files per directory */
140         int32_t  fs_save_cgsize;        /* save real cg size to use fs_bsize */
141         int32_t  fs_sparecon32[26];     /* reserved for future constants */
142         int32_t  fs_flags;              /* see FS_ flags below */
143         int32_t  fs_contigsumsize;      /* size of cluster summary array */ 
144         int32_t  fs_maxsymlinklen;      /* max length of an internal symlink */
145         int32_t  fs_old_inodefmt;       /* format of on-disk inodes */
146         u_int64_t fs_maxfilesize;       /* maximum representable file size */
147         int64_t  fs_qbmask;             /* ~fs_bmask for use with 64-bit size */
148         int64_t  fs_qfmask;             /* ~fs_fmask for use with 64-bit size */
149         int32_t  fs_state;              /* validate fs_clean field */
150         int32_t  fs_old_postblformat;   /* format of positional layout tables */
151         int32_t  fs_old_nrpos;          /* number of rotational positions */
152         int32_t  fs_spare5[2];          /* old fs_postbloff */
153                                         /* old fs_rotbloff */
154         int32_t  fs_magic;              /* magic number */
155 };