]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/agi.c
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
45 static int agi_f(int argc
, char **argv
);
46 static void agi_help(void);
48 static const cmdinfo_t agi_cmd
=
49 { "agi", NULL
, agi_f
, 0, 1, 1, "[agno]",
50 "set address to agi header", agi_help
};
52 const field_t agi_hfld
[] = {
53 { "", FLDT_AGI
, OI(0), C1
, 0, TYP_NONE
},
57 #define OFF(f) bitize(offsetof(xfs_agi_t, agi_ ## f))
58 const field_t agi_flds
[] = {
59 { "magicnum", FLDT_UINT32X
, OI(OFF(magicnum
)), C1
, 0, TYP_NONE
},
60 { "versionnum", FLDT_UINT32D
, OI(OFF(versionnum
)), C1
, 0, TYP_NONE
},
61 { "seqno", FLDT_AGNUMBER
, OI(OFF(seqno
)), C1
, 0, TYP_NONE
},
62 { "length", FLDT_AGBLOCK
, OI(OFF(length
)), C1
, 0, TYP_NONE
},
63 { "count", FLDT_AGINO
, OI(OFF(count
)), C1
, 0, TYP_NONE
},
64 { "root", FLDT_AGBLOCK
, OI(OFF(root
)), C1
, 0, TYP_INOBT
},
65 { "level", FLDT_UINT32D
, OI(OFF(level
)), C1
, 0, TYP_NONE
},
66 { "freecount", FLDT_AGINO
, OI(OFF(freecount
)), C1
, 0, TYP_NONE
},
67 { "newino", FLDT_AGINO
, OI(OFF(newino
)), C1
, 0, TYP_INODE
},
68 { "dirino", FLDT_AGINO
, OI(OFF(dirino
)), C1
, 0, TYP_INODE
},
69 { "unlinked", FLDT_AGINONN
, OI(OFF(unlinked
)),
70 CI(XFS_AGI_UNLINKED_BUCKETS
), FLD_ARRAY
, TYP_NONE
},
79 " set allocation group inode btree\n"
83 " agi 3 (set location to 3rd allocation group inode btree and type to 'agi')\n"
85 " Located in the 3rd 512 byte block of each allocation group,\n"
86 " the agi inode btree tracks all used/free inodes in the allocation group.\n"
87 " Inodes are allocated in 16k 'chunks', each btree entry tracks a 'chunk'.\n"
101 agno
= (xfs_agnumber_t
)strtoul(argv
[1], &p
, 0);
102 if (*p
!= '\0' || agno
>= mp
->m_sb
.sb_agcount
) {
103 dbprintf("bad allocation group number %s\n", argv
[1]);
107 } else if (cur_agno
== NULLAGNUMBER
)
109 ASSERT(typtab
[TYP_AGI
].typnm
== TYP_AGI
);
110 set_cur(&typtab
[TYP_AGI
],
111 XFS_AG_DADDR(mp
, cur_agno
, XFS_AGI_DADDR(mp
)),
112 XFS_FSS_TO_BB(mp
, 1), DB_RING_ADD
, NULL
);
119 add_command(&agi_cmd
);
129 return bitize(mp
->m_sb
.sb_sectsize
);