Back to index

glibc  2.9
fxstat.c
Go to the documentation of this file.
00001 /* fxstat using old-style Unix fstat system call.
00002    Copyright (C) 1991,1995-1998,2000,2002,2003 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 /* Ho hum, if xstat == xstat64 we must get rid of the prototype or gcc
00021    will complain since they don't strictly match.  */
00022 #define __fxstat64 __fxstat64_disable
00023 
00024 #include <errno.h>
00025 #include <stddef.h>
00026 #include <sys/types.h>
00027 #include <sys/stat.h>
00028 #include <kernel_stat.h>
00029 
00030 #include <sysdep.h>
00031 #include <sys/syscall.h>
00032 #include <bp-checks.h>
00033 
00034 #include <xstatconv.h>
00035 
00036 /* Get information about the file FD in BUF.  */
00037 int
00038 __fxstat (int vers, int fd, struct stat *buf)
00039 {
00040   if (vers == _STAT_VER_KERNEL)
00041     return INLINE_SYSCALL (fstat, 2, fd, CHECK_1 ((struct kernel_stat *) buf));
00042 
00043 #ifdef STAT_IS_KERNEL_STAT
00044   errno = EINVAL;
00045   return -1;
00046 #else
00047   struct kernel_stat kbuf;
00048   int result;
00049 
00050   result = INLINE_SYSCALL (fstat, 2, fd, __ptrvalue (&kbuf));
00051   if (result == 0)
00052     result = __xstat_conv (vers, &kbuf, buf);
00053 
00054   return result;
00055 #endif
00056 }
00057 
00058 hidden_def (__fxstat)
00059 weak_alias (__fxstat, _fxstat);
00060 #ifdef XSTAT_IS_XSTAT64
00061 #undef __fxstat64
00062 strong_alias (__fxstat, __fxstat64);
00063 hidden_ver (__fxstat, __fxstat64)
00064 #endif