]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/agi.c
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
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
7 * published by the Free Software Foundation.
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.
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
31 static int agi_f(int argc
, char **argv
);
32 static void agi_help(void);
34 static const cmdinfo_t agi_cmd
=
35 { "agi", NULL
, agi_f
, 0, 1, 1, N_("[agno]"),
36 N_("set address to agi header"), agi_help
};
38 const field_t agi_hfld
[] = {
39 { "", FLDT_AGI
, OI(0), C1
, 0, TYP_NONE
},
43 #define OFF(f) bitize(offsetof(xfs_agi_t, agi_ ## f))
44 const field_t agi_flds
[] = {
45 { "magicnum", FLDT_UINT32X
, OI(OFF(magicnum
)), C1
, 0, TYP_NONE
},
46 { "versionnum", FLDT_UINT32D
, OI(OFF(versionnum
)), C1
, 0, TYP_NONE
},
47 { "seqno", FLDT_AGNUMBER
, OI(OFF(seqno
)), C1
, 0, TYP_NONE
},
48 { "length", FLDT_AGBLOCK
, OI(OFF(length
)), C1
, 0, TYP_NONE
},
49 { "count", FLDT_AGINO
, OI(OFF(count
)), C1
, 0, TYP_NONE
},
50 { "root", FLDT_AGBLOCK
, OI(OFF(root
)), C1
, 0, TYP_INOBT
},
51 { "level", FLDT_UINT32D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
52 { "freecount", FLDT_AGINO
, OI(OFF(freecount
)), C1
, 0, TYP_NONE
},
53 { "newino", FLDT_AGINO
, OI(OFF(newino
)), C1
, 0, TYP_INODE
},
54 { "dirino", FLDT_AGINO
, OI(OFF(dirino
)), C1
, 0, TYP_INODE
},
55 { "unlinked", FLDT_AGINONN
, OI(OFF(unlinked
)),
56 CI(XFS_AGI_UNLINKED_BUCKETS
), FLD_ARRAY
, TYP_NONE
},
57 { "uuid", FLDT_UUID
, OI(OFF(uuid
)), C1
, 0, TYP_NONE
},
58 { "lsn", FLDT_UINT64X
, OI(OFF(lsn
)), C1
, 0, TYP_NONE
},
59 { "crc", FLDT_CRC
, OI(OFF(crc
)), C1
, 0, TYP_NONE
},
60 { "free_root", FLDT_AGBLOCK
, OI(OFF(free_root
)), C1
, 0, TYP_FINOBT
},
61 { "free_level", FLDT_UINT32D
, OI(OFF(free_level
)), C1
, 0, TYP_NONE
},
70 " set allocation group inode btree\n"
74 " agi 3 (set location to 3rd allocation group inode btree and type to 'agi')\n"
76 " Located in the 3rd 512 byte block of each allocation group,\n"
77 " the agi inode btree tracks all used/free inodes in the allocation group.\n"
78 " Inodes are allocated in 16k 'chunks', each btree entry tracks a 'chunk'.\n"
92 agno
= (xfs_agnumber_t
)strtoul(argv
[1], &p
, 0);
93 if (*p
!= '\0' || agno
>= mp
->m_sb
.sb_agcount
) {
94 dbprintf(_("bad allocation group number %s\n"), argv
[1]);
98 } else if (cur_agno
== NULLAGNUMBER
)
100 ASSERT(typtab
[TYP_AGI
].typnm
== TYP_AGI
);
101 set_cur(&typtab
[TYP_AGI
],
102 XFS_AG_DADDR(mp
, cur_agno
, XFS_AGI_DADDR(mp
)),
103 XFS_FSS_TO_BB(mp
, 1), DB_RING_ADD
, NULL
);
110 add_command(&agi_cmd
);
120 return bitize(mp
->m_sb
.sb_sectsize
);