www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/12/01/10:45:57

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3C08FA41.B9181F10@phekda.freeserve.co.uk>
Date: Sat, 01 Dec 2001 15:41:53 +0000
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: DJGPP workers <djgpp-workers AT delorie DOT com>
Subject: st_blksize patch, revision 4
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Below is the latest revision of the st_blksize patch for *stat(). Here are
the changes since the last revision:

* Describe blksize_t and blkcnt_t in 'What's Changed' texinfo docs.
* The block size for network drives is now defaulted to 4096.
* The default block sizes are described (for floppies & network drives) in
*stat() texinfo docs.
* statfs() is now in libc/stubs.h.
* Fixed a bug in lstat(), where the path was being passed to
_get_cached_blksize() without having been _fixpath()'d.
* *stat() now check that _get_cached_blksize() was successful, otherwise
they pass on the error.
* Removed _STAT_* definitions from xstat.c and _STFAIL_* from xstat.h,
since they're both in sys/stat.h.

OK to commit?

Thanks, bye, Rich =]

-- 
Richard Dawe
http://www.phekda.freeserve.co.uk/richdawe/

Index: include/sys/types.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/sys/types.h,v
retrieving revision 1.6
diff -p -c -3 -r1.6 types.h
*** include/sys/types.h 2000/12/05 14:05:53     1.6
--- include/sys/types.h 2001/12/01 15:28:28
*************** extern "C" {
*** 13,19 ****
  #ifndef __STRICT_ANSI__
  
  #include <sys/djtypes.h>
!   
  typedef int           dev_t;
  typedef int           ino_t;
  typedef int           mode_t;
--- 13,21 ----
  #ifndef __STRICT_ANSI__
  
  #include <sys/djtypes.h>
! 
! typedef int             blkcnt_t;
! typedef int             blksize_t;
  typedef int           dev_t;
  typedef int           ino_t;
  typedef int           mode_t;
Index: include/sys/stat.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/sys/stat.h,v
retrieving revision 1.4
diff -p -c -3 -r1.4 stat.h
*** include/sys/stat.h  2000/12/05 14:05:53     1.4
--- include/sys/stat.h  2001/12/01 15:28:31
*************** struct stat {
*** 49,57 ****
    time_t      st_mtime;
    nlink_t     st_nlink;
    off_t               st_size;
!   off_t               st_blksize;
    uid_t               st_uid;
!   dev_t               st_rdev; /* unused */
  };
  
  int   chmod(const char *_path, mode_t _mode);
--- 49,57 ----
    time_t      st_mtime;
    nlink_t     st_nlink;
    off_t               st_size;
!   blksize_t   st_blksize;
    uid_t               st_uid;
!   dev_t               st_rdev;
  };
  
  int   chmod(const char *_path, mode_t _mode);
