]> sourceware.org Git - newlib-cygwin.git/commitdiff
* cygwin.din (fstatvfs): Export.
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 23 Feb 2005 13:12:43 +0000 (13:12 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 23 Feb 2005 13:12:43 +0000 (13:12 +0000)
(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.

winsup/cygwin/ChangeLog
winsup/cygwin/cygwin.din
winsup/cygwin/include/cygwin/types.h
winsup/cygwin/include/cygwin/version.h
winsup/cygwin/include/sys/statvfs.h [new file with mode: 0644]
winsup/cygwin/syscalls.cc

index 648a5f3089caf75efcda9534b51d65908d542116..667096acd08386cffc0f107c095bd7fcc9b84cfb 100644 (file)
@@ -1,3 +1,17 @@
+2005-02-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * 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.
+
 2005-02-23  Corinna Vinschen  <corinna@vinschen.de>
 
        * devices.h: Switch FH_ZERO and FH_PORT as on Linux.  Add FH_FULL.
index 877a544dc25a1b19474155270a377fa5fdae55ce..dd8e5a8c40eb0ec595537fa5467744cc840a0536 100644 (file)
@@ -564,6 +564,7 @@ _fsetpos64 = fsetpos64 SIGFE
 _fstat64 = fstat64 SIGFE
 fstatfs SIGFE
 _fstatfs = fstatfs SIGFE
+fstatvfs SIGFE
 fdatasync SIGFE
 fsync SIGFE
 _fsync = fsync SIGFE
@@ -1307,6 +1308,7 @@ _sscanf = sscanf SIGFE
 _stat64 = stat64 SIGFE
 statfs SIGFE
 _statfs = statfs SIGFE
+statvfs SIGFE
 strcasecmp NOSIGFE
 _strcasecmp = strcasecmp NOSIGFE
 strcat NOSIGFE
index 3964ae3a9d384fb9ed164390f0777a5301a7f73f..9b5c51b73f32773a64cd19691f0371c344a58a50 100644 (file)
@@ -66,6 +66,16 @@ typedef __blkcnt32_t  blkcnt_t;
 #endif
 #endif /*__blkcnt_t_defined*/
 
+#ifndef __fsblkcnt_t_defined
+#define __fsblkcnt_t_defined
+typedef unsigned long fsblkcnt_t;
+#endif /* __fsblkcnt_t_defined */
+
+#ifndef __fsfilcnt_t_defined
+#define __fsfilcnt_t_defined
+typedef unsigned long fsfilcnt_t;
+#endif /* __fsfilcnt_t_defined */
+
 #ifndef __uid_t_defined
 #define __uid_t_defined
 typedef unsigned short __uid16_t;
index fac4ea2ea384ebdeec81c79ff51526285ea4f414..10cf2ba2d8665a772de416e15b10ff745734d5a5 100644 (file)
@@ -248,12 +248,13 @@ details. */
       118: Export getpriority, setpriority.
       119: Export fdatasync.
       120: Export basename, dirname.
+      121: Export statvfs, fstatvfs.
      */
 
      /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
 
 #define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 120
+#define CYGWIN_VERSION_API_MINOR 121
 
      /* There is also a compatibity version number associated with the
        shared memory regions.  It is incremented when incompatible
diff --git a/winsup/cygwin/include/sys/statvfs.h b/winsup/cygwin/include/sys/statvfs.h
new file mode 100644 (file)
index 0000000..a32c198
--- /dev/null
@@ -0,0 +1,41 @@
+/* sys/statvfs.h
+
+   Copyright 2005 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _SYS_STATVFS_H_
+#define _SYS_STATVFS_H_
+
+#include <sys/types.h>
+
+struct statvfs {
+   unsigned long    f_bsize;    /* file system block size */
+   unsigned long    f_frsize;   /* fragment size */
+   fsblkcnt_t      f_blocks;   /* size of fs in f_frsize units */
+   fsblkcnt_t      f_bfree;    /* free blocks in fs */
+   fsblkcnt_t      f_bavail;   /* free blocks avail to non-superuser */
+   fsfilcnt_t      f_files;    /* total file nodes in file system */
+   fsfilcnt_t      f_ffree;    /* free file nodes in fs */
+   fsfilcnt_t      f_favail;   /* avail file nodes in fs */
+   unsigned long    f_fsid;     /* file system id */
+   unsigned long    f_flag;    /* mount flags */
+   unsigned long    f_namemax;  /* maximum length of filenames */
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+int statvfs (const char *__path, struct statvfs *__buf);
+int fstatvfs (int __fd, struct statvfs *__buf);
+
+#ifdef __cplusplus
+};
+#endif /* __cplusplus */
+
+#endif /*_SYS_STATVFS_H_*/
index a80b470904d253ed6401aa06210bdcdfa67c043a..8cd7368ec233da9b59befe1cb48fbebc506ab4c1 100644 (file)
@@ -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,18 +1734,51 @@ 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)
 {
This page took 0.042276 seconds and 5 git commands to generate.