TEST(sys_vfs, fstatfs64) { struct statfs64 sb; int fd = open("/proc", O_RDONLY); ASSERT_EQ(0, fstatfs64(fd, &sb)); close(fd); Check(sb); }
int fstatvfs64 (int fd, struct statvfs64 *buf) { struct statfs64 fsbuf; struct stat64 st; #if !defined __UCLIBC_LINUX_SPECIFIC__ int ret; struct statvfs buf32; ret = fstatvfs (fd, &buf32); if (ret == 0) { fsbuf.f_bsize = buf32.f_bsize; fsbuf.f_frsize = buf32.f_frsize; fsbuf.f_blocks = buf32.f_blocks; fsbuf.f_bfree = buf32.f_bfree; fsbuf.f_bavail = buf32.f_bavail; fsbuf.f_files = buf32.f_files; fsbuf.f_ffree = buf32.f_ffree; if (sizeof (fsbuf.f_fsid) == sizeof(buf32.f_fsid)) memcpy (&fsbuf.f_fsid, &buf32.f_fsid, sizeof(fsbuf.f_fsid)); /* and if not, then you could approximate or whatever.. */ fsbuf.f_namelen = buf32.f_namemax; } else return ret; #else /* Get as much information as possible from the system. */ if (fstatfs64 (fd, &fsbuf) < 0) return -1; #endif #define STAT(st) fstat64 (fd, st) #include "internal_statvfs.c" /* We signal success if the statfs call succeeded. */ return 0; }
static INT64_T chirp_fs_local_fstatfs(int fd, struct chirp_statfs *info) { PREAMBLE("fstatfs(%d, %p)", fd, info); SETUP_FILE struct statfs64 linfo; rc = fstatfs64(lfd, &linfo); if (rc == 0) COPY_STATFS_LOCAL_TO_CHIRP(*info, linfo); PROLOGUE }
void CImageDisk::getFreeSpace(QWORD *qwAvailDiskSpace) // [Main-Thread] { int nRes; #ifdef HAVE_FSTATFS64 struct statfs64 fsInfo; #else struct statfs fsInfo; #endif *qwAvailDiskSpace = 0LL; #ifdef HAVE_FSTATFS64 nRes = fstatfs64(m_nImageFd, &fsInfo); #else nRes = fstatfs(m_nImageFd, &fsInfo); #endif if (nRes == -1) // error THROW(ERR_ERRNO, errno); *qwAvailDiskSpace = ((QWORD) fsInfo.f_bavail) * ((QWORD)fsInfo.f_bsize); }
static INT64_T chirp_fs_local_fstatfs(int fd, struct chirp_statfs *buf) { struct statfs64 info; int result; result = fstatfs64(fd, &info); if(result == 0) { memset(buf, 0, sizeof(*buf)); #ifdef CCTOOLS_OPSYS_SUNOS buf->f_type = info.f_fsid; buf->f_bsize = info.f_frsize; #else buf->f_type = info.f_type; buf->f_bsize = info.f_bsize; #endif buf->f_blocks = info.f_blocks; buf->f_bavail = info.f_bavail; buf->f_bfree = info.f_bfree; buf->f_files = info.f_files; buf->f_ffree = info.f_ffree; } return result; }