Back to index

glibc  2.9
lxstat.c
Go to the documentation of this file.
00001 /* lxstat using old-style Unix lstat 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 __lxstat64 __lxstat64_disable
00023 
00024 #include <errno.h>
00025 #include <stddef.h>
00026 #include <sys/stat.h>
00027 #include <kernel_stat.h>
00028 
00029 #include <sysdep.h>
00030 #include <sys/syscall.h>
00031 #include <bp-checks.h>
00032 
00033 #include <xstatconv.h>
00034 
00035 /* Get information about the file NAME in BUF.  */
00036 int
00037 __lxstat (int vers, const char *name, struct stat *buf)
00038 {
00039   if (vers == _STAT_VER_KERNEL)
00040     return INLINE_SYSCALL (lstat, 2, CHECK_STRING (name),
00041                         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 (lstat, 2, CHECK_STRING (name), __ptrvalue (&kbuf));
00051   if (result == 0)
00052     result = __xstat_conv (vers, &kbuf, buf);
00053 
00054   return result;
00055 #endif
00056 }
00057 
00058 hidden_def (__lxstat)
00059 weak_alias (__lxstat, _lxstat);
00060 #ifdef XSTAT_IS_XSTAT64
00061 #undef __lxstat64
00062 strong_alias (__lxstat, __lxstat64);
00063 hidden_ver (__lxstat, __lxstat64)
00064 #endif