]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - db/agi.c
Update copyright dates
[thirdparty/xfsprogs-dev.git] / db / agi.c
CommitLineData
2bd0ea18 1/*
cc08d43e 2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
2bd0ea18
NS
3 *
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.
7 *
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.
11 *
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.
18 *
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.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33#include <libxfs.h>
34#include "agi.h"
35#include "command.h"
36#include "data.h"
37#include "type.h"
38#include "faddr.h"
39#include "fprint.h"
40#include "field.h"
41#include "io.h"
42#include "bit.h"
43#include "output.h"
44#include "mount.h"
45
46static int agi_f(int argc, char **argv);
47static void agi_help(void);
48
49static const cmdinfo_t agi_cmd =
50 { "agi", NULL, agi_f, 0, 1, 1, "[agno]",
51 "set address to agi header", agi_help };
52
53const field_t agi_hfld[] = {
54 { "", FLDT_AGI, OI(0), C1, 0, TYP_NONE },
55 { NULL }
56};
57
58#define OFF(f) bitize(offsetof(xfs_agi_t, agi_ ## f))
59const field_t agi_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 { "count", FLDT_AGINO, OI(OFF(count)), C1, 0, TYP_NONE },
65 { "root", FLDT_AGBLOCK, OI(OFF(root)), C1, 0, TYP_INOBT },
66 { "level", FLDT_UINT32D, OI(OFF(level)), C1, 0, TYP_NONE },
67 { "freecount", FLDT_AGINO, OI(OFF(freecount)), C1, 0, TYP_NONE },
68 { "newino", FLDT_AGINO, OI(OFF(newino)), C1, 0, TYP_INODE },
69 { "dirino", FLDT_AGINO, OI(OFF(dirino)), C1, 0, TYP_INODE },
70 { "unlinked", FLDT_AGINONN, OI(OFF(unlinked)),
71 CI(XFS_AGI_UNLINKED_BUCKETS), FLD_ARRAY, TYP_NONE },
72 { NULL }
73};
74
75static void
76agi_help(void)
77{
78 dbprintf(
79"\n"
80" set allocation group inode btree\n"
81"\n"
82" Example:\n"
83"\n"
84" agi 3 (set location to 3rd allocation group inode btree and type to 'agi')\n"
85"\n"
86" Located in the 3rd 512 byte block of each allocation group,\n"
87" the agi inode btree tracks all used/free inodes in the allocation group.\n"
88" Inodes are allocated in 16k 'chunks', each btree entry tracks a 'chunk'.\n"
89"\n"
90);
91}
92
93static int
94agi_f(
95 int argc,
96 char **argv)
97{
98 xfs_agnumber_t agno;
99 char *p;
100
101 if (argc > 1) {
102 agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0);
103 if (*p != '\0' || agno >= mp->m_sb.sb_agcount) {
104 dbprintf("bad allocation group number %s\n", argv[1]);
105 return 0;
106 }
107 cur_agno = agno;
108 } else if (cur_agno == NULLAGNUMBER)
109 cur_agno = 0;
110 ASSERT(typtab[TYP_AGI].typnm == TYP_AGI);
111 set_cur(&typtab[TYP_AGI], XFS_AG_DADDR(mp, cur_agno, XFS_AGI_DADDR), 1,
112 DB_RING_ADD, NULL);
113 return 0;
114}
115
116void
117agi_init(void)
118{
119 add_command(&agi_cmd);
120}
121
122/*ARGSUSED*/
123int
124agi_size(
125 void *obj,
126 int startoff,
127 int idx)
128{
129 return bitize(mp->m_sb.sb_sectsize);
130}