• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <sys/statfs.h>
18 #include <sys/statvfs.h>
19 
__bionic_statfs_to_statvfs(const struct statfs * src,struct statvfs * dst)20 static inline void __bionic_statfs_to_statvfs(const struct statfs* src, struct statvfs* dst) {
21   dst->f_bsize = src->f_bsize;
22   dst->f_frsize = src->f_frsize;
23   dst->f_blocks = src->f_blocks;
24   dst->f_bfree = src->f_bfree;
25   dst->f_bavail = src->f_bavail;
26   dst->f_files = src->f_files;
27   dst->f_ffree = src->f_ffree;
28   dst->f_favail = src->f_ffree;
29   dst->f_fsid = src->f_fsid.__val[0] | static_cast<uint64_t>(src->f_fsid.__val[1]) << 32;
30   dst->f_flag = src->f_flags;
31   dst->f_namemax = src->f_namelen;
32 }
33 
statvfs(const char * path,struct statvfs * result)34 int statvfs(const char* path, struct statvfs* result) {
35   struct statfs tmp;
36   if (statfs(path, &tmp) == -1) return -1;
37   __bionic_statfs_to_statvfs(&tmp, result);
38   return 0;
39 }
40 
fstatvfs(int fd,struct statvfs * result)41 int fstatvfs(int fd, struct statvfs* result) {
42   struct statfs tmp;
43   if (fstatfs(fd, &tmp) == -1) return -1;
44   __bionic_statfs_to_statvfs(&tmp, result);
45   return 0;
46 }
47 
48 // Historically we provided actual symbols for statvfs64 and fstatvfs64.
49 // They're not particularly useful, but we can't take them away.
50 __strong_alias(statvfs64, statvfs);
51 __strong_alias(fstatvfs64, fstatvfs);
52