mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Minor type fixes to DOS.
This commit is contained in:
@@ -45,11 +45,11 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
void FileAttributes(const char* path)
|
||||
{
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned total, actionTaken;
|
||||
unsigned int rc, wRc, cRc;
|
||||
int handle;
|
||||
int i;
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned total, actionTaken;
|
||||
unsigned int rc, wRc, cRc;
|
||||
int handle;
|
||||
int i;
|
||||
|
||||
if(driveNo > 32) driveNo -= 32;
|
||||
|
||||
@@ -74,12 +74,17 @@ void FileAttributes(const char* path)
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
wRc = _dos_write(handle, (void*)dos_attrs[i].contents, strlen(dos_attrs[i].contents), &actionTaken);
|
||||
cRc = _dos_close(handle);
|
||||
rc = _dos_setfileattr(dos_attrs[i].filename, dos_attrs[i].attr);
|
||||
wRc = _dos_write(handle, (void*)dos_attrs[i].contents, strlen(dos_attrs[i].contents), &actionTaken);
|
||||
cRc = _dos_close(handle);
|
||||
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);
|
||||
printf("\t%s: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
dos_attrs[i].description,
|
||||
dos_attrs[i].filename,
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char filename[9];
|
||||
char contents[170];
|
||||
char description[63];
|
||||
unsigned int attr;
|
||||
char filename[9];
|
||||
char contents[170];
|
||||
char description[63];
|
||||
unsigned int attr;
|
||||
} dos_attr_tests_t;
|
||||
|
||||
#define KNOWN_DOS_ATTRS 16
|
||||
@@ -50,34 +50,67 @@ static const dos_attr_tests_t dos_attrs[KNOWN_DOS_ATTRS] = {
|
||||
{"SYSTEM", "This file has the system attribute set.\n", "File with system attribute", _A_SYSTEM},
|
||||
{"HIDDEN", "This file has the hidden attribute set.\n", "File with hidden attribute", _A_HIDDEN},
|
||||
{"READONLY", "This file has the read-only attribute set.\n", "File with read-only attribute", _A_RDONLY},
|
||||
{"HIDDREAD", "This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n", "File with hidden, read-only attributes", _A_HIDDEN | _A_RDONLY},
|
||||
{"SYSTREAD", "This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n", "File with system, read-only attributes", _A_SYSTEM | _A_RDONLY},
|
||||
{"SYSTHIDD", "This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n", "File with system, hidden attributes", _A_SYSTEM | _A_HIDDEN},
|
||||
{"SYSRDYHD", "This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n"
|
||||
"This file has the hidden attribute set.\n", "File with system, read-only, hidden attributes", _A_SYSTEM | _A_RDONLY | _A_HIDDEN},
|
||||
{"ARCHREAD", "This file has the archived attribute set.\n"
|
||||
"This file has the read-only attribute set.\n", "File with archived, read-only attributes", _A_ARCH | _A_RDONLY},
|
||||
{"ARCHHIDD", "This file has the archived attribute set.\n"
|
||||
"This file has the hidden attribute set.\n", "File with archived, hidden attributes", _A_ARCH | _A_HIDDEN},
|
||||
{"ARCHDRDY", "This file has the archived attribute set.\n"
|
||||
"This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n", "File with archived, hidden, read-only attributes", _A_ARCH | _A_HIDDEN | _A_RDONLY},
|
||||
{"ARCHSYST", "This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n", "File with archived, system attributes", _A_ARCH | _A_SYSTEM},
|
||||
{"ARSYSRDY", "This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n", "File with archived, system, read-only attributes", _A_ARCH | _A_SYSTEM | _A_RDONLY},
|
||||
{"ARCSYSHD", "This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n", "File with archived, system, hidden attributes", _A_ARCH | _A_SYSTEM | _A_HIDDEN},
|
||||
{"ARSYHDRD", "This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n", "File with all (archived, system, hidden, read-only) attributes", _A_ARCH | _A_SYSTEM | _A_HIDDEN | _A_RDONLY},
|
||||
{"HIDDREAD",
|
||||
"This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with hidden, read-only attributes",
|
||||
_A_HIDDEN | _A_RDONLY},
|
||||
{"SYSTREAD",
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with system, read-only attributes",
|
||||
_A_SYSTEM | _A_RDONLY},
|
||||
{"SYSTHIDD",
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n",
|
||||
"File with system, hidden attributes",
|
||||
_A_SYSTEM | _A_HIDDEN},
|
||||
{"SYSRDYHD",
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n"
|
||||
"This file has the hidden attribute set.\n",
|
||||
"File with system, read-only, hidden attributes",
|
||||
_A_SYSTEM | _A_RDONLY | _A_HIDDEN},
|
||||
{"ARCHREAD",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with archived, read-only attributes",
|
||||
_A_ARCH | _A_RDONLY},
|
||||
{"ARCHHIDD",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the hidden attribute set.\n",
|
||||
"File with archived, hidden attributes",
|
||||
_A_ARCH | _A_HIDDEN},
|
||||
{"ARCHDRDY",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with archived, hidden, read-only attributes",
|
||||
_A_ARCH | _A_HIDDEN | _A_RDONLY},
|
||||
{"ARCHSYST",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n",
|
||||
"File with archived, system attributes",
|
||||
_A_ARCH | _A_SYSTEM},
|
||||
{"ARSYSRDY",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with archived, system, read-only attributes",
|
||||
_A_ARCH | _A_SYSTEM | _A_RDONLY},
|
||||
{"ARCSYSHD",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n",
|
||||
"File with archived, system, hidden attributes",
|
||||
_A_ARCH | _A_SYSTEM | _A_HIDDEN},
|
||||
{"ARSYHDRD",
|
||||
"This file has the archived attribute set.\n"
|
||||
"This file has the system attribute set.\n"
|
||||
"This file has the hidden attribute set.\n"
|
||||
"This file has the read-only attribute set.\n",
|
||||
"File with all (archived, system, hidden, read-only) attributes",
|
||||
_A_ARCH | _A_SYSTEM | _A_HIDDEN | _A_RDONLY},
|
||||
};
|
||||
|
||||
#endif // SETTER_SRC_DOS_ATTR_H_
|
||||
|
||||
@@ -44,12 +44,12 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
void DeleteFiles(const char* path)
|
||||
{
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc;
|
||||
char filename[9];
|
||||
short pos;
|
||||
unsigned total;
|
||||
int handle;
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc;
|
||||
char filename[9];
|
||||
short pos;
|
||||
unsigned total;
|
||||
int handle;
|
||||
|
||||
if(driveNo > 32) driveNo -= 32;
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
void DirectoryDepth(const char* path)
|
||||
{
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc ;
|
||||
unsigned total;
|
||||
char filename[9];
|
||||
int pos = 2;
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc;
|
||||
unsigned total;
|
||||
char filename[9];
|
||||
int pos = 2;
|
||||
|
||||
if(driveNo > 32) driveNo -= 32;
|
||||
|
||||
|
||||
@@ -35,19 +35,19 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <string.h>
|
||||
#elif defined(__DJGPP__)
|
||||
#include <dpmi.h>
|
||||
#include <sys/movedata.h>
|
||||
#include <go32.h>
|
||||
#include <sys/movedata.h>
|
||||
#endif
|
||||
|
||||
#include "dos.h"
|
||||
|
||||
unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *diskspace)
|
||||
unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t* diskspace)
|
||||
{
|
||||
#if defined(__WATCOM__)
|
||||
char drivePath[4];
|
||||
union REGS regs;
|
||||
struct SREGS sregs;
|
||||
struct diskfree_ex_t *copy;
|
||||
char drivePath[4];
|
||||
union REGS regs;
|
||||
struct SREGS sregs;
|
||||
struct diskfree_ex_t* copy;
|
||||
|
||||
copy = malloc(sizeof(struct diskfree_ex_t));
|
||||
|
||||
@@ -82,7 +82,7 @@ unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *disks
|
||||
else if(regs.w.cflag)
|
||||
{
|
||||
free(copy);
|
||||
errno = EINVAL;
|
||||
errno = EINVAL;
|
||||
_doserrno = regs.w.ax;
|
||||
return -1;
|
||||
}
|
||||
@@ -90,12 +90,12 @@ unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *disks
|
||||
memcpy(diskspace, copy, sizeof(struct diskfree_ex_t));
|
||||
|
||||
free(copy);
|
||||
errno = 0;
|
||||
errno = 0;
|
||||
_doserrno = regs.w.ax;
|
||||
|
||||
return 0;
|
||||
#elif defined(__DJGPP__)
|
||||
char drivePath[4];
|
||||
char drivePath[4];
|
||||
__dpmi_regs regs;
|
||||
|
||||
drivePath[0] = (drive & 0xFF) + '@';
|
||||
@@ -106,32 +106,30 @@ unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *disks
|
||||
// Use transferBuffer[0] for drivePath and transferBuffer[16] for diskfree_ex_t
|
||||
dosmemput(drivePath, 0, __tb);
|
||||
|
||||
regs.x.ds =
|
||||
|
||||
regs.x.ax = 0x7303;
|
||||
regs.x.ds = __tb >> 4;
|
||||
regs.x.ds = __tb >> 4;
|
||||
regs.x.dx = __tb & 0x0F;
|
||||
regs.x.es = (__tb + 16) >> 4;
|
||||
regs.x.es = (__tb + 16) >> 4;
|
||||
regs.x.di = (__tb + 16) & 0x0F;
|
||||
regs.x.cx = sizeof(struct diskfree_ex_t);
|
||||
|
||||
__dpmi_int (0x21, ®s);
|
||||
__dpmi_int(0x21, ®s);
|
||||
|
||||
if(regs.h.al == 0 && !(regs.x.flags & 1))
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
else if(regs.x.flags & 1)
|
||||
{
|
||||
errno = EINVAL;
|
||||
_doserrno = regs.x.ax;
|
||||
return -1;
|
||||
}
|
||||
if(regs.h.al == 0 && !(regs.x.flags & 1))
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
else if(regs.x.flags & 1)
|
||||
{
|
||||
errno = EINVAL;
|
||||
_doserrno = regs.x.ax;
|
||||
return -1;
|
||||
}
|
||||
|
||||
dosmemget(__tb + 16, sizeof(struct diskfree_ex_t), diskspace);
|
||||
|
||||
errno = 0;
|
||||
errno = 0;
|
||||
_doserrno = regs.x.ax;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -61,7 +61,7 @@ typedef struct diskfree_ex_t
|
||||
unsigned char reserved[8];
|
||||
} diskfree_ex;
|
||||
|
||||
unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t *diskspace);
|
||||
unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t* diskspace);
|
||||
|
||||
#if defined(__WATCOM__)
|
||||
#pragma pack(__pop)
|
||||
|
||||
@@ -45,12 +45,12 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
void Filenames(const char* path)
|
||||
{
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc, wRc = 0, cRc = 0;
|
||||
unsigned actionTaken, total;
|
||||
int handle;
|
||||
char message[300];
|
||||
int pos;
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc, wRc = 0, cRc = 0;
|
||||
unsigned actionTaken, total;
|
||||
int handle;
|
||||
char message[300];
|
||||
int pos;
|
||||
|
||||
if(driveNo > 32) driveNo -= 32;
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
void MillionFiles(const char* path)
|
||||
{
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc;
|
||||
char filename[9];
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc;
|
||||
char filename[9];
|
||||
unsigned int pos;
|
||||
int handle;
|
||||
unsigned total;
|
||||
int handle;
|
||||
unsigned total;
|
||||
|
||||
if(driveNo > 32) driveNo -= 32;
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
void Fragmentation(const char* path, size_t clusterSize)
|
||||
{
|
||||
unsigned int halfCluster = clusterSize / 2;
|
||||
unsigned int quarterCluster = clusterSize / 4;
|
||||
unsigned int twoCluster = clusterSize * 2;
|
||||
unsigned int threeQuartersCluster = halfCluster + quarterCluster;
|
||||
unsigned int twoAndThreeQuartCluster = threeQuartersCluster + twoCluster;
|
||||
unsigned int halfCluster = clusterSize / 2;
|
||||
unsigned int quarterCluster = clusterSize / 4;
|
||||
unsigned int twoCluster = clusterSize * 2;
|
||||
unsigned int threeQuartersCluster = halfCluster + quarterCluster;
|
||||
unsigned int twoAndThreeQuartCluster = threeQuartersCluster + twoCluster;
|
||||
unsigned char* buffer;
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc, wRc = 0, cRc = 0;
|
||||
unsigned int rc, wRc = 0, cRc = 0;
|
||||
unsigned total, actionTaken = 0;
|
||||
int handle;
|
||||
long i;
|
||||
|
||||
@@ -46,13 +46,13 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
void Timestamps(const char* path)
|
||||
{
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc, wRc = 0, cRc = 0, tRc = 0;
|
||||
unsigned actionTaken, total;
|
||||
int handle;
|
||||
char message[300];
|
||||
union REGS regs;
|
||||
int i;
|
||||
char driveNo = path[0] - '@';
|
||||
unsigned int rc, wRc = 0, cRc = 0, tRc = 0;
|
||||
unsigned actionTaken, total;
|
||||
int handle;
|
||||
char message[300];
|
||||
union REGS regs;
|
||||
int i;
|
||||
|
||||
if(driveNo > 32) driveNo -= 32;
|
||||
|
||||
@@ -99,7 +99,8 @@ void Timestamps(const char* path)
|
||||
cRc = _dos_close(handle);
|
||||
}
|
||||
|
||||
printf("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", dos_times[i].filename, rc, wRc, cRc, tRc);
|
||||
printf(
|
||||
"\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", dos_times[i].filename, rc, wRc, cRc, tRc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,20 +30,20 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#if defined(__DOS__) || defined(MSDOS)
|
||||
|
||||
#include <dos.h>
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "dos.h"
|
||||
|
||||
void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
{
|
||||
char driveNo = path[0] - '@';
|
||||
struct diskfree_t oldFreeSpace;
|
||||
struct diskfree_ex_t freeSpace;
|
||||
unsigned int rc;
|
||||
char driveNo = path[0] - '@';
|
||||
struct diskfree_t oldFreeSpace;
|
||||
struct diskfree_ex_t freeSpace;
|
||||
unsigned int rc;
|
||||
|
||||
memset(&oldFreeSpace, 0, sizeof(struct diskfree_t));
|
||||
memset(&freeSpace, 0, sizeof(struct diskfree_ex_t));
|
||||
@@ -57,15 +57,15 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
if(errno == ENOSYS)
|
||||
{
|
||||
rc = _dos_getdiskfree(driveNo, &oldFreeSpace);
|
||||
freeSpace.sectorsPerCluster = oldFreeSpace.sectors_per_cluster;
|
||||
freeSpace.freeClusters = oldFreeSpace.avail_clusters;
|
||||
freeSpace.bytesPerSector = oldFreeSpace.bytes_per_sector;
|
||||
freeSpace.totalClusters = oldFreeSpace.total_clusters;
|
||||
freeSpace.sectorsPerCluster = oldFreeSpace.sectors_per_cluster;
|
||||
freeSpace.freeClusters = oldFreeSpace.avail_clusters;
|
||||
freeSpace.bytesPerSector = oldFreeSpace.bytes_per_sector;
|
||||
freeSpace.totalClusters = oldFreeSpace.total_clusters;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error %d requesting volume information.\n", _doserrno);
|
||||
return;
|
||||
printf("Error %d requesting volume information.\n", _doserrno);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user