Date: Sun, 05 Jan 2003 14:30:52 +0000 From: "Richard Dawe" Sender: rich AT phekda DOT freeserve DOT co DOT uk To: djgpp-workers AT delorie DOT com X-Mailer: Emacs 21.3.50 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6 Subject: statvfs f_frsize bugfix, revision 2 [PATCH] Message-Id: Reply-To: djgpp-workers AT delorie DOT com Hello. Below is the second revision of the bugfix for the f_frsize (fundamental block size) in statvfs. The method I have chosen is to return the cluster size as the fundamental block size. OK to commit? Bye, Rich =] Index: src/libc/posix/sys/statvfs/statvfs.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/statvfs/statvfs.c,v retrieving revision 1.2 diff -p -c -3 -r1.2 statvfs.c *** src/libc/posix/sys/statvfs/statvfs.c 17 Oct 2002 23:00:25 -0000 1.2 --- src/libc/posix/sys/statvfs/statvfs.c 5 Jan 2003 14:27:19 -0000 *************** *** 1,3 **** --- 1,4 ---- + /* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ *************** statvfs (const char *path, struct statvf *** 34,43 **** outbuf->f_ffree = sbuf.f_bfree; outbuf->f_favail = sbuf.f_bavail; ! /* We pretend that the fundamental block size `f_frsize' for all devices ! * is 512 bytes. This seems reasonable since many (if not most) devices ! * have 512 byte sectors. */ ! outbuf->f_frsize = 512; /* Set the flags. */ outbuf->f_flag = ST_NOSUID; --- 35,44 ---- outbuf->f_ffree = sbuf.f_bfree; outbuf->f_favail = sbuf.f_bavail; ! /* We pretend that the fundamental block size `f_frsize' is the same ! * as the file system's block size ("clusters" for FAT file systems). ! */ ! outbuf->f_frsize = outbuf->f_bsize; /* Set the flags. */ outbuf->f_flag = ST_NOSUID; Index: src/libc/posix/sys/statvfs/statvfs.txh =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/statvfs/statvfs.txh,v retrieving revision 1.2 diff -p -c -3 -r1.2 statvfs.txh *** src/libc/posix/sys/statvfs/statvfs.txh 14 Dec 2002 16:41:57 -0000 1.2 --- src/libc/posix/sys/statvfs/statvfs.txh 5 Jan 2003 14:27:19 -0000 *************** the structure below: *** 18,27 **** struct statvfs @{ unsigned long f_bsize; /* FS block size */ unsigned long f_frsize; /* fundamental block size */ ! fsblkcnt_t f_blocks; /* # of blocks on filesystem */ ! fsblkcnt_t f_bfree; /* # of free blocks on FS */ ! fsblkcnt_t f_bavail; /* # of free blocks on FS for ! * unprivileged users */ fsfilcnt_t f_files; /* # of file serial numbers */ fsfilcnt_t f_ffree; /* # of free file serial numbers */ fsfilcnt_t f_favail; /* # of free file serial numbers --- 18,27 ---- struct statvfs @{ unsigned long f_bsize; /* FS block size */ unsigned long f_frsize; /* fundamental block size */ ! fsblkcnt_t f_blocks; /* # of blocks on FS of size f_frsize */ ! fsblkcnt_t f_bfree; /* # of free blocks on FS of size f_frsize */ ! fsblkcnt_t f_bavail; /* # of free blocks on FS of size f_frsize ! * for unprivileged users */ fsfilcnt_t f_files; /* # of file serial numbers */ fsfilcnt_t f_ffree; /* # of free file serial numbers */ fsfilcnt_t f_favail; /* # of free file serial numbers *************** to approximately 2GB. TSRs that hook IN *** 43,52 **** --- 43,60 ---- These may be loaded by @file{autoexec.bat} or @file{config.sys}. + The fundamental block size is considered to be a cluster. Really + the fundamental block is the sector of the physical media rather + than the logical block of the filesystem, but the sector size + cannot be determined in all cases. So for consistency we return + the cluster size. + @subheading Return Value Zero on success, nonzero on failure (and @code{errno} set). @subheading Portability + + @port-note posix See the comments on the fundamental block size above. @portability !ansi, posix