Index: include/libc/fd_props.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/libc/fd_props.h,v
retrieving revision 1.6
diff -p -c -3 -r1.6 fd_props.h
*** include/libc/fd_props.h     2001/06/06 21:09:50     1.6
--- include/libc/fd_props.h     2001/12/01 15:28:38
*************** extern "C" {
*** 8,13 ****
--- 8,15 ----
  
  #ifndef __dj_ENFORCE_ANSI_FREESTANDING
  
+ #include <string.h>
+ 
  #ifndef __STRICT_ANSI__
  
  #ifndef _POSIX_SOURCE
*************** static __inline__ void __clear_fd_flags(
*** 63,68 ****
--- 65,75 ----
  static __inline__ unsigned long __get_fd_flags(int _fd)
  {
    return __has_fd_properties(_fd) ? __fd_properties[_fd]->flags : 0;
+ }
+ 
+ static __inline__ const char * __get_fd_name(int _fd)
+ {
+   return __has_fd_properties(_fd) ? __fd_properties[_fd]->filename :
NULL;
  }
  
  #endif /* !_POSIX_SOURCE */
Index: src/libc/posix/sys/stat/fstat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/fstat.c,v
retrieving revision 1.7
diff -p -c -3 -r1.7 fstat.c
*** src/libc/posix/sys/stat/fstat.c     2001/09/25 01:00:52     1.7
--- src/libc/posix/sys/stat/fstat.c     2001/12/01 15:28:47
***************
*** 106,111 ****
--- 106,113 ----
  #include <dos.h>
  #include <sys/types.h>
  #include <sys/stat.h>
+ #include <limits.h>
+ #include <libc/fd_props.h>
  
  #include <dpmi.h>
  #include <go32.h>
*************** fstat_assist(int fhandle, struct stat *s
*** 433,440 ****
    stat_buf->st_uid = getuid();
    stat_buf->st_gid = getgid();
    stat_buf->st_nlink = 1;
  #ifndef  NO_ST_BLKSIZE
!   stat_buf->st_blksize = _go32_info_block.size_of_transfer_buffer;
  #endif
  
    /* If SFT entry for our handle is required and available, we will use
it.  */
--- 435,460 ----
    stat_buf->st_uid = getuid();
    stat_buf->st_gid = getgid();
    stat_buf->st_nlink = 1;
+ 
+   /* Get the block size for the device associated with `fhandle'. */
  #ifndef  NO_ST_BLKSIZE
!   if (__get_fd_name(fhandle))
!     {
!       const char *filename;
!       char fixed_filename[PATH_MAX + 1];
! 
!       filename = __get_fd_name(fhandle);
!       _fixpath(filename, fixed_filename);
!       stat_buf->st_blksize = _get_cached_blksize(fixed_filename);
!       if (stat_buf->st_blksize == -1)
!       return -1; /* errno set by _get_cached_blksize() */
!     }
!   else
!     {
!       /* Fall back on transfer buffer size, if we can't determine file
name
!        * (which gives the drive letter and then the drive's cluster
size). */
!       stat_buf->st_blksize = _go32_info_block.size_of_transfer_buffer;
!     }
  #endif
  
    /* If SFT entry for our handle is required and available, we will use
it.  */
*************** int main(int argc, char *argv[])
*** 936,941 ****
--- 956,964 ----
        _djstat_describe_lossage(stderr);
      }
  
+   if (!argc)
+     return EXIT_SUCCESS;
+ 
    /* Now call fstat() for each command-line argument. */
    while (++argv, --argc)
      {
*************** int main(int argc, char *argv[])
*** 956,961 ****
--- 979,986 ----
          fprintf (stderr, "\t\t\tTimes: %lu %lu\n",
                   (unsigned long)stat_buf.st_atime,
                   (unsigned long)stat_buf.st_ctime);
+         fprintf(stderr, "\t\t\tBlock size: %d\n",
+                 stat_buf.st_blksize);
            _djstat_describe_lossage(stderr);
          }
        else
*************** int main(int argc, char *argv[])
*** 965,971 ****
            _djstat_describe_lossage(stderr);
          }
      }
!   return 0;
  }
  
  #endif  /* TEST */
--- 990,996 ----
            _djstat_describe_lossage(stderr);
          }
      }
!   return EXIT_SUCCESS;
  }
  
  #endif  /* TEST */
