From 0aef69272b42a257a58453800c716d73b2059a84 Mon Sep 17 00:00:00 2001 From: mlelstv Date: Sun, 31 Jan 2010 16:04:34 +0000 Subject: [PATCH] Skip handling of APPLEUFS_LABEL if it is smaller than a device block. In particular: - newfs will not try to erase the label - fsck_ffs will not try to validate the label This lets newfs and fsck work on 2048-byte-per-sector media. Does Apple UFS support such media and how? --- sbin/fsck_ffs/setup.c | 6 ++++-- sbin/newfs/mkfs.c | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 331f594d853b..aa09c37b0df2 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.89 2009/09/27 17:13:37 bouyer Exp $ */ +/* $NetBSD: setup.c,v 1.90 2010/01/31 16:04:35 mlelstv Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95"; #else -__RCSID("$NetBSD: setup.c,v 1.89 2009/09/27 17:13:37 bouyer Exp $"); +__RCSID("$NetBSD: setup.c,v 1.90 2010/01/31 16:04:35 mlelstv Exp $"); #endif #endif /* not lint */ @@ -554,6 +554,8 @@ readappleufs(void) /* XXX do we have to deal with APPLEUFS_LABEL_OFFSET not * being block aligned (CD's?) */ + if (APPLEUFS_LABEL_SIZE % dev_bsize != 0) + return 0; if (bread(fsreadfd, (char *)appleufsblk.b_un.b_fs, label, (long)APPLEUFS_LABEL_SIZE) != 0) return 0; diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index d94867ac30b2..f1c314e71171 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs.c,v 1.106 2009/05/07 06:56:56 lukem Exp $ */ +/* $NetBSD: mkfs.c,v 1.107 2010/01/31 16:04:34 mlelstv Exp $ */ /* * Copyright (c) 1980, 1989, 1993 @@ -73,7 +73,7 @@ #if 0 static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: mkfs.c,v 1.106 2009/05/07 06:56:56 lukem Exp $"); +__RCSID("$NetBSD: mkfs.c,v 1.107 2010/01/31 16:04:34 mlelstv Exp $"); #endif #endif /* not lint */ @@ -603,7 +603,7 @@ mkfs(const char *fsys, int fi, int fo, tv.tv_sec, 0); wtfs(APPLEUFS_LABEL_OFFSET/sectorsize, APPLEUFS_LABEL_SIZE, &appleufs); - } else { + } else if (APPLEUFS_LABEL_SIZE % sectorsize == 0) { struct appleufslabel appleufs; /* Look for & zap any existing valid apple ufs labels */ rdfs(APPLEUFS_LABEL_OFFSET/sectorsize,