2 * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 #include <sys/statvfs.h>
14 fill_statvfs(dev_t device
, struct statvfs
*statvfs
)
17 if (fs_stat_dev(device
, &info
) < 0)
20 statvfs
->f_frsize
= statvfs
->f_bsize
= info
.block_size
;
21 statvfs
->f_blocks
= info
.total_blocks
;
22 statvfs
->f_bavail
= statvfs
->f_bfree
= info
.free_blocks
;
23 statvfs
->f_files
= info
.total_nodes
;
24 statvfs
->f_favail
= statvfs
->f_ffree
= info
.free_nodes
;
25 statvfs
->f_fsid
= device
;
26 statvfs
->f_flag
= info
.flags
& B_FS_IS_READONLY
? ST_RDONLY
: 0;
27 statvfs
->f_namemax
= B_FILE_NAME_LENGTH
;
37 statvfs(const char *path
, struct statvfs
*statvfs
)
39 dev_t device
= dev_for_path(path
);
43 return fill_statvfs(device
, statvfs
);
48 fstatvfs(int fd
, struct statvfs
*statvfs
)
51 if (fstat(fd
, &stat
) < 0)
54 return fill_statvfs(stat
.st_dev
, statvfs
);