Home | History | Annotate | Download | only in arch-mips
      1 /*
      2  * Copyright 2012, 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 <statfs_portable.h>
     18 #include <string.h>
     19 
     20 static inline void statfs_ntop(struct statfs *n_statfs, struct statfs_portable *p_statfs)
     21 {
     22     memset(p_statfs, '\0', sizeof(struct statfs_portable));
     23     p_statfs->f_type = n_statfs->f_type;
     24     p_statfs->f_bsize = n_statfs->f_bsize;
     25     p_statfs->f_blocks = n_statfs->f_blocks;
     26     p_statfs->f_bfree = n_statfs->f_bfree;
     27     p_statfs->f_bavail = n_statfs->f_bavail;
     28     p_statfs->f_files = n_statfs->f_files;
     29     p_statfs->f_ffree = n_statfs->f_ffree;
     30     p_statfs->f_fsid = n_statfs->f_fsid;
     31     p_statfs->f_namelen = n_statfs->f_namelen;
     32     p_statfs->f_frsize = n_statfs->f_frsize;
     33 }
     34 
     35 int statfs_portable(const char*  path, struct statfs_portable*  stat)
     36 {
     37     struct statfs mips_stat;
     38     int ret = statfs(path, &mips_stat);
     39     statfs_ntop(&mips_stat, stat);
     40     return ret;
     41 }
     42 
     43 int fstatfs_portable(int fd, struct statfs_portable*  stat)
     44 {
     45     struct statfs mips_stat;
     46     int ret = fstatfs(fd, &mips_stat);
     47     statfs_ntop(&mips_stat, stat);
     48     return ret;
     49 }
     50