]>
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/
52 if (cur_agno
== NULLAGNUMBER
) {
53 dbprintf("no current allocation group, cannot set new addr\n");
56 bno
= (xfs_agblock_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
57 if (bno
== NULLAGBLOCK
) {
58 dbprintf("null block number, cannot set new addr\n");
61 ASSERT(typtab
[next
].typnm
== next
);
62 set_cur(&typtab
[next
], XFS_AGB_TO_DADDR(mp
, cur_agno
, bno
), blkbb
,
75 if (cur_agno
== NULLAGNUMBER
) {
76 dbprintf("no current allocation group, cannot set new addr\n");
79 agino
= (xfs_agino_t
)getbitval(obj
, bit
, bitsz(agino
), BVUNSIGNED
);
80 if (agino
== NULLAGINO
) {
81 dbprintf("null inode number, cannot set new addr\n");
84 set_cur_inode(XFS_AGINO_TO_INO(mp
, cur_agno
, agino
));
99 bno
= (__uint32_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
101 dbprintf("null attribute block number, cannot set new addr\n");
105 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
107 dbprintf("attribute block is unmapped\n");
110 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
111 ASSERT(typtab
[next
].typnm
== next
);
112 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
,
127 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
129 if (bno
== NULLDFILOFF
) {
130 dbprintf("null block number, cannot set new addr\n");
134 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
136 dbprintf("file block is unmapped\n");
139 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
140 ASSERT(typtab
[next
].typnm
== next
);
141 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
, DB_RING_ADD
,
158 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, BMBT_STARTOFF_BITLEN
,
160 if (bno
== NULLDFILOFF
) {
161 dbprintf("null block number, cannot set new addr\n");
164 nex
= nb
= next
== TYP_DIR2
? mp
->m_dirblkfsbs
: 1;
165 bmp
= malloc(nb
* sizeof(*bmp
));
166 bmap(bno
, nb
, XFS_DATA_FORK
, &nex
, bmp
);
168 dbprintf("file block is unmapped\n");
172 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
173 ASSERT(typtab
[next
].typnm
== next
);
175 make_bbmap(&bbmap
, nex
, bmp
);
176 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), nb
* blkbb
,
177 DB_RING_ADD
, nex
> 1 ? &bbmap
: NULL
);
189 bno
= (xfs_dfsbno_t
)getbitval(obj
, bit
, BMBT_STARTBLOCK_BITLEN
,
191 if (bno
== NULLDFSBNO
) {
192 dbprintf("null block number, cannot set new addr\n");
195 ASSERT(typtab
[next
].typnm
== next
);
196 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), blkbb
, DB_RING_ADD
,
211 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
212 if (bno
== NULLDFILOFF
) {
213 dbprintf("null block number, cannot set new addr\n");
217 bmap(bno
, 1, XFS_ATTR_FORK
, &nex
, &bm
);
219 dbprintf("file block is unmapped\n");
222 dfsbno
= bm
.startblock
+ (bno
- bm
.startoff
);
223 ASSERT(typtab
[next
].typnm
== next
);
224 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), blkbb
, DB_RING_ADD
,
241 bno
= (xfs_dfiloff_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
242 if (bno
== NULLDFILOFF
) {
243 dbprintf("null block number, cannot set new addr\n");
246 nex
= nb
= next
== TYP_DIR2
? mp
->m_dirblkfsbs
: 1;
247 bmp
= malloc(nb
* sizeof(*bmp
));
248 bmap(bno
, nb
, XFS_DATA_FORK
, &nex
, bmp
);
250 dbprintf("file block is unmapped\n");
254 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
255 ASSERT(typtab
[next
].typnm
== next
);
257 make_bbmap(&bbmap
, nex
, bmp
);
258 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, dfsbno
), nb
* blkbb
,
259 DB_RING_ADD
, nex
> 1 ? &bbmap
: NULL
);
271 bno
= (xfs_dfsbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
272 if (bno
== NULLDFSBNO
) {
273 dbprintf("null block number, cannot set new addr\n");
276 ASSERT(typtab
[next
].typnm
== next
);
277 set_cur(&typtab
[next
], XFS_FSB_TO_DADDR(mp
, bno
), blkbb
, DB_RING_ADD
,
294 bno
= (__uint32_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
296 dbprintf("null directory block number, cannot set new addr\n");
299 nex
= mp
->m_dirblkfsbs
;
300 bmp
= malloc(nex
* sizeof(*bmp
));
301 bmap(bno
, mp
->m_dirblkfsbs
, XFS_DATA_FORK
, &nex
, bmp
);
303 dbprintf("directory block is unmapped\n");
307 dfsbno
= bmp
->startblock
+ (bno
- bmp
->startoff
);
308 ASSERT(typtab
[next
].typnm
== next
);
310 make_bbmap(&bbmap
, nex
, bmp
);
311 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_DADDR(mp
, dfsbno
),
312 (int)XFS_FSB_TO_DADDR(mp
, mp
->m_dirblkfsbs
), DB_RING_ADD
,
313 nex
> 1 ? &bbmap
: NULL
);
325 bno
= (xfs_drfsbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
326 if (bno
== NULLDRFSBNO
) {
327 dbprintf("null block number, cannot set new addr\n");
330 ASSERT(typtab
[next
].typnm
== next
);
331 set_cur(&typtab
[next
], (__int64_t
)XFS_FSB_TO_BB(mp
, bno
), blkbb
,
344 bno
= (xfs_drtbno_t
)getbitval(obj
, bit
, bitsz(bno
), BVUNSIGNED
);
345 if (bno
== NULLDRTBNO
) {
346 dbprintf("null block number, cannot set new addr\n");
349 /* need set_cur to understand rt subvolume */
361 ASSERT(next
== TYP_INODE
);
362 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino
), BVUNSIGNED
);
363 if (ino
== NULLFSINO
) {
364 dbprintf("null inode number, cannot set new addr\n");
377 xfs_dir2_ino4_t ino4
;
379 ASSERT(next
== TYP_INODE
);
380 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino4
), BVUNSIGNED
);
381 if (ino
== NULLFSINO
) {
382 dbprintf("null inode number, cannot set new addr\n");
395 xfs_dir2_ino8_t ino8
;
397 ASSERT(next
== TYP_INODE
);
398 ino
= (xfs_ino_t
)getbitval(obj
, bit
, bitsz(ino8
), BVUNSIGNED
);
399 if (ino
== NULLFSINO
) {
400 dbprintf("null inode number, cannot set new addr\n");