Back to index

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