Mail Archives: djgpp-workers/2000/12/26/16:41:33
Martin Stromberg wrote:
> Sorry to nag, but zipped does not do the trick. As you can see it's
> impossible to see your patch.
For me the attachment did work; here are its contents for everybody else.
Hope this helps,
Laurynas
*** src/libc/compat/sys/vfs/statfs.c.~ Mon Jun 19 19:00:56 2000
--- src/libc/compat/sys/vfs/statfs.c Mon Dec 25 18:02:18 2000
***************
*** 13,18 ****
--- 13,19 ----
#include <fcntl.h>
#include <sys/vfs.h>
#include <libc/dosio.h>
+ #include <malloc.h>
#if 0
#include <stdio.h>
***************
*** 25,42 ****
int drive_number;
int cdrom_calls_used = 0;
long blocks = 0;
! long free = 0;
long bsize = 0;
/* Get the drive number, including the case of magic
names like /dev/c/foo. */
_put_path(path);
drive_number = (_farpeekb(_dos_ds, __tb) & 0x1f) - 1;
if (_farpeekb(_dos_ds, __tb + 1) != ':' || drive_number == -1)
{
regs.h.ah = 0x19;
__dpmi_int(0x21, ®s);
drive_number = regs.h.al;
}
/* For a CD-ROM drive, 213600 gives incorrect info.
--- 26,46 ----
int drive_number;
int cdrom_calls_used = 0;
long blocks = 0;
! long freec = 0;
long bsize = 0;
+ char *curdrive;
/* Get the drive number, including the case of magic
names like /dev/c/foo. */
_put_path(path);
+ (const char *)curdrive = path;
drive_number = (_farpeekb(_dos_ds, __tb) & 0x1f) - 1;
if (_farpeekb(_dos_ds, __tb + 1) != ':' || drive_number == -1)
{
regs.h.ah = 0x19;
__dpmi_int(0x21, ®s);
drive_number = regs.h.al;
+ curdrive = getcwd (NULL, 256);
}
/* For a CD-ROM drive, 213600 gives incorrect info.
***************
*** 99,105 ****
&& _farpeekw (_dos_ds, __tb + 5 + 0x12) == 5)
{
/* bsize has been set some lines above. */
! free = 0; /* no free space: cannot add data to CD-ROM */
blocks = _farpeekl (_dos_ds, __tb + 1);
cdrom_calls_used = 1;
}
--- 103,109 ----
&& _farpeekw (_dos_ds, __tb + 5 + 0x12) == 5)
{
/* bsize has been set some lines above. */
! freec = 0; /* no free space: cannot add data to CD-ROM */
blocks = _farpeekl (_dos_ds, __tb + 1);
cdrom_calls_used = 1;
}
***************
*** 120,131 ****
return -1;
}
bsize = regs.x.cx * regs.x.ax;
! free = regs.x.bx;
blocks = regs.x.dx;
#if 0
printf("First: bsize = %ld, free = %ld, blocks = %ld.\n"
, bsize
! , free
, blocks
);
#endif
--- 124,135 ----
return -1;
}
bsize = regs.x.cx * regs.x.ax;
! freec = regs.x.bx;
blocks = regs.x.dx;
#if 0
printf("First: bsize = %ld, free = %ld, blocks = %ld.\n"
, bsize
! , freec
, blocks
);
#endif
***************
*** 134,196 ****
&& _is_fat32(drive_number + 1) /* Is it a FAT32 drive? */
)
{
! /* Get free space info from Extended Drive Parameter Block. */
! regs.x.ax = 0x7302;
! regs.h.dl = drive_number + 1;
! regs.x.es = __tb_segment;
! regs.x.di = __tb_offset;
regs.x.cx = 0x100; /* 256 bytes should be enough (RBIL says 0x3f). */
! __dpmi_int(0x21, ®s);
!
! /* Errors? */
! if( regs.x.flags & 1 )
! {
! errno = ENODEV;
! return( -1 );
! }
! /* We trust previous int21 call more if free hasn't maxed out. */
! if( free < blocks )
! {
! /* Previous bsize is a multiple of this bsize, so the multiplication
! and division here is really a rescaling of the previous free
! value. */
! free *= bsize;
! bsize = _farpeekw (_dos_ds, __tb + 0x2 + 0x2) *
! ( _farpeekb (_dos_ds, __tb + 0x2 + 0x4) + 1 );
! free /= bsize;
! }
! else
{
! free = _farpeekw (_dos_ds, __tb + 0x2 + 0x1f) +
65536 * _farpeekw (_dos_ds, __tb + 0x2 + 0x21);
bsize = _farpeekw (_dos_ds, __tb + 0x2 + 0x2) *
( _farpeekb (_dos_ds, __tb + 0x2 + 0x4) + 1 );
- }
! blocks = _farpeekl( _dos_ds, __tb + 0x2 + 0x2d);
#if 0
! printf("Second: bsize = %ld, free = %ld, blocks = %ld.\n"
! , bsize
! , free
! , blocks
! );
#endif
}
}
/* Fill in the structure */
! buf->f_bavail = free;
! buf->f_bfree = free;
buf->f_blocks = blocks;
buf->f_bsize = bsize;
! buf->f_ffree = free;
buf->f_files = blocks;
buf->f_type = 0;
buf->f_fsid[0] = drive_number;
buf->f_fsid[1] = MOUNT_UFS;
buf->f_magic = FS_MAGIC;
return 0;
}
--- 138,209 ----
&& _is_fat32(drive_number + 1) /* Is it a FAT32 drive? */
)
{
! /* First try 217303 as 217302 reports fake free space
! (largest block of free clusters?) */
! _put_path (curdrive);
! regs.x.ax = 0x7303;
! regs.x.ds = regs.x.es = __tb_segment;
! regs.x.dx = regs.x.di = __tb_offset;
regs.x.cx = 0x100; /* 256 bytes should be enough (RBIL says 0x3f). */
! __dpmi_int (0x21, ®s);
! /* Errors? (217303 seams to fail under plain DOS) */
! if (regs.x.flags & 1)
{
! /* Get free space info from Extended Drive Parameter Block. */
! regs.x.ax = 0x7302;
! regs.h.dl = drive_number + 1;
! regs.x.es = __tb_segment;
! regs.x.di = __tb_offset;
! regs.x.cx = 0x100; /* 256 bytes should be enough (RBIL says 0x3f). */
! __dpmi_int(0x21, ®s);
!
! /* Errors? */
! if( regs.x.flags & 1 )
! {
! errno = ENODEV;
! return( -1 );
! }
!
! freec = _farpeekw (_dos_ds, __tb + 0x2 + 0x1f) +
65536 * _farpeekw (_dos_ds, __tb + 0x2 + 0x21);
bsize = _farpeekw (_dos_ds, __tb + 0x2 + 0x2) *
( _farpeekb (_dos_ds, __tb + 0x2 + 0x4) + 1 );
! blocks = _farpeekl( _dos_ds, __tb + 0x2 + 0x2d) - 1;
#if 0
! printf("Second: bsize = %ld, free = %ld, blocks = %ld.\n"
! , bsize
! , freec
! , blocks
! );
#endif
+ }
+ else
+ {
+ freec = _farpeekl (_dos_ds, __tb + 0x0c);
+ bsize = _farpeekl (_dos_ds, __tb + 0x08)
+ * _farpeekl (_dos_ds, __tb + 0x04);
+ blocks = _farpeekl (_dos_ds, __tb + 0x10);
+ }
}
}
/* Fill in the structure */
! buf->f_bavail = freec;
! buf->f_bfree = freec;
buf->f_blocks = blocks;
buf->f_bsize = bsize;
! buf->f_ffree = freec;
buf->f_files = blocks;
buf->f_type = 0;
buf->f_fsid[0] = drive_number;
buf->f_fsid[1] = MOUNT_UFS;
buf->f_magic = FS_MAGIC;
+ if (curdrive != path)
+ free (curdrive);
+
return 0;
}
- Raw text -