mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Add options to write to a log and be quiet.
This commit is contained in:
@@ -30,6 +30,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void DeleteFiles(const char* path)
|
||||
{
|
||||
@@ -42,7 +43,7 @@ void DeleteFiles(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to specified path.\n", errno);
|
||||
log_write("Error %d changing to specified path.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ void DeleteFiles(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d creating working directory.\n", errno);
|
||||
log_write("Error %d creating working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,11 +59,11 @@ void DeleteFiles(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to working directory.\n", errno);
|
||||
log_write("Error %d changing to working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Creating and deleting files.\n");
|
||||
log_write("Creating and deleting files.\n");
|
||||
|
||||
for(pos = 0; pos < 64; pos++)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void DirectoryDepth(const char* path)
|
||||
{
|
||||
@@ -40,7 +41,7 @@ void DirectoryDepth(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to specified path.\n", errno);
|
||||
log_write("Error %d changing to specified path.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ void DirectoryDepth(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d creating working directory.\n", errno);
|
||||
log_write("Error %d creating working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,11 +57,11 @@ void DirectoryDepth(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to working directory.\n", errno);
|
||||
log_write("Error %d changing to working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Creating deepest directory tree.\n");
|
||||
log_write("Creating deepest directory tree.\n");
|
||||
|
||||
while(!ret)
|
||||
{
|
||||
@@ -76,5 +77,5 @@ void DirectoryDepth(const char* path)
|
||||
if(pos >= 1000) break;
|
||||
}
|
||||
|
||||
printf("\tCreated %ld levels of directory hierarchy\n", pos);
|
||||
log_write("\tCreated %ld levels of directory hierarchy\n", pos);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
#include "../include/consts.h"
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void Filenames(const char* path)
|
||||
{
|
||||
@@ -43,7 +44,7 @@ void Filenames(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to specified path.\n", errno);
|
||||
log_write("Error %d changing to specified path.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ void Filenames(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d creating working directory.\n", errno);
|
||||
log_write("Error %d creating working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,11 +60,11 @@ void Filenames(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to working directory.\n", errno);
|
||||
log_write("Error %d changing to working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Creating files with different filenames.\n");
|
||||
log_write("Creating files with different filenames.\n");
|
||||
|
||||
for(pos = 0; filenames[pos]; pos++)
|
||||
{
|
||||
@@ -85,6 +86,6 @@ void Filenames(const char* path)
|
||||
if(ret) { cRc = errno; }
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void MillionFiles(const char* path)
|
||||
{
|
||||
@@ -42,7 +43,7 @@ void MillionFiles(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to specified path.\n", errno);
|
||||
log_write("Error %d changing to specified path.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ void MillionFiles(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d creating working directory.\n", errno);
|
||||
log_write("Error %d creating working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,11 +59,11 @@ void MillionFiles(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to working directory.\n", errno);
|
||||
log_write("Error %d changing to working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Creating lots of files.\n");
|
||||
log_write("Creating lots of files.\n");
|
||||
|
||||
for(pos = 0; pos < 1000; pos++)
|
||||
{
|
||||
@@ -75,5 +76,5 @@ void MillionFiles(const char* path)
|
||||
fclose(h);
|
||||
}
|
||||
|
||||
printf("\tCreated %ld files\n", pos);
|
||||
log_write("\tCreated %ld files\n", pos);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
#include "../include/consts.h"
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void Fragmentation(const char* path, size_t clusterSize)
|
||||
{
|
||||
@@ -50,7 +51,7 @@ void Fragmentation(const char* path, size_t clusterSize)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to specified path.\n", errno);
|
||||
log_write("Error %d changing to specified path.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ void Fragmentation(const char* path, size_t clusterSize)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d creating working directory.\n", errno);
|
||||
log_write("Error %d creating working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,11 +67,11 @@ void Fragmentation(const char* path, size_t clusterSize)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to working directory.\n", errno);
|
||||
log_write("Error %d changing to working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Writing fragmented files:\n");
|
||||
log_write("Writing fragmented files:\n");
|
||||
|
||||
h = fopen("HALFCLST", "w+");
|
||||
rc = 0;
|
||||
@@ -92,7 +93,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);
|
||||
|
||||
h = fopen("QUARCLST", "w+");
|
||||
rc = 0;
|
||||
@@ -114,7 +115,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);
|
||||
|
||||
h = fopen("TWOCLST", "w+");
|
||||
rc = 0;
|
||||
@@ -136,7 +138,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);
|
||||
|
||||
h = fopen("TRQTCLST", "w+");
|
||||
rc = 0;
|
||||
@@ -158,12 +160,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);
|
||||
|
||||
h = fopen("TWTQCLST", "w+");
|
||||
rc = 0;
|
||||
@@ -185,12 +187,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);
|
||||
|
||||
h = fopen("TWO1", "w+");
|
||||
rc = 0;
|
||||
@@ -212,7 +214,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);
|
||||
|
||||
h = fopen("TWO2", "w+");
|
||||
rc = 0;
|
||||
@@ -234,7 +236,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);
|
||||
|
||||
h = fopen("TWO3", "w+");
|
||||
rc = 0;
|
||||
@@ -256,11 +258,11 @@ void Fragmentation(const char* path, size_t clusterSize)
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
printf("\tDeleting \"TWO2\".\n");
|
||||
log_write("\tDeleting \"TWO2\".\n");
|
||||
ret = unlink("TWO2");
|
||||
if(!ret) { rc = errno; }
|
||||
|
||||
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);
|
||||
|
||||
h = fopen("FRAGTHRQ", "w+");
|
||||
rc = 0;
|
||||
@@ -282,19 +284,19 @@ void Fragmentation(const char* path, size_t clusterSize)
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
printf("\tDeleting \"TWO1\".\n");
|
||||
log_write("\tDeleting \"TWO1\".\n");
|
||||
ret = unlink("TWO1");
|
||||
if(!ret) { rc = errno; }
|
||||
printf("\tDeleting \"TWO3\".\n");
|
||||
log_write("\tDeleting \"TWO3\".\n");
|
||||
ret = unlink("TWO3");
|
||||
if(!ret) { rc = errno; }
|
||||
|
||||
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);
|
||||
|
||||
h = fopen("FRAGSIXQ", "w+");
|
||||
rc = 0;
|
||||
@@ -316,10 +318,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);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void Links(const char* path)
|
||||
{
|
||||
@@ -39,7 +40,7 @@ void Links(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to specified path.\n", errno);
|
||||
log_write("Error %d changing to specified path.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ void Links(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d creating working directory.\n", errno);
|
||||
log_write("Error %d creating working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -55,17 +56,17 @@ void Links(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to working directory.\n", errno);
|
||||
log_write("Error %d changing to working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Creating links.\n");
|
||||
log_write("Creating links.\n");
|
||||
|
||||
h = fopen("TARGET", "w+");
|
||||
|
||||
if(h == NULL)
|
||||
{
|
||||
printf("Error %d creating target file.\n", errno);
|
||||
log_write("Error %d creating target file.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,9 +76,9 @@ void Links(const char* path)
|
||||
|
||||
ret = link("TARGET", "HARD");
|
||||
|
||||
if(ret) { printf("Error %d creating hard link.\n", errno); }
|
||||
if(ret) { log_write("Error %d creating hard link.\n", errno); }
|
||||
|
||||
ret = symlink("TARGET", "SYMBOLIC");
|
||||
|
||||
if(ret) { printf("Error %d creating symbolic link.\n", errno); }
|
||||
if(ret) { log_write("Error %d creating symbolic link.\n", errno); }
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void GetOsInfo()
|
||||
{
|
||||
@@ -37,13 +38,13 @@ void GetOsInfo()
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d retrieving OS information.\n", errno);
|
||||
log_write("Error %d retrieving OS information.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("OS information:\n");
|
||||
printf("\tOS name: %s\n", buf.sysname);
|
||||
printf("\tRelease: %s\n", buf.release);
|
||||
printf("\tVersion: %s\n", buf.version);
|
||||
printf("\tMachine: %s\n", buf.machine);
|
||||
log_write("OS information:\n");
|
||||
log_write("\tOS name: %s\n", buf.sysname);
|
||||
log_write("\tRelease: %s\n", buf.release);
|
||||
log_write("\tVersion: %s\n", buf.version);
|
||||
log_write("\tMachine: %s\n", buf.machine);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include "perms.h"
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void FilePermissions(const char* path)
|
||||
{
|
||||
@@ -43,7 +44,7 @@ void FilePermissions(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to specified path.\n", errno);
|
||||
log_write("Error %d changing to specified path.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ void FilePermissions(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d creating working directory.\n", errno);
|
||||
log_write("Error %d creating working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,11 +60,11 @@ void FilePermissions(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to working directory.\n", errno);
|
||||
log_write("Error %d changing to working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Creating attributes files.\n");
|
||||
log_write("Creating attributes files.\n");
|
||||
|
||||
for(i = 0; i < KNOWN_UNIX_PERMS; i++)
|
||||
{
|
||||
@@ -79,6 +80,7 @@ void FilePermissions(const char* path)
|
||||
cRc = chmod(unix_perms[i].filename, unix_perms[i].mode);
|
||||
}
|
||||
|
||||
printf("\t%s: name = \"%s\", rc = %d, cRc = %d\n", unix_perms[i].description, unix_perms[i].filename, rc, cRc);
|
||||
log_write(
|
||||
"\t%s: name = \"%s\", rc = %d, cRc = %d\n", unix_perms[i].description, unix_perms[i].filename, rc, cRc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <utime.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
#include "unix.h"
|
||||
|
||||
void Timestamps(const char* path)
|
||||
@@ -47,7 +48,7 @@ void Timestamps(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to specified path.\n", errno);
|
||||
log_write("Error %d changing to specified path.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ void Timestamps(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d creating working directory.\n", errno);
|
||||
log_write("Error %d creating working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,11 +64,11 @@ void Timestamps(const char* path)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d changing to working directory.\n", errno);
|
||||
log_write("Error %d changing to working directory.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Creating timestamped files.\n");
|
||||
log_write("Creating timestamped files.\n");
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("MAXATIME", "w+");
|
||||
@@ -91,7 +92,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("MAXATIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "MAXATIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "MAXATIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("MAXMTIME", "w+");
|
||||
@@ -115,7 +116,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("MAXMTIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "MAXMTIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "MAXMTIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("MINATIME", "w+");
|
||||
@@ -139,7 +140,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("MINATIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "MINATIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "MINATIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("MINMTIME", "w+");
|
||||
@@ -163,7 +164,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("MINMTIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "MINMTIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "MINMTIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("Y1KATIME", "w+");
|
||||
@@ -187,7 +188,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("Y1KATIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "Y1KATIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "Y1KATIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("Y1KMTIME", "w+");
|
||||
@@ -211,7 +212,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("Y1KMTIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "Y1KMTIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "Y1KMTIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("Y2KATIME", "w+");
|
||||
@@ -235,7 +236,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("Y2KATIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "Y2KATIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "Y2KATIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("Y2KMTIME", "w+");
|
||||
@@ -259,7 +260,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("Y2KMTIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "Y2KMTIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "Y2KMTIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("LESSATIME", "w+");
|
||||
@@ -283,7 +284,7 @@ void Timestamps(const char* path)
|
||||
ret = utime("LESSATIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "LESSATIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "LESSATIME", rc, wRc, cRc, tRc);
|
||||
|
||||
memset(×, 0, sizeof(struct utimbuf));
|
||||
h = fopen("LESSMTIME", "w+");
|
||||
@@ -307,5 +308,5 @@ void Timestamps(const char* path)
|
||||
ret = utime("LESSMTIME", ×);
|
||||
if(ret) { tRc = errno; }
|
||||
}
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "LESSMTIME", rc, wRc, cRc, tRc);
|
||||
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", "LESSMTIME", rc, wRc, cRc, tRc);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <sys/statfs.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
#include "unix.h"
|
||||
|
||||
void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
@@ -39,177 +40,177 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
|
||||
if(ret)
|
||||
{
|
||||
printf("Error %d querying volume information.\n", errno);
|
||||
log_write("Error %d querying volume information.\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Volume information:\n");
|
||||
printf("\tPath: %s\n", path);
|
||||
log_write("Volume information:\n");
|
||||
log_write("\tPath: %s\n", path);
|
||||
|
||||
printf("\tFilesystem: ");
|
||||
log_write("\tFilesystem: ");
|
||||
switch(buf.f_type)
|
||||
{
|
||||
case ADFS_SUPER_MAGIC: printf("ADFS"); break;
|
||||
case AFFS_SUPER_MAGIC: printf("Amiga FFS"); break;
|
||||
case AFS_SUPER_MAGIC: printf("AFS"); break;
|
||||
case ANON_INODE_FS_MAGIC: printf("anonymous inode fs"); break;
|
||||
case AUTOFS_SUPER_MAGIC: printf("autofs"); break;
|
||||
case BDEVFS_MAGIC: printf("bdevfs"); break;
|
||||
case BEFS_SUPER_MAGIC: printf("BeFS"); break;
|
||||
case BFS_MAGIC: printf("bfs"); break;
|
||||
case BINFMTFS_MAGIC: printf("binfmtfs"); break;
|
||||
case BPF_FS_MAGIC: printf("bpffs"); break;
|
||||
case ADFS_SUPER_MAGIC: log_write("ADFS"); break;
|
||||
case AFFS_SUPER_MAGIC: log_write("Amiga FFS"); break;
|
||||
case AFS_SUPER_MAGIC: log_write("AFS"); break;
|
||||
case ANON_INODE_FS_MAGIC: log_write("anonymous inode fs"); break;
|
||||
case AUTOFS_SUPER_MAGIC: log_write("autofs"); break;
|
||||
case BDEVFS_MAGIC: log_write("bdevfs"); break;
|
||||
case BEFS_SUPER_MAGIC: log_write("BeFS"); break;
|
||||
case BFS_MAGIC: log_write("bfs"); break;
|
||||
case BINFMTFS_MAGIC: log_write("binfmtfs"); break;
|
||||
case BPF_FS_MAGIC: log_write("bpffs"); break;
|
||||
case BTRFS_SUPER_MAGIC:
|
||||
case BTRFS_TEST_MAGIC: printf("btrfs"); break;
|
||||
case CGROUP_SUPER_MAGIC: printf("cgroup"); break;
|
||||
case CGROUP2_SUPER_MAGIC: printf("cgroup2"); break;
|
||||
case CIFS_MAGIC_NUMBER: printf("CIFS"); break;
|
||||
case CODA_SUPER_MAGIC: printf("CODA"); break;
|
||||
case COH_SUPER_MAGIC: printf("Coherent"); break;
|
||||
case CRAMFS_MAGIC: printf("cramfs"); break;
|
||||
case DEBUGFS_MAGIC: printf("debufs"); break;
|
||||
case DEVFS_SUPER_MAGIC: printf("devfs"); break;
|
||||
case DEVPTS_SUPER_MAGIC: printf("devpts"); break;
|
||||
case ECRYPTFS_SUPER_MAGIC: printf("ecryptfs"); break;
|
||||
case EFIVARFS_MAGIC: printf("efivars"); break;
|
||||
case EFS_SUPER_MAGIC: printf("EFS"); break;
|
||||
case EXT_SUPER_MAGIC: printf("ext"); break;
|
||||
case EXT2_OLD_SUPER_MAGIC: printf("ext2"); break;
|
||||
case EXT2_SUPER_MAGIC: printf("ext2/3/4"); break;
|
||||
case F2FS_SUPER_MAGIC: printf("f2fs"); break;
|
||||
case FUSE_SUPER_MAGIC: printf("fuse"); break;
|
||||
case FUTEXFS_SUPER_MAGIC: printf("futexfs"); break;
|
||||
case HFS_SUPER_MAGIC: printf("HFS"); break;
|
||||
case HOSTFS_SUPER_MAGIC: printf("hostfs"); break;
|
||||
case HPFS_SUPER_MAGIC: printf("HPFS"); break;
|
||||
case HUGETLBFS_MAGIC: printf("hugetlbfs"); break;
|
||||
case ISOFS_SUPER_MAGIC: printf("ISO9660"); break;
|
||||
case JFFS2_SUPER_MAGIC: printf("jffs2"); break;
|
||||
case JFS_SUPER_MAGIC: printf("JFS"); break;
|
||||
case BTRFS_TEST_MAGIC: log_write("btrfs"); break;
|
||||
case CGROUP_SUPER_MAGIC: log_write("cgroup"); break;
|
||||
case CGROUP2_SUPER_MAGIC: log_write("cgroup2"); break;
|
||||
case CIFS_MAGIC_NUMBER: log_write("CIFS"); break;
|
||||
case CODA_SUPER_MAGIC: log_write("CODA"); break;
|
||||
case COH_SUPER_MAGIC: log_write("Coherent"); break;
|
||||
case CRAMFS_MAGIC: log_write("cramfs"); break;
|
||||
case DEBUGFS_MAGIC: log_write("debufs"); break;
|
||||
case DEVFS_SUPER_MAGIC: log_write("devfs"); break;
|
||||
case DEVPTS_SUPER_MAGIC: log_write("devpts"); break;
|
||||
case ECRYPTFS_SUPER_MAGIC: log_write("ecryptfs"); break;
|
||||
case EFIVARFS_MAGIC: log_write("efivars"); break;
|
||||
case EFS_SUPER_MAGIC: log_write("EFS"); break;
|
||||
case EXT_SUPER_MAGIC: log_write("ext"); break;
|
||||
case EXT2_OLD_SUPER_MAGIC: log_write("ext2"); break;
|
||||
case EXT2_SUPER_MAGIC: log_write("ext2/3/4"); break;
|
||||
case F2FS_SUPER_MAGIC: log_write("f2fs"); break;
|
||||
case FUSE_SUPER_MAGIC: log_write("fuse"); break;
|
||||
case FUTEXFS_SUPER_MAGIC: log_write("futexfs"); break;
|
||||
case HFS_SUPER_MAGIC: log_write("HFS"); break;
|
||||
case HOSTFS_SUPER_MAGIC: log_write("hostfs"); break;
|
||||
case HPFS_SUPER_MAGIC: log_write("HPFS"); break;
|
||||
case HUGETLBFS_MAGIC: log_write("hugetlbfs"); break;
|
||||
case ISOFS_SUPER_MAGIC: log_write("ISO9660"); break;
|
||||
case JFFS2_SUPER_MAGIC: log_write("jffs2"); break;
|
||||
case JFS_SUPER_MAGIC: log_write("JFS"); break;
|
||||
case MINIX_SUPER_MAGIC:
|
||||
case MINIX_SUPER_MAGIC2: printf("minix"); break;
|
||||
case MINIX_SUPER_MAGIC2: log_write("minix"); break;
|
||||
case MINIX2_SUPER_MAGIC:
|
||||
case MINIX2_SUPER_MAGIC2: printf("minix2"); break;
|
||||
case MINIX3_SUPER_MAGIC: printf("minix3"); break;
|
||||
case MQUEUE_MAGIC: printf("mqueue"); break;
|
||||
case MSDOS_SUPER_MAGIC: printf("msdos/vfat"); break;
|
||||
case MTD_INODE_FS_MAGIC: printf("mtd inodefs"); break;
|
||||
case NCP_SUPER_MAGIC: printf("NCP"); break;
|
||||
case NFS_SUPER_MAGIC: printf("NFS"); break;
|
||||
case NILFS_SUPER_MAGIC: printf("nilfs"); break;
|
||||
case NSFS_MAGIC: printf("nsfs"); break;
|
||||
case NTFS_SB_MAGIC: printf("NTFS"); break;
|
||||
case OCFS2_SUPER_MAGIC: printf("OCFS2"); break;
|
||||
case OPENPROM_SUPER_MAGIC: printf("OpenPROM"); break;
|
||||
case OVERLAYFS_SUPER_MAGIC: printf("overlayfs"); break;
|
||||
case PIPEFS_MAGIC: printf("pipefs"); break;
|
||||
case PROC_SUPER_MAGIC: printf("proc"); break;
|
||||
case PSTOREFS_MAGIC: printf("pstorefs"); break;
|
||||
case QNX4_SUPER_MAGIC: printf("qnx4"); break;
|
||||
case QNX6_SUPER_MAGIC: printf("qnx6"); break;
|
||||
case RAMFS_MAGIC: printf("ramfs"); break;
|
||||
case REISERFS_SUPER_MAGIC: printf("Reiser"); break;
|
||||
case ROMFS_MAGIC: printf("romfs"); break;
|
||||
case SECURITYFS_MAGIC: printf("securityfs"); break;
|
||||
case SELINUX_MAGIC: printf("SELinux"); break;
|
||||
case SMACK_MAGIC: printf("smack"); break;
|
||||
case SMB_SUPER_MAGIC: printf("SMB"); break;
|
||||
case SOCKFS_MAGIC: printf("sockfs"); break;
|
||||
case SQUASHFS_MAGIC: printf("squashfs"); break;
|
||||
case SYSFS_MAGIC: printf("sysfs"); break;
|
||||
case SYSV2_SUPER_MAGIC: printf("System V Release 2"); break;
|
||||
case SYSV4_SUPER_MAGIC: printf("System V Release 4"); break;
|
||||
case TMPFS_MAGIC: printf("tmpfs"); break;
|
||||
case TRACEFS_MAGIC: printf("tracefs"); break;
|
||||
case UDF_SUPER_MAGIC: printf("UDF"); break;
|
||||
case UFS_MAGIC: printf("UFS"); break;
|
||||
case USBDEVICE_SUPER_MAGIC: printf("usbdevice"); break;
|
||||
case V9FS_MAGIC: printf("V9"); break;
|
||||
case VXFS_SUPER_MAGIC: printf("vxfs"); break;
|
||||
case XENFS_SUPER_MAGIC: printf("xenfs"); break;
|
||||
case XENIX_SUPER_MAGIC: printf("XENIX"); break;
|
||||
case XFS_SUPER_MAGIC: printf("XFS"); break;
|
||||
case _XIAFS_SUPER_MAGIC: printf("xia"); break;
|
||||
default: printf("unknown type -> 0x%lX", buf.f_type);
|
||||
case MINIX2_SUPER_MAGIC2: log_write("minix2"); break;
|
||||
case MINIX3_SUPER_MAGIC: log_write("minix3"); break;
|
||||
case MQUEUE_MAGIC: log_write("mqueue"); break;
|
||||
case MSDOS_SUPER_MAGIC: log_write("msdos/vfat"); break;
|
||||
case MTD_INODE_FS_MAGIC: log_write("mtd inodefs"); break;
|
||||
case NCP_SUPER_MAGIC: log_write("NCP"); break;
|
||||
case NFS_SUPER_MAGIC: log_write("NFS"); break;
|
||||
case NILFS_SUPER_MAGIC: log_write("nilfs"); break;
|
||||
case NSFS_MAGIC: log_write("nsfs"); break;
|
||||
case NTFS_SB_MAGIC: log_write("NTFS"); break;
|
||||
case OCFS2_SUPER_MAGIC: log_write("OCFS2"); break;
|
||||
case OPENPROM_SUPER_MAGIC: log_write("OpenPROM"); break;
|
||||
case OVERLAYFS_SUPER_MAGIC: log_write("overlayfs"); break;
|
||||
case PIPEFS_MAGIC: log_write("pipefs"); break;
|
||||
case PROC_SUPER_MAGIC: log_write("proc"); break;
|
||||
case PSTOREFS_MAGIC: log_write("pstorefs"); break;
|
||||
case QNX4_SUPER_MAGIC: log_write("qnx4"); break;
|
||||
case QNX6_SUPER_MAGIC: log_write("qnx6"); break;
|
||||
case RAMFS_MAGIC: log_write("ramfs"); break;
|
||||
case REISERFS_SUPER_MAGIC: log_write("Reiser"); break;
|
||||
case ROMFS_MAGIC: log_write("romfs"); break;
|
||||
case SECURITYFS_MAGIC: log_write("securityfs"); break;
|
||||
case SELINUX_MAGIC: log_write("SELinux"); break;
|
||||
case SMACK_MAGIC: log_write("smack"); break;
|
||||
case SMB_SUPER_MAGIC: log_write("SMB"); break;
|
||||
case SOCKFS_MAGIC: log_write("sockfs"); break;
|
||||
case SQUASHFS_MAGIC: log_write("squashfs"); break;
|
||||
case SYSFS_MAGIC: log_write("sysfs"); break;
|
||||
case SYSV2_SUPER_MAGIC: log_write("System V Release 2"); break;
|
||||
case SYSV4_SUPER_MAGIC: log_write("System V Release 4"); break;
|
||||
case TMPFS_MAGIC: log_write("tmpfs"); break;
|
||||
case TRACEFS_MAGIC: log_write("tracefs"); break;
|
||||
case UDF_SUPER_MAGIC: log_write("UDF"); break;
|
||||
case UFS_MAGIC: log_write("UFS"); break;
|
||||
case USBDEVICE_SUPER_MAGIC: log_write("usbdevice"); break;
|
||||
case V9FS_MAGIC: log_write("V9"); break;
|
||||
case VXFS_SUPER_MAGIC: log_write("vxfs"); break;
|
||||
case XENFS_SUPER_MAGIC: log_write("xenfs"); break;
|
||||
case XENIX_SUPER_MAGIC: log_write("XENIX"); break;
|
||||
case XFS_SUPER_MAGIC: log_write("XFS"); break;
|
||||
case _XIAFS_SUPER_MAGIC: log_write("xia"); break;
|
||||
default: log_write("unknown type -> 0x%lX", buf.f_type);
|
||||
}
|
||||
printf("\n");
|
||||
log_write("\n");
|
||||
|
||||
printf("\tBytes per block: %ld\n", buf.f_bsize);
|
||||
printf("\tVolume size: %llu bytes\n", ((unsigned long long)buf.f_blocks) * buf.f_bsize);
|
||||
printf("\tVolume free: %llu bytes\n", ((unsigned long long)buf.f_bfree) * buf.f_bsize);
|
||||
printf("\tMaximum component length: %ld\n", buf.f_namelen);
|
||||
log_write("\tBytes per block: %ld\n", buf.f_bsize);
|
||||
log_write("\tVolume size: %llu bytes\n", ((unsigned long long)buf.f_blocks) * buf.f_bsize);
|
||||
log_write("\tVolume free: %llu bytes\n", ((unsigned long long)buf.f_bfree) * buf.f_bsize);
|
||||
log_write("\tMaximum component length: %ld\n", buf.f_namelen);
|
||||
|
||||
if(buf.f_flags)
|
||||
{
|
||||
printf("\tFlags:\n");
|
||||
log_write("\tFlags:\n");
|
||||
|
||||
if(buf.f_flags & ST_RDONLY)
|
||||
{
|
||||
printf("\t\tVolume is read-only.\n");
|
||||
log_write("\t\tVolume is read-only.\n");
|
||||
buf.f_flags -= ST_RDONLY;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NOSUID)
|
||||
{
|
||||
printf("\t\tVolume ignores suid and sgid bits.\n");
|
||||
log_write("\t\tVolume ignores suid and sgid bits.\n");
|
||||
buf.f_flags -= ST_NOSUID;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NODEV)
|
||||
{
|
||||
printf("\t\tVolume disallows access to device special files.\n");
|
||||
log_write("\t\tVolume disallows access to device special files.\n");
|
||||
buf.f_flags -= ST_NODEV;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NOEXEC)
|
||||
{
|
||||
printf("\t\tVolume disallows program execution.\n");
|
||||
log_write("\t\tVolume disallows program execution.\n");
|
||||
buf.f_flags -= ST_NOEXEC;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_SYNCHRONOUS)
|
||||
{
|
||||
printf("\t\tVolume writes are synced at once.\n");
|
||||
log_write("\t\tVolume writes are synced at once.\n");
|
||||
buf.f_flags -= ST_SYNCHRONOUS;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_MANDLOCK)
|
||||
{
|
||||
printf("\t\tVolume allows mandatory locks.\n");
|
||||
log_write("\t\tVolume allows mandatory locks.\n");
|
||||
buf.f_flags -= ST_MANDLOCK;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_WRITE)
|
||||
{
|
||||
printf("\t\tVolume writes on file/directory/symlink.\n");
|
||||
log_write("\t\tVolume writes on file/directory/symlink.\n");
|
||||
buf.f_flags -= ST_WRITE;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_APPEND)
|
||||
{
|
||||
printf("\t\tVolume appends.\n");
|
||||
log_write("\t\tVolume appends.\n");
|
||||
buf.f_flags -= ST_APPEND;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_IMMUTABLE)
|
||||
{
|
||||
printf("\t\tVolume is immutable.\n");
|
||||
log_write("\t\tVolume is immutable.\n");
|
||||
buf.f_flags -= ST_IMMUTABLE;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NOATIME)
|
||||
{
|
||||
printf("\t\tVolume does not update access times.\n");
|
||||
log_write("\t\tVolume does not update access times.\n");
|
||||
buf.f_flags -= ST_NOATIME;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NODIRATIME)
|
||||
{
|
||||
printf("\t\tVolume does not update directory access times.\n");
|
||||
log_write("\t\tVolume does not update directory access times.\n");
|
||||
buf.f_flags -= ST_NODIRATIME;
|
||||
}
|
||||
|
||||
if(buf.f_flags) { printf("\t\tRemaining flags: 0x%08lX\n", buf.f_flags); }
|
||||
if(buf.f_flags) { log_write("\t\tRemaining flags: 0x%08lX\n", buf.f_flags); }
|
||||
}
|
||||
|
||||
*clusterSize = buf.f_bsize;
|
||||
|
||||
Reference in New Issue
Block a user