]>
Commit | Line | Data |
---|---|---|
959ef981 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2bd0ea18 | 2 | /* |
da23017d NS |
3 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
2bd0ea18 NS |
5 | */ |
6 | ||
6b803e5a | 7 | #include "libxfs.h" |
2bd0ea18 | 8 | #include "command.h" |
2bd0ea18 NS |
9 | #include "type.h" |
10 | #include "faddr.h" | |
11 | #include "fprint.h" | |
12 | #include "field.h" | |
13 | #include "io.h" | |
14 | #include "bit.h" | |
15 | #include "output.h" | |
4ca431fc | 16 | #include "init.h" |
28d8e155 | 17 | #include "agfl.h" |
2bd0ea18 | 18 | |
9440d84d | 19 | static int agfl_bno_size(void *obj, int startoff); |
2bd0ea18 NS |
20 | static int agfl_f(int argc, char **argv); |
21 | static void agfl_help(void); | |
22 | ||
23 | static const cmdinfo_t agfl_cmd = | |
9ee7055c AM |
24 | { "agfl", NULL, agfl_f, 0, 1, 1, N_("[agno]"), |
25 | N_("set address to agfl block"), agfl_help }; | |
2bd0ea18 | 26 | |
9440d84d NS |
27 | const field_t agfl_hfld[] = { { |
28 | "", FLDT_AGFL, OI(0), C1, 0, TYP_NONE, }, | |
2bd0ea18 NS |
29 | { NULL } |
30 | }; | |
31 | ||
c2907bd7 DC |
32 | const field_t agfl_crc_hfld[] = { { |
33 | "", FLDT_AGFL_CRC, OI(0), C1, 0, TYP_NONE, }, | |
34 | { NULL } | |
35 | }; | |
36 | ||
2bd0ea18 NS |
37 | #define OFF(f) bitize(offsetof(xfs_agfl_t, agfl_ ## f)) |
38 | const field_t agfl_flds[] = { | |
c2907bd7 DC |
39 | { "bno", FLDT_AGBLOCKNZ, OI(OFF(magicnum)), agfl_bno_size, |
40 | FLD_ARRAY|FLD_COUNT, TYP_DATA }, | |
41 | { NULL } | |
42 | }; | |
43 | ||
44 | const field_t agfl_crc_flds[] = { | |
45 | { "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE }, | |
46 | { "seqno", FLDT_AGNUMBER, OI(OFF(seqno)), C1, 0, TYP_NONE }, | |
47 | { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, | |
48 | { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, | |
0522f1cc | 49 | { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE }, |
9440d84d NS |
50 | { "bno", FLDT_AGBLOCKNZ, OI(OFF(bno)), agfl_bno_size, |
51 | FLD_ARRAY|FLD_COUNT, TYP_DATA }, | |
2bd0ea18 NS |
52 | { NULL } |
53 | }; | |
54 | ||
9440d84d NS |
55 | static int |
56 | agfl_bno_size( | |
57 | void *obj, | |
58 | int startoff) | |
59 | { | |
b8165508 | 60 | return libxfs_agfl_size(mp); |
9440d84d NS |
61 | } |
62 | ||
2bd0ea18 NS |
63 | static void |
64 | agfl_help(void) | |
65 | { | |
9ee7055c | 66 | dbprintf(_( |
2bd0ea18 NS |
67 | "\n" |
68 | " set allocation group freelist\n" | |
69 | "\n" | |
70 | " Example:\n" | |
71 | "\n" | |
72 | " agfl 5" | |
73 | "\n" | |
9440d84d | 74 | " Located in the fourth sector of each allocation group,\n" |
2bd0ea18 | 75 | " the agfl freelist for internal btree space allocation is maintained\n" |
dfc130f3 | 76 | " for each allocation group. This acts as a reserved pool of space\n" |
2bd0ea18 NS |
77 | " separate from the general filesystem freespace (not used for user data).\n" |
78 | "\n" | |
9ee7055c | 79 | )); |
2bd0ea18 NS |
80 | |
81 | } | |
82 | ||
83 | static int | |
84 | agfl_f( | |
85 | int argc, | |
86 | char **argv) | |
87 | { | |
88 | xfs_agnumber_t agno; | |
89 | char *p; | |
90 | ||
91 | if (argc > 1) { | |
92 | agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0); | |
93 | if (*p != '\0' || agno >= mp->m_sb.sb_agcount) { | |
9ee7055c | 94 | dbprintf(_("bad allocation group number %s\n"), argv[1]); |
2bd0ea18 NS |
95 | return 0; |
96 | } | |
97 | cur_agno = agno; | |
98 | } else if (cur_agno == NULLAGNUMBER) | |
99 | cur_agno = 0; | |
100 | ASSERT(typtab[TYP_AGFL].typnm == TYP_AGFL); | |
9440d84d NS |
101 | set_cur(&typtab[TYP_AGFL], |
102 | XFS_AG_DADDR(mp, cur_agno, XFS_AGFL_DADDR(mp)), | |
103 | XFS_FSS_TO_BB(mp, 1), DB_RING_ADD, NULL); | |
2bd0ea18 NS |
104 | return 0; |
105 | } | |
106 | ||
107 | void | |
108 | agfl_init(void) | |
109 | { | |
110 | add_command(&agfl_cmd); | |
111 | } | |
112 | ||
113 | /*ARGSUSED*/ | |
114 | int | |
115 | agfl_size( | |
116 | void *obj, | |
117 | int startoff, | |
118 | int idx) | |
119 | { | |
120 | return bitize(mp->m_sb.sb_sectsize); | |
121 | } |