diff --git a/setter/src/dos/CMakeLists.txt b/setter/src/dos/CMakeLists.txt
index fd3a6e4..20dde7a 100644
--- a/setter/src/dos/CMakeLists.txt
+++ b/setter/src/dos/CMakeLists.txt
@@ -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")
diff --git a/setter/src/dos/djgpp.c b/setter/src/dos/djgpp.c
new file mode 100644
index 0000000..9bf0678
--- /dev/null
+++ b/setter/src/dos/djgpp.c
@@ -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 .
+
+-----------------------------------------------------------------------------
+Copyright (C) 2011-2021 Natalia Portillo
+*****************************************************************************/
+
+#include
+#include
+#include
+#include
+
+#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;
+}
diff --git a/setter/src/dos/dos.c b/setter/src/dos/dos.c
index a7de58d..3fe4c0f 100644
--- a/setter/src/dos/dos.c
+++ b/setter/src/dos/dos.c
@@ -33,10 +33,6 @@ Copyright (C) 2011-2021 Natalia Portillo
#include
#include
#include
-#elif defined(__DJGPP__)
-#include
-#include
-#include
#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;
diff --git a/setter/src/dos/dosdefs.h b/setter/src/dos/dosdefs.h
index 20ada90..7de2946 100644
--- a/setter/src/dos/dosdefs.h
+++ b/setter/src/dos/dosdefs.h
@@ -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)