Index: src/libc/posix/sys/stat/lstat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/lstat.c,v
retrieving revision 1.7
diff -p -c -3 -r1.7 lstat.c
*** src/libc/posix/sys/stat/lstat.c     2001/10/17 05:08:39     1.7
--- src/libc/posix/sys/stat/lstat.c     2001/12/01 15:28:57
*************** stat_assist(const char *path, struct sta
*** 444,452 ****
    statbuf->st_uid     = getuid();
    statbuf->st_gid     = getgid();
    statbuf->st_nlink   = 1;
- #ifndef  NO_ST_BLKSIZE
-   statbuf->st_blksize = _go32_info_block.size_of_transfer_buffer;
- #endif
  
    /* Make the path explicit.  This makes the rest of our job much
       easier by getting rid of some constructs which, if present,
--- 444,449 ----
*************** stat_assist(const char *path, struct sta
*** 455,460 ****
--- 452,464 ----
       to make an illusion of having a ".." entry in root directories.  */
    _fixpath (path, pathname);
  
+   /* Get the block size for the device associated with `pathname'. */
+ #ifndef  NO_ST_BLKSIZE
+   statbuf->st_blksize = _get_cached_blksize(pathname);
+   if (statbuf->st_blksize == -1)
+     return -1; /* errno set by _get_cached_blksize() */
+ #endif
+ 
    /* Get the drive number.  It is always explicit, since we
       called `_fixpath' on the original pathname.  */
    drv_no = toupper((unsigned char)pathname[0]) - 'A';
*************** lstat(const char *path, struct stat *sta
*** 932,940 ****
  
  #ifdef  TEST
  
  unsigned short _djstat_flags = 0;
  
! void
  main(int argc, char *argv[])
  {
    struct stat stat_buf;
--- 936,946 ----
  
  #ifdef  TEST
  
+ #include <stdlib.h>
+ 
  unsigned short _djstat_flags = 0;
  
! int
  main(int argc, char *argv[])
  {
    struct stat stat_buf;
*************** main(int argc, char *argv[])
*** 943,949 ****
    if (argc < 2)
      {
        fprintf (stderr, "Usage: %s <_djstat_flags> <file...>\n",
argv[0]);
!       exit(0);
      }
  
    if (lstat(*argv, &stat_buf) != 0)
--- 949,955 ----
    if (argc < 2)
      {
        fprintf (stderr, "Usage: %s <_djstat_flags> <file...>\n",
argv[0]);
!       return (EXIT_FAILURE);
      }
  
    if (lstat(*argv, &stat_buf) != 0)
*************** main(int argc, char *argv[])
*** 968,973 ****
--- 974,981 ----
                    (long)stat_buf.st_size,
                    (unsigned long)stat_buf.st_mtime,
                    ctime(&stat_buf.st_mtime));
+         fprintf(stderr, "\t\t\tBlock size: %d\n",
+                 stat_buf.st_blksize);
            _djstat_describe_lossage(stderr);
          }
        else
*************** main(int argc, char *argv[])
*** 980,986 ****
        ++argv;
      }
  
!     exit (0);
  }
  
  #endif
--- 988,994 ----
        ++argv;
      }
  
!     return (EXIT_SUCCESS);
  }
  
  #endif
Index: src/libc/posix/sys/stat/xstat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/xstat.c,v
retrieving revision 1.3
diff -p -c -3 -r1.3 xstat.c
*** src/libc/posix/sys/stat/xstat.c     2000/08/05 16:53:46     1.3
--- src/libc/posix/sys/stat/xstat.c     2001/12/01 15:29:03
***************
*** 13,24 ****
--- 13,26 ----
   *
   */
  
+ #include <libc/stubs.h>
  #include <stdlib.h>
  #include <string.h>
  #include <sys/types.h>
  #include <limits.h>
  #include <time.h>
  #include <errno.h>
+ #include <sys/vfs.h>
  #include <dos.h>
  #include <dpmi.h>
  #include <libc/farptrgs.h>
*************** static int xstat_count = -1;
*** 40,51 ****
     This improvement was suggested by Charles Sandmann
     <sandmann AT clio DOT rice DOT edu> and DJ Delorie <dj AT delorie DOT com>.  */
  
! #define _STAT_INODE         1   /* should we bother getting inode
numbers? */
! #define _STAT_EXEC_EXT      2   /* get execute bits from file extension?
*/
! #define _STAT_EXEC_MAGIC    4   /* get execute bits from magic
signature? */
! #define _STAT_DIRSIZE       8   /* compute directory size? */
! #define _STAT_ROOT_TIME  0x10   /* try to get root dir time stamp? */
! #define _STAT_WRITEBIT   0x20   /* fstat() needs write bit? */
  
  /* Should we bother about executables at all? */
  #define _STAT_EXECBIT       (_STAT_EXEC_EXT | _STAT_EXEC_MAGIC)
--- 42,48 ----
     This improvement was suggested by Charles Sandmann
     <sandmann AT clio DOT rice DOT edu> and DJ Delorie <dj AT delorie DOT com>.  */
  
! /* Please see the header file sys/stat.h for the definitions of _STAT_*.
*/
  
  /* Should we bother about executables at all? */
  #define _STAT_EXECBIT       (_STAT_EXEC_EXT | _STAT_EXEC_MAGIC)
