Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #287 from eskimor/statvfs
Browse files Browse the repository at this point in the history
Statvfs
  • Loading branch information
andralex committed Aug 13, 2012
2 parents 22e74c5 + 7d20baa commit 6dcb04d
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
2 changes: 2 additions & 0 deletions posix.mak
Expand Up @@ -144,6 +144,7 @@ MANIFEST= \
src/core/sys/posix/sys/shm.d \
src/core/sys/posix/sys/socket.d \
src/core/sys/posix/sys/stat.d \
src/core/sys/posix/sys/statvfs.d \
src/core/sys/posix/sys/time.d \
src/core/sys/posix/sys/types.d \
src/core/sys/posix/sys/uio.d \
Expand Down Expand Up @@ -502,6 +503,7 @@ COPY=\
$(IMPDIR)/core/sys/posix/sys/shm.d \
$(IMPDIR)/core/sys/posix/sys/socket.d \
$(IMPDIR)/core/sys/posix/sys/stat.d \
$(IMPDIR)/core/sys/posix/sys/statvfs.d \
$(IMPDIR)/core/sys/posix/sys/time.d \
$(IMPDIR)/core/sys/posix/sys/types.d \
$(IMPDIR)/core/sys/posix/sys/uio.d \
Expand Down
99 changes: 99 additions & 0 deletions src/core/sys/posix/sys/statvfs.d
@@ -0,0 +1,99 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Robert Klotzner 2012
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: Robert Klotzner
* Standards: The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition
*/

module core.sys.posix.sys.statvfs;
private import core.stdc.config;
private import core.sys.posix.config;
public import core.sys.posix.sys.types;

extern (C) :

version(linux) {
static if(__WORDSIZE == 32)
{
version=_STATVFSBUF_F_UNUSED;
}
struct statvfs_t
{
c_ulong f_bsize;
c_ulong f_frsize;
fsblkcnt_t f_blocks;
fsblkcnt_t f_bfree;
fsblkcnt_t f_bavail;
fsfilcnt_t f_files;
fsfilcnt_t f_ffree;
fsfilcnt_t f_favail;
c_ulong f_fsid;
version(_STATVFSBUF_F_UNUSED)
{
int __f_unused;
}
c_ulong f_flag;
c_ulong f_namemax;
int __f_spare[6];
}
/* Definitions for the flag in `f_flag'. These definitions should be
kept in sync with the definitions in <sys/mount.h>. */
static if(__USE_GNU)
{
enum FFlag
{
ST_RDONLY = 1, /* Mount read-only. */
ST_NOSUID = 2,
ST_NODEV = 4, /* Disallow access to device special files. */
ST_NOEXEC = 8, /* Disallow program execution. */
ST_SYNCHRONOUS = 16, /* Writes are synced at once. */
ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
ST_WRITE = 128, /* Write on file/directory/symlink. */
ST_APPEND = 256, /* Append-only file. */
ST_IMMUTABLE = 512, /* Immutable file. */
ST_NOATIME = 1024, /* Do not update access times. */
ST_NODIRATIME = 2048, /* Do not update directory access times. */
ST_RELATIME = 4096 /* Update atime relative to mtime/ctime. */

}
} /* Use GNU. */
else
{ // Posix defined:
enum FFlag
{
ST_RDONLY = 1, /* Mount read-only. */
ST_NOSUID = 2
}
}
}
else version (Posix)
{
struct statvfs_t
{
c_ulong f_bsize;
c_ulong f_frsize;
fsblkcnt_t f_blocks;
fsblkcnt_t f_bfree;
fsblkcnt_t f_bavail;
fsfilcnt_t f_files;
fsfilcnt_t f_ffree;
fsfilcnt_t f_favail;
c_ulong f_fsid;
c_ulong f_flag;
c_ulong f_namemax;
}

enum FFlag
{
ST_RDONLY = 1, /* Mount read-only. */
ST_NOSUID = 2
}
}

version(Posix)
{
extern int statvfs (const char * file, statvfs_t* buf);
extern int fstatvfs (int fildes, statvfs_t *buf);
}

0 comments on commit 6dcb04d

Please sign in to comment.