]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/faddr.c
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
51 if (cur_agno
== NULLAGNUMBER
) {
52 dbprintf("no current allocation group, cannot set new addr\n");
55 bno
= (xfs_agblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
56 if (bno
== NULLAGBLOCK
) {
57 dbprintf("null block number, cannot set new addr\n");
60 ASSERT(typtab
[next
].typnm
== next
);
61 set_cur(&typtab
[next
], XFS_AGB_TO_DADDR(mp
, cur_agno
, bno
), blkbb
,
74 if (cur_agno
== NULLAGNUMBER
) {
75 dbprintf("no current allocation group, cannot set new addr\n");
78 agino
= (xfs_agino_t
)getbitval(obj
, bit
, bitsz(agino
), BVUNSIGNED
);
79 if (agino
== NULLAGINO
) {
80 dbprintf("null inode number, cannot set new addr\n");
83 set_cur_inode(XFS_AGINO_TO_INO(mp
, cur_agno
, agino
));
98 bno
= (__uint32_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
100 dbprintf("null attribute block number, cannot set new addr\n");
104 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
106 dbprintf("attribute block is unmapped\n");
109 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
110 ASSERT(typtab
[next
].typnm
== next
);
111 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
,
126 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
128 if (bno
== NULLDFILOFF
) {
129 dbprintf("null block number, cannot set new addr\n");
133 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
135 dbprintf("file block is unmapped\n");
138 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
139 ASSERT(typtab
[next
].typnm
== next
);
140 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
, DB_RING_ADD
,
157 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
159 if (bno
== NULLDFILOFF
) {
160 dbprintf("null block number, cannot set new addr\n");
163 nex
= nb
= next
== TYP_DIR2
? mp
->m_dirblkfsbs
: 1;
164 bmp
= malloc(nb
* sizeof(*bmp
));
165 bmap(bno
, nb
, XFS_DATA_FORK
, &nex
, bmp
);
167 dbprintf("file block is unmapped\n");
171 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
172 ASSERT(typtab
[next
].typnm
== next
);
174 make_bbmap(&bbmap
, nex
, bmp
);
175 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), nb
* blkbb
,
176 DB_RING_ADD
, nex
> 1 ? &bbmap
: NULL
);
188 bno
= (xfs_dfsbno_t
)getbitval(obj
, bit
, BMBT_STARTBLOCK_BITLEN
,
190 if (bno
== NULLDFSBNO
) {
191 dbprintf("null block number, cannot set new addr\n");
194 ASSERT(typtab
[next
].typnm
== next
);
195 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), blkbb
, DB_RING_ADD
,
210 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
211 if (bno
== NULLDFILOFF
) {
212 dbprintf("null block number, cannot set new addr\n");
216 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
218 dbprintf("file block is unmapped\n");
221 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
222 ASSERT(typtab
[next
].typnm
== next
);
223 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
, DB_RING_ADD
,
240 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
241 if (bno
== NULLDFILOFF
) {
242 dbprintf("null block number, cannot set new addr\n");
245 nex
= nb
= next
== TYP_DIR2
? mp
->m_dirblkfsbs
: 1;
246 bmp
= malloc(nb
* sizeof(*bmp
));
247 bmap(bno
, nb
, XFS_DATA_FORK
, &nex
, bmp
);
249 dbprintf("file block is unmapped\n");
253 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
254 ASSERT(typtab
[next
].typnm
== next
);
256 make_bbmap(&bbmap
, nex
, bmp
);
257 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), nb
* blkbb
,
258 DB_RING_ADD
, nex
> 1 ? &bbmap
: NULL
);
270 bno
= (xfs_dfsbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
271 if (bno
== NULLDFSBNO
) {
272 dbprintf("null block number, cannot set new addr\n");
275 ASSERT(typtab
[next
].typnm
== next
);
276 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), blkbb
, DB_RING_ADD
,
293 bno
= (__uint32_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
295 dbprintf("null directory block number, cannot set new addr\n");
298 nex
= mp
->m_dirblkfsbs
;
299 bmp
= malloc(nex
* sizeof(*bmp
));
300 bmap(bno
, mp
->m_dirblkfsbs
, XFS_DATA_FORK
, &nex
, bmp
);
302 dbprintf("directory block is unmapped\n");
306 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
307 ASSERT(typtab
[next
].typnm
== next
);
309 make_bbmap(&bbmap
, nex
, bmp
);
310 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_DADDR(mp
, dfsbno
),
311 XFS_FSB_TO_BB(mp
, mp
->m_dirblkfsbs
), DB_RING_ADD
,
312 nex
> 1 ? &bbmap
: NULL
);
324 bno
= (xfs_drfsbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
325 if (bno
== NULLDRFSBNO
) {
326 dbprintf("null block number, cannot set new addr\n");
329 ASSERT(typtab
[next
].typnm
== next
);
330 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_BB(mp
, bno
), blkbb
,
343 bno
= (xfs_drtbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
344 if (bno
== NULLDRTBNO
) {
345 dbprintf("null block number, cannot set new addr\n");
348 /* need set_cur to understand rt subvolume */
360 ASSERT(next
== TYP_INODE
);
361 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino
), BVUNSIGNED
);
362 if (ino
== NULLFSINO
) {
363 dbprintf("null inode number, cannot set new addr\n");
376 xfs_dir2_ino4_t ino4
;
378 ASSERT(next
== TYP_INODE
);
379 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino4
), BVUNSIGNED
);
380 if (ino
== NULLFSINO
) {
381 dbprintf("null inode number, cannot set new addr\n");
394 xfs_dir2_ino8_t ino8
;
396 ASSERT(next
== TYP_INODE
);
397 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino8
), BVUNSIGNED
);
398 if (ino
== NULLFSINO
) {
399 dbprintf("null inode number, cannot set new addr\n");