blob: 829f35a93397089645ea07c5dfc32e1277e1f61f [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* vi: set sw=4 ts=4: */
2/*
3 * stat() for uClibc
4 *
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6 *
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 */
9
10#include <sys/syscall.h>
11#include <unistd.h>
12#include <sys/stat.h>
13#include "xstatconv.h"
14
15#undef stat
16
17int stat(const char *file_name, struct stat *buf)
18{
19 int result;
20#ifdef __NR_stat64
21 /* normal stat call has limited values for various stat elements
22 * e.g. uid device major/minor etc.
23 * so we use 64 variant if available
24 * in order to get newer versions of stat elements
25 */
26 struct kernel_stat64 kbuf;
27 result = INLINE_SYSCALL(stat64, 2, file_name, &kbuf);
28 if (result == 0) {
29 __xstat32_conv(&kbuf, buf);
30 }
31#else
32 struct kernel_stat kbuf;
33
34 result = INLINE_SYSCALL(stat, 2, file_name, &kbuf);
35 if (result == 0) {
36 __xstat_conv(&kbuf, buf);
37 }
38#endif
39 return result;
40}
41libc_hidden_def(stat)
42
43#if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
44strong_alias_untyped(stat,stat64)
45libc_hidden_def(stat64)
46#endif