*************** _getftime(int fhandle, unsigned int *dos
*** 116,121 ****
--- 113,193 ----
    *dos_ftime = ((unsigned int)regs.x.dx << 16) + (unsigned
int)regs.x.cx;
  
    return 0;
+ }
+ 
+ /* Cache the cluster size (aka block size) for each drive letter, so we
can
+  * populate the st_blksize of struct stat easily. The cluster size is
+  * measured in bytes.
+  *
+  * ASSUMPTION: path has already been fixed by `_fixpath'.
+  */
+ 
+ /* Comment copied from DJGPP 2.03's src/libc/compat/mntent/mntent.c:
+  *
+  * There may be a maximum of 32 block devices.  Novell Netware indeed
+  * allows for 32 disks (A-Z plus 6 more characters from '[' to '\'')
+  */
+ static blksize_t cache_blksize[32];
+ static int cache_blksize_count = -1;
+ 
+ blksize_t
+ _get_cached_blksize (const char *path)
+ {
+   struct statfs sbuf;
+   int           d; /* index into drive cache = drive_num - 1 */  
+   static int    overmax_d = sizeof(cache_blksize) /
sizeof(cache_blksize[0]);
+ 
+   /* Force initialization in restarted programs (emacs).  */
+   if (cache_blksize_count != __bss_count)
+     {
+       cache_blksize_count = __bss_count;
+       memset(cache_blksize, 0, sizeof(cache_blksize));
+ 
+       /* Default floppy drives to 512B block size, to improve
performance. */
+       cache_blksize[0] = cache_blksize[1] = 512;
+     }
+ 
+   /* Get the drive number. The fixed filename will begin with a
lowercase
+    * letter or a symbol. The symbols for drives > 'z:' occur straight
+    * after 'Z' in ASCII.
+    */
+   if ((path[0] >= 'a') && (path[0] <= 'z'))
+     d = path[0] - 'a';
+   else
+     d = path[0] - 'A';
+ 
+   if ((d < 0) || (d >= overmax_d))
+     {
+       errno = ENODEV;
+       return -1;
+     }
+ 
+   if (!cache_blksize[d])
+     {
+       if (_is_remote_drive(d + 1))
+       {
+         /* Default remote drives to 4K block size, to improve
performance.
+          *
+          * Also the size returned by statfs() may not be correct.
Testing
+          * against files shared by Samba 2.0.10 on Linux kernel 2.2.19
+          * returned a 32K block size, even though the ext2 filesystem
+          * holding the share share had a 4K block size. */
+         cache_blksize[d] = 4096;
+       }
+       else
+       {
+         /* No entry => retrieve cluster size */
+         if (statfs(path, &sbuf) != 0)
+           {
+             /* Failed, pass error through */
+             return -1;
+           }
+ 
+         cache_blksize[d] = sbuf.f_bsize;
+       }
+     }
+ 
+   return cache_blksize[d];
  }
  
  /* Invent an inode number for those files which don't have valid DOS
Index: src/libc/posix/sys/stat/stat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/stat.c,v
retrieving revision 1.10
diff -p -c -3 -r1.10 stat.c
*** src/libc/posix/sys/stat/stat.c      2000/08/22 18:45:07     1.10
--- src/libc/posix/sys/stat/stat.c      2001/12/01 15:29:09
*************** stat(const char *path, struct stat *stat
*** 31,39 ****
  
  #ifdef  TEST
  
  unsigned short _djstat_flags = 0;
  
! void
  main(int argc, char *argv[])
  {
    struct stat stat_buf;
--- 31,41 ----
  
  #ifdef  TEST
  
+ #include <stdlib.h>
+ 
  unsigned short _djstat_flags = 0;
  
! int
  main(int argc, char *argv[])
  {
    struct stat stat_buf;
*************** main(int argc, char *argv[])
*** 42,48 ****
    if (argc < 2)
      {
        fprintf (stderr, "Usage: %s <_djstat_flags> <file...>\n",
argv[0]);
!       exit(0);
      }
  
    if (stat(*argv, &stat_buf) != 0)
--- 44,50 ----
    if (argc < 2)
      {
        fprintf (stderr, "Usage: %s <_djstat_flags> <file...>\n",
argv[0]);
!       return (EXIT_FAILURE);
      }
  
    if (stat(*argv, &stat_buf) != 0)
*************** main(int argc, char *argv[])
*** 67,72 ****
--- 69,76 ----
                    (long)stat_buf.st_size,
                    (unsigned long)stat_buf.st_mtime,
                    ctime(&stat_buf.st_mtime));
+         fprintf(stderr, "\t\t\tBlock size: %d\n",
+                 stat_buf.st_blksize);
            _djstat_describe_lossage(stderr);
          }
        else
*************** main(int argc, char *argv[])
*** 79,85 ****
        ++argv;
      }
  
!     exit (0);
  }
  
  #endif
--- 83,89 ----
        ++argv;
      }
  
!     return (EXIT_SUCCESS);
  }
  
  #endif
Index: src/libc/posix/sys/stat/xstat.h
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/xstat.h,v
retrieving revision 1.4
diff -p -c -3 -r1.4 xstat.h
*** src/libc/posix/sys/stat/xstat.h     2000/08/05 16:53:46     1.4
--- src/libc/posix/sys/stat/xstat.h     2001/12/01 15:29:14
***************
*** 38,61 ****
  extern unsigned short   _osmajor, _osminor;
  extern const    char  * _os_flavor;
  
- /* Bits to flag f?stat() failed to use individual undocumented features.
*/
- #define _STFAIL_SDA         1   /* Get SDA call failed */
- #define _STFAIL_OSVER       2   /* Unsupported DOS version */
- #define _STFAIL_BADSDA      4   /* Bad pointer to SDA */
- #define _STFAIL_TRUENAME    8   /* _truename() failed */
- #define _STFAIL_HASH     0x10   /* inode defaults to hashing */
- #define _STFAIL_LABEL    0x20   /* Root dir, but no volume label */
- #define _STFAIL_DCOUNT   0x40   /* dirent_count ridiculously large */
- #define _STFAIL_WRITEBIT 0x80   /* fstat() failed to get write access
bit */
- #define _STFAIL_DEVNO   0x100   /* fstat() failed to get device number
*/
- #define _STFAIL_BADSFT  0x200   /* SFT entry found, but can't be trusted
*/
- #define _STFAIL_SFTIDX  0x400   /* bad SFT index in JFT */
- #define _STFAIL_SFTNF   0x800   /* file entry not found in SFT array */
- 
- extern unsigned short   _djstat_fail_bits;
- 
- extern unsigned short   _djstat_flags;
- 
  extern time_t           _file_time_stamp(unsigned int);
  extern ino_t            _invent_inode(const char *, unsigned, unsigned
long);
  extern unsigned short   _get_magic(const char *, int);
