Add options to write to a log and be quiet.

This commit is contained in:
2021-03-14 22:55:55 +00:00
parent f4ebb40f33
commit d65be35f01
62 changed files with 1152 additions and 885 deletions

View File

@@ -33,6 +33,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#endif
#include "../include/defs.h"
#include "../log.h"
#include "attr.h"
#include "dos.h"
@@ -53,13 +54,13 @@ void FileAttributes(const char* path)
if(rc)
{
printf("Cannot create working directory.\n");
log_write("Cannot create working directory.\n");
return;
}
chdir("ATTRS");
printf("Creating attributes files.\n");
log_write("Creating attributes files.\n");
for(i = 0; i < KNOWN_DOS_ATTRS; i++)
{
@@ -72,11 +73,11 @@ void FileAttributes(const char* path)
rc = _dos_setfileattr(dos_attrs[i].filename, dos_attrs[i].attr);
}
printf("\t%s: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
dos_attrs[i].description,
dos_attrs[i].filename,
rc,
wRc,
cRc);
log_write("\t%s: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
dos_attrs[i].description,
dos_attrs[i].filename,
rc,
wRc,
cRc);
}
}

View File

@@ -33,6 +33,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#endif
#include "../include/defs.h"
#include "../log.h"
#include "dos.h"
void DeleteFiles(const char* path)
@@ -53,13 +54,13 @@ void DeleteFiles(const char* path)
if(rc)
{
printf("Cannot create working directory.\n");
log_write("Cannot create working directory.\n");
return;
}
chdir("DELETED");
printf("Creating and deleting files.\n");
log_write("Creating and deleting files.\n");
for(pos = 0; pos < 64; pos++)
{

View File

@@ -33,6 +33,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#endif
#include "../include/defs.h"
#include "../log.h"
#include "dos.h"
void DirectoryDepth(const char* path)
@@ -52,13 +53,13 @@ void DirectoryDepth(const char* path)
if(rc)
{
printf("Cannot create working directory.\n");
log_write("Cannot create working directory.\n");
return;
}
rc = chdir("DEPTH");
printf("Creating deepest directory tree.\n");
log_write("Creating deepest directory tree.\n");
while(!rc)
{
@@ -71,5 +72,5 @@ void DirectoryDepth(const char* path)
pos++;
}
printf("\tCreated %d levels of directory hierarchy\n", pos);
log_write("\tCreated %d levels of directory hierarchy\n", pos);
}

View File

@@ -34,6 +34,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#include "../include/consts.h"
#include "../include/defs.h"
#include "../log.h"
#include "dos.h"
void Filenames(const char* path)
@@ -54,13 +55,13 @@ void Filenames(const char* path)
if(rc)
{
printf("Cannot create working directory.\n");
log_write("Cannot create working directory.\n");
return;
}
chdir("FILENAME");
printf("Creating files with different filenames.\n");
log_write("Creating files with different filenames.\n");
for(pos = 0; filenames[pos]; pos++)
{
@@ -74,6 +75,6 @@ void Filenames(const char* path)
cRc = _dos_close(handle);
}
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", filenames[pos], rc, wRc, cRc);
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", filenames[pos], rc, wRc, cRc);
}
}

View File

@@ -33,6 +33,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#endif
#include "../include/defs.h"
#include "../log.h"
#include "dos.h"
void MillionFiles(const char* path)
@@ -53,13 +54,13 @@ void MillionFiles(const char* path)
if(rc)
{
printf("Cannot create working directory.\n");
log_write("Cannot create working directory.\n");
return;
}
chdir("MILLION");
printf("Creating lots of files.\n");
log_write("Creating lots of files.\n");
for(pos = 0; pos < 1000; pos++)
{
@@ -71,5 +72,5 @@ void MillionFiles(const char* path)
_dos_close(handle);
}
printf("\tCreated %d files\n", pos);
log_write("\tCreated %d files\n", pos);
}

View File

