Subject: Re: install/25138: 2.0: sysinst upgrade broken: fsck_ffs bails out
To: Hubert Feyrer <hubert@feyrer.de>
From: Darrin B. Jewell <dbj@netbsd.org>
List: netbsd-bugs
Date: 04/12/2004 14:05:47
--=-=-=

"Darrin B. Jewell" <dbj@netbsd.org> writes:
> I also plan to create a simple shell script test for the existence of
> the botched superblock problem.

For reference, here's a script that will do such a test.


--=-=-=
Content-Type: application/x-sh
Content-Disposition: attachment; filename=checksb.sh
Content-Description: shell script to test for botched superblock conditions

#!/bin/sh

# This shell script extracts the `ffs superblock' of any files listed
# on standard input 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)
# it prints the names of successful tests on stdout
#
# dbj@netbsd.org 2004-04-12T13:49:43-0400 

#debug=1

fsmagicn="^@^A^YT"  # 0x00011954 FS_UFS1_MAGIC
fsmagics="T^Y^A^@"  # 0x54190100 FS_UFS1_MAGIC_SWAPPED

check_part()
{
  magic="`(dd if="$1" bs=8192 skip=1 count=1 | dd bs=1 count=4 skip=1372 | cat -v) 2> /dev/null`"
  if [ "${magic}" = "${fsmagicn}" -o "${magic}" = "${fsmagics}" ]; then
    bsize="`(dd if="$1" bs=8192 skip=1 count=1 | dd bs=1 count=4 skip=48 | cat -v) 2> /dev/null`"
    maxbsize="`(dd if="$1" bs=8192 skip=1 count=1 | dd bs=1 count=4 skip=860 | cat -v) 2> /dev/null`"
    oldflags="`(dd if="$1" bs=8192 skip=1 count=1 | dd bs=1 count=1 skip=211 | cat -v) 2> /dev/null`"
    if [ ! -z "${debug}" ]; then
      echo "$1: magic=${magic} bsize=${bsize} maxbsize=${maxbsize} oldflags=${oldflags}"
    fi
    if [ "${bsize}" = "${maxbsize}" ]; then
      case "${oldflags}" in
        M-*)
        ;;
 	*)
        return 0
        ;;
      esac
    fi
  fi
  return 1
}

for p in ${1+"$@"}; do
  if check_part "$p"; then
    echo "$p"
  fi
done
exit 0

--=-=-=--