mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Move GetDiskFreeEx implementation in DJGPP to another file as some compilers try to index it's include files.
This commit is contained in:
@@ -30,7 +30,7 @@ project(fssetter-dos
|
||||
DESCRIPTION "Filesystem test creator for DOS"
|
||||
LANGUAGES C)
|
||||
|
||||
set(PLATFORM_SOURCES attr.c deleted.c dirdepth.c filename.c files.c frag.c links.c os.c perms.c rsrcfork.c sparse.c dostime.h time.c volume.c xattr.c dos.c attr.h dosuname.c dosuname.h dosdefs.h)
|
||||
set(PLATFORM_SOURCES attr.c deleted.c dirdepth.c filename.c files.c frag.c links.c os.c perms.c rsrcfork.c sparse.c dostime.h time.c volume.c xattr.c dos.c attr.h dosuname.c dosuname.h dosdefs.h djgpp.c)
|
||||
|
||||
set(EXECUTABLE_NAME "fssetter")
|
||||
|
||||
|
||||
72
setter/src/dos/djgpp.c
Normal file
72
setter/src/dos/djgpp.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
Aaru Data Preservation Suite
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
--[ License ] ---------------------------------------------------------------
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2021 Natalia Portillo
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dpmi.h>
|
||||
#include <errno.h>
|
||||
#include <go32.h>
|
||||
#include <sys/movedata.h>
|
||||
|
||||
#include "dosdefs.h"
|
||||
|
||||
unsigned int _djgpp_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t* diskspace)
|
||||
{
|
||||
char drivePath[4];
|
||||
__dpmi_regs regs;
|
||||
|
||||
drivePath[0] = (drive & 0xFF) + '@';
|
||||
drivePath[1] = ':';
|
||||
drivePath[2] = '\\';
|
||||
drivePath[3] = 0;
|
||||
|
||||
// Use transferBuffer[0] for drivePath and transferBuffer[16] for diskfree_ex_t
|
||||
dosmemput(drivePath, 0, __tb);
|
||||
|
||||
regs.x.ax = 0x7303;
|
||||
regs.x.ds = __tb >> 4;
|
||||
regs.x.dx = __tb & 0x0F;
|
||||
regs.x.es = (__tb + 16) >> 4;
|
||||
regs.x.di = (__tb + 16) & 0x0F;
|
||||
regs.x.cx = sizeof(struct diskfree_ex_t);
|
||||
|
||||
__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;
|
||||
}
|
||||
|
||||
dosmemget(__tb + 16, sizeof(struct diskfree_ex_t), diskspace);
|
||||
|
||||
errno = 0;
|
||||
_doserrno = regs.x.ax;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -33,10 +33,6 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <io.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#elif defined(__DJGPP__)
|
||||
#include <dpmi.h>
|
||||
#include <go32.h>
|
||||
#include <sys/movedata.h>
|
||||
#endif
|
||||
|
||||
#include "dosdefs.h"
|
||||
@@ -95,44 +91,7 @@ unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t* disks
|
||||
|
||||
return 0;
|
||||
#elif defined(__DJGPP__)
|
||||
char drivePath[4];
|
||||
__dpmi_regs regs;
|
||||
|
||||
drivePath[0] = (drive & 0xFF) + '@';
|
||||
drivePath[1] = ':';
|
||||
drivePath[2] = '\\';
|
||||
drivePath[3] = 0;
|
||||
|
||||
// Use transferBuffer[0] for drivePath and transferBuffer[16] for diskfree_ex_t
|
||||
dosmemput(drivePath, 0, __tb);
|
||||
|
||||
regs.x.ax = 0x7303;
|
||||
regs.x.ds = __tb >> 4;
|
||||
regs.x.dx = __tb & 0x0F;
|
||||
regs.x.es = (__tb + 16) >> 4;
|
||||
regs.x.di = (__tb + 16) & 0x0F;
|
||||
regs.x.cx = sizeof(struct diskfree_ex_t);
|
||||
|
||||
__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;
|
||||
}
|
||||
|
||||
dosmemget(__tb + 16, sizeof(struct diskfree_ex_t), diskspace);
|
||||
|
||||
errno = 0;
|
||||
_doserrno = regs.x.ax;
|
||||
|
||||
return 0;
|
||||
return _djgpp_getdiskfree_ex(drive, diskspace);
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
||||
@@ -75,6 +75,10 @@ typedef struct diskfree_ex_t
|
||||
|
||||
unsigned int _dos_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t* diskspace);
|
||||
|
||||
#ifdef __DJGPP__
|
||||
unsigned int _djgpp_getdiskfree_ex(unsigned int drive, struct diskfree_ex_t* diskspace);
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
#if __WATCOMC__ >= 1100
|
||||
#pragma pack(__pop)
|
||||
|
||||
Reference in New Issue
Block a user