• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <portability.h>
18 #include <errno.h>
19 #include <errno_portable.h>
20 #include <stat_portable.h>
21 
22 /* Note: The Portable Header will define stat to stat_portable */
WRAP(stat)23 int WRAP(stat)(const char *path, struct stat_portable *s)
24 {
25     struct stat mips_stat;
26     int ret;
27 
28     if (invalid_pointer(s)) {
29         *REAL(__errno)() = EFAULT;
30         return -1;
31     }
32     ret = REAL(stat)(path, &mips_stat);
33     stat_ntop(&mips_stat, s);
34     return ret;
35 }
36 
WRAP(fstat)37 int WRAP(fstat)(int fd, struct stat_portable *s)
38 {
39     struct stat mips_stat;
40     int ret;
41 
42     if (invalid_pointer(s)) {
43         *REAL(__errno)() = EFAULT;
44         return -1;
45     }
46     ret = REAL(fstat)(fd, &mips_stat);
47     stat_ntop(&mips_stat, s);
48     return ret;
49 }
50 
WRAP(lstat)51 int WRAP(lstat)(const char *path, struct stat_portable *s)
52 {
53     struct stat mips_stat;
54     int ret;
55 
56     if (invalid_pointer(s)) {
57         *REAL(__errno)() = EFAULT;
58         return -1;
59     }
60     ret = REAL(lstat)(path, &mips_stat);
61     stat_ntop(&mips_stat, s);
62     return ret;
63 }
64 
WRAP(fstatat)65 int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags)
66 {
67     struct stat mips_stat;
68     int ret;
69 
70     if (invalid_pointer(s)) {
71         *REAL(__errno)() = EFAULT;
72         return -1;
73     }
74     ret = REAL(fstatat)(dirfd, path, &mips_stat, flags);
75     stat_ntop(&mips_stat, s);
76     return ret;
77 }
78