1c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner/*
2c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * Copyright (C) 2008 The Android Open Source Project
3c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * All rights reserved.
4c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *
5c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * Redistribution and use in source and binary forms, with or without
6c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * modification, are permitted provided that the following conditions
7c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * are met:
8c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *  * Redistributions of source code must retain the above copyright
9c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *    notice, this list of conditions and the following disclaimer.
10c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *  * Redistributions in binary form must reproduce the above copyright
11c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *    notice, this list of conditions and the following disclaimer in
12c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *    the documentation and/or other materials provided with the
13c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *    distribution.
14c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *
15c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * SUCH DAMAGE.
27c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner */
28c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#ifndef _SYS_STAT_H_
29c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#define _SYS_STAT_H_
30c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
31c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#include <sys/cdefs.h>
32c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#include <sys/types.h>
33c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#include <sys/time.h>
34c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#include <linux/stat.h>
35c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
36c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#include <endian.h>
37c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
38c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner__BEGIN_DECLS
39c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
40c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner/* really matches stat64 in the kernel, hence the padding
41c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * Note: The kernel zero's the padded region because glibc might read them
42c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * in the hope that the kernel has stretched to using larger sizes.
43c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner */
44c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerstruct stat {
45c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long long  st_dev;
46c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned char       __pad0[4];
47c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
48c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       __st_ino;
49c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned int        st_mode;
50c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned int        st_nlink;
51c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
52c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       st_uid;
53c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       st_gid;
54c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
55c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long long  st_rdev;
56c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned char       __pad3[4];
57c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
58c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    long long           st_size;
59c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long	st_blksize;
60c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long long  st_blocks;
61c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
62c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       st_atime;
63c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       st_atime_nsec;
64c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
65c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       st_mtime;
66c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       st_mtime_nsec;
67c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
68c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       st_ctime;
69c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long       st_ctime_nsec;
70c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
71c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    unsigned long long  st_ino;
72c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner};
73c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
74c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner/* For compatibility with GLibc, we provide macro aliases
75c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * for the non-Posix nano-seconds accessors.
76c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner */
77c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#define  st_atimensec  st_atime_nsec
78c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#define  st_mtimensec  st_mtime_nsec
79c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#define  st_ctimensec  st_ctime_nsec
80c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
81c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int    chmod(const char *, mode_t);
82c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int    fchmod(int, mode_t);
83c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int    mkdir(const char *, mode_t);
84c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
85c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int    stat(const char *, struct stat *);
86c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int    fstat(int, struct stat *);
87c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int    lstat(const char *, struct stat *);
88c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int    mknod(const char *, mode_t, dev_t);
89c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern mode_t umask(mode_t);
90c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
91c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#define  stat64    stat
92c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#define  fstat64   fstat
93c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#define  lstat64   lstat
94c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
95c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerstatic __inline__ int mkfifo(const char *__p, mode_t __m)
96c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner{
97c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner  return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t)0);
98c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner}
99c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
100c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int  fstatat(int dirfd, const char *path, struct stat *buf, int flags);
101c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int  mkdirat(int dirfd, const char *pathname, mode_t mode);
102c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flags);
103c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int fchmodat(int dirfd, const char *path, mode_t mode, int flags);
104c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turnerextern int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
105c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
106c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner__END_DECLS
107c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
108c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#endif /* _SYS_STAT_H_ */
109