]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/agi.c
apply gettext translation to more strings
[thirdparty/xfsprogs-dev.git] / db / agi.c
1 /*
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
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.
8 *
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.
13 *
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
17 */
18
19 #include <xfs/libxfs.h>
20 #include "command.h"
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"
28 #include "init.h"
29 #include "agi.h"
30
31 static int agi_f(int argc, char **argv);
32 static void agi_help(void);
33
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 };
37
38 const field_t agi_hfld[] = {
39 { "", FLDT_AGI, OI(0), C1, 0, TYP_NONE },
40 { NULL }
41 };
42
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 { NULL }
58 };
59
60 static void
61 agi_help(void)
62 {
63 dbprintf(_(
64 "\n"
65 " set allocation group inode btree\n"
66 "\n"
67 " Example:\n"
68 "\n"
69 " agi 3 (set location to 3rd allocation group inode btree and type to 'agi')\n"
70 "\n"
71 " Located in the 3rd 512 byte block of each allocation group,\n"
72 " the agi inode btree tracks all used/free inodes in the allocation group.\n"
73 " Inodes are allocated in 16k 'chunks', each btree entry tracks a 'chunk'.\n"
74 "\n"
75 ));
76 }
77
78 static int
79 agi_f(
80 int argc,
81 char **argv)
82 {
83 xfs_agnumber_t agno;
84 char *p;
85
86 if (argc > 1) {
87 agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0);
88 if (*p != '\0' || agno >= mp->m_sb.sb_agcount) {
89 dbprintf(_("bad allocation group number %s\n"), argv[1]);
90 return 0;
91 }
92 cur_agno = agno;
93 } else if (cur_agno == NULLAGNUMBER)
94 cur_agno = 0;
95 ASSERT(typtab[TYP_AGI].typnm == TYP_AGI);
96 set_cur(&typtab[TYP_AGI],
97 XFS_AG_DADDR(mp, cur_agno, XFS_AGI_DADDR(mp)),
98 XFS_FSS_TO_BB(mp, 1), DB_RING_ADD, NULL);
99 return 0;
100 }
101
102 void
103 agi_init(void)
104 {
105 add_command(&agi_cmd);
106 }
107
108 /*ARGSUSED*/
109 int
110 agi_size(
111 void *obj,
112 int startoff,
113 int idx)
114 {
115 return bitize(mp->m_sb.sb_sectsize);
116 }