--- 38,43 ----
*************** extern long             __filelength(int
*** 68,72 ****
--- 50,55 ----
  extern int              _is_remote_handle(int);
  extern void             _djstat_describe_lossage(FILE *);
  extern int              _getftime(int, unsigned int *);
+ extern blksize_t        _get_cached_blksize (const char *path);
  
  #endif  /* __XSTAT_H */
Index: src/libc/posix/sys/stat/lstat.txh
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/lstat.txh,v
retrieving revision 1.3
diff -p -c -3 -r1.3 lstat.txh
*** src/libc/posix/sys/stat/lstat.txh   2001/08/01 10:31:02     1.3
--- src/libc/posix/sys/stat/lstat.txh   2001/12/01 15:29:20
*************** it in @var{sbuf}, which has this structu
*** 14,30 ****
  
  @smallexample
  struct  stat @{
!         time_t   st_atime;     /* time of last access       */
!         time_t   st_ctime;     /* time of file's creation   */
!         dev_t    st_dev;       /* The drive number (0 = a:) */
!         gid_t    st_gid;       /* what getgid() returns */
!         ino_t    st_ino;       /* starting cluster or unique identifier
*/
!         mode_t   st_mode;      /* file mode - S_IF* and S_IRUSR/S_IWUSR
*/
!         time_t   st_mtime;     /* time that the file was last written */
!         nlink_t  st_nlink;     /* 2 + number of subdirs, or 1 for files
*/
!         off_t    st_size;      /* size of file in bytes */
!         off_t    st_blksize;   /* the size of transfer buffer */
!         uid_t    st_uid;       /* what getuid() returns */
  @};
  @end smallexample
  
--- 14,31 ----
  
  @smallexample
  struct  stat @{
!         time_t    st_atime;     /* time of last access       */
!         time_t    st_ctime;     /* time of file's creation   */
!         dev_t     st_dev;       /* The drive number (0 = a:) */
!         gid_t     st_gid;       /* what getgid() returns */
!         ino_t     st_ino;       /* starting cluster or unique identifier
*/
!         mode_t    st_mode;      /* file mode - S_IF* and S_IRUSR/S_IWUSR
*/
!         time_t    st_mtime;     /* time that the file was last written
*/
!         nlink_t   st_nlink;     /* 2 + number of subdirs, or 1 for files
*/
!         off_t     st_size;      /* size of file in bytes */
!       blksize_t st_blksize;   /* block size in bytes*/
!         uid_t     st_uid;       /* what getuid() returns */
!       dev_t     st_rdev;      /* The drive number (0 = a:) */
  @};
  @end smallexample
  
*************** The @code{st_size} member is an signed 3
*** 47,52 ****
--- 48,57 ----
  overflow on FAT32 volumes for files that are larger than 2GB.
  Therefore, if your program needs to support large files, you should
  treat the value of @code{st_size} as an unsigned value.
+ 
+ For some drives @code{st_blksize} has a default value, to improve
+ performance.  The floppy drives A: and B: default to a block size
+ of 512 bytes.  Network drives default to a block size of 4096 bytes.
  
  Some members of @code{struct stat} are very expensive to compute.  If
  your application is a heavy user of @code{lstat} and is too slow, you
can
Index: src/libc/posix/sys/stat/stat.txh
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/stat.txh,v
retrieving revision 1.8
diff -p -c -3 -r1.8 stat.txh
*** src/libc/posix/sys/stat/stat.txh    2001/08/01 10:31:02     1.8
--- src/libc/posix/sys/stat/stat.txh    2001/12/01 15:29:27
*************** it in @var{sbuf}, which has this structu
*** 14,30 ****
  
  @smallexample
  struct  stat @{
!         time_t   st_atime;     /* time of last access       */
!         time_t   st_ctime;     /* time of file's creation   */
!         dev_t    st_dev;       /* The drive number (0 = a:) */
!         gid_t    st_gid;       /* what getgid() returns */
!         ino_t    st_ino;       /* starting cluster or unique identifier
*/
!         mode_t   st_mode;      /* file mode - S_IF* and S_IRUSR/S_IWUSR
*/
!         time_t   st_mtime;     /* time that the file was last written */
!         nlink_t  st_nlink;     /* 2 + number of subdirs, or 1 for files
*/
!         off_t    st_size;      /* size of file in bytes */
!         off_t    st_blksize;   /* the size of transfer buffer */
!         uid_t    st_uid;       /* what getuid() returns */
  @};
  @end smallexample
  
--- 14,31 ----
  
  @smallexample
  struct  stat @{
!         time_t    st_atime;     /* time of last access       */
!         time_t    st_ctime;     /* time of file's creation   */
!         dev_t     st_dev;       /* The drive number (0 = a:) */
!         gid_t     st_gid;       /* what getgid() returns */
!         ino_t     st_ino;       /* starting cluster or unique identifier
*/
!         mode_t    st_mode;      /* file mode - S_IF* and S_IRUSR/S_IWUSR
*/
!         time_t    st_mtime;     /* time that the file was last written
*/
!         nlink_t   st_nlink;     /* 2 + number of subdirs, or 1 for files
*/
!         off_t     st_size;      /* size of file in bytes */
!         blksize_t st_blksize;   /* block size in bytes*/
!         uid_t     st_uid;       /* what getuid() returns */
!       dev_t     st_rdev;      /* The drive number (0 = a:) */
  @};
  @end smallexample
  
*************** The @code{st_size} member is an signed 3
*** 47,52 ****
--- 48,57 ----
  overflow on FAT32 volumes for files that are larger than 2GB.
  Therefore, if your program needs to support large files, you should
  treat the value of @code{st_size} as an unsigned value.
+ 
+ For some drives @code{st_blksize} has a default value, to improve
+ performance.  The floppy drives A: and B: default to a block size
+ of 512 bytes.  Network drives default to a block size of 4096 bytes.
  
  Some members of @code{struct stat} are very expensive to compute.  If
  your application is a heavy user of @code{stat} and is too slow, you can
Index: src/libc/posix/sys/stat/fstat.txh
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/fstat.txh,v
retrieving revision 1.8
diff -p -c -3 -r1.8 fstat.txh
*** src/libc/posix/sys/stat/fstat.txh   2001/08/04 14:00:12     1.8
--- src/libc/posix/sys/stat/fstat.txh   2001/12/01 15:29:33
*************** overflow on FAT32 volumes for files that
*** 18,23 ****
--- 18,27 ----
  Therefore, if your program needs to support large files, you should
  treat the value of @code{st_size} as an unsigned value.
  
+ For some drives @code{st_blksize} has a default value, to improve
+ performance.  The floppy drives A: and B: default to a block size
+ of 512 bytes.  Network drives default to a block size of 4096 bytes.
+ 
  Some members of @code{struct stat} are very expensive to compute.  If
  your application is a heavy user of @code{fstat} and is too slow, you
  can disable computation of the members your application doesn't need, as
Index: src/docs/kb/develop.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/develop.txi,v
retrieving revision 1.6
diff -p -c -3 -r1.6 develop.txi
*** src/docs/kb/develop.txi     2001/11/02 18:48:50     1.6
--- src/docs/kb/develop.txi     2001/12/01 15:29:39
*************** functions, it should include @file{libc/
*** 77,82 ****
--- 77,89 ----
  @sc{gs} register instead of @sc{fs}, to avoid clobbering @sc{fs} which
  might be used by the application.
  
+ @subsection Filename manipulation
+ 
+ When manipulating filenames, don't use the ctype functions from
+ @file{ctype.h}, because they are locale sensitive.  For example,
+ instead of using @code{tolower} (@pxref{tolower, , tolower, libc}),
+ convert the case with explicit code.
+ 
  @subsection Assertions
  @cindex Assertions
  
Index: src/docs/kb/wc204.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc204.txi,v
retrieving revision 1.100
diff -p -c -3 -r1.100 wc204.txi
*** src/docs/kb/wc204.txi       2001/10/17 05:19:49     1.100
--- src/docs/kb/wc204.txi       2001/12/01 15:29:48
*************** case lowering.  This replaces the functi
*** 675,677 ****
--- 675,691 ----
  which is hopelessly buggy on Windows 2000 and XP.  New function used in
  @file{srchpath.c}, @file{readdir.c}, @file{glob.c}, @file{fixpath.c},
  @file{lstat.c} and @file{getcwd.c}.
+ 
+ @findex stat AT r{, and block size}
+ @findex lstat AT r{, and block size}
+ @findex fstat AT r{, and block size}
+ The functions @code{stat}, @code{lstat} and @code{fstat} now fill
+ the @code{st_blksize} member of @code{struct stat} with the correct
block
+ size for the device where the file is located.
+ 
+ @tindex blksize_t
+ @tindex blkcnt_t
+ @tindex struct stat AT r{, and }blksize_t
+ The types @code{blksize_t} and @code{blkcnt_t} were added.
+ @code{blksize_t} is now used for the @code{st_blksize} member of
+ @code{struct stat}.
Index: include/libc/stubs.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/libc/stubs.h,v
retrieving revision 1.9
diff -p -c -3 -r1.9 stubs.h
*** include/libc/stubs.h        2001/06/19 19:10:15     1.9
--- include/libc/stubs.h        2001/12/01 15:29:53
*************** extern "C" {
*** 60,65 ****
--- 60,66 ----
  #define setmode __setmode
  #define spawnve __spawnve
  #define spawnvpe __spawnvpe
+ #define statfs __statfs
  #define stricmp __stricmp
  #define sync __sync

- Raw text -


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