Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2005-02-23 16:12:43 +0300
committerCorinna Vinschen <corinna@vinschen.de>2005-02-23 16:12:43 +0300
commita652e6d52a0d403bc8ffebfc1a83e305eff42d2c (patch)
treecb4d4fc7dc0fb7a9ca21e229d1b60b370f026daa /winsup/cygwin/syscalls.cc
parente5ef74dfb2c6b8e00daf6afc7ac8895c626a59d9 (diff)
* cygwin.din (fstatvfs): Export.
(statvfs): Export. * syscalls.cc: Include sys/statvfs.h. (statvfs): New function. Move statfs functionality here. (fstatvfs): New function. (statfs): Just call statvfs and copy structure. Check validity of incoming struct statfs pointer. * include/cygwin/types.h (fsblkcnt_t): Define. (fsfilcnt_t): Define. * include/cygwin/version.h: Bump API minor version. * include/sys/statvfs.h: New file.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc50
1 files changed, 44 insertions, 6 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index a80b47090..8cd7368ec 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -24,6 +24,7 @@ details. */
#include "winsup.h"
#include <sys/stat.h>
#include <sys/vfs.h> /* needed for statfs */
+#include <sys/statvfs.h> /* needed for statvfs */
#include <pwd.h>
#include <grp.h>
#include <stdlib.h>
@@ -1684,10 +1685,14 @@ get_osfhandle (int fd)
}
extern "C" int
-statfs (const char *fname, struct statfs *sfs)
+statvfs (const char *fname, struct statvfs *sfs)
{
char root[CYG_MAX_PATH];
+ if (check_null_empty_str_errno (fname)
+ || check_null_invalid_struct_errno (sfs))
+ return -1;
+
syscall_printf ("statfs %s", fname);
if (!sfs)
@@ -1729,19 +1734,52 @@ statfs (const char *fname, struct statfs *sfs)
__seterrno ();
return -1;
}
- sfs->f_type = flags;
sfs->f_bsize = spc*bps;
+ sfs->f_frsize = spc*bps;
sfs->f_blocks = totalc;
- sfs->f_bavail = availc;
sfs->f_bfree = freec;
- sfs->f_files = -1;
- sfs->f_ffree = -1;
+ sfs->f_bavail = availc;
+ sfs->f_files = ULONG_MAX;
+ sfs->f_ffree = ULONG_MAX;
+ sfs->f_favail = ULONG_MAX;
sfs->f_fsid = vsn;
- sfs->f_namelen = maxlen;
+ sfs->f_flag = flags;
+ sfs->f_namemax = maxlen;
return 0;
}
extern "C" int
+fstatvfs (int fd, struct statvfs *sfs)
+{
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return -1;
+ return statvfs (cfd->get_name (), sfs);
+}
+
+extern "C" int
+statfs (const char *fname, struct statfs *sfs)
+{
+ if (check_null_invalid_struct_errno (sfs))
+ return -1;
+ struct statvfs vfs;
+ int ret = statvfs (fname, &vfs);
+ if (!ret)
+ {
+ sfs->f_type = vfs.f_flag;
+ sfs->f_bsize = vfs.f_bsize;
+ sfs->f_blocks = vfs.f_blocks;
+ sfs->f_bavail = vfs.f_bavail;
+ sfs->f_bfree = vfs.f_bfree;
+ sfs->f_files = -1;
+ sfs->f_ffree = -1;
+ sfs->f_fsid = vfs.f_fsid;
+ sfs->f_namelen = vfs.f_namemax;
+ }
+ return ret;
+}
+
+extern "C" int
fstatfs (int fd, struct statfs *sfs)
{
cygheap_fdget cfd (fd);