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 "DevFs.h"
24#include "ResolvedPath.h"
25#include "logging.h"
26#include "modules/system/vfs/File.h"
27#include "modules/system/vfs/Filesystem.h"
28#include "modules/system/vfs/VFS.h"
29#include <sys/types.h>
30
31// Forward-declare some of the data types, file-syscalls.cc can include the
32// proper headers for them.
33struct dirent;
34struct stat;
35struct statvfs;
36struct timeval;
37struct utimbuf;
38
39#define MAXNAMLEN 255
40
41int posix_close(int fd);
42int posix_open(const char* name, int flags, int mode);
43int posix_read(int fd, char* ptr, int len);
44int posix_write(int fd, char* ptr, int len, bool nocheck = false);
45ssize_t posix_pread64(int fd, char* ptr, size_t len, off_t offset);
46ssize_t posix_pwrite64(int fd, const char* ptr, size_t len, off_t offset);
47ssize_t posix_preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset);
48ssize_t posix_pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset);
49ssize_t posix_preadv2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags);
50ssize_t posix_pwritev2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags);
51off_t posix_lseek(int file, off_t ptr, int dir);
52int posix_link(char* old, char* _new);
53int posix_unlink(char* name);
54int posix_stat(const char* file, struct stat* st);
55int posix_fstat(int fd, struct stat* st);
56int posix_lstat(char* file, struct stat* st);
57int posix_rename(const char* src, const char* dst);
58int posix_symlink(char* target, char* link);
59
60int posix_writev(int fd, const struct iovec* iov, int iovcnt);
61int posix_readv(int fd, const struct iovec* iov, int iovcnt);
62
63int posix_getcwd(char* buf, size_t maxlen);
64int posix_readlink(const char* path, char* buf, unsigned int bufsize);
65int posix_realpath(const char* path, char* buf, size_t bufsize);
66
67int posix_getdents(int fd, struct linux_dirent* ents, int count);
68int posix_getdents64(int fd, struct dirent* ents, int count);
69
70int posix_ioctl(int fd, size_t operation, void* buf);
71
72int posix_chmod(const char* path, mode_t mode);
73int posix_chown(const char* path, uid_t owner, gid_t group);
74int posix_fchmod(int fd, mode_t mode);
75int posix_fchown(int fd, uid_t owner, gid_t group);
76int posix_chdir(const char* path);
77int posix_fchdir(int fd);
78
79int posix_dup(int fd);
80int posix_dup2(int fd1, int fd2);
81int posix_dup3(int oldfd, int newfd, int flags);
82
83int posix_fcntl(int fd, int cmd, void* arg);
84
85int posix_mkdir(const char* name, int mode);
86int posix_rmdir(const char* path);
87
88int posix_isatty(int fd);
89
90void* posix_mmap(void* addr, size_t len, int prot, int flags, int fd, off_t off);
91int posix_msync(void* p, size_t len, int flags);
92int posix_munmap(void* addr, size_t len);
93int posix_mprotect(void* addr, size_t len, int prot);
94
95int posix_access(const char* name, int amode);
96
97int posix_ftruncate(int a, off_t b);
98
99int posix_fsync(int fd);
100
101int posix_fstatvfs(int fd, struct statvfs* buf);
102int posix_statvfs(const char* path, struct statvfs* buf);
103
104int posix_utime(const char* path, const struct utimbuf* times);
105int posix_utimes(const char* path, const struct timeval* times);
106
107int posix_chroot(const char* path);
108int posix_flock(int fd, int operation);
109
110bool normalisePath(String& nameToOpen, const char* name, bool* onDevFs = 0);
111
112File* findFilePath(const String& name, ResolvedPath& result,
113 const FilesystemPathRef& start = FilesystemPathRef(), bool followFinal = false);
114File* followFilePath(ResolvedPath& selected);
115
116int posix_openat(int dirfd, const char* pathname, int flags, mode_t mode);
117int posix_mkdirat(int dirfd, const char* pathname, mode_t mode);
118int posix_fchownat(int dirfd, const char* pathname, uid_t owner, gid_t group, int flags);
119int posix_futimesat(int dirfd, const char* pathname, const struct timeval* times);
120int posix_fstatat(int dirfd, const char* pathname, struct stat* buf, int flags);
121int posix_unlinkat(int dirfd, const char* pathname, int flags);
122int posix_renameat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath);
123int posix_linkat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath, int flags);
124int posix_symlinkat(const char* oldpath, int newdirfd, const char* newpath);
125int posix_readlinkat(int dirfd, const char* pathname, char* buf, size_t bufsiz);
126int posix_fchmodat(int dirfd, const char* pathname, mode_t mode, int flags);
127int posix_faccessat(int dirfd, const char* pathname, int mode, int flags);
128
129int posix_mknod(const char* pathname, mode_t mode, dev_t dev);
130
131int posix_statfs(const char* path, struct statfs* buf);
132int posix_fstatfs(int fd, struct statfs* buf);
133
134int posix_mount(const char*, const char*, const char*, size_t, const void*);
135
136void generate_mtab(String& result);
137
138int pedigree_get_mount(char* mount_buf, char* info_buf, size_t n);
139
140#endif
Definition File.h:74
Definition cmd.h:30