]>
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
19 #include <xfs/libxfs.h>
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
,
114 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
116 if (bno
== NULLDFILOFF
) {
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
,
145 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
147 if (bno
== NULLDFILOFF
) {
148 dbprintf("null block number, cannot set new addr\n");
151 nex
= nb
= next
== TYP_DIR2
? mp
->m_dirblkfsbs
: 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_dfsbno_t
)getbitval(obj
, bit
, BMBT_STARTBLOCK_BITLEN
,
179 if (bno
== NULLDFSBNO
) {
180 dbprintf("null block number, cannot set new addr\n");
183 nb
= next
== TYP_DIR2
? mp
->m_dirblkfsbs
: 1;
184 ASSERT(typtab
[next
].typnm
== next
);
185 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), nb
* blkbb
,
200 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
201 if (bno
== NULLDFILOFF
) {
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
,
230 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
231 if (bno
== NULLDFILOFF
) {
232 dbprintf("null block number, cannot set new addr\n");
235 nex
= nb
= next
== TYP_DIR2
? mp
->m_dirblkfsbs
: 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_dfsbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
261 if (bno
== NULLDFSBNO
) {
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
,
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_dirblkfsbs
;
289 bmp
= malloc(nex
* sizeof(*bmp
));
290 bmap(bno
, mp
->m_dirblkfsbs
, 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_dirblkfsbs
), DB_RING_ADD
,
302 nex
> 1 ? &bbmap
: NULL
);
314 bno
= (xfs_drfsbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
315 if (bno
== NULLDRFSBNO
) {
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_drtbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
334 if (bno
== NULLDRTBNO
) {
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");
366 xfs_dir2_ino4_t ino4
;
368 ASSERT(next
== TYP_INODE
);
369 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino4
), BVUNSIGNED
);
370 if (ino
== NULLFSINO
) {
371 dbprintf("null inode number, cannot set new addr\n");
384 xfs_dir2_ino8_t ino8
;
386 ASSERT(next
== TYP_INODE
);
387 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino8
), BVUNSIGNED
);
388 if (ino
== NULLFSINO
) {
389 dbprintf("null inode number, cannot set new addr\n");