The Pedigree Project  0.1
file-syscalls.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef FILE_SYSCALLS_H
21 #define FILE_SYSCALLS_H
22 
23 #include "modules/system/vfs/File.h"
24 #include "modules/system/vfs/Filesystem.h"
25 #include "modules/system/vfs/VFS.h"
26 
27 #include "DevFs.h"
28 #include "logging.h"
29 
30 #include <sys/types.h>
31 
32 // Forward-declare some of the data types, file-syscalls.cc can include the
33 // proper headers for them.
34 struct dirent;
35 struct stat;
36 struct statvfs;
37 struct timeval;
38 struct utimbuf;
39 
40 #define MAXNAMLEN 255
41 
42 int posix_close(int fd);
43 int posix_open(const char *name, int flags, int mode);
44 int posix_read(int fd, char *ptr, int len);
45 int posix_write(int fd, char *ptr, int len, bool nocheck = false);
46 off_t posix_lseek(int file, off_t ptr, int dir);
47 int posix_link(char *old, char *_new);
48 int posix_unlink(char *name);
49 int posix_stat(const char *file, struct stat *st);
50 int posix_fstat(int fd, struct stat *st);
51 int posix_lstat(char *file, struct stat *st);
52 int posix_rename(const char *src, const char *dst);
53 int posix_symlink(char *target, char *link);
54 
55 int posix_writev(int fd, const struct iovec *iov, int iovcnt);
56 int posix_readv(int fd, const struct iovec *iov, int iovcnt);
57 
58 int posix_getcwd(char *buf, size_t maxlen);
59 int posix_readlink(const char *path, char *buf, unsigned int bufsize);
60 int posix_realpath(const char *path, char *buf, size_t bufsize);
61 
62 int posix_getdents(int fd, struct linux_dirent *ents, int count);
63 int posix_getdents64(int fd, struct dirent *ents, int count);
64 
65 int posix_ioctl(int fd, size_t operation, void *buf);
66 
67 int posix_chmod(const char *path, mode_t mode);
68 int posix_chown(const char *path, uid_t owner, gid_t group);
69 int posix_fchmod(int fd, mode_t mode);
70 int posix_fchown(int fd, uid_t owner, gid_t group);
71 int posix_chdir(const char *path);
72 int posix_fchdir(int fd);
73 
74 int posix_dup(int fd);
75 int posix_dup2(int fd1, int fd2);
76 
77 int posix_fcntl(int fd, int cmd, void *arg);
78 
79 int posix_mkdir(const char *name, int mode);
80 int posix_rmdir(const char *path);
81 
82 int posix_isatty(int fd);
83 
84 void *
85 posix_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off);
86 int posix_msync(void *p, size_t len, int flags);
87 int posix_munmap(void *addr, size_t len);
88 int posix_mprotect(void *addr, size_t len, int prot);
89 
90 int posix_access(const char *name, int amode);
91 
92 int posix_ftruncate(int a, off_t b);
93 
94 int posix_fsync(int fd);
95 
96 int posix_fstatvfs(int fd, struct statvfs *buf);
97 int posix_statvfs(const char *path, struct statvfs *buf);
98 
99 int posix_utime(const char *path, const struct utimbuf *times);
100 int posix_utimes(const char *path, const struct timeval *times);
101 
102 int posix_chroot(const char *path);
103 int posix_flock(int fd, int operation);
104 
105 bool normalisePath(String &nameToOpen, const char *name, bool *onDevFs = 0);
106 
108 File *findFileWithAbiFallbacks(const String &name, File *cwd = nullptr);
109 
110 int posix_openat(int dirfd, const char *pathname, int flags, mode_t mode);
111 int posix_mkdirat(int dirfd, const char *pathname, mode_t mode);
112 int posix_fchownat(
113  int dirfd, const char *pathname, uid_t owner, gid_t group, int flags);
114 int posix_futimesat(
115  int dirfd, const char *pathname, const struct timeval *times);
116 int posix_fstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
117 int posix_unlinkat(int dirfd, const char *pathname, int flags);
118 int posix_renameat(
119  int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
120 int posix_linkat(
121  int olddirfd, const char *oldpath, int newdirfd, const char *newpath,
122  int flags);
123 int posix_symlinkat(const char *oldpath, int newdirfd, const char *newpath);
124 int posix_readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);
125 int posix_fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
126 int posix_faccessat(int dirfd, const char *pathname, int mode, int flags);
127 
128 ssize_t
129 posix_getxattr(const char *path, const char *name, void *value, size_t size);
130 ssize_t
131 posix_lgetxattr(const char *path, const char *name, void *value, size_t size);
132 ssize_t posix_fgetxattr(int fd, const char *name, void *value, size_t size);
133 
134 int posix_mknod(const char *pathname, mode_t mode, dev_t dev);
135 
136 int posix_statfs(const char *path, struct statfs *buf);
137 int posix_fstatfs(int fd, struct statfs *buf);
138 
139 int posix_mount(const char *, const char *, const char *, size_t, const void *);
140 
141 void generate_mtab(String &result);
142 
143 int pedigree_get_mount(char *mount_buf, char *info_buf, size_t n);
144 
145 #endif
Definition: cmd.h:30
Definition: String.h:49
Definition: File.h:66