@@ -36,6 +36,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#include "../include/consts.h"
#include "../include/defs.h"
#include "../log.h"
#include "dos.h"
void Fragmentation(const char* path, size_t clusterSize)
@@ -61,7 +62,7 @@ void Fragmentation(const char* path, size_t clusterSize)
if(rc)
{
printf("Cannot create working directory.\n");
log_write("Cannot create working directory.\n");
return;
}
@@ -80,7 +81,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "HALFCLST", halfCluster, rc, wRc, cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "HALFCLST", halfCluster, rc, wRc, cRc);
rc = _dos_creatnew("QUARCLST", _A_NORMAL, &handle);
if(!rc)
@@ -95,7 +96,8 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "QUARCLST", quarterCluster, rc, wRc, cRc);
log_write(
"\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "QUARCLST", quarterCluster, rc, wRc, cRc);
rc = _dos_creatnew("TWOCLST", _A_NORMAL, &handle);
if(!rc)
@@ -110,7 +112,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWOCLST", twoCluster, rc, wRc, cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWOCLST", twoCluster, rc, wRc, cRc);
rc = _dos_creatnew("TRQTCLST", _A_NORMAL, &handle);
if(!rc)
@@ -125,12 +127,12 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
"TRQTCLST",
threeQuartersCluster,
rc,
wRc,
cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
"TRQTCLST",
threeQuartersCluster,
rc,
wRc,
cRc);
rc = _dos_creatnew("TWTQCLST", _A_NORMAL, &handle);
if(!rc)
@@ -145,12 +147,12 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
"TWTQCLST",
twoAndThreeQuartCluster,
rc,
wRc,
cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
"TWTQCLST",
twoAndThreeQuartCluster,
rc,
wRc,
cRc);
rc = _dos_creatnew("TWO1", _A_NORMAL, &handle);
if(!rc)
@@ -165,7 +167,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO1", twoCluster, rc, wRc, cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO1", twoCluster, rc, wRc, cRc);
rc = _dos_creatnew("TWO2", _A_NORMAL, &handle);
if(!rc)
@@ -180,7 +182,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO2", twoCluster, rc, wRc, cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO2", twoCluster, rc, wRc, cRc);
rc = _dos_creatnew("TWO3", _A_NORMAL, &handle);
if(!rc)
@@ -195,10 +197,10 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tDeleting \"TWO2\".\n");
log_write("\tDeleting \"TWO2\".\n");
rc = unlink("TWO2");
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO3", twoCluster, rc, wRc, cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO3", twoCluster, rc, wRc, cRc);
rc = _dos_creatnew("FRAGTHRQ", _A_NORMAL, &handle);
if(!rc)
@@ -213,17 +215,17 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tDeleting \"TWO1\".\n");
log_write("\tDeleting \"TWO1\".\n");
unlink("TWO1");
printf("\tDeleting \"TWO3\".\n");
log_write("\tDeleting \"TWO3\".\n");
rc = unlink("TWO3");
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
"FRAGTHRQ",
threeQuartersCluster,
rc,
wRc,
cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
"FRAGTHRQ",
threeQuartersCluster,
rc,
wRc,
cRc);
rc = _dos_creatnew("FRAGSIXQ", _A_NORMAL, &handle);
if(!rc)
@@ -238,10 +240,10 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
"FRAGSIXQ",
twoAndThreeQuartCluster,
rc,
wRc,
cRc);
log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
"FRAGSIXQ",
twoAndThreeQuartCluster,
rc,
wRc,
cRc);
}

View File

