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).
This commit is contained in:
dsl 2006-06-10 14:48:46 +00:00
parent bc1d1f7877
commit 6d35173b6d
3 changed files with 31 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.129 2006/04/05 16:55:01 garbled Exp $ */
/* $NetBSD: defs.h,v 1.130 2006/06/10 14:48:46 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -325,7 +325,7 @@ int check_swap(const char *, int);
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);

View File

@ -1,4 +1,4 @@
/* $NetBSD: label.c,v 1.48 2006/05/16 00:16:59 dogcow Exp $ */
/* $NetBSD: label.c,v 1.49 2006/06/10 14:48:46 dsl 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.48 2006/05/16 00:16:59 dogcow Exp $");
__RCSID("$NetBSD: label.c,v 1.49 2006/06/10 14:48:46 dsl Exp $");
#endif
#include <sys/types.h>
@ -687,7 +687,7 @@ incorelabel(const char *dkname, partinfo *lp)
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 @@ incorelabel(const char *dkname, partinfo *lp)
* 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 @@ get_last_mounted(int fd, int partstart)
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 @@ get_last_mounted(int fd, int partstart)
}
}
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

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbr.c,v 1.74 2006/05/16 00:16:59 dogcow Exp $ */
/* $NetBSD: mbr.c,v 1.75 2006/06/10 14:48:46 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -1464,7 +1464,7 @@ read_mbr(const char *disk, mbr_info_t *mbri)
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)