]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/agfl.c
xfs: zero length symlinks are not valid
[thirdparty/xfsprogs-dev.git] / db / agfl.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6
7 #include "libxfs.h"
8 #include "command.h"
9 #include "type.h"
10 #include "faddr.h"
11 #include "fprint.h"
12 #include "field.h"
13 #include "io.h"
14 #include "bit.h"
15 #include "output.h"
16 #include "init.h"
17 #include "agfl.h"
18
19 static int agfl_bno_size(void *obj, int startoff);
20 static int agfl_f(int argc, char **argv);
21 static void agfl_help(void);
22
23 static const cmdinfo_t agfl_cmd =
24 { "agfl", NULL, agfl_f, 0, 1, 1, N_("[agno]"),
25 N_("set address to agfl block"), agfl_help };
26
27 const field_t agfl_hfld[] = { {
28 "", FLDT_AGFL, OI(0), C1, 0, TYP_NONE, },
29 { NULL }
30 };
31
32 const field_t agfl_crc_hfld[] = { {
33 "", FLDT_AGFL_CRC, OI(0), C1, 0, TYP_NONE, },
34 { NULL }
35 };
36
37 #define OFF(f) bitize(offsetof(xfs_agfl_t, agfl_ ## f))
38 const field_t agfl_flds[] = {
39 { "bno", FLDT_AGBLOCKNZ, OI(OFF(magicnum)), agfl_bno_size,
40 FLD_ARRAY|FLD_COUNT, TYP_DATA },
41 { NULL }
42 };
43
44 const field_t agfl_crc_flds[] = {
45 { "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE },
46 { "seqno", FLDT_AGNUMBER, OI(OFF(seqno)), C1, 0, TYP_NONE },
47 { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
48 { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
49 { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE },
50 { "bno", FLDT_AGBLOCKNZ, OI(OFF(bno)), agfl_bno_size,
51 FLD_ARRAY|FLD_COUNT, TYP_DATA },
52 { NULL }
53 };
54
55 static int
56 agfl_bno_size(
57 void *obj,
58 int startoff)
59 {
60 return libxfs_agfl_size(mp);
61 }
62
63 static void
64 agfl_help(void)
65 {
66 dbprintf(_(
67 "\n"
68 " set allocation group freelist\n"
69 "\n"
70 " Example:\n"
71 "\n"
72 " agfl 5"
73 "\n"
74 " Located in the fourth sector of each allocation group,\n"
75 " the agfl freelist for internal btree space allocation is maintained\n"
76 " for each allocation group. This acts as a reserved pool of space\n"
77 " separate from the general filesystem freespace (not used for user data).\n"
78 "\n"
79 ));
80
81 }
82
83 static int
84 agfl_f(
85 int argc,
86 char **argv)
87 {
88 xfs_agnumber_t agno;
89 char *p;
90
91 if (argc > 1) {
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]);
95 return 0;
96 }
97 cur_agno = agno;
98 } else if (cur_agno == NULLAGNUMBER)
99 cur_agno = 0;
100 ASSERT(typtab[TYP_AGFL].typnm == TYP_AGFL);
101 set_cur(&typtab[TYP_AGFL],
102 XFS_AG_DADDR(mp, cur_agno, XFS_AGFL_DADDR(mp)),
103 XFS_FSS_TO_BB(mp, 1), DB_RING_ADD, NULL);
104 return 0;
105 }
106
107 void
108 agfl_init(void)
109 {
110 add_command(&agfl_cmd);
111 }
112
113 /*ARGSUSED*/
114 int
115 agfl_size(
116 void *obj,
117 int startoff,
118 int idx)
119 {
120 return bitize(mp->m_sb.sb_sectsize);
121 }