Mail Archives: djgpp-workers/2001/08/05/09:17:15
> On Sun, 5 Aug 2001, Andrew Cottrell wrote:
>
> > I have downloaded the touch program from the freedos site and it works
on
> > Win2K. I am in the process of downloading the source files and I hope
the
> > source is in one of them.
>
> It might be that function 5701 fails from protected mode, but not from
> real mode. (Crazy, I know; but so is the failure itself.)
>
Looks like you are not crazy. I downloaded the FreeDOS touch source code and
it was in assembler, bit it worked. I then downloaded PACIFIC C and wrote a
small test app below for DJGPP and PACIFIC C. I hope the examples are not
to big, but I thought they may be useful for analysis of the problem. The
app does the same interrupt calls.
Real mode works in Pacific C and protected mode in DJGPP fails. I thought I
was going crazy. The sample works fine on Win 98.
Any suggestions for me to try tmorrow night after work.
Andrew
======================= DJGPP TOUCH.EXE EXAMPLE =======================
DJGPP_204 D:\dj204\contrib\touch>dir new.txt
07/08/2001 11:00p 4 new.txt
DJGPP_204 D:\dj204\contrib\touch>touch
fildes = 5
dostime (cx)= 0xB80D
dosdate (dx)= 0x2B07
r.x.flags = 0x0002
r.x.ax = 0x5700
NEW dosdate (dx)= 0x2B08
dostime (cx)= 0xB80D
dosdate (dx)= 0x2B08
r.x.flags = 0x0003
r.x.ax = 0x0001
DJGPP_204 D:\dj204\contrib\touch>dir new.txt
07/08/2001 11:00p 4 new.txt
======================= PACIFIC TOUCH.EXE EXAMPLE =======================
PAC D:\pacific\test>dir new.txt
07/08/2001 10:27p 6 new.txt
PAC D:\pacific\test>touch
14 filedes = 5
20 dostime (cx) = 0xB378
21 dosdate (dx) = 0x2B07
22 cflag value = 0x0000
24 return value (ax) = 0x5700
27 dostime (cx) = 0xB378
28 dosdate (dx) = 0x2B08
29 cflag value = 0x0000
30 return value (ax) = 0x5700
36 dostime (cx) = 0xB378
37 dosdate (dx) = 0x2B08
38 cflag value = 0x0000
39 return value (ax) = 0x5701
PAC D:\pacific\test>dir new.txt
08/08/2001 10:27p 6 new.txt
======================= DJGPP TOUCH.C CODE =======================
#include <fcntl.h>
#include <sys/stat.h> /* for mode definitions */
#include <dpmi.h>
static void touchfile(const char *path)
{
__dpmi_regs r;
int fildes;
fildes = open(path, O_RDONLY);
if (fildes == -1)
{
printf("%s %d\n",__FILE__,__LINE__);
return;
}
printf("fildes = %d\n",fildes);
r.x.ax = 0x5700;
r.x.bx = fildes;
__dpmi_int(0x21, &r);
printf("dostime (cx)= 0x%04X\n", r.x.cx);
printf("dosdate (dx)= 0x%04X\n", r.x.dx);
printf("r.x.flags = 0x%04X\n", r.x.flags);
printf("r.x.ax = 0x%04X\n\n", r.x.ax);
r.x.dx++;
printf("NEW dosdate (dx)= 0x%04X\n", r.x.dx);
r.x.ax = 0x5701;
r.x.bx = fildes; /* File handle */
__dpmi_int(0x21, &r);
printf("dostime (cx)= 0x%04X\n", r.x.cx);
printf("dosdate (dx)= 0x%04X\n", r.x.dx);
printf("r.x.flags = 0x%04X\n", r.x.flags);
printf("r.x.ax = 0x%04X\n", r.x.ax);
close(fildes);
return;
}
int main()
{
touchfile("new.txt");
return 0;
}
======================= PACIFIC TOUCH.C CODE =======================
#include <stdio.h>
#include <string.h>
#include <dos.h>
#include <unixio.h>
#include <stat.h>
static void touchfile(register char * filename)
{
union REGS regs;
int filedes;
filedes = open(filename, S_IREAD);
printf("%d filedes = %d\n", __LINE__, filedes);
regs.x.ax = 0x5700;
regs.x.bx = filedes;
intdos(®s, ®s);
printf("%d dostime (cx) = 0x%04X\n", __LINE__, regs.x.cx);
printf("%d dosdate (dx) = 0x%04X\n", __LINE__, regs.x.dx);
printf("%d cflag value = 0x%04X\n", __LINE__, regs.x.cflag);
printf("%d return value (ax) = 0x%04X\n", __LINE__, regs.x.ax);
regs.x.dx++;
printf("%d dostime (cx) = 0x%04X\n", __LINE__, regs.x.cx);
printf("%d dosdate (dx) = 0x%04X\n", __LINE__, regs.x.dx);
printf("%d cflag value = 0x%04X\n", __LINE__, regs.x.cflag);
printf("%d return value (ax) = 0x%04X\n", __LINE__, regs.x.ax);
regs.x.ax = 0x5701;
regs.x.bx = filedes;
intdos(®s, ®s);
printf("%d dostime (cx) = 0x%04X\n", __LINE__, regs.x.cx);
printf("%d dosdate (dx) = 0x%04X\n", __LINE__, regs.x.dx);
printf("%d cflag value = 0x%04X\n", __LINE__, regs.x.cflag);
printf("%d return value (ax) = 0x%04X\n", __LINE__, regs.x.ax);
close(filedes);
}
int main()
{
touchfile("new.txt");
}
- Raw text -