Add the -E command line option to force error conditions for testing.

Sponsord by:	St. Bernard Software
This commit is contained in:
wes 2003-11-16 07:17:30 +00:00
parent bdb65f103c
commit c1263a5de6
3 changed files with 18 additions and 2 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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*/