delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/08/09/07:32:02

X-Authentication-Warning: new-smtp2.ihug.com.au: Host p240-tnt4.syd.ihug.com.au [203.173.134.240] claimed to be acceleron
Message-ID: <007701c120c6$2d72db80$0a02a8c0@acceleron>
From: "Andrew Cottrell" <acottrel AT ihug DOT com DOT au>
To: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Cc: <djgpp-workers AT delorie DOT com>, "Charles Sandmann" <sandmann AT clio DOT rice DOT edu>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1010808181731 DOT 27271C-100000 AT is>
Subject: Re: Windows 2000 patch for utime.c v1
Date: Thu, 9 Aug 2001 21:26:46 +1000
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Reply-To: djgpp-workers AT delorie DOT com

This is a multi-part message in MIME format.

------=_NextPart_000_0074_01C12119.FE276C20
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

> On Wed, 8 Aug 2001, Andrew Cottrell wrote:
>
> > Here is my first attempt at a patch to fix the problem with utime under
> > Windows 2000.
>
> Thanks!  Comments below.
>
> > Should I change the code to execute the new check for all versions of
> > Windows or only NT or ....?
>
> If most other versions of Windows fail with 7143h, I think we shouldn't
> call it unless on NT/W2K/XP.
Included code update from below.

> > + #include <libc\dosio.h>
>
> Please always use the (much more portable) forward slash.  The above will
> not compile in cross-compiled environment.
Change included in patch files attached.

> > +   if ((_USE_LFN) && ( _osmajor < 7 || _osmajor > 9)) /* LFN & NT */
>
> This is not the right way to test for NT/W2K.  Please use this:
>
> if (_osmajor == 5
>     && _USE_LFN
>     && _get_dos_version (1) == 0x532)  /* LFN & NT */
Change included in patch files attached.

> > +      _put_path(path);
> > +      r.x.ds = __tb_segment;  /* DS:DX -> ASCIZ filename */
> > +      r.x.dx = __tb_offset;
> > +
> > +      r.x.cx = dostime; /* New time */
> > +      r.x.di = dosdate; /* New date */
> > +      r.x.si = 0x00;    /* Set to zero just in case */
> > +
> > +      r.x.ax = 0x7143;  /* LFN API for extend3ed get/set time */
>
> There's a typo in the comment here.
Shows that I am a tru programmer.