@@ -31,6 +31,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#endif
#include "../include/defs.h"
#include "../log.h"
#include "dos.h"
#include "dosuname.h"
@@ -45,55 +46,49 @@ void GetOsInfo()
switch(dosuname_version.flavor)
{
case DOS_FLAVOR_UNKNOWN:
printf("OS information:\n");
printf("\tRunning under DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_MSDOS:
printf("OS information:\n");
printf("\tRunning under MS-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under MS-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_PCDOS:
printf("OS information:\n");
printf("\tRunning under PC-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under PC-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_DRDOS:
printf("OS information:\n");
printf("\tRunning under DR-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under DR-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_FREEDOS:
printf("OS information:\n");
printf("\tRunning under FreeDOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under FreeDOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_WIN95:
case DOS_FLAVOR_WIN9X:
case DOS_FLAVOR_WINME:
printf("Will not run under Windows 9x. Exiting...\n");
exit(1);
case DOS_FLAVOR_WINNT:
printf("Will not run under Windows NT. Exiting...\n");
exit(1);
case DOS_FLAVOR_OS2:
printf("Will not run under OS/2. Exiting...\n");
exit(1);
case DOS_FLAVOR_WINME: log_write("Will not run under Windows 9x. Exiting...\n"); exit(1);
case DOS_FLAVOR_WINNT: log_write("Will not run under Windows NT. Exiting...\n"); exit(1);
case DOS_FLAVOR_OS2: log_write("Will not run under OS/2. Exiting...\n"); exit(1);
case DOS_FLAVOR_PTSDOS:
printf("OS information:\n");
printf("\tRunning under PTS-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under PTS-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_RXDOS:
printf("OS information:\n");
printf("\tRunning under RxDOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under RxDOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_CONCURRENTDOS:
printf("OS information:\n");
printf("\tRunning under Concurrent DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under Concurrent DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_NOVELLDOS:
printf("OS information:\n");
printf("\tRunning under Novell DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under Novell DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
case DOS_FLAVOR_MSPCDOS:
printf("OS information:\n");
printf("\tRunning under MS-DOS or PC-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
log_write("OS information:\n");
log_write("\tRunning under MS-DOS or PC-DOS %d.%d\n", dosuname_version.major, dosuname_version.minor);
break;
}
}

View File

@@ -34,6 +34,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#endif
#include "../include/defs.h"
#include "../log.h"
#include "dos.h"
#include "time.h"
@@ -56,13 +57,13 @@ void Timestamps(const char* path)
if(rc)
{
printf("Cannot create working directory.\n");
log_write("Cannot create working directory.\n");
return;
}
chdir("TIMES");
printf("Creating timestamped files.\n");
log_write("Creating timestamped files.\n");
for(i = 0; i < KNOWN_DOS_TIMES; i++)
{
@@ -92,7 +93,7 @@ void Timestamps(const char* path)
cRc = _dos_close(handle);
}
printf(
log_write(
"\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", dos_times[i].filename, rc, wRc, cRc, tRc);
}
}

View File

@@ -29,6 +29,7 @@ Copyright (C) 2011-2021 Natalia Portillo
#include <string.h>
#include "../include/defs.h"
#include "../log.h"
#include "dos.h"
void GetVolumeInfo(const char* path, size_t* clusterSize)
@@ -57,23 +58,23 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
}
else
{
printf("Error %d requesting volume information.\n", _doserrno);
log_write("Error %d requesting volume information.\n", _doserrno);
return;
}
}
if(rc == 0)
{
printf("\tBytes per sector: %lu\n", freeSpace.bytesPerSector);
printf("\tSectors per cluster: %lu (%lu bytes)\n",
freeSpace.sectorsPerCluster,
freeSpace.sectorsPerCluster * freeSpace.bytesPerSector);
printf("\tClusters: %lu (%lu bytes)\n",
freeSpace.totalClusters,
freeSpace.sectorsPerCluster * freeSpace.bytesPerSector * freeSpace.totalClusters);
printf("\tFree clusters: %lu (%lu bytes)\n",
freeSpace.freeClusters,
freeSpace.sectorsPerCluster * freeSpace.bytesPerSector * freeSpace.freeClusters);
log_write("\tBytes per sector: %lu\n", freeSpace.bytesPerSector);
log_write("\tSectors per cluster: %lu (%lu bytes)\n",
freeSpace.sectorsPerCluster,
freeSpace.sectorsPerCluster * freeSpace.bytesPerSector);
log_write("\tClusters: %lu (%lu bytes)\n",
freeSpace.totalClusters,
freeSpace.sectorsPerCluster * freeSpace.bytesPerSector * freeSpace.totalClusters);
log_write("\tFree clusters: %lu (%lu bytes)\n",
freeSpace.freeClusters,
freeSpace.sectorsPerCluster * freeSpace.bytesPerSector * freeSpace.freeClusters);
*clusterSize = freeSpace.sectorsPerCluster * freeSpace.bytesPerSector;
}