Back to index

glibc  2.9
fxstat.c
Go to the documentation of this file.
00001 /* fxstat using old-style Unix stat system call.
00002    Copyright (C) 2004 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 #define __fxstat64 __fxstat64_disable
00021 
00022 #include <errno.h>
00023 #include <stddef.h>
00024 #include <sys/stat.h>
00025 #include <kernel_stat.h>
00026 #include <sysdep.h>
00027 #include <sys/syscall.h>
00028 #include <xstatconv.h>
00029 
00030 #undef __fxstat64
00031 
00032 
00033 /* Get information about the file NAME in BUF.  */
00034 int
00035 __fxstat (int vers, int fd, struct stat *buf)
00036 {
00037   INTERNAL_SYSCALL_DECL (err);
00038   int result, errno_out;
00039   struct kernel_stat kbuf;
00040 
00041   if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
00042     {
00043       result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
00044       if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
00045        return result;
00046       errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
00047       if (errno_out != ENOSYS)
00048        goto fail;
00049       __libc_missing_axp_stat64 = 1;
00050     }
00051 
00052   result = INTERNAL_SYSCALL (fstat, err, 2, fd, &kbuf);
00053   if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
00054     return __xstat_conv (vers, &kbuf, buf);
00055   errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
00056   
00057  fail:
00058   __set_errno (errno_out);
00059   return -1;
00060 }
00061 hidden_def (__fxstat)
00062 weak_alias (__fxstat, _fxstat);
00063 strong_alias (__fxstat, __fxstat64);
00064 hidden_ver (__fxstat, __fxstat64)