]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
da23017d NS |
2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
dfc130f3 | 4 | * |
da23017d NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
2bd0ea18 | 7 | * published by the Free Software Foundation. |
dfc130f3 | 8 | * |
da23017d NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
dfc130f3 | 13 | * |
da23017d NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
2bd0ea18 NS |
17 | */ |
18 | ||
6b803e5a | 19 | #include "libxfs.h" |
2bd0ea18 | 20 | #include "command.h" |
2bd0ea18 NS |
21 | #include "type.h" |
22 | #include "faddr.h" | |
23 | #include "fprint.h" | |
24 | #include "field.h" | |
25 | #include "io.h" | |
26 | #include "bit.h" | |
27 | #include "output.h" | |
4ca431fc | 28 | #include "init.h" |
28d8e155 | 29 | #include "agfl.h" |
2bd0ea18 | 30 | |
9440d84d | 31 | static int agfl_bno_size(void *obj, int startoff); |
2bd0ea18 NS |
32 | static int agfl_f(int argc, char **argv); |
33 | static void agfl_help(void); | |
34 | ||
35 | static const cmdinfo_t agfl_cmd = | |
9ee7055c AM |
36 | { "agfl", NULL, agfl_f, 0, 1, 1, N_("[agno]"), |
37 | N_("set address to agfl block"), agfl_help }; | |
2bd0ea18 | 38 | |
9440d84d NS |
39 | const field_t agfl_hfld[] = { { |
40 | "", FLDT_AGFL, OI(0), C1, 0, TYP_NONE, }, | |
2bd0ea18 NS |
41 | { NULL } |
42 | }; | |
43 | ||
c2907bd7 DC |
44 | const field_t agfl_crc_hfld[] = { { |
45 | "", FLDT_AGFL_CRC, OI(0), C1, 0, TYP_NONE, }, | |
46 | { NULL } | |
47 | }; | |
48 | ||
2bd0ea18 NS |
49 | #define OFF(f) bitize(offsetof(xfs_agfl_t, agfl_ ## f)) |
50 | const field_t agfl_flds[] = { | |
c2907bd7 DC |
51 | { "bno", FLDT_AGBLOCKNZ, OI(OFF(magicnum)), agfl_bno_size, |
52 | FLD_ARRAY|FLD_COUNT, TYP_DATA }, | |
53 | { NULL } | |
54 | }; | |
55 | ||
56 | const field_t agfl_crc_flds[] = { | |
57 | { "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE }, | |
58 | { "seqno", FLDT_AGNUMBER, OI(OFF(seqno)), C1, 0, TYP_NONE }, | |
59 | { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, | |
60 | { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, | |
0522f1cc | 61 | { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE }, |
9440d84d NS |
62 | { "bno", FLDT_AGBLOCKNZ, OI(OFF(bno)), agfl_bno_size, |
63 | FLD_ARRAY|FLD_COUNT, TYP_DATA }, | |
2bd0ea18 NS |
64 | { NULL } |
65 | }; | |
66 | ||
9440d84d NS |
67 | static int |
68 | agfl_bno_size( | |
69 | void *obj, | |
70 | int startoff) | |
71 | { | |
72 | return XFS_AGFL_SIZE(mp); | |
73 | } | |
74 | ||
2bd0ea18 NS |
75 | static void |
76 | agfl_help(void) | |
77 | { | |
9ee7055c | 78 | dbprintf(_( |
2bd0ea18 NS |
79 | "\n" |
80 | " set allocation group freelist\n" | |
81 | "\n" | |
82 | " Example:\n" | |
83 | "\n" | |
84 | " agfl 5" | |
85 | "\n" | |
9440d84d | 86 | " Located in the fourth sector of each allocation group,\n" |
2bd0ea18 | 87 | " the agfl freelist for internal btree space allocation is maintained\n" |
dfc130f3 | 88 | " for each allocation group. This acts as a reserved pool of space\n" |
2bd0ea18 NS |
89 | " separate from the general filesystem freespace (not used for user data).\n" |
90 | "\n" | |
9ee7055c | 91 | )); |
2bd0ea18 NS |
92 | |
93 | } | |
94 | ||
95 | static int | |
96 | agfl_f( | |
97 | int argc, | |
98 | char **argv) | |
99 | { | |
100 | xfs_agnumber_t agno; | |
101 | char *p; | |
102 | ||
103 | if (argc > 1) { | |
104 | agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0); | |
105 | if (*p != '\0' || agno >= mp->m_sb.sb_agcount) { | |
9ee7055c | 106 | dbprintf(_("bad allocation group number %s\n"), argv[1]); |
2bd0ea18 NS |
107 | return 0; |
108 | } | |
109 | cur_agno = agno; | |
110 | } else if (cur_agno == NULLAGNUMBER) | |
111 | cur_agno = 0; | |
112 | ASSERT(typtab[TYP_AGFL].typnm == TYP_AGFL); | |
9440d84d NS |
113 | set_cur(&typtab[TYP_AGFL], |
114 | XFS_AG_DADDR(mp, cur_agno, XFS_AGFL_DADDR(mp)), | |
115 | XFS_FSS_TO_BB(mp, 1), DB_RING_ADD, NULL); | |
2bd0ea18 NS |
116 | return 0; |
117 | } | |
118 | ||
119 | void | |
120 | agfl_init(void) | |
121 | { | |
122 | add_command(&agfl_cmd); | |
123 | } | |
124 | ||
125 | /*ARGSUSED*/ | |
126 | int | |
127 | agfl_size( | |
128 | void *obj, | |
129 | int startoff, | |
130 | int idx) | |
131 | { | |
132 | return bitize(mp->m_sb.sb_sectsize); | |
133 | } |