]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - db/agfl.c
Update copyright/license notices to match SGI legal prefered boilerplate.
[thirdparty/xfsprogs-dev.git] / db / agfl.c
CommitLineData
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
1d7e80ee 19#include <xfs/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 31static int agfl_bno_size(void *obj, int startoff);
2bd0ea18
NS
32static int agfl_f(int argc, char **argv);
33static void agfl_help(void);
34
35static const cmdinfo_t agfl_cmd =
dfc130f3 36 { "agfl", NULL, agfl_f, 0, 1, 1, "[agno]",
2bd0ea18
NS
37 "set address to agfl block", agfl_help };
38
9440d84d
NS
39const field_t agfl_hfld[] = { {
40 "", FLDT_AGFL, OI(0), C1, 0, TYP_NONE, },
2bd0ea18
NS
41 { NULL }
42};
43
44#define OFF(f) bitize(offsetof(xfs_agfl_t, agfl_ ## f))
45const field_t agfl_flds[] = {
9440d84d
NS
46 { "bno", FLDT_AGBLOCKNZ, OI(OFF(bno)), agfl_bno_size,
47 FLD_ARRAY|FLD_COUNT, TYP_DATA },
2bd0ea18
NS
48 { NULL }
49};
50
9440d84d
NS
51static int
52agfl_bno_size(
53 void *obj,
54 int startoff)
55{
56 return XFS_AGFL_SIZE(mp);
57}
58
2bd0ea18
NS
59static void
60agfl_help(void)
61{
62 dbprintf(
63"\n"
64" set allocation group freelist\n"
65"\n"
66" Example:\n"
67"\n"
68" agfl 5"
69"\n"
9440d84d 70" Located in the fourth sector of each allocation group,\n"
2bd0ea18 71" the agfl freelist for internal btree space allocation is maintained\n"
dfc130f3 72" for each allocation group. This acts as a reserved pool of space\n"
2bd0ea18
NS
73" separate from the general filesystem freespace (not used for user data).\n"
74"\n"
75);
76
77}
78
79static int
80agfl_f(
81 int argc,
82 char **argv)
83{
84 xfs_agnumber_t agno;
85 char *p;
86
87 if (argc > 1) {
88 agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0);
89 if (*p != '\0' || agno >= mp->m_sb.sb_agcount) {
90 dbprintf("bad allocation group number %s\n", argv[1]);
91 return 0;
92 }
93 cur_agno = agno;
94 } else if (cur_agno == NULLAGNUMBER)
95 cur_agno = 0;
96 ASSERT(typtab[TYP_AGFL].typnm == TYP_AGFL);
9440d84d
NS
97 set_cur(&typtab[TYP_AGFL],
98 XFS_AG_DADDR(mp, cur_agno, XFS_AGFL_DADDR(mp)),
99 XFS_FSS_TO_BB(mp, 1), DB_RING_ADD, NULL);
2bd0ea18
NS
100 return 0;
101}
102
103void
104agfl_init(void)
105{
106 add_command(&agfl_cmd);
107}
108
109/*ARGSUSED*/
110int
111agfl_size(
112 void *obj,
113 int startoff,
114 int idx)
115{
116 return bitize(mp->m_sb.sb_sectsize);
117}