]>
git.saurik.com Git - apple/libc.git/blob - emulated/statvfs.c
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 #include <sys/param.h>
28 #include <sys/mount.h>
30 #include <sys/statvfs.h> /* glue header */
33 /* Internal common conversion function */
35 cvt_statfs_to_statvfs(struct statfs
*from
, struct statvfs
*to
)
37 to
->f_bsize
= from
->f_iosize
;
38 to
->f_frsize
= from
->f_bsize
;
39 to
->f_blocks
= from
->f_blocks
;
40 to
->f_bfree
= from
->f_bfree
;
41 to
->f_bavail
= from
->f_bavail
;
42 to
->f_files
= from
->f_files
;
43 to
->f_ffree
= from
->f_ffree
;
44 to
->f_favail
= from
->f_ffree
;
45 to
->f_fsid
= from
->f_fsid
.val
[0]; /* XXX bad if non-root */
46 to
->f_namemax
= NAME_MAX
; /* XXX should be per FS */
50 if( from
->f_flags
& MNT_RDONLY
)
51 to
->f_flag
|= ST_RDONLY
;
52 if( from
->f_flags
& MNT_NOSUID
)
53 to
->f_flag
|= ST_NOSUID
;
60 fstatvfs(int fildes
, struct statvfs
*buf
)
65 if ((rv
= fstatfs(fildes
, &cvt
)) == 0)
66 cvt_statfs_to_statvfs(&cvt
, buf
);
73 statvfs(const char * __restrict path
, struct statvfs
* __restrict buf
)
78 if ((rv
= statfs(path
, &cvt
)) == 0)
79 cvt_statfs_to_statvfs(&cvt
, buf
);