Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/fsck_ffs Add a test for duplicate inodes on the persist...



details:   https://anonhg.NetBSD.org/src/rev/404076a5b8a2
branches:  trunk
changeset: 433798:404076a5b8a2
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Oct 05 09:49:23 2018 +0000

description:
Add a test for duplicate inodes on the persistent snapshot list.

diffstat:

 sbin/fsck_ffs/setup.c |  52 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 2 deletions(-)

diffs (84 lines):

diff -r fd474629b7c0 -r 404076a5b8a2 sbin/fsck_ffs/setup.c
--- a/sbin/fsck_ffs/setup.c     Fri Oct 05 08:23:58 2018 +0000
+++ b/sbin/fsck_ffs/setup.c     Fri Oct 05 09:49:23 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setup.c,v 1.101 2017/02/08 16:11:40 rin Exp $  */
+/*     $NetBSD: setup.c,v 1.102 2018/10/05 09:49:23 hannken Exp $      */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c    8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.101 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: setup.c,v 1.102 2018/10/05 09:49:23 hannken Exp $");
 #endif
 #endif /* not lint */
 
@@ -73,6 +73,7 @@
 #ifndef NO_APPLE_UFS
 static int readappleufs(void);
 #endif
+static int check_snapinum(void);
 
 int16_t sblkpostbl[256];
 
@@ -341,6 +342,14 @@
                        dirty(&asblk);
                }
        }
+       if (check_snapinum()) {
+               if (preen)
+                       printf(" (FIXED)\n");
+               if (preen || reply("FIX") == 1) {
+                       sbdirty();
+                       dirty(&asblk);
+               }
+       }
        if (is_ufs2 || sblock->fs_old_inodefmt >= FS_44INODEFMT) {
                if (sblock->fs_maxfilesize != maxfilesize) {
                        pwarn("INCORRECT MAXFILESIZE=%lld IN SUPERBLOCK",
@@ -1094,3 +1103,42 @@
        }
        return (1);
 }
+
+/*
+ * Test the list of snapshot inode numbers for duplicates and repair.
+ */
+static int
+check_snapinum(void)
+{
+       int loc, loc2, res;
+       int *snapinum = &sblock->fs_snapinum[0];
+
+       res = 0;
+ 
+       if (isappleufs)
+               return 0;
+
+       for (loc = 0; loc < FSMAXSNAP; loc++) {
+               if (snapinum[loc] == 0)
+                       break;
+               for (loc2 = loc + 1; loc2 < FSMAXSNAP; loc2++) {
+                       if (snapinum[loc2] == 0 ||
+                           snapinum[loc2] == snapinum[loc])
+                               break;
+               }
+               if (loc2 >= FSMAXSNAP || snapinum[loc2] == 0)
+                       continue;
+               pwarn("SNAPSHOT INODE %u ALREADY ON LIST%s", snapinum[loc2],
+                   (res ? "" : "\n"));
+               res = 1;
+               for (loc2 = loc + 1; loc2 < FSMAXSNAP; loc2++) {
+                       if (snapinum[loc2] == 0)
+                               break;
+                       snapinum[loc2 - 1] = snapinum[loc2];
+               }
+               snapinum[loc2 - 1] = 0;
+               loc--;
+       }
+
+       return res;
+}



Home | Main Index | Thread Index | Old Index