]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
0d3e0b37 | 2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. |
2bd0ea18 NS |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it would be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 | * | |
12 | * Further, this software is distributed without any warranty that it is | |
13 | * free of the rightful claim of any third person regarding infringement | |
14 | * or the like. Any license provided herein, whether implied or | |
15 | * otherwise, applies only to this software file. Patent licenses, if | |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | ||
33 | #include <libxfs.h> | |
34 | #include "command.h" | |
35 | #include "data.h" | |
36 | #include "type.h" | |
37 | #include "faddr.h" | |
38 | #include "fprint.h" | |
39 | #include "field.h" | |
40 | #include "io.h" | |
41 | #include "sb.h" | |
42 | #include "bit.h" | |
43 | #include "output.h" | |
44 | #include "mount.h" | |
45 | ||
46 | static int sb_f(int argc, char **argv); | |
47 | static void sb_help(void); | |
48 | ||
49 | static const cmdinfo_t sb_cmd = | |
50 | { "sb", NULL, sb_f, 0, 1, 1, "[agno]", | |
51 | "set current address to sb header", sb_help }; | |
52 | ||
53 | const field_t sb_hfld[] = { | |
54 | { "", FLDT_SB, OI(0), C1, 0, TYP_NONE }, | |
55 | { NULL } | |
56 | }; | |
57 | ||
58 | #define OFF(f) bitize(offsetof(xfs_sb_t, sb_ ## f)) | |
59 | #define SZC(f) szcount(xfs_sb_t, sb_ ## f) | |
60 | const field_t sb_flds[] = { | |
61 | { "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE }, | |
62 | { "blocksize", FLDT_UINT32D, OI(OFF(blocksize)), C1, 0, TYP_NONE }, | |
63 | { "dblocks", FLDT_DRFSBNO, OI(OFF(dblocks)), C1, 0, TYP_NONE }, | |
64 | { "rblocks", FLDT_DRFSBNO, OI(OFF(rblocks)), C1, 0, TYP_NONE }, | |
65 | { "rextents", FLDT_DRTBNO, OI(OFF(rextents)), C1, 0, TYP_NONE }, | |
66 | { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, | |
67 | { "logstart", FLDT_DFSBNO, OI(OFF(logstart)), C1, 0, TYP_LOG }, | |
68 | { "rootino", FLDT_INO, OI(OFF(rootino)), C1, 0, TYP_INODE }, | |
69 | { "rbmino", FLDT_INO, OI(OFF(rbmino)), C1, 0, TYP_INODE }, | |
70 | { "rsumino", FLDT_INO, OI(OFF(rsumino)), C1, 0, TYP_INODE }, | |
71 | { "rextsize", FLDT_AGBLOCK, OI(OFF(rextsize)), C1, 0, TYP_NONE }, | |
72 | { "agblocks", FLDT_AGBLOCK, OI(OFF(agblocks)), C1, 0, TYP_NONE }, | |
73 | { "agcount", FLDT_AGNUMBER, OI(OFF(agcount)), C1, 0, TYP_NONE }, | |
74 | { "rbmblocks", FLDT_EXTLEN, OI(OFF(rbmblocks)), C1, 0, TYP_NONE }, | |
75 | { "logblocks", FLDT_EXTLEN, OI(OFF(logblocks)), C1, 0, TYP_NONE }, | |
76 | { "versionnum", FLDT_UINT16X, OI(OFF(versionnum)), C1, 0, TYP_NONE }, | |
77 | { "sectsize", FLDT_UINT16D, OI(OFF(sectsize)), C1, 0, TYP_NONE }, | |
78 | { "inodesize", FLDT_UINT16D, OI(OFF(inodesize)), C1, 0, TYP_NONE }, | |
79 | { "inopblock", FLDT_UINT16D, OI(OFF(inopblock)), C1, 0, TYP_NONE }, | |
80 | { "fname", FLDT_CHARNS, OI(OFF(fname)), CI(SZC(fname)), 0, TYP_NONE }, | |
81 | { "blocklog", FLDT_UINT8D, OI(OFF(blocklog)), C1, 0, TYP_NONE }, | |
82 | { "sectlog", FLDT_UINT8D, OI(OFF(sectlog)), C1, 0, TYP_NONE }, | |
83 | { "inodelog", FLDT_UINT8D, OI(OFF(inodelog)), C1, 0, TYP_NONE }, | |
84 | { "inopblog", FLDT_UINT8D, OI(OFF(inopblog)), C1, 0, TYP_NONE }, | |
85 | { "agblklog", FLDT_UINT8D, OI(OFF(agblklog)), C1, 0, TYP_NONE }, | |
86 | { "rextslog", FLDT_UINT8D, OI(OFF(rextslog)), C1, 0, TYP_NONE }, | |
87 | { "inprogress", FLDT_UINT8D, OI(OFF(inprogress)), C1, 0, TYP_NONE }, | |
88 | { "imax_pct", FLDT_UINT8D, OI(OFF(imax_pct)), C1, 0, TYP_NONE }, | |
89 | { "icount", FLDT_UINT64D, OI(OFF(icount)), C1, 0, TYP_NONE }, | |
90 | { "ifree", FLDT_UINT64D, OI(OFF(ifree)), C1, 0, TYP_NONE }, | |
91 | { "fdblocks", FLDT_UINT64D, OI(OFF(fdblocks)), C1, 0, TYP_NONE }, | |
92 | { "frextents", FLDT_UINT64D, OI(OFF(frextents)), C1, 0, TYP_NONE }, | |
93 | { "uquotino", FLDT_INO, OI(OFF(uquotino)), C1, 0, TYP_INODE }, | |
b36eef04 | 94 | { "gquotino", FLDT_INO, OI(OFF(gquotino)), C1, 0, TYP_INODE }, |
2bd0ea18 NS |
95 | { "qflags", FLDT_UINT16X, OI(OFF(qflags)), C1, 0, TYP_NONE }, |
96 | { "flags", FLDT_UINT8X, OI(OFF(flags)), C1, 0, TYP_NONE }, | |
97 | { "shared_vn", FLDT_UINT8D, OI(OFF(shared_vn)), C1, 0, TYP_NONE }, | |
98 | { "inoalignmt", FLDT_EXTLEN, OI(OFF(inoalignmt)), C1, 0, TYP_NONE }, | |
99 | { "unit", FLDT_UINT32D, OI(OFF(unit)), C1, 0, TYP_NONE }, | |
100 | { "width", FLDT_UINT32D, OI(OFF(width)), C1, 0, TYP_NONE }, | |
101 | { "dirblklog", FLDT_UINT8D, OI(OFF(dirblklog)), C1, 0, TYP_NONE }, | |
102 | { NULL } | |
103 | }; | |
104 | ||
105 | static void | |
106 | sb_help(void) | |
107 | { | |
108 | dbprintf( | |
109 | "\n" | |
110 | " set allocation group superblock\n" | |
111 | "\n" | |
112 | " Example:\n" | |
113 | "\n" | |
114 | " 'sb 7' - set location to 7th allocation group superblock, set type to 'sb'\n" | |
115 | "\n" | |
116 | " Located in the 1st 512 byte block of each allocation group,\n" | |
117 | " the superblock contains the base information for the filesystem.\n" | |
118 | " The superblock in allocation group 0 is the primary. The copies in the\n" | |
119 | " remaining allocation groups only serve as backup for filesystem recovery.\n" | |
120 | " The icount/ifree/fdblocks/frextents are only updated in superblock 0.\n" | |
121 | "\n" | |
122 | ); | |
123 | } | |
124 | ||
125 | static int | |
126 | sb_f( | |
127 | int argc, | |
128 | char **argv) | |
129 | { | |
130 | xfs_agnumber_t agno; | |
131 | char *p; | |
132 | ||
133 | if (argc > 1) { | |
134 | agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0); | |
135 | if (*p != '\0' || agno >= mp->m_sb.sb_agcount) { | |
136 | dbprintf("bad allocation group number %s\n", argv[1]); | |
137 | return 0; | |
138 | } | |
139 | cur_agno = agno; | |
140 | } else if (cur_agno == NULLAGNUMBER) | |
141 | cur_agno = 0; | |
142 | ASSERT(typtab[TYP_SB].typnm == TYP_SB); | |
143 | set_cur(&typtab[TYP_SB], XFS_AG_DADDR(mp, cur_agno, XFS_SB_DADDR), 1, | |
144 | DB_RING_ADD, NULL); | |
145 | return 0; | |
146 | } | |
147 | ||
148 | void | |
149 | sb_init(void) | |
150 | { | |
151 | add_command(&sb_cmd); | |
152 | } | |
153 | ||
154 | /*ARGSUSED*/ | |
155 | int | |
156 | sb_size( | |
157 | void *obj, | |
158 | int startoff, | |
159 | int idx) | |
160 | { | |
161 | return bitize(mp->m_sb.sb_sectsize); | |
162 | } |