]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/faddr.c
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2004-2005 Silicon Graphics, Inc.
27 if (cur_agno
== NULLAGNUMBER
) {
28 dbprintf(_("no current allocation group, cannot set new addr\n"));
31 bno
= (xfs_agblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
32 if (bno
== NULLAGBLOCK
) {
33 dbprintf(_("null block number, cannot set new addr\n"));
36 ASSERT(typtab
[next
].typnm
== next
);
37 set_cur(&typtab
[next
], XFS_AGB_TO_DADDR(mp
, cur_agno
, bno
), blkbb
,
50 if (cur_agno
== NULLAGNUMBER
) {
51 dbprintf(_("no current allocation group, cannot set new addr\n"));
54 agino
= (xfs_agino_t
)getbitval(obj
, bit
, bitsz(agino
), BVUNSIGNED
);
55 if (agino
== NULLAGINO
) {
56 dbprintf(_("null inode number, cannot set new addr\n"));
59 set_cur_inode(XFS_AGINO_TO_INO(mp
, cur_agno
, agino
));
74 bno
= (uint32_t)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
76 dbprintf(_("null attribute block number, cannot set new addr\n"));
80 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
82 dbprintf(_("attribute block is unmapped\n"));
85 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
86 ASSERT(typtab
[next
].typnm
== next
);
87 set_cur(&typtab
[next
], (int64_t)XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
,
102 bno
= (xfs_fileoff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
104 if (bno
== NULLFILEOFF
) {
105 dbprintf(_("null block number, cannot set new addr\n"));
109 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
111 dbprintf(_("file block is unmapped\n"));
114 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
115 ASSERT(typtab
[next
].typnm
== next
);
116 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
, DB_RING_ADD
,
129 xfs_fsblock_t dfsbno
;
133 bno
= (xfs_fileoff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
135 if (bno
== NULLFILEOFF
) {
136 dbprintf(_("null block number, cannot set new addr\n"));
139 nex
= nb
= next
== TYP_DIR2
? mp
->m_dir_geo
->fsbcount
: 1;
140 bmp
= malloc(nb
* sizeof(*bmp
));
141 bmap(bno
, nb
, XFS_DATA_FORK
, &nex
, bmp
);
143 dbprintf(_("file block is unmapped\n"));
147 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
148 ASSERT(typtab
[next
].typnm
== next
);
150 make_bbmap(&bbmap
, nex
, bmp
);
151 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), nb
* blkbb
,
152 DB_RING_ADD
, nex
> 1 ? &bbmap
: NULL
);
165 bno
= (xfs_fsblock_t
)getbitval(obj
, bit
, BMBT_STARTBLOCK_BITLEN
,
167 if (bno
== NULLFSBLOCK
) {
168 dbprintf(_("null block number, cannot set new addr\n"));
171 nb
= next
== TYP_DIR2
? mp
->m_dir_geo
->fsbcount
: 1;
172 ASSERT(typtab
[next
].typnm
== next
);
173 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), nb
* blkbb
,
185 xfs_fsblock_t dfsbno
;
188 bno
= (xfs_fileoff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
189 if (bno
== NULLFILEOFF
) {
190 dbprintf(_("null block number, cannot set new addr\n"));
194 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
196 dbprintf(_("file block is unmapped\n"));
199 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
200 ASSERT(typtab
[next
].typnm
== next
);
201 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
, DB_RING_ADD
,
214 xfs_fsblock_t dfsbno
;
218 bno
= (xfs_fileoff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
219 if (bno
== NULLFILEOFF
) {
220 dbprintf(_("null block number, cannot set new addr\n"));
223 nex
= nb
= next
== TYP_DIR2
? mp
->m_dir_geo
->fsbcount
: 1;
224 bmp
= malloc(nb
* sizeof(*bmp
));
225 bmap(bno
, nb
, XFS_DATA_FORK
, &nex
, bmp
);
227 dbprintf(_("file block is unmapped\n"));
231 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
232 ASSERT(typtab
[next
].typnm
== next
);
234 make_bbmap(&bbmap
, nex
, bmp
);
235 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), nb
* blkbb
,
236 DB_RING_ADD
, nex
> 1 ? &bbmap
: NULL
);
248 bno
= (xfs_fsblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
249 if (bno
== NULLFSBLOCK
) {
250 dbprintf(_("null block number, cannot set new addr\n"));
253 ASSERT(typtab
[next
].typnm
== next
);
254 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), blkbb
, DB_RING_ADD
,
268 xfs_fsblock_t dfsbno
;
271 bno
= (uint32_t)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
273 dbprintf(_("null directory block number, cannot set new addr\n"));
276 nex
= mp
->m_dir_geo
->fsbcount
;
277 bmp
= malloc(nex
* sizeof(*bmp
));
278 bmap(bno
, mp
->m_dir_geo
->fsbcount
, XFS_DATA_FORK
, &nex
, bmp
);
280 dbprintf(_("directory block is unmapped\n"));
284 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
285 ASSERT(typtab
[next
].typnm
== next
);
287 make_bbmap(&bbmap
, nex
, bmp
);
288 set_cur(&typtab
[next
], (int64_t)XFS_FSB_TO_DADDR(mp
, dfsbno
),
289 XFS_FSB_TO_BB(mp
, mp
->m_dir_geo
->fsbcount
), DB_RING_ADD
,
290 nex
> 1 ? &bbmap
: NULL
);
302 bno
= (xfs_rfsblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
303 if (bno
== NULLRFSBLOCK
) {
304 dbprintf(_("null block number, cannot set new addr\n"));
307 ASSERT(typtab
[next
].typnm
== next
);
308 set_cur(&typtab
[next
], (int64_t)XFS_FSB_TO_BB(mp
, bno
), blkbb
,
321 bno
= (xfs_rtblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
322 if (bno
== NULLRTBLOCK
) {
323 dbprintf(_("null block number, cannot set new addr\n"));
326 /* need set_cur to understand rt subvolume */
338 ASSERT(next
== TYP_INODE
);
339 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino
), BVUNSIGNED
);
340 if (ino
== NULLFSINO
) {
341 dbprintf(_("null inode number, cannot set new addr\n"));
355 ASSERT(next
== TYP_INODE
);
356 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitize(XFS_INO32_SIZE
),
358 if (ino
== NULLFSINO
) {
359 dbprintf(_("null inode number, cannot set new addr\n"));
373 ASSERT(next
== TYP_INODE
);
374 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitize(XFS_INO64_SIZE
),
376 if (ino
== NULLFSINO
) {
377 dbprintf(_("null inode number, cannot set new addr\n"));