Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
stat.h
Go to the documentation of this file.
1 
4 #ifndef __STAT_H__
5 #define __STAT_H__
6 
7 #include <sys/types.h>
8 #include <time.h>
9 
10 /* File types, with the values POSIX gives them */
11 #define S_IFMT 0170000 /* Mask for the file type */
12 #define S_IFIFO 0010000 /* FIFO */
13 #define S_IFCHR 0020000 /* Character device */
14 #define S_IFDIR 0040000 /* Directory */
15 #define S_IFBLK 0060000 /* Block device */
16 #define S_IFREG 0100000 /* Regular file */
17 #define S_IFLNK 0120000 /* Symbolic link */
18 #define S_IFSOCK 0140000 /* Socket */
19 
20 #define S_ISFIFO(m) (((m) &S_IFMT) == S_IFIFO)
21 #define S_ISCHR(m) (((m) &S_IFMT) == S_IFCHR)
22 #define S_ISDIR(m) (((m) &S_IFMT) == S_IFDIR)
23 #define S_ISBLK(m) (((m) &S_IFMT) == S_IFBLK)
24 #define S_ISREG(m) (((m) &S_IFMT) == S_IFREG)
25 #define S_ISLNK(m) (((m) &S_IFMT) == S_IFLNK)
26 #define S_ISSOCK(m) (((m) &S_IFMT) == S_IFSOCK)
27 
28 /* Permission bits. Tenok stores them and checks none of them */
29 #define S_ISUID 0004000
30 #define S_ISGID 0002000
31 #define S_ISVTX 0001000
32 #define S_IRWXU 0000700
33 #define S_IRUSR 0000400
34 #define S_IWUSR 0000200
35 #define S_IXUSR 0000100
36 #define S_IRWXG 0000070
37 #define S_IRGRP 0000040
38 #define S_IWGRP 0000020
39 #define S_IXGRP 0000010
40 #define S_IRWXO 0000007
41 #define S_IROTH 0000004
42 #define S_IWOTH 0000002
43 #define S_IXOTH 0000001
44 
45 /* Return type of the stat() and fstat() syscalls */
46 struct stat {
47  dev_t st_dev; /* Device the file lives on */
48  ino_t st_ino; /* inode number */
49  mode_t st_mode; /* File type and permission bits */
50  nlink_t st_nlink; /* Number of hard links */
51  uid_t st_uid; /* Owner of the file */
52  gid_t st_gid; /* Group of the file */
53  dev_t st_rdev; /* Device number, when the file is a device */
54  off_t st_size; /* Total size in bytes */
55  blksize_t st_blksize; /* Block size of the file system */
56  blkcnt_t st_blocks; /* Number of the blocks used by the file */
57  struct timespec st_atim; /* Time of the last access */
58  struct timespec st_mtim; /* Time of the last modification */
59  struct timespec st_ctim; /* Time of the last status change */
60 };
61 
62 /* Tenok keeps the modification time, the other two read back as zero */
63 #define st_atime st_atim.tv_sec
64 #define st_mtime st_mtim.tv_sec
65 #define st_ctime st_ctim.tv_sec
66 
72 int fstat(int fd, struct stat *statbuf);
73 
82 int mknod(const char *pathname, mode_t mode, dev_t dev);
83 
90 int mkfifo(const char *pathname, mode_t mode);
91 
98 int mkdir(const char *pathname, mode_t mode);
99 
105 mode_t umask(mode_t mask);
106 
107 /* Given to utime() in place of a time, asking for the present one */
108 #define UTIME_TO_NOW ((uint32_t) -1)
109 
110 /* What utimensat() of POSIX is given in place of a time */
111 #define UTIME_NOW ((1l << 30) - 1l)
112 #define UTIME_OMIT ((1l << 30) - 2l)
113 
120 int utime(const char *pathname, uint32_t mtime);
121 
128 int chmod(const char *pathname, mode_t mode);
129 
137 int stat(const char *pathname, struct stat *statbuf);
138 
147 int lstat(const char *pathname, struct stat *statbuf);
148 
157 int futimens(int fd, const struct timespec times[2]);
158 
159 #endif
int mkfifo(const char *pathname, mode_t mode)
Makes a FIFO special file with name pathname.
Definition: file.c:294
int utime(const char *pathname, uint32_t mtime)
Replace the time the contents of a file were last written.
Definition: file.c:321
int chmod(const char *pathname, mode_t mode)
Replace the permission bits of a file.
Definition: file.c:331
int fstat(int fd, struct stat *statbuf)
Return information about a file, in the buffer pointed to by statbuf.
Definition: file.c:178
int futimens(int fd, const struct timespec times[2])
Stamp the file a descriptor is open on with the times given. Tenok keeps no way back from a descripto...
Definition: wrapper.c:457
int stat(const char *pathname, struct stat *statbuf)
Return information about the file specified by the pathname, in the buffer pointed to by statbuf.
Definition: file.c:366
mode_t umask(mode_t mask)
Set the permission bits withheld from the files the task creates.
Definition: file.c:310
int mknod(const char *pathname, mode_t mode, dev_t dev)
Create a filesystem node (file, device special file, or named pipe) named pathname,...
Definition: file.c:284
int mkdir(const char *pathname, mode_t mode)
Create a directory named pathname.
Definition: file.c:304
int lstat(const char *pathname, struct stat *statbuf)
Return information about the file specified by the pathname, the way stat() does. Tenok gives a file ...
Definition: file.c:377
Definition: stat.h:46
Definition: time.h:16