]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
0d3e0b37 | 2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. |
dfc130f3 | 3 | * |
2bd0ea18 NS |
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. | |
dfc130f3 | 7 | * |
2bd0ea18 NS |
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. | |
dfc130f3 | 11 | * |
2bd0ea18 NS |
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. | |
dfc130f3 | 18 | * |
2bd0ea18 NS |
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. | |
dfc130f3 | 22 | * |
2bd0ea18 NS |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
24 | * Mountain View, CA 94043, or: | |
dfc130f3 RC |
25 | * |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
2bd0ea18 NS |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ |
31 | */ | |
32 | ||
1d7e80ee | 33 | #include <xfs/libxfs.h> |
2bd0ea18 NS |
34 | #include "agf.h" |
35 | #include "command.h" | |
2bd0ea18 NS |
36 | #include "type.h" |
37 | #include "faddr.h" | |
38 | #include "fprint.h" | |
39 | #include "field.h" | |
40 | #include "io.h" | |
41 | #include "bit.h" | |
42 | #include "output.h" | |
4ca431fc | 43 | #include "init.h" |
2bd0ea18 NS |
44 | |
45 | static int agf_f(int argc, char **argv); | |
46 | static void agf_help(void); | |
47 | ||
48 | static const cmdinfo_t agf_cmd = | |
49 | { "agf", NULL, agf_f, 0, 1, 1, "[agno]", | |
50 | "set address to agf header", agf_help }; | |
51 | ||
52 | const field_t agf_hfld[] = { | |
53 | { "", FLDT_AGF, OI(0), C1, 0, TYP_NONE }, | |
54 | { NULL } | |
55 | }; | |
56 | ||
57 | #define OFF(f) bitize(offsetof(xfs_agf_t, agf_ ## f)) | |
58 | #define SZ(f) bitszof(xfs_agf_t, agf_ ## f) | |
59 | const field_t agf_flds[] = { | |
60 | { "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE }, | |
61 | { "versionnum", FLDT_UINT32D, OI(OFF(versionnum)), C1, 0, TYP_NONE }, | |
62 | { "seqno", FLDT_AGNUMBER, OI(OFF(seqno)), C1, 0, TYP_NONE }, | |
63 | { "length", FLDT_AGBLOCK, OI(OFF(length)), C1, 0, TYP_NONE }, | |
64 | { "roots", FLDT_AGBLOCK, OI(OFF(roots)), CI(XFS_BTNUM_AGF), | |
65 | FLD_ARRAY|FLD_SKIPALL, TYP_NONE }, | |
66 | { "bnoroot", FLDT_AGBLOCK, | |
67 | OI(OFF(roots) + XFS_BTNUM_BNO * SZ(roots[XFS_BTNUM_BNO])), C1, 0, | |
68 | TYP_BNOBT }, | |
69 | { "cntroot", FLDT_AGBLOCK, | |
70 | OI(OFF(roots) + XFS_BTNUM_CNT * SZ(roots[XFS_BTNUM_CNT])), C1, 0, | |
71 | TYP_CNTBT }, | |
72 | { "levels", FLDT_UINT32D, OI(OFF(levels)), CI(XFS_BTNUM_AGF), | |
73 | FLD_ARRAY|FLD_SKIPALL, TYP_NONE }, | |
74 | { "bnolevel", FLDT_UINT32D, | |
75 | OI(OFF(levels) + XFS_BTNUM_BNO * SZ(levels[XFS_BTNUM_BNO])), C1, 0, | |
76 | TYP_NONE }, | |
77 | { "cntlevel", FLDT_UINT32D, | |
78 | OI(OFF(levels) + XFS_BTNUM_CNT * SZ(levels[XFS_BTNUM_CNT])), C1, 0, | |
79 | TYP_NONE }, | |
80 | { "flfirst", FLDT_UINT32D, OI(OFF(flfirst)), C1, 0, TYP_NONE }, | |
81 | { "fllast", FLDT_UINT32D, OI(OFF(fllast)), C1, 0, TYP_NONE }, | |
82 | { "flcount", FLDT_UINT32D, OI(OFF(flcount)), C1, 0, TYP_NONE }, | |
83 | { "freeblks", FLDT_EXTLEN, OI(OFF(freeblks)), C1, 0, TYP_NONE }, | |
84 | { "longest", FLDT_EXTLEN, OI(OFF(longest)), C1, 0, TYP_NONE }, | |
85 | { NULL } | |
86 | }; | |
87 | ||
88 | static void | |
89 | agf_help(void) | |
90 | { | |
91 | dbprintf( | |
92 | "\n" | |
93 | " set allocation group free block list\n" | |
94 | "\n" | |
95 | " Example:\n" | |
96 | "\n" | |
97 | " agf 2 - move location to AGF in 2nd filesystem allocation group\n" | |
98 | "\n" | |
9440d84d NS |
99 | " Located in the second sector of each allocation group, the AGF\n" |
100 | " contains the root of two different freespace btrees:\n" | |
2bd0ea18 NS |
101 | " The 'cnt' btree keeps track freespace indexed on section size.\n" |
102 | " The 'bno' btree tracks sections of freespace indexed on block number.\n" | |
103 | ); | |
104 | } | |
105 | ||
106 | static int | |
107 | agf_f( | |
108 | int argc, | |
109 | char **argv) | |
110 | { | |
111 | xfs_agnumber_t agno; | |
112 | char *p; | |
113 | ||
114 | if (argc > 1) { | |
115 | agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0); | |
116 | if (*p != '\0' || agno >= mp->m_sb.sb_agcount) { | |
117 | dbprintf("bad allocation group number %s\n", argv[1]); | |
118 | return 0; | |
119 | } | |
120 | cur_agno = agno; | |
121 | } else if (cur_agno == NULLAGNUMBER) | |
122 | cur_agno = 0; | |
123 | ASSERT(typtab[TYP_AGF].typnm == TYP_AGF); | |
9440d84d NS |
124 | set_cur(&typtab[TYP_AGF], |
125 | XFS_AG_DADDR(mp, cur_agno, XFS_AGF_DADDR(mp)), | |
126 | XFS_FSS_TO_BB(mp, 1), DB_RING_ADD, NULL); | |
2bd0ea18 NS |
127 | return 0; |
128 | } | |
129 | ||
130 | void | |
131 | agf_init(void) | |
132 | { | |
133 | add_command(&agf_cmd); | |
134 | } | |
135 | ||
136 | int | |
137 | agf_size( | |
138 | void *obj, | |
139 | int startoff, | |
140 | int idx) | |
141 | { | |
142 | return bitize(mp->m_sb.sb_sectsize); | |
143 | } |