]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/faddr.c
2 * Copyright (c) 2000-2001,2004-2005 Silicon Graphics, Inc.
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.
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.
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
39 if (cur_agno
== NULLAGNUMBER
) {
40 dbprintf(_("no current allocation group, cannot set new addr\n"));
43 bno
= (xfs_agblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
44 if (bno
== NULLAGBLOCK
) {
45 dbprintf(_("null block number, cannot set new addr\n"));
48 ASSERT(typtab
[next
].typnm
== next
);
49 set_cur(&typtab
[next
], XFS_AGB_TO_DADDR(mp
, cur_agno
, bno
), blkbb
,
62 if (cur_agno
== NULLAGNUMBER
) {
63 dbprintf(_("no current allocation group, cannot set new addr\n"));
66 agino
= (xfs_agino_t
)getbitval(obj
, bit
, bitsz(agino
), BVUNSIGNED
);
67 if (agino
== NULLAGINO
) {
68 dbprintf(_("null inode number, cannot set new addr\n"));
71 set_cur_inode(XFS_AGINO_TO_INO(mp
, cur_agno
, agino
));
86 bno
= (__uint32_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
88 dbprintf(_("null attribute block number, cannot set new addr\n"));
92 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
94 dbprintf(_("attribute block is unmapped\n"));
97 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
98 ASSERT(typtab
[next
].typnm
== next
);
99 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
,
111 xfs_fsblock_t dfsbno
;
114 bno
= (xfs_fileoff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
116 if (bno
== NULLFILEOFF
) {
117 dbprintf(_("null block number, cannot set new addr\n"));
121 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
123 dbprintf(_("file block is unmapped\n"));
126 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
127 ASSERT(typtab
[next
].typnm
== next
);
128 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
, DB_RING_ADD
,
141 xfs_fsblock_t dfsbno
;
145 bno
= (xfs_fileoff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
147 if (bno
== NULLFILEOFF
) {
148 dbprintf(_("null block number, cannot set new addr\n"));
151 nex
= nb
= next
== TYP_DIR2
? mp
->m_dir_geo
->fsbcount
: 1;
152 bmp
= malloc(nb
* sizeof(*bmp
));
153 bmap(bno
, nb
, XFS_DATA_FORK
, &nex
, bmp
);
155 dbprintf(_("file block is unmapped\n"));
159 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
160 ASSERT(typtab
[next
].typnm
== next
);
162 make_bbmap(&bbmap
, nex
, bmp
);
163 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), nb
* blkbb
,
164 DB_RING_ADD
, nex
> 1 ? &bbmap
: NULL
);
177 bno
= (xfs_fsblock_t
)getbitval(obj
, bit
, BMBT_STARTBLOCK_BITLEN
,
179 if (bno
== NULLFSBLOCK
) {
180 dbprintf(_("null block number, cannot set new addr\n"));
183 nb
= next
== TYP_DIR2
? mp
->m_dir_geo
->fsbcount
: 1;
184 ASSERT(typtab
[next
].typnm
== next
);
185 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), nb
* blkbb
,
197 xfs_fsblock_t dfsbno
;
200 bno
= (xfs_fileoff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
201 if (bno
== NULLFILEOFF
) {
202 dbprintf(_("null block number, cannot set new addr\n"));
206 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
208 dbprintf(_("file block is unmapped\n"));
211 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
212 ASSERT(typtab
[next
].typnm
== next
);
213 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
, DB_RING_ADD
,
226 xfs_fsblock_t dfsbno
;
230 bno
= (xfs_fileoff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
231 if (bno
== NULLFILEOFF
) {
232 dbprintf(_("null block number, cannot set new addr\n"));
235 nex
= nb
= next
== TYP_DIR2
? mp
->m_dir_geo
->fsbcount
: 1;
236 bmp
= malloc(nb
* sizeof(*bmp
));
237 bmap(bno
, nb
, XFS_DATA_FORK
, &nex
, bmp
);
239 dbprintf(_("file block is unmapped\n"));
243 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
244 ASSERT(typtab
[next
].typnm
== next
);
246 make_bbmap(&bbmap
, nex
, bmp
);
247 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), nb
* blkbb
,
248 DB_RING_ADD
, nex
> 1 ? &bbmap
: NULL
);
260 bno
= (xfs_fsblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
261 if (bno
== NULLFSBLOCK
) {
262 dbprintf(_("null block number, cannot set new addr\n"));
265 ASSERT(typtab
[next
].typnm
== next
);
266 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), blkbb
, DB_RING_ADD
,
280 xfs_fsblock_t dfsbno
;
283 bno
= (__uint32_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
285 dbprintf(_("null directory block number, cannot set new addr\n"));
288 nex
= mp
->m_dir_geo
->fsbcount
;
289 bmp
= malloc(nex
* sizeof(*bmp
));
290 bmap(bno
, mp
->m_dir_geo
->fsbcount
, XFS_DATA_FORK
, &nex
, bmp
);
292 dbprintf(_("directory block is unmapped\n"));
296 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
297 ASSERT(typtab
[next
].typnm
== next
);
299 make_bbmap(&bbmap
, nex
, bmp
);
300 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_DADDR(mp
, dfsbno
),
301 XFS_FSB_TO_BB(mp
, mp
->m_dir_geo
->fsbcount
), DB_RING_ADD
,
302 nex
> 1 ? &bbmap
: NULL
);
314 bno
= (xfs_rfsblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
315 if (bno
== NULLRFSBLOCK
) {
316 dbprintf(_("null block number, cannot set new addr\n"));
319 ASSERT(typtab
[next
].typnm
== next
);
320 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_BB(mp
, bno
), blkbb
,
333 bno
= (xfs_rtblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
334 if (bno
== NULLRTBLOCK
) {
335 dbprintf(_("null block number, cannot set new addr\n"));
338 /* need set_cur to understand rt subvolume */
350 ASSERT(next
== TYP_INODE
);
351 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino
), BVUNSIGNED
);
352 if (ino
== NULLFSINO
) {
353 dbprintf(_("null inode number, cannot set new addr\n"));
367 ASSERT(next
== TYP_INODE
);
368 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(XFS_INO32_SIZE
), BVUNSIGNED
);
369 if (ino
== NULLFSINO
) {
370 dbprintf(_("null inode number, cannot set new addr\n"));
384 ASSERT(next
== TYP_INODE
);
385 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(XFS_INO64_SIZE
), BVUNSIGNED
);
386 if (ino
== NULLFSINO
) {
387 dbprintf(_("null inode number, cannot set new addr\n"));