Source-Changes-HG archive

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

[src/netbsd-3-0]: src/distrib/utils/sysinst Pull up following revision(s) (re...



details:   https://anonhg.NetBSD.org/src/rev/d4c167d91c1f
branches:  netbsd-3-0
changeset: 579276:d4c167d91c1f
user:      riz <riz%NetBSD.org@localhost>
date:      Sat Aug 12 19:20:41 2006 +0000

description:
Pull up following revision(s) (requested by dsl in ticket #1463):
        distrib/utils/sysinst/mbr.c: revision 1.75
        distrib/utils/sysinst/label.c: revision 1.49
        distrib/utils/sysinst/defs.h: revision 1.130
When we read 'last mounted' from an FFSv2 superblock set the flag to
default the partition to FFSv2 (instead of FFSv1).
This makes update installs add the correct bootstrap code.
Fixes PR/33682 and PR/32636 (and 33228 which has alrady been closed
as a duplicate of 32636).

diffstat:

 distrib/utils/sysinst/defs.h  |   4 +-
 distrib/utils/sysinst/label.c |  45 +++++++++++++++++++++++++-----------------
 distrib/utils/sysinst/mbr.c   |   4 +-
 3 files changed, 31 insertions(+), 22 deletions(-)

diffs (139 lines):

diff -r 9459a540d336 -r d4c167d91c1f distrib/utils/sysinst/defs.h
--- a/distrib/utils/sysinst/defs.h      Sat Aug 12 19:17:42 2006 +0000
+++ b/distrib/utils/sysinst/defs.h      Sat Aug 12 19:20:41 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.123 2005/02/26 17:40:49 dsl Exp $   */
+/*     $NetBSD: defs.h,v 1.123.4.1 2006/08/12 19:20:41 riz Exp $       */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -291,7 +291,7 @@
 int    fs_is_lfs(void *);
 
 /* from label.c */
-const char *get_last_mounted(int, int);
+const char *get_last_mounted(int, int, partinfo *);
 int    savenewlabel(partinfo *, int);
 int    incorelabel(const char *, partinfo *);
 int    edit_and_check_label(partinfo *, int, int, int);
diff -r 9459a540d336 -r d4c167d91c1f distrib/utils/sysinst/label.c
--- a/distrib/utils/sysinst/label.c     Sat Aug 12 19:17:42 2006 +0000
+++ b/distrib/utils/sysinst/label.c     Sat Aug 12 19:20:41 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: label.c,v 1.47.4.1 2006/08/12 19:17:42 riz Exp $       */
+/*     $NetBSD: label.c,v 1.47.4.2 2006/08/12 19:20:41 riz Exp $       */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.47.4.1 2006/08/12 19:17:42 riz Exp $");
+__RCSID("$NetBSD: label.c,v 1.47.4.2 2006/08/12 19:20:41 riz Exp $");
 #endif
 
 #include <sys/types.h>
@@ -687,7 +687,7 @@
                lp->pi_partition = *pp;
                if (lp->pi_fstype >= FSMAXTYPES)
                        lp->pi_fstype = FS_OTHER;
-               strlcpy(lp->pi_mount, get_last_mounted(fd, pp->p_offset),
+               strlcpy(lp->pi_mount, get_last_mounted(fd, pp->p_offset, lp),
                        sizeof lp->pi_mount);
        }
        if (fd != -1)
@@ -700,21 +700,21 @@
  * Try to get 'last mounted on' (or equiv) from fs superblock.
  */
 const char *
-get_last_mounted(int fd, int partstart)
+get_last_mounted(int fd, int partstart, partinfo *lp)
 {
        static char sblk[SBLOCKSIZE];           /* is this enough? */
        #define SB ((struct fs *)sblk)
        const static int sblocks[] = SBLOCKSEARCH;
        const int *sbp;
        char *cp;
-       const char *mnt = "";
-       int l;
+       const char *mnt = NULL;
+       int len;
 
        if (fd == -1)
-               return mnt;
+               return "";
 
        /* Check UFS1/2 (and hence LFS) superblock */
-       for (sbp = sblocks; *mnt == 0 && *sbp != -1; sbp++) {
+       for (sbp = sblocks; mnt == NULL && *sbp != -1; sbp++) {
                if (pread(fd, sblk, sizeof sblk,
                    partstart * (off_t)512 + *sbp) != sizeof sblk)
                        continue;
@@ -724,15 +724,21 @@
                case FS_UFS1_MAGIC_SWAPPED:
                        if (!(SB->fs_old_flags & FS_FLAGS_UPDATED)) {
                                if (*sbp == SBLOCK_UFS1)
-                                       mnt = (const char *) SB->fs_fsmnt;
-                               continue;
+                                       mnt = (const char *)SB->fs_fsmnt;
+                       } else {
+                               /* Check we have the main superblock */
+                               if (SB->fs_sblockloc == *sbp)
+                                       mnt = (const char *)SB->fs_fsmnt;
                        }
-                       /* FALLTHROUGH */
+                       continue;
                case FS_UFS2_MAGIC:
                case FS_UFS2_MAGIC_SWAPPED:
                        /* Check we have the main superblock */
-                       if (SB->fs_sblockloc == *sbp)
-                               mnt = (const char *) SB->fs_fsmnt;
+                       if (SB->fs_sblockloc == *sbp) {
+                               mnt = (const char *)SB->fs_fsmnt;
+                               if (lp != NULL)
+                                       lp->pi_flags |= PIF_FFSv2;
+                       }
                        continue;
                }
 
@@ -756,13 +762,16 @@
                }
        }
 
+       if (mnt == NULL)
+               return "";
+
        /* If sysinst mounted this last then strip prefix */
-       l = strlen(targetroot_mnt);
-       if (memcmp(mnt, targetroot_mnt, l) == 0) {
-               if (mnt[l] == 0)
+       len = strlen(targetroot_mnt);
+       if (memcmp(mnt, targetroot_mnt, len) == 0) {
+               if (mnt[len] == 0)
                        return "/";
-               if (mnt[l] == '/')
-                       return mnt + l;
+               if (mnt[len] == '/')
+                       return mnt + len;
        }
        return mnt;
        #undef SB
diff -r 9459a540d336 -r d4c167d91c1f distrib/utils/sysinst/mbr.c
--- a/distrib/utils/sysinst/mbr.c       Sat Aug 12 19:17:42 2006 +0000
+++ b/distrib/utils/sysinst/mbr.c       Sat Aug 12 19:20:41 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbr.c,v 1.68.2.3 2005/11/21 20:42:02 tron Exp $ */
+/*     $NetBSD: mbr.c,v 1.68.2.3.2.1 2006/08/12 19:20:41 riz Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1444,7 +1444,7 @@
                                        ext_size = mbrp->mbrp_size;
                        } else {
                                mbri->last_mounted[i] = strdup(get_last_mounted(
-                                       fd, mbri->sector + mbrp->mbrp_start));
+                                       fd, mbri->sector + mbrp->mbrp_start, NULL));
 #if BOOTSEL
                                if (ombri->install == 0 &&
                                    strcmp(mbri->last_mounted[i], "/") == 0)



Home | Main Index | Thread Index | Old Index