Back to index

glibc  2.9
statfs64.c
Go to the documentation of this file.
00001 /* Return information about the filesystem on which FILE resides.
00002    Copyright (C) 1996-2000,2003,2004,2007 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <errno.h>
00021 #include <string.h>
00022 #include <sys/statfs.h>
00023 #include <stddef.h>
00024 #include <sysdep.h>
00025 #include <kernel-features.h>
00026 
00027 
00028 # if __ASSUME_STATFS64 == 0
00029 int __no_statfs64 attribute_hidden;
00030 #endif
00031 
00032 /* Return information about the filesystem on which FILE resides.  */
00033 int
00034 __statfs64 (const char *file, struct statfs64 *buf)
00035 {
00036 #ifdef __NR_statfs64
00037 # if __ASSUME_STATFS64 == 0
00038   if (! __no_statfs64)
00039 # endif
00040     {
00041       int result = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
00042 
00043 # if __ASSUME_STATFS64 == 0
00044       if (result == 0 || errno != ENOSYS)
00045 # endif
00046        return result;
00047 
00048 # if __ASSUME_STATFS64 == 0
00049       __no_statfs64 = 1;
00050 # endif
00051     }
00052 #endif
00053 
00054 #if __ASSUME_STATFS64 == 0
00055   struct statfs buf32;
00056 
00057   if (__statfs (file, &buf32) < 0)
00058     return -1;
00059 
00060   buf->f_type = buf32.f_type;
00061   buf->f_bsize = buf32.f_bsize;
00062   buf->f_blocks = buf32.f_blocks;
00063   buf->f_bfree = buf32.f_bfree;
00064   buf->f_bavail = buf32.f_bavail;
00065   buf->f_files = buf32.f_files;
00066   buf->f_ffree = buf32.f_ffree;
00067   buf->f_fsid = buf32.f_fsid;
00068   buf->f_namelen = buf32.f_namelen;
00069   buf->f_frsize = buf32.f_frsize;
00070   memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
00071 
00072   return 0;
00073 #endif
00074 }
00075 weak_alias (__statfs64, statfs64)