> > +      r.x.bx = 0x03;    /* Set last write date / time */
> > +      __dpmi_int(0x21, &r);
> > +
> > +      if (!(r.x.flags & 1))  /* Pass exit otherwise try other methods
*/
> > +      {
> > +          return 0;
>
> I think we should set access date/time as well (using subfunction 05),
> like we do on Windows 9X.  Please see if subfunction 05 works, and if
> so, does it support setting the access time, not only date.
All of the sub functions wrt to time appeared to work when I tested them. I
have added setting of subfunction 05 in both patches. What about the
subfunction 07h set last write date/time? Should I also set this? I have
included this in the utime_v2_full.dif

> Thanks again for working on this.
Not a problem. One step closer to getting DJGPP to work on Win2K.

Sorry, but to save time I have attached two version of an updated utime.c
patch. The patch called utime_v2.dif does not include setting 7143
subfunction 07. The patch file called utime_v2_full.dif includes setting all
times included in 7143.

Andrew

------=_NextPart_000_0074_01C12119.FE276C20
Content-Type: application/octet-stream;
	name="utime_v2_full.dif"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="utime_v2_full.dif"

*** utimeold.c	Sun Mar 11 00:10:04 2001
--- utime.c	Thu Aug  9 21:27:18 2001
***************
*** 1,3 ****
--- 1,4 ----
+ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
***************
*** 8,13 ****
--- 9,16 ----
  #include <errno.h>		/* For errno */
  #include <go32.h>
  #include <dpmi.h>
+ #include <dos.h>
+ #include <libc/dosio.h>
 =20
  /* An implementation of utime() for DJGPP.  The utime() function
     specifies an access time and a modification time.  DOS has only one
***************
*** 24,33 ****
    unsigned int dostime, dosdate;
    int retval =3D 0, e =3D 0;
 =20
-   /* DOS wants the file open */
-   fildes =3D open(path, O_RDONLY);
-   if (fildes =3D=3D -1) return -1;
-=20
    /* NULL times means use current time */
    if (times =3D=3D NULL)
      modtime =3D time((time_t *) 0);
--- 27,32 ----
***************
*** 41,46 ****
--- 40,88 ----
    dostime =3D tm->tm_sec / 2 + (tm->tm_min << 5) +
      (tm->tm_hour << 11);
 =20
+=20
+   if (_osmajor =3D=3D 5 &&
+       (_USE_LFN)    &&
+       (_get_dos_version(1) =3D=3D 0x532)) /* LFN and NT (or 2000 or =
XP) */
+   {
+=20
+      _put_path(path);
+      r.x.ds =3D __tb_segment;  /* DS:DX -> ASCIZ filename */
+      r.x.dx =3D __tb_offset;
+=20
+      r.x.cx =3D dostime; /* New time */
+      r.x.di =3D dosdate; /* New date */
+      r.x.si =3D 0x00;    /* Set to zero just in case */
+     =20
+      r.x.ax =3D 0x7143;  /* LFN API for extended get and set time */
+      r.x.bx =3D 0x03;    /* Set last write date / time */
+      __dpmi_int(0x21, &r);
+     =20
+      if (!(r.x.flags & 1))  /* Pass then continue */
+      {
+          /* Uses date allready in r.x.di */
+          r.x.ax =3D 0x7143;  /* LFN API for extended get and set time =
*/
+          r.x.bx =3D 0x05;    /* Set last access date / time */
+          __dpmi_int(0x21, &r);
+          if (!(r.x.flags & 1))  /* Pass then continue */
+          {
+             /* Uses date allready in r.x.di and time allready in =
r.x.cx */
+              r.x.ax =3D 0x7143;  /* LFN API for extended get and set =
time */
+              r.x.bx =3D 0x07;    /* Set last write date / time */
+              __dpmi_int(0x21, &r);
+              if (!(r.x.flags & 1))  /* Pass then continue */
+              {
+                  return 0;
+              }
+          }
+      }
+   }
+=20
+   /* DOS wants the file open */
+   fildes =3D open(path, O_RDONLY);
+   if (fildes =3D=3D -1) return -1;
+=20
+=20
    /* Set the file timestamp */
    r.h.ah =3D 0x57; /* DOS FileTimes call */
    r.h.al =3D 0x01; /* Set date/time request */

------=_NextPart_000_0074_01C12119.FE276C20
Content-Type: application/octet-stream;
	name="utime_v2.dif"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="utime_v2.dif"

*** utimeold.c	Sun Mar 11 00:10:04 2001
--- utime.c	Thu Aug  9 21:18:06 2001
***************
*** 1,3 ****
--- 1,4 ----
+ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
***************
*** 8,13 ****
--- 9,16 ----
  #include <errno.h>		/* For errno */
  #include <go32.h>
  #include <dpmi.h>
+ #include <dos.h>
+ #include <libc/dosio.h>
  
  /* An implementation of utime() for DJGPP.  The utime() function
     specifies an access time and a modification time.  DOS has only one
***************
*** 24,33 ****
    unsigned int dostime, dosdate;
    int retval = 0, e = 0;
  
-   /* DOS wants the file open */
-   fildes = open(path, O_RDONLY);
-   if (fildes == -1) return -1;
- 
    /* NULL times means use current time */
    if (times == NULL)
      modtime = time((time_t *) 0);
--- 27,32 ----
***************
*** 41,46 ****
--- 40,81 ----
    dostime = tm->tm_sec / 2 + (tm->tm_min << 5) +
      (tm->tm_hour << 11);
  
+ 
+   if (_osmajor == 5 &&
+       (_USE_LFN)    &&
+       (_get_dos_version(1) == 0x532)) /* LFN and NT (or 2000 or XP) */
+   {
+ 
+      _put_path(path);
+      r.x.ds = __tb_segment;  /* DS:DX -> ASCIZ filename */
+      r.x.dx = __tb_offset;
+ 
+      r.x.cx = dostime; /* New time */
+      r.x.di = dosdate; /* New date */
+      r.x.si = 0x00;    /* Set to zero just in case */
+      
+      r.x.ax = 0x7143;  /* LFN API for extended get and set time */
+      r.x.bx = 0x03;    /* Set last write date / time */
+      __dpmi_int(0x21, &r);
+      
+      if (!(r.x.flags & 1))  /* Pass then continue */
+      {
+          /* Uses date allready in r.x.di */
+          r.x.ax = 0x7143;  /* LFN API for extended get and set time */
+          r.x.bx = 0x05;    /* Set last access date / time */
+          __dpmi_int(0x21, &r);
+          if (!(r.x.flags & 1))  /* Pass then continue */
+          {
+              return 0;
+          }
+      }
+   }
+ 
+   /* DOS wants the file open */
+   fildes = open(path, O_RDONLY);
+   if (fildes == -1) return -1;
+ 
+ 
    /* Set the file timestamp */
    r.h.ah = 0x57; /* DOS FileTimes call */
    r.h.al = 0x01; /* Set date/time request */

------=_NextPart_000_0074_01C12119.FE276C20--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019