source: mainline/uspace/lib/posix/sys/stat.h@ 53900ab

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 53900ab was 53900ab, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 15 years ago

Add sys/stat.h

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * Copyright (c) 2011 Jiri Zarevucky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef POSIX_SYS_STAT_H_
30#define POSIX_SYS_STAT_H_
31
32#include "../libc/sys/stat.h"
33#include "time.h"
34
35/* values are the same as on Linux */
36#define S_IFMT 0170000 /* all file types */
37#define S_IFSOCK 0140000 /* socket */
38#define S_IFLNK 0120000 /* symbolic link */
39#define S_IFREG 0100000 /* regular file */
40#define S_IFBLK 0060000 /* block device */
41#define S_IFDIR 0040000 /* directory */
42#define S_IFCHR 0020000 /* character device */
43#define S_IFIFO 0010000 /* FIFO */
44
45#define S_ISUID 0004000 /* SUID */
46#define S_ISGID 0002000 /* SGID */
47#define S_ISVTX 0001000 /* sticky */
48
49#define S_IRWXU 00700 /* owner permissions */
50#define S_IRUSR 00400
51#define S_IWUSR 00200
52#define S_IXUSR 00100
53
54#define S_IRWXG 00070 /* group permissions */
55#define S_IRGRP 00040
56#define S_IWGRP 00020
57#define S_IXGRP 00010
58
59#define S_IRWXO 00007 /* other permissions */
60#define S_IROTH 00004
61#define S_IWOTH 00002
62#define S_IXOTH 00001
63
64#define S_ISREG(m) ((m & S_IFREG) != 0)
65#define S_ISDIR(m) ((m & S_IFDIR) != 0)
66#define S_ISCHR(m) ((m & S_IFCHR) != 0)
67#define S_ISBLK(m) ((m & S_IFBLK) != 0)
68#define S_ISFIFO(m) ((m & S_IFIFO) != 0)
69#define S_ISLNK(m) ((m & S_IFLNK) != 0) /* symbolic link? (Not in POSIX.1-1996.) */
70#define S_ISSOCK(m) ((m & S_IFSOCK) != 0) /* socket? (Not in POSIX.1-1996.) */
71
72typedef devmap_handle_t dev_t;
73typedef unsigned int ino_t;
74typedef unsigned int nlink_t;
75typedef unsigned int uid_t;
76typedef unsigned int gid_t;
77typedef aoff64_t off_t;
78typedef unsigned int blksize_t;
79typedef unsigned int blkcnt_t;
80
81struct posix_stat {
82 struct stat sys_stat;
83
84 dev_t st_dev; /* ID of device containing file */
85 ino_t st_ino; /* inode number */
86 mode_t st_mode; /* protection */
87 nlink_t st_nlink; /* number of hard links */
88 uid_t st_uid; /* user ID of owner */
89 gid_t st_gid; /* group ID of owner */
90 dev_t st_rdev; /* device ID (if special file) */
91 off_t st_size; /* total size, in bytes */
92 blksize_t st_blksize; /* blocksize for file system I/O */
93 blkcnt_t st_blocks; /* number of 512B blocks allocated */
94 time_t st_atime; /* time of last access */
95 time_t st_mtime; /* time of last modification */
96 time_t st_ctime; /* time of last status change */
97};
98
99extern int posix_fstat(int, struct posix_stat *);
100extern int posix_stat(const char *, struct posix_stat *);
101
102#ifndef LIBPOSIX_INTERNAL
103 #define fstat posix_fstat
104 #define stat posix_stat
105#endif
106
107#endif /* POSIX_SYS_STAT_H */
108
Note: See TracBrowser for help on using the repository browser.