fixsb has done its job.

This commit is contained in:
ad 2007-07-14 21:20:31 +00:00
parent bba99c25aa
commit 96d0aa8e9b
6 changed files with 11 additions and 209 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.194 2007/07/14 20:05:34 adrianp Exp $
# $NetBSD: mi,v 1.195 2007/07/14 21:20:32 ad Exp $
#
# Note: end-user configuration files that are moved to another location
# should not be marked "obsolete"; they should just be removed from
@ -179,7 +179,7 @@
./etc/rc.d/dmesg etc-sys-rc
./etc/rc.d/downinterfaces etc-sys-rc
./etc/rc.d/envsys etc-sys-rc
./etc/rc.d/fixsb etc-sys-rc
./etc/rc.d/fixsb etc-obsolete obsolete
./etc/rc.d/fsck etc-sys-rc
./etc/rc.d/fsck.sh etc-obsolete obsolete
./etc/rc.d/ftpd etc-net-rc

View File

@ -1,4 +1,4 @@
# $NetBSD: rc.conf,v 1.87 2007/07/01 07:55:53 xtraeme Exp $
# $NetBSD: rc.conf,v 1.88 2007/07/14 21:20:32 ad Exp $
#
# /etc/defaults/rc.conf --
# default configuration of /etc/rc.conf
@ -119,9 +119,6 @@ rtclocaltime=NO
# NOTE: default coredump name now set in /etc/sysctl.conf
# Automatically check for and repair the botched superblock problem
fixsb=YES
#
# File system check flags; default to preen mode, checking filesystems
# that are listed in /etc/fstab in parallel as the fsck pass number

View File

@ -1,4 +1,4 @@
# $NetBSD: special,v 1.114 2007/07/02 15:26:18 xtraeme Exp $
# $NetBSD: special,v 1.115 2007/07/14 21:20:33 ad Exp $
# @(#)special 8.2 (Berkeley) 1/23/94
#
# This file may be overwritten on upgrades.
@ -193,7 +193,6 @@
./etc/rc.d/dmesg type=file mode=0555
./etc/rc.d/downinterfaces type=file mode=0555
./etc/rc.d/envsys type=file mode=0555
./etc/rc.d/fixsb type=file mode=0555
./etc/rc.d/fsck type=file mode=0555
./etc/rc.d/ftpd type=file mode=0555
./etc/rc.d/hostapd type=file mode=0555

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.65 2007/07/01 08:01:29 xtraeme Exp $
# $NetBSD: Makefile,v 1.66 2007/07/14 21:20:31 ad Exp $
.include <bsd.own.mk>
@ -13,7 +13,7 @@ CONFIGFILES=\
bootconf.sh bootparams btconfig btdevctl bthcid btuartd \
ccd cgd cleartmp cron \
dhclient dhcpd dhcrelay dmesg downinterfaces envsys \
fixsb fsck ftpd \
fsck ftpd \
hostapd \
identd ifwatchd inetd ipfilter ipfs ipmon ipnat ipsec \
irdaattach iscsi_target isdnd \

View File

@ -1,195 +0,0 @@
#!/bin/sh
#
# $NetBSD: fixsb,v 1.13 2007/04/06 14:20:17 apb Exp $
#
# PROVIDE: fixsb
# REQUIRE: localswap
# BEFORE: fsck
$_rc_subr_loaded . /etc/rc.subr
name="fixsb"
rcvar=$name
start_cmd="fsck_start"
stop_cmd=":"
# This rc.d script attempts to correct problems with ffs1 filesystems
# which may have been introduced by booting a netbsd-current kernel
# from between April of 2003 and January 2004. For more information
# see <http://mail-index.NetBSD.org/current-users/2004/01/11/0022.html>
# This script was developed as a response to NetBSD pr install/25138
# Additional prs regarding the original issue include:
# bin/17910 kern/21283 kern/21404 port-macppc/23925 port-macppc/23926
#
fstab=/etc/fstab
#verbose=1
verbose()
{
if [ -n "${verbose}" ]; then
echo "$@" 1>&2
fi
}
# This reads a field from the ffs superblock
# at the specified offset and length in bytes
# from the start of the superblock
readsbfield()
{
# The first dd command reads in the superblock using block aligned i/o
# so that it works on a raw character device. The second dd extracts
# the exact field from the superblock that we wish to read.
(dd if="$1" bs=8192 count=1 skip=1 |
dd bs=1 skip="$2" count="$3" | cat -v) 2> /dev/null
}
# This shell function extracts the `ffs superblock' of the file
# provided as its argument and tests for the following condition:
# ((fs_magic == FS_UFS1_MAGIC) || fs_magic == FS_UFS1_MAGIC_SWAPPED) &&
# (fs_sbsize == fs_maxbsize) && !(fs_old_flags & FS_FLAGS_UPDATED)
#
# return status is based on status of last filesystem checked:
# 0 for botched superblock
# 1 for filesystem does not appear to be ffs1 filesystem
# 3 for ok fslevel 3 filesystem
# 4 for ok fslevel 4 filesystem
#
# dbj@NetBSD.org 2004-04-12T18:15:06-0400
check_part()
{
verbose -n "Checking $1 ... "
# The following are 'cat -v' representations of the ffs1 magic number:
fsmagicn="^@^A^YT" # 0x00011954 FS_UFS1_MAGIC
fsmagics="T^Y^A^@" # 0x54190100 FS_UFS1_MAGIC_SWAPPED
# First we extract the superblock magic number field.
# We use cat -v to avoid having binary data in shell strings.
magic="$(readsbfield "$1" 1372 4)"
# Then we check if the magic number is valid (swapped or unswapped):
if [ "${magic}" != "${fsmagicn}" -a "${magic}" != "${fsmagics}" ]; then
verbose "does not appear to be an ffs1 filesystem."
return 1
fi
# Then we read fs_old_flags fields from disk
# And check the value of its high bit.
oldflags="$(readsbfield "$1" 211 1)"
case "${oldflags}" in
# Since the shell variable is the cat -v output, the
# high bit is indicated in the variable with the prefix M-
M-*)
verbose "file system looks ok at fslevel 4."
return 4
;;
esac
# Then we read fs_bsize, fs_maxbsize fields from the disk:
bsize="$(readsbfield "$1" 48 4)"
maxbsize="$(readsbfield "$1" 860 4)"
# Compare the fs_bsize with fs_maxbsize to see if they are the same
if [ "${bsize}" != "${maxbsize}" ]; then
verbose "file system looks ok at fslevel 3."
return 3
fi
verbose "file system has botched superblock upgrade."
return 0
}
# This extracts raw ufs partitions to be fsck'ed from the file ${fstab}
parse_fstab()
{
for l in 1 2; do
cat "${fstab}" 2> /dev/null |
while read d m t o b f err; do
case "$d" in
\#*)
continue
;;
/dev/*)
d="/dev/r${d#/dev/}"
;;
esac
case "$t" in
ffs|ufs)
if [ "$f" = "$l" ]; then
echo "$d"
fi
;;
esac
done
done
}
do_fsck()
{
# During fsck ignore SIGQUIT
fsck_ffs "$@"
case $? in
0)
;;
2)
stop_boot
;;
4)
echo "Rebooting..."
reboot
echo "Reboot failed; help!"
stop_boot
;;
8)
echo "Automatic file system check failed; help!"
stop_boot
;;
12)
echo "Boot interrupted."
stop_boot
;;
130)
stop_boot
;;
*)
echo "Unknown error; help!"
stop_boot
;;
esac
}
fsck_start()
{
if [ -e /fastboot ]; then
echo "Fast boot: skipping disk checks."
else
# During fsck ignore SIGQUIT
trap : 3
okfs=true
echo -n "Checking for botched superblock upgrades:"
for p in $(parse_fstab); do
if check_part "$p"; then
if $okfs; then
echo
okfs=false
fi
echo "Repairing partition $p"
do_fsck -p -b 16 -c 4 "$p"
do_fsck -p -c 3 "$p"
fi
done
if $okfs; then
echo " done."
else
echo "Superblock(s) updated successfully."
fi
fi
}
load_rc_config $name
run_rc_command "$1"

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: postinstall,v 1.44 2007/07/12 07:13:07 xtraeme Exp $
# $NetBSD: postinstall,v 1.45 2007/07/14 21:20:33 ad Exp $
#
# Copyright (c) 2002-2006 The NetBSD Foundation, Inc.
# All rights reserved.
@ -863,7 +863,7 @@ do_rc()
bootconf.sh bootparams btconfig btdevctl bthcid \
ccd cgd cleartmp cron \
dhclient dhcpd dhcrelay dmesg downinterfaces envsys \
fixsb fsck ftpd \
fsck ftpd \
hostapd \
identd ifwatchd inetd ipfilter ipfs ipmon ipnat ipsec \
irdaattach iscsi_target isdnd \
@ -885,8 +885,8 @@ do_rc()
failed=$(( ${failed} + $? ))
# check for obsolete rc.d files
for f in NETWORK btcontrol fsck.sh kerberos nfsiod servers systemfs \
daemon gated login portmap sunndd xntpd; do
for f in NETWORK btcontrol fsck.sh fixsb kerberos nfsiod servers \
systemfs daemon gated login portmap sunndd xntpd; do
fd=/etc/rc.d/${f}
[ -e "${DEST_DIR}${fd}" ] && echo "${fd}"
done | obsolete_paths ${op}
@ -897,6 +897,7 @@ do_rc()
btcontrol btcontrol_devices \
critical_filesystems critical_filesystems_beforenet \
defcorename \
fixsb \
ip6forwarding \
mountcritlocal mountcritremote \
network nfsiod_flags \