]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/agf.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 agf_f(int argc
, char **argv
);
46 static void agf_help(void);
48 static const cmdinfo_t agf_cmd
=
49 { "agf", NULL
, agf_f
, 0, 1, 1, "[agno]",
50 "set address to agf header", agf_help
};
52 const field_t agf_hfld
[] = {
53 { "", FLDT_AGF
, OI(0), C1
, 0, TYP_NONE
},
57 #define OFF(f) bitize(offsetof(xfs_agf_t, agf_ ## f))
58 #define SZ(f) bitszof(xfs_agf_t, agf_ ## f)
59 const field_t agf_flds
[] = {
60 { "magicnum", FLDT_UINT32X
, OI(OFF(magicnum
)), C1
, 0, TYP_NONE
},
61 { "versionnum", FLDT_UINT32D
, OI(OFF(versionnum
)), C1
, 0, TYP_NONE
},
62 { "seqno", FLDT_AGNUMBER
, OI(OFF(seqno
)), C1
, 0, TYP_NONE
},
63 { "length", FLDT_AGBLOCK
, OI(OFF(length
)), C1
, 0, TYP_NONE
},
64 { "roots", FLDT_AGBLOCK
, OI(OFF(roots
)), CI(XFS_BTNUM_AGF
),
65 FLD_ARRAY
|FLD_SKIPALL
, TYP_NONE
},
66 { "bnoroot", FLDT_AGBLOCK
,
67 OI(OFF(roots
) + XFS_BTNUM_BNO
* SZ(roots
[XFS_BTNUM_BNO
])), C1
, 0,
69 { "cntroot", FLDT_AGBLOCK
,
70 OI(OFF(roots
) + XFS_BTNUM_CNT
* SZ(roots
[XFS_BTNUM_CNT
])), C1
, 0,
72 { "levels", FLDT_UINT32D
, OI(OFF(levels
)), CI(XFS_BTNUM_AGF
),
73 FLD_ARRAY
|FLD_SKIPALL
, TYP_NONE
},
74 { "bnolevel", FLDT_UINT32D
,
75 OI(OFF(levels
) + XFS_BTNUM_BNO
* SZ(levels
[XFS_BTNUM_BNO
])), C1
, 0,
77 { "cntlevel", FLDT_UINT32D
,
78 OI(OFF(levels
) + XFS_BTNUM_CNT
* SZ(levels
[XFS_BTNUM_CNT
])), C1
, 0,
80 { "flfirst", FLDT_UINT32D
, OI(OFF(flfirst
)), C1
, 0, TYP_NONE
},
81 { "fllast", FLDT_UINT32D
, OI(OFF(fllast
)), C1
, 0, TYP_NONE
},
82 { "flcount", FLDT_UINT32D
, OI(OFF(flcount
)), C1
, 0, TYP_NONE
},
83 { "freeblks", FLDT_EXTLEN
, OI(OFF(freeblks
)), C1
, 0, TYP_NONE
},
84 { "longest", FLDT_EXTLEN
, OI(OFF(longest
)), C1
, 0, TYP_NONE
},
93 " set allocation group free block list\n"
97 " agf 2 - move location to AGF in 2nd filesystem allocation group\n"
99 " Located in the second sector of each allocation group, the AGF\n"
100 " contains the root of two different freespace btrees:\n"
101 " The 'cnt' btree keeps track freespace indexed on section size.\n"
102 " The 'bno' btree tracks sections of freespace indexed on block number.\n"
115 agno
= (xfs_agnumber_t
)strtoul(argv
[1], &p
, 0);
116 if (*p
!= '\0' || agno
>= mp
->m_sb
.sb_agcount
) {
117 dbprintf("bad allocation group number %s\n", argv
[1]);
121 } else if (cur_agno
== NULLAGNUMBER
)
123 ASSERT(typtab
[TYP_AGF
].typnm
== TYP_AGF
);
124 set_cur(&typtab
[TYP_AGF
],
125 XFS_AG_DADDR(mp
, cur_agno
, XFS_AGF_DADDR(mp
)),
126 XFS_FSS_TO_BB(mp
, 1), DB_RING_ADD
, NULL
);
133 add_command(&agf_cmd
);
142 return bitize(mp
->m_sb
.sb_sectsize
);