1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1980, 1986, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 #if 0
33 #ifndef lint
34 static const char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
35 #endif /* not lint */
36 #endif
37 #include <sys/cdefs.h>
38 #include <sys/param.h>
39 #include <sys/stat.h>
40 #include <sys/sysctl.h>
41
42 #include <ufs/ufs/dinode.h>
43 #include <ufs/ufs/dir.h>
44 #include <ufs/ffs/fs.h>
45
46 #include <err.h>
47 #include <limits.h>
48 #include <stdint.h>
49 #include <string.h>
50
51 #include "fsck.h"
52
53 static ufs2_daddr_t badblk;
54 static ufs2_daddr_t dupblk;
55 static ino_t lastino; /* last inode in use */
56
57 static int checkinode(ino_t inumber, struct inodesc *, int rebuiltcg);
58
59 void
pass1(void)60 pass1(void)
61 {
62 struct inostat *info;
63 struct inodesc idesc;
64 struct bufarea *cgbp;
65 struct cg *cgp;
66 ino_t inumber, inosused, mininos;
67 ufs2_daddr_t i, cgd;
68 u_int8_t *cp;
69 int c, rebuiltcg;
70
71 badblk = dupblk = lastino = 0;
72
73 /*
74 * Set file system reserved blocks in used block map.
75 */
76 for (c = 0; c < sblock.fs_ncg; c++) {
77 cgd = cgdmin(&sblock, c);
78 if (c == 0) {
79 i = cgbase(&sblock, c);
80 } else
81 i = cgsblock(&sblock, c);
82 for (; i < cgd; i++)
83 setbmap(i);
84 }
85 i = sblock.fs_csaddr;
86 cgd = i + howmany(sblock.fs_cssize, sblock.fs_fsize);
87 for (; i < cgd; i++)
88 setbmap(i);
89
90 /*
91 * Find all allocated blocks.
92 */
93 memset(&idesc, 0, sizeof(struct inodesc));
94 idesc.id_func = pass1check;
95 n_files = n_blks = 0;
96 for (c = 0; c < sblock.fs_ncg; c++) {
97 inumber = c * sblock.fs_ipg;
98 cgbp = cglookup(c);
99 cgp = cgbp->b_un.b_cg;
100 rebuiltcg = 0;
101 if (!check_cgmagic(c, cgbp)) {
102 if (!reply("REBUILD CYLINDER GROUP")) {
103 cgheader_corrupt = 1;
104 if (!nflag) {
105 pwarn("YOU WILL NEED TO RERUN FSCK.\n");
106 rerun = 1;
107 }
108 } else {
109 rebuild_cg(c, cgbp);
110 rebuiltcg = 1;
111 }
112 }
113 if (!rebuiltcg && sblock.fs_magic == FS_UFS2_MAGIC) {
114 inosused = cgp->cg_initediblk;
115 if (inosused > sblock.fs_ipg) {
116 pfatal("Too many initialized inodes (%ju > %d) "
117 "in cylinder group %d\nReset to %d\n",
118 (uintmax_t)inosused, sblock.fs_ipg, c,
119 sblock.fs_ipg);
120 inosused = sblock.fs_ipg;
121 }
122 } else {
123 inosused = sblock.fs_ipg;
124 }
125 if (got_siginfo) {
126 printf("%s: phase 1: cyl group %d of %d (%d%%)\n",
127 cdevname, c, sblock.fs_ncg,
128 c * 100 / sblock.fs_ncg);
129 got_siginfo = 0;
130 }
131 if (got_sigalarm) {
132 setproctitle("%s p1 %d%%", cdevname,
133 c * 100 / sblock.fs_ncg);
134 got_sigalarm = 0;
135 }
136 /*
137 * If we are using soft updates, then we can trust the
138 * cylinder group inode allocation maps to tell us which
139 * inodes are allocated. We will scan the used inode map
140 * to find the inodes that are really in use, and then
141 * read only those inodes in from disk.
142 */
143 if ((preen || inoopt) && usedsoftdep && !rebuiltcg) {
144 cp = &cg_inosused(cgp)[(inosused - 1) / CHAR_BIT];
145 for ( ; inosused != 0; cp--) {
146 if (*cp == 0) {
147 if (inosused > CHAR_BIT)
148 inosused -= CHAR_BIT;
149 else
150 inosused = 0;
151 continue;
152 }
153 for (i = 1 << (CHAR_BIT - 1); i > 0; i >>= 1) {
154 if (*cp & i)
155 break;
156 inosused--;
157 }
158 break;
159 }
160 }
161 /*
162 * Allocate inoinfo structures for the allocated inodes.
163 */
164 inostathead[c].il_numalloced = inosused;
165 if (inosused == 0) {
166 inostathead[c].il_stat = NULL;
167 continue;
168 }
169 info = Calloc((unsigned)inosused, sizeof(struct inostat));
170 if (info == NULL)
171 errx(EEXIT, "cannot alloc %u bytes for inoinfo",
172 (unsigned)(sizeof(struct inostat) * inosused));
173 inostathead[c].il_stat = info;
174 /*
175 * Scan the allocated inodes.
176 */
177 setinodebuf(c, inosused);
178 for (i = 0; i < inosused; i++, inumber++) {
179 if (inumber < UFS_ROOTINO) {
180 (void)getnextinode(inumber, rebuiltcg);
181 continue;
182 }
183 /*
184 * NULL return indicates probable end of allocated
185 * inodes during cylinder group rebuild attempt.
186 * We always keep trying until we get to the minimum
187 * valid number for this cylinder group.
188 */
189 if (checkinode(inumber, &idesc, rebuiltcg) == 0 &&
190 i > cgp->cg_initediblk)
191 break;
192 }
193 /*
194 * This optimization speeds up future runs of fsck
195 * by trimming down the number of inodes in cylinder
196 * groups that formerly had many inodes but now have
197 * fewer in use.
198 */
199 mininos = roundup(inosused + INOPB(&sblock), INOPB(&sblock));
200 if (inoopt && !preen && !rebuiltcg &&
201 sblock.fs_magic == FS_UFS2_MAGIC &&
202 cgp->cg_initediblk > 2 * INOPB(&sblock) &&
203 mininos < cgp->cg_initediblk) {
204 i = cgp->cg_initediblk;
205 if (mininos < 2 * INOPB(&sblock))
206 cgp->cg_initediblk = 2 * INOPB(&sblock);
207 else
208 cgp->cg_initediblk = mininos;
209 pwarn("CYLINDER GROUP %d: RESET FROM %ju TO %d %s\n",
210 c, i, cgp->cg_initediblk, "VALID INODES");
211 cgdirty(cgbp);
212 }
213 if (inosused < sblock.fs_ipg)
214 continue;
215 lastino += 1;
216 if (lastino < (c * sblock.fs_ipg))
217 inosused = 0;
218 else
219 inosused = lastino - (c * sblock.fs_ipg);
220 if (rebuiltcg && inosused > cgp->cg_initediblk &&
221 sblock.fs_magic == FS_UFS2_MAGIC) {
222 cgp->cg_initediblk = roundup(inosused, INOPB(&sblock));
223 pwarn("CYLINDER GROUP %d: FOUND %d VALID INODES\n", c,
224 cgp->cg_initediblk);
225 }
226 /*
227 * If we were not able to determine in advance which inodes
228 * were in use, then reduce the size of the inoinfo structure
229 * to the size necessary to describe the inodes that we
230 * really found. Always leave map space in the first cylinder
231 * group in case we need to a root or lost+found directory.
232 */
233 if (inumber == lastino || c == 0)
234 continue;
235 inostathead[c].il_numalloced = inosused;
236 if (inosused == 0) {
237 free(inostathead[c].il_stat);
238 inostathead[c].il_stat = NULL;
239 continue;
240 }
241 info = Calloc((unsigned)inosused, sizeof(struct inostat));
242 if (info == NULL)
243 errx(EEXIT, "cannot alloc %u bytes for inoinfo",
244 (unsigned)(sizeof(struct inostat) * inosused));
245 memmove(info, inostathead[c].il_stat, inosused * sizeof(*info));
246 free(inostathead[c].il_stat);
247 inostathead[c].il_stat = info;
248 }
249 freeinodebuf();
250 }
251
252 static int
checkinode(ino_t inumber,struct inodesc * idesc,int rebuiltcg)253 checkinode(ino_t inumber, struct inodesc *idesc, int rebuiltcg)
254 {
255 struct inode ip;
256 union dinode *dp;
257 ufs2_daddr_t ndb;
258 mode_t mode;
259 intmax_t size, fixsize;
260 int j, ret, offset;
261
262 if ((dp = getnextinode(inumber, rebuiltcg)) == NULL) {
263 pfatal("INVALID INODE");
264 goto unknown;
265 }
266 mode = DIP(dp, di_mode) & IFMT;
267 if (mode == 0) {
268 if ((sblock.fs_magic == FS_UFS1_MAGIC &&
269 (memcmp(dp->dp1.di_db, zino.dp1.di_db,
270 UFS_NDADDR * sizeof(ufs1_daddr_t)) ||
271 memcmp(dp->dp1.di_ib, zino.dp1.di_ib,
272 UFS_NIADDR * sizeof(ufs1_daddr_t)) ||
273 dp->dp1.di_mode || dp->dp1.di_size)) ||
274 (sblock.fs_magic == FS_UFS2_MAGIC &&
275 (memcmp(dp->dp2.di_db, zino.dp2.di_db,
276 UFS_NDADDR * sizeof(ufs2_daddr_t)) ||
277 memcmp(dp->dp2.di_ib, zino.dp2.di_ib,
278 UFS_NIADDR * sizeof(ufs2_daddr_t)) ||
279 dp->dp2.di_mode || dp->dp2.di_size))) {
280 pfatal("PARTIALLY ALLOCATED INODE I=%lu",
281 (u_long)inumber);
282 if (reply("CLEAR") == 1) {
283 ginode(inumber, &ip);
284 clearinode(ip.i_dp);
285 inodirty(&ip);
286 irelse(&ip);
287 }
288 }
289 inoinfo(inumber)->ino_state = USTATE;
290 return (1);
291 }
292 lastino = inumber;
293 if (chkfilesize(mode, DIP(dp, di_size)) == 0) {
294 pfatal("BAD FILE SIZE");
295 goto unknown;
296 }
297 if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) {
298 ginode(inumber, &ip);
299 dp = ip.i_dp;
300 DIP_SET(dp, di_size, sblock.fs_fsize);
301 DIP_SET(dp, di_mode, IFREG|0600);
302 inodirty(&ip);
303 irelse(&ip);
304 }
305 if ((mode == IFBLK || mode == IFCHR || mode == IFIFO ||
306 mode == IFSOCK) && DIP(dp, di_size) != 0) {
307 if (debug)
308 printf("bad special-file size %ju:",
309 (uintmax_t)DIP(dp, di_size));
310 pfatal("BAD SPECIAL-FILE SIZE");
311 goto unknown;
312 }
313 if ((mode == IFBLK || mode == IFCHR) &&
314 (dev_t)DIP(dp, di_rdev) == NODEV) {
315 if (debug)
316 printf("bad special-file rdev NODEV:");
317 pfatal("BAD SPECIAL-FILE RDEV");
318 goto unknown;
319 }
320 ndb = howmany(DIP(dp, di_size), sblock.fs_bsize);
321 if (ndb < 0) {
322 if (debug)
323 printf("negative size %ju ndb %ju:",
324 (uintmax_t)DIP(dp, di_size), (uintmax_t)ndb);
325 pfatal("NEGATIVE FILE SIZE");
326 goto unknown;
327 }
328 if (mode == IFBLK || mode == IFCHR)
329 ndb++;
330 if (mode == IFLNK) {
331 /*
332 * Fake ndb value so direct/indirect block checks below
333 * will detect any garbage after symlink string.
334 */
335 if (DIP(dp, di_size) < (off_t)sblock.fs_maxsymlinklen) {
336 if (sblock.fs_magic == FS_UFS1_MAGIC)
337 ndb = howmany(DIP(dp, di_size),
338 sizeof(ufs1_daddr_t));
339 else
340 ndb = howmany(DIP(dp, di_size),
341 sizeof(ufs2_daddr_t));
342 if (ndb > UFS_NDADDR) {
343 j = ndb - UFS_NDADDR;
344 for (ndb = 1; j > 1; j--)
345 ndb *= NINDIR(&sblock);
346 ndb += UFS_NDADDR;
347 }
348 }
349 }
350 for (j = ndb; ndb < UFS_NDADDR && j < UFS_NDADDR; j++) {
351 if (DIP(dp, di_db[j]) == 0)
352 continue;
353 if (debug)
354 printf("invalid direct addr[%d]: %ju\n", j,
355 (uintmax_t)DIP(dp, di_db[j]));
356 pfatal("INVALID DIRECT BLOCK");
357 ginode(inumber, &ip);
358 prtinode(&ip);
359 if (reply("CLEAR") == 1) {
360 DIP_SET(ip.i_dp, di_db[j], 0);
361 inodirty(&ip);
362 }
363 irelse(&ip);
364 }
365 for (j = 0, ndb -= UFS_NDADDR; ndb > 0; j++)
366 ndb /= NINDIR(&sblock);
367 for (; j < UFS_NIADDR; j++) {
368 if (DIP(dp, di_ib[j]) == 0)
369 continue;
370 if (debug)
371 printf("invalid indirect addr: %ju\n",
372 (uintmax_t)DIP(dp, di_ib[j]));
373 pfatal("INVALID INDIRECT BLOCK");
374 ginode(inumber, &ip);
375 prtinode(&ip);
376 if (reply("CLEAR") == 1) {
377 DIP_SET(ip.i_dp, di_ib[j], 0);
378 inodirty(&ip);
379 }
380 irelse(&ip);
381 }
382 if (ftypeok(dp) == 0) {
383 pfatal("UNKNOWN FILE TYPE");
384 goto unknown;
385 }
386 n_files++;
387 inoinfo(inumber)->ino_linkcnt = DIP(dp, di_nlink);
388 if (mode == IFDIR) {
389 if (DIP(dp, di_size) == 0) {
390 inoinfo(inumber)->ino_state = DCLEAR;
391 } else if (DIP(dp, di_nlink) == 0) {
392 inoinfo(inumber)->ino_state = DZLINK;
393 } else {
394 inoinfo(inumber)->ino_state = DSTATE;
395 }
396 cacheino(dp, inumber);
397 countdirs++;
398 } else if (DIP(dp, di_nlink) <= 0)
399 inoinfo(inumber)->ino_state = FZLINK;
400 else
401 inoinfo(inumber)->ino_state = FSTATE;
402 inoinfo(inumber)->ino_type = IFTODT(mode);
403 badblk = dupblk = 0;
404 idesc->id_number = inumber;
405 if (DIP(dp, di_flags) & SF_SNAPSHOT)
406 inoinfo(inumber)->ino_idtype = SNAP;
407 else
408 inoinfo(inumber)->ino_idtype = ADDR;
409 idesc->id_type = inoinfo(inumber)->ino_idtype;
410 (void)ckinode(dp, idesc);
411 if (sblock.fs_magic == FS_UFS2_MAGIC && dp->dp2.di_extsize > 0) {
412 ndb = howmany(dp->dp2.di_extsize, sblock.fs_bsize);
413 for (j = 0; j < UFS_NXADDR; j++) {
414 if (--ndb == 0 &&
415 (offset = blkoff(&sblock, dp->dp2.di_extsize)) != 0)
416 idesc->id_numfrags = numfrags(&sblock,
417 fragroundup(&sblock, offset));
418 else
419 idesc->id_numfrags = sblock.fs_frag;
420 if (dp->dp2.di_extb[j] == 0)
421 continue;
422 idesc->id_blkno = dp->dp2.di_extb[j];
423 ret = (*idesc->id_func)(idesc);
424 if (ret & STOP)
425 break;
426 }
427 }
428 if (sblock.fs_magic == FS_UFS2_MAGIC)
429 eascan(idesc, &dp->dp2);
430 idesc->id_entryno *= btodb(sblock.fs_fsize);
431 if (DIP(dp, di_blocks) != idesc->id_entryno) {
432 pwarn("INCORRECT BLOCK COUNT I=%lu (%ju should be %ju)",
433 (u_long)inumber, (uintmax_t)DIP(dp, di_blocks),
434 (uintmax_t)idesc->id_entryno);
435 if (preen)
436 printf(" (CORRECTED)\n");
437 else if (reply("CORRECT") == 0)
438 return (1);
439 if (bkgrdflag == 0) {
440 ginode(inumber, &ip);
441 DIP_SET(ip.i_dp, di_blocks, idesc->id_entryno);
442 inodirty(&ip);
443 irelse(&ip);
444 } else {
445 cmd.value = idesc->id_number;
446 cmd.size = idesc->id_entryno - DIP(dp, di_blocks);
447 if (debug)
448 printf("adjblkcnt ino %ju amount %lld\n",
449 (uintmax_t)cmd.value, (long long)cmd.size);
450 if (sysctl(adjblkcnt, MIBSIZE, 0, 0,
451 &cmd, sizeof cmd) == -1)
452 rwerror("ADJUST INODE BLOCK COUNT", cmd.value);
453 }
454 }
455 /*
456 * UFS does not allow files to end with a hole; it requires that
457 * the last block of a file be allocated. The last allocated block
458 * in a file is tracked in id_lballoc. Here, we check for a size
459 * past the last allocated block of the file and if that is found,
460 * shorten the file to reference the last allocated block to avoid
461 * having it reference a hole at its end.
462 *
463 * Soft updates will always ensure that the file size is correct
464 * for files that contain only direct block pointers. However
465 * soft updates does not roll back sizes for files with indirect
466 * blocks that it has set to unallocated because their contents
467 * have not yet been written to disk. Hence, the file can appear
468 * to have a hole at its end because the block pointer has been
469 * rolled back to zero. Thus finding a hole at the end of a file
470 * that is located in an indirect block receives only a warning
471 * while finding a hole at the end of a file in a direct block
472 * receives a fatal error message.
473 */
474 size = DIP(dp, di_size);
475 if (idesc->id_lballoc < lblkno(&sblock, size - 1) &&
476 /* exclude embedded symbolic links */
477 ((mode != IFLNK) || size >= sblock.fs_maxsymlinklen)) {
478 fixsize = lblktosize(&sblock, idesc->id_lballoc + 1);
479 if (size > UFS_NDADDR * sblock.fs_bsize)
480 pwarn("INODE %lu: FILE SIZE %ju BEYOND END OF "
481 "ALLOCATED FILE, SIZE SHOULD BE %ju",
482 (u_long)inumber, size, fixsize);
483 else
484 pfatal("INODE %lu: FILE SIZE %ju BEYOND END OF "
485 "ALLOCATED FILE, SIZE SHOULD BE %ju",
486 (u_long)inumber, size, fixsize);
487 if (preen)
488 printf(" (ADJUSTED)\n");
489 else if (reply("ADJUST") == 0)
490 return (1);
491 if (bkgrdflag == 0) {
492 ginode(inumber, &ip);
493 DIP_SET(ip.i_dp, di_size, fixsize);
494 inodirty(&ip);
495 irelse(&ip);
496 } else {
497 cmd.value = idesc->id_number;
498 cmd.size = fixsize;
499 if (debug)
500 printf("setsize ino %ju size set to %ju\n",
501 (uintmax_t)cmd.value, (uintmax_t)cmd.size);
502 if (sysctl(setsize, MIBSIZE, 0, 0,
503 &cmd, sizeof cmd) == -1)
504 rwerror("SET INODE SIZE", cmd.value);
505 }
506
507 }
508 return (1);
509 unknown:
510 ginode(inumber, &ip);
511 prtinode(&ip);
512 inoinfo(inumber)->ino_state = USTATE;
513 if (reply("CLEAR") == 1) {
514 clearinode(ip.i_dp);
515 inodirty(&ip);
516 }
517 irelse(&ip);
518 return (1);
519 }
520
521 int
pass1check(struct inodesc * idesc)522 pass1check(struct inodesc *idesc)
523 {
524 int res = KEEPON;
525 int anyout, nfrags;
526 ufs2_daddr_t blkno = idesc->id_blkno;
527 struct dups *dlp;
528 struct dups *new;
529
530 if (idesc->id_type == SNAP) {
531 if (blkno == BLK_NOCOPY)
532 return (KEEPON);
533 if (idesc->id_number == cursnapshot) {
534 if (blkno == blkstofrags(&sblock, idesc->id_lbn))
535 return (KEEPON);
536 if (blkno == BLK_SNAP) {
537 blkno = blkstofrags(&sblock, idesc->id_lbn);
538 idesc->id_entryno -= idesc->id_numfrags;
539 }
540 } else {
541 if (blkno == BLK_SNAP)
542 return (KEEPON);
543 }
544 }
545 if ((anyout = chkrange(blkno, idesc->id_numfrags)) != 0) {
546 blkerror(idesc->id_number, "BAD", blkno);
547 if (badblk++ >= MAXBAD) {
548 pwarn("EXCESSIVE BAD BLKS I=%lu",
549 (u_long)idesc->id_number);
550 if (preen)
551 printf(" (SKIPPING)\n");
552 else if (reply("CONTINUE") == 0) {
553 ckfini(0);
554 exit(EEXIT);
555 }
556 rerun = 1;
557 return (STOP);
558 }
559 }
560 for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
561 if (anyout && chkrange(blkno, 1)) {
562 res = SKIP;
563 } else if (!testbmap(blkno)) {
564 n_blks++;
565 setbmap(blkno);
566 } else {
567 blkerror(idesc->id_number, "DUP", blkno);
568 if (dupblk++ >= MAXDUP) {
569 pwarn("EXCESSIVE DUP BLKS I=%lu",
570 (u_long)idesc->id_number);
571 if (preen)
572 printf(" (SKIPPING)\n");
573 else if (reply("CONTINUE") == 0) {
574 ckfini(0);
575 exit(EEXIT);
576 }
577 rerun = 1;
578 return (STOP);
579 }
580 new = (struct dups *)Malloc(sizeof(struct dups));
581 if (new == NULL) {
582 pfatal("DUP TABLE OVERFLOW.");
583 if (reply("CONTINUE") == 0) {
584 ckfini(0);
585 exit(EEXIT);
586 }
587 rerun = 1;
588 return (STOP);
589 }
590 new->dup = blkno;
591 if (muldup == NULL) {
592 duplist = muldup = new;
593 new->next = NULL;
594 } else {
595 new->next = muldup->next;
596 muldup->next = new;
597 }
598 for (dlp = duplist; dlp != muldup; dlp = dlp->next)
599 if (dlp->dup == blkno)
600 break;
601 if (dlp == muldup && dlp->dup != blkno)
602 muldup = new;
603 }
604 /*
605 * count the number of blocks found in id_entryno
606 */
607 idesc->id_entryno++;
608 }
609 if (idesc->id_level == 0 && idesc->id_lballoc < idesc->id_lbn)
610 idesc->id_lballoc = idesc->id_lbn;
611 return (res);
612 }
613