Deleted Added
full compact
dir.c (63810) dir.c (74556)
1/*
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static const char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
37#endif
38static const char rcsid[] =
1/*
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static const char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
37#endif
38static const char rcsid[] =
39 "$FreeBSD: head/sbin/fsck_ffs/dir.c 63810 2000-07-24 19:50:20Z mckusick $";
39 "$FreeBSD: head/sbin/fsck_ffs/dir.c 74556 2001-03-21 09:48:03Z mckusick $";
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/time.h>
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/time.h>
44#include <sys/sysctl.h>
44
45#include <ufs/ufs/dinode.h>
46#include <ufs/ufs/dir.h>
47#include <ufs/ffs/fs.h>
48
49#include <err.h>
50#include <string.h>
51
52#include "fsck.h"
53
54char *lfname = "lost+found";
55int lfmode = 01777;
45
46#include <ufs/ufs/dinode.h>
47#include <ufs/ufs/dir.h>
48#include <ufs/ffs/fs.h>
49
50#include <err.h>
51#include <string.h>
52
53#include "fsck.h"
54
55char *lfname = "lost+found";
56int lfmode = 01777;
56struct dirtemplate emptydir = { 0, DIRBLKSIZ };
57struct dirtemplate emptydir = {
58 0, DIRBLKSIZ, DT_UNKNOWN, 0, "",
59 0, 0, DT_UNKNOWN, 0, ""
60};
57struct dirtemplate dirhead = {
58 0, 12, DT_DIR, 1, ".",
59 0, DIRBLKSIZ - 12, DT_DIR, 2, ".."
60};
61struct odirtemplate odirhead = {
62 0, 12, 1, ".",
63 0, DIRBLKSIZ - 12, 2, ".."
64};

--- 37 unchanged lines hidden (view full) ---

102 * Scan each entry in a directory block.
103 */
104int
105dirscan(idesc)
106 register struct inodesc *idesc;
107{
108 register struct direct *dp;
109 register struct bufarea *bp;
61struct dirtemplate dirhead = {
62 0, 12, DT_DIR, 1, ".",
63 0, DIRBLKSIZ - 12, DT_DIR, 2, ".."
64};
65struct odirtemplate odirhead = {
66 0, 12, 1, ".",
67 0, DIRBLKSIZ - 12, 2, ".."
68};

--- 37 unchanged lines hidden (view full) ---

106 * Scan each entry in a directory block.
107 */
108int
109dirscan(idesc)
110 register struct inodesc *idesc;
111{
112 register struct direct *dp;
113 register struct bufarea *bp;
110 int dsize, n;
114 u_int dsize, n;
111 long blksiz;
112 char dbuf[DIRBLKSIZ];
113
114 if (idesc->id_type != DATA)
115 errx(EEXIT, "wrong type to dirscan %d", idesc->id_type);
116 if (idesc->id_entryno == 0 &&
117 (idesc->id_filesize & (DIRBLKSIZ - 1)) != 0)
118 idesc->id_filesize = roundup(idesc->id_filesize, DIRBLKSIZ);

--- 200 unchanged lines hidden (view full) ---

319
320 dp = ginode(idesc->id_number);
321 if (dp->di_nlink == lcnt) {
322 /*
323 * If we have not hit any unresolved problems, are running
324 * in preen mode, and are on a filesystem using soft updates,
325 * then just toss any partially allocated files.
326 */
115 long blksiz;
116 char dbuf[DIRBLKSIZ];
117
118 if (idesc->id_type != DATA)
119 errx(EEXIT, "wrong type to dirscan %d", idesc->id_type);
120 if (idesc->id_entryno == 0 &&
121 (idesc->id_filesize & (DIRBLKSIZ - 1)) != 0)
122 idesc->id_filesize = roundup(idesc->id_filesize, DIRBLKSIZ);

--- 200 unchanged lines hidden (view full) ---

323
324 dp = ginode(idesc->id_number);
325 if (dp->di_nlink == lcnt) {
326 /*
327 * If we have not hit any unresolved problems, are running
328 * in preen mode, and are on a filesystem using soft updates,
329 * then just toss any partially allocated files.
330 */
327 if (resolved && preen && usedsoftdep) {
331 if (resolved && (preen || bkgrdflag) && usedsoftdep) {
328 clri(idesc, "UNREF", 1);
329 return;
330 } else {
331 /*
332 * The filesystem can be marked clean even if
333 * a file is not linked up, but is cleared.
334 * Hence, resolved should not be cleared when
335 * linkup is answered no, but clri is answered yes.

--- 21 unchanged lines hidden (view full) ---

357 if (lcnt < 0) {
358 printf("\n");
359 pfatal("LINK COUNT INCREASING");
360 }
361 if (preen)
362 printf(" (ADJUSTED)\n");
363 }
364 if (preen || reply("ADJUST") == 1) {
332 clri(idesc, "UNREF", 1);
333 return;
334 } else {
335 /*
336 * The filesystem can be marked clean even if
337 * a file is not linked up, but is cleared.
338 * Hence, resolved should not be cleared when
339 * linkup is answered no, but clri is answered yes.

--- 21 unchanged lines hidden (view full) ---

361 if (lcnt < 0) {
362 printf("\n");
363 pfatal("LINK COUNT INCREASING");
364 }
365 if (preen)
366 printf(" (ADJUSTED)\n");
367 }
368 if (preen || reply("ADJUST") == 1) {
365 dp->di_nlink -= lcnt;
366 inodirty();
369 if (bkgrdflag == 0) {
370 dp->di_nlink -= lcnt;
371 inodirty();
372 } else {
373 cmd.value = idesc->id_number;
374 cmd.size = -lcnt;
375 if (debug)
376 printf("adjrefcnt ino %d amt %d\n",
377 (long)cmd.value, cmd.size);
378 if (sysctl(adjrefcnt, MIBSIZE, 0, 0,
379 &cmd, sizeof cmd) == -1)
380 rwerror("ADJUST INODE", cmd.value);
381 }
367 }
368 }
369}
370
371static int
372mkentry(idesc)
373 struct inodesc *idesc;
374{

--- 68 unchanged lines hidden (view full) ---

443
444 memset(&idesc, 0, sizeof(struct inodesc));
445 dp = ginode(orphan);
446 lostdir = (dp->di_mode & IFMT) == IFDIR;
447 pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
448 pinode(orphan);
449 if (preen && dp->di_size == 0)
450 return (0);
382 }
383 }
384}
385
386static int
387mkentry(idesc)
388 struct inodesc *idesc;
389{

--- 68 unchanged lines hidden (view full) ---

458
459 memset(&idesc, 0, sizeof(struct inodesc));
460 dp = ginode(orphan);
461 lostdir = (dp->di_mode & IFMT) == IFDIR;
462 pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
463 pinode(orphan);
464 if (preen && dp->di_size == 0)
465 return (0);
466 if (cursnapshot != 0) {
467 pfatal("FILE LINKUP IN SNAPSHOT");
468 return (0);
469 }
451 if (preen)
452 printf(" (RECONNECTED)\n");
453 else
454 if (reply("RECONNECT") == 0)
455 return (0);
456 if (lfdir == 0) {
457 dp = ginode(ROOTINO);
458 idesc.id_name = lfname;

--- 321 unchanged lines hidden ---
470 if (preen)
471 printf(" (RECONNECTED)\n");
472 else
473 if (reply("RECONNECT") == 0)
474 return (0);
475 if (lfdir == 0) {
476 dp = ginode(ROOTINO);
477 idesc.id_name = lfname;

--- 321 unchanged lines hidden ---