summaryrefslogtreecommitdiffstats
path: root/sbin/newfs
diff options
context:
space:
mode:
authorwes <wes@FreeBSD.org>2003-11-16 07:17:30 +0000
committerwes <wes@FreeBSD.org>2003-11-16 07:17:30 +0000
commita79f1dd547b90d142814637f968b1b79ba96aab6 (patch)
tree268aee28f92ddb4ffb10809f224a66f994fcf5f1 /sbin/newfs
parent6288a669519a7fbdfd0465318c62c56d1b223e17 (diff)
downloadFreeBSD-src-a79f1dd547b90d142814637f968b1b79ba96aab6.zip
FreeBSD-src-a79f1dd547b90d142814637f968b1b79ba96aab6.tar.gz
Add the -E command line option to force error conditions for testing.
Sponsord by: St. Bernard Software
Diffstat (limited to 'sbin/newfs')
-rw-r--r--sbin/newfs/mkfs.c13
-rw-r--r--sbin/newfs/newfs.c6
-rw-r--r--sbin/newfs/newfs.h1
3 files changed, 18 insertions, 2 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 4cbce26..4ed46e3 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -451,7 +451,14 @@ mkfs(struct partition *pp, char *fsys)
}
if (!Nflag)
sbwrite(&disk, 0);
- sblock.fs_magic = FS_UFS2_MAGIC;
+ if (Eflag == 1) {
+ printf("** Exiting on Eflag 1\n");
+ exit(0);
+ }
+ if (Eflag == 2)
+ printf("** Leaving BAD MAGIC on Eflag 2\n");
+ else
+ sblock.fs_magic = FS_UFS2_MAGIC;
/*
* Now build the cylinders group blocks and
@@ -507,6 +514,10 @@ mkfs(struct partition *pp, char *fsys)
sblock.fs_old_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree;
sblock.fs_old_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree;
}
+ if (Eflag == 3) {
+ printf("** Exiting on Eflag 3\n");
+ exit(0);
+ }
if (!Nflag)
sbwrite(&disk, 0);
for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize)
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 584ff0c..aff266e 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -119,6 +119,7 @@ int Nflag; /* run without writing file system */
int Oflag = 2; /* file system format (1 => UFS1, 2 => UFS2) */
int Rflag; /* regression test */
int Uflag; /* enable soft updates for file system */
+int Eflag = 0; /* exit in middle of newfs for testing */
quad_t fssize; /* file system size */
int sectorsize; /* bytes/sector */
int realsectorsize; /* bytes/sector in hardware */
@@ -156,8 +157,11 @@ main(int argc, char *argv[])
off_t mediasize;
while ((ch = getopt(argc, argv,
- "L:NO:RS:T:Ua:b:c:d:e:f:g:h:i:m:o:s:")) != -1)
+ "EL:NO:RS:T:Ua:b:c:d:e:f:g:h:i:m:o:s:")) != -1)
switch (ch) {
+ case 'E':
+ Eflag++;
+ break;
case 'L':
volumelabel = optarg;
i = -1;
diff --git a/sbin/newfs/newfs.h b/sbin/newfs/newfs.h
index 37cfb45..1c82685 100644
--- a/sbin/newfs/newfs.h
+++ b/sbin/newfs/newfs.h
@@ -52,6 +52,7 @@ extern int Nflag; /* run mkfs without writing file system */
extern int Oflag; /* build UFS1 format file system */
extern int Rflag; /* regression test */
extern int Uflag; /* enable soft updates for file system */
+extern int Eflag; /* exit as if error, for testing */
extern quad_t fssize; /* file system size */
extern int sectorsize; /* bytes/sector */
extern int realsectorsize; /* bytes/sector in hardware*/
OpenPOWER on IntegriCloud