]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - db/agi.c
xfsprogs: document environment variables
[thirdparty/xfsprogs-dev.git] / db / agi.c
CommitLineData
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 "agi.h"
2bd0ea18
NS
18
19static int agi_f(int argc, char **argv);
20static void agi_help(void);
21
22static const cmdinfo_t agi_cmd =
9ee7055c
AM
23 { "agi", NULL, agi_f, 0, 1, 1, N_("[agno]"),
24 N_("set address to agi header"), agi_help };
2bd0ea18
NS
25
26const field_t agi_hfld[] = {
27 { "", FLDT_AGI, OI(0), C1, 0, TYP_NONE },
28 { NULL }
29};
30
31#define OFF(f) bitize(offsetof(xfs_agi_t, agi_ ## f))
32const field_t agi_flds[] = {
33 { "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE },
34 { "versionnum", FLDT_UINT32D, OI(OFF(versionnum)), C1, 0, TYP_NONE },
35 { "seqno", FLDT_AGNUMBER, OI(OFF(seqno)), C1, 0, TYP_NONE },
36 { "length", FLDT_AGBLOCK, OI(OFF(length)), C1, 0, TYP_NONE },
37 { "count", FLDT_AGINO, OI(OFF(count)), C1, 0, TYP_NONE },
38 { "root", FLDT_AGBLOCK, OI(OFF(root)), C1, 0, TYP_INOBT },
39 { "level", FLDT_UINT32D, OI(OFF(level)), C1, 0, TYP_NONE },
40 { "freecount", FLDT_AGINO, OI(OFF(freecount)), C1, 0, TYP_NONE },
41 { "newino", FLDT_AGINO, OI(OFF(newino)), C1, 0, TYP_INODE },
42 { "dirino", FLDT_AGINO, OI(OFF(dirino)), C1, 0, TYP_INODE },
43 { "unlinked", FLDT_AGINONN, OI(OFF(unlinked)),
44 CI(XFS_AGI_UNLINKED_BUCKETS), FLD_ARRAY, TYP_NONE },
c2907bd7 45 { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
0522f1cc 46 { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE },
70c1cceb
DW
47 { "pad32", FLDT_UINT32X, OI(OFF(pad32)), C1, FLD_SKIPALL, TYP_NONE },
48 { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
61a15567 49 { "free_root", FLDT_AGBLOCK, OI(OFF(free_root)), C1, 0, TYP_FINOBT },
2a0cd7ad 50 { "free_level", FLDT_UINT32D, OI(OFF(free_level)), C1, 0, TYP_NONE },
2bd0ea18
NS
51 { NULL }
52};
53
54static void
55agi_help(void)
56{
9ee7055c 57 dbprintf(_(
2bd0ea18
NS
58"\n"
59" set allocation group inode btree\n"
60"\n"
61" Example:\n"
62"\n"
63" agi 3 (set location to 3rd allocation group inode btree and type to 'agi')\n"
64"\n"
65" Located in the 3rd 512 byte block of each allocation group,\n"
66" the agi inode btree tracks all used/free inodes in the allocation group.\n"
67" Inodes are allocated in 16k 'chunks', each btree entry tracks a 'chunk'.\n"
68"\n"
9ee7055c 69));
2bd0ea18
NS
70}
71
72static int
73agi_f(
74 int argc,
75 char **argv)
76{
77 xfs_agnumber_t agno;
78 char *p;
79
80 if (argc > 1) {
81 agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0);
82 if (*p != '\0' || agno >= mp->m_sb.sb_agcount) {
9ee7055c 83 dbprintf(_("bad allocation group number %s\n"), argv[1]);
2bd0ea18
NS
84 return 0;
85 }
86 cur_agno = agno;
87 } else if (cur_agno == NULLAGNUMBER)
88 cur_agno = 0;
89 ASSERT(typtab[TYP_AGI].typnm == TYP_AGI);
9440d84d
NS
90 set_cur(&typtab[TYP_AGI],
91 XFS_AG_DADDR(mp, cur_agno, XFS_AGI_DADDR(mp)),
92 XFS_FSS_TO_BB(mp, 1), DB_RING_ADD, NULL);
2bd0ea18
NS
93 return 0;
94}
95
96void
97agi_init(void)
98{
99 add_command(&agi_cmd);
100}
101
102/*ARGSUSED*/
103int
104agi_size(
105 void *obj,
106 int startoff,
107 int idx)
108{
109 return bitize(mp->m_sb.sb_sectsize);
110}