+# Check an ext2/3/4 filesystem
+#
+_check_extN_filesystem()
+{
+ device=$1
+
+ # If type is set, we're mounted
+ type=`_fs_type $device`
+ ok=1
+
+ if [ "$type" = "$FSTYP" ]
+ then
+ # mounted ...
+ mountpoint=`_umount_or_remount_ro $device`
+ fi
+
+ e2fsck -nf $device >$tmp.fsck 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "_check_extN_filesystem: filesystem on $device is inconsistent (see $seq.full)"
+
+ echo "_check_extN filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
+ echo "*** e2fsck output ***" >>$here/$seq.full
+ cat $tmp.fsck >>$here/$seq.full
+ echo "*** end e2fsck output" >>$here/$seq.full
+
+ ok=0
+ fi
+ rm -f $tmp.fsck
+
+ if [ $ok -eq 0 ]
+ then
+ echo "*** mount output ***" >>$here/$seq.full
+ _mount >>$here/$seq.full
+ echo "*** end mount output" >>$here/$seq.full
+ elif [ "$type" = "$FSTYP" ]
+ then
+ # was mounted ...
+ _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+ ok=$?
+ fi
+
+ [ $ok -eq 0 ] && exit 1
+ return 0
+}
+