xref: /haiku/headers/build/private/kernel/syscalls.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2004-2017, Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _KERNEL_SYSCALLS_H
6 #define _KERNEL_SYSCALLS_H
7 
8 
9 #include <OS.h>
10 #include <image.h>
11 
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 
18 /* Since libroot_build is also used on Haiku and linked against the real
19  * libroot which also has the syscall functions, these must be shadowed. */
20 #define _kern_entry_ref_to_path		_kernbuild_entry_ref_to_path
21 #define _kern_open_entry_ref		_kernbuild_open_entry_ref
22 #define _kern_open					_kernbuild_open
23 #define _kern_open_dir_entry_ref	_kernbuild_open_dir_entry_ref
24 #define _kern_open_dir				_kernbuild_open_dir
25 #define _kern_open_parent_dir		_kernbuild_open_parent_dir
26 #define _kern_fsync					_kernbuild_fsync
27 #define _kern_seek					_kernbuild_seek
28 #define _kern_create_dir_entry_ref	_kernbuild_create_dir_entry_ref
29 #define _kern_create_dir			_kernbuild_create_dir
30 #define _kern_read_link				_kernbuild_read_link
31 #define _kern_create_symlink		_kernbuild_create_symlink
32 #define _kern_unlink				_kernbuild_unlink
33 #define _kern_rename				_kernbuild_rename
34 #define _kern_open_attr_dir			_kernbuild_open_attr_dir
35 #define _kern_remove_attr			_kernbuild_remove_attr
36 #define _kern_rename_attr			_kernbuild_rename_attr
37 #define _kern_read					_kernbuild_read
38 #define _kern_write					_kernbuild_write
39 #define _kern_read_dir				_kernbuild_read_dir
40 #define _kern_rewind_dir			_kernbuild_rewind_dir
41 #define _kern_read_stat				_kernbuild_read_stat
42 #define _kern_write_stat			_kernbuild_write_stat
43 #define _kern_close					_kernbuild_close
44 #define _kern_dup					_kernbuild_dup
45 #define _kern_lock_node				_kernbuild_lock_node
46 #define _kern_unlock_node			_kernbuild_unlock_node
47 
48 
49 struct stat;
50 struct dirent;
51 
52 extern status_t		_kern_entry_ref_to_path(dev_t device, ino_t inode,
53 						const char *leaf, char *userPath, size_t pathLength);
54 extern int			_kern_open_entry_ref(dev_t device, ino_t inode,
55 						const char *name, int openMode, int perms);
56 extern int			_kern_open(int fd, const char *path, int openMode,
57 						int perms);
58 extern int			_kern_open_dir_entry_ref(dev_t device, ino_t inode,
59 						const char *name);
60 extern int			_kern_open_dir(int fd, const char *path);
61 extern int			_kern_open_parent_dir(int fd, char *name,
62 						size_t nameLength);
63 extern status_t		_kern_fsync(int fd);
64 extern off_t		_kern_seek(int fd, off_t pos, int seekType);
65 extern status_t		_kern_create_dir_entry_ref(dev_t device, ino_t inode,
66 						const char *name, int perms);
67 extern status_t		_kern_create_dir(int fd, const char *path, int perms);
68 extern status_t		_kern_read_link(int fd, const char *path, char *buffer,
69 						size_t *_bufferSize);
70 extern status_t		_kern_create_symlink(int fd, const char *path,
71 						const char *toPath, int mode);
72 extern status_t		_kern_unlink(int fd, const char *path);
73 extern status_t		_kern_rename(int oldDir, const char *oldpath, int newDir,
74 						const char *newpath);
75 extern int			_kern_open_attr_dir(int fd, const char *path);
76 extern status_t		_kern_remove_attr(int fd, const char *name);
77 extern status_t		_kern_rename_attr(int fromFile, const char *fromName,
78 						int toFile, const char *toName);
79 
80 // file descriptor functions
81 extern ssize_t		_kern_read(int fd, off_t pos, void *buffer,
82 						size_t bufferSize);
83 extern ssize_t		_kern_write(int fd, off_t pos, const void *buffer,
84 						size_t bufferSize);
85 extern ssize_t		_kern_read_dir(int fd, struct dirent *buffer,
86 						size_t bufferSize, uint32 maxCount);
87 extern status_t		_kern_rewind_dir(int fd);
88 extern status_t		_kern_read_stat(int fd, const char *path,
89 						bool traverseLink, struct stat *stat, size_t statSize);
90 extern status_t		_kern_write_stat(int fd, const char *path,
91 						bool traverseLink, const struct stat *stat,
92 						size_t statSize, int statMask);
93 extern status_t		_kern_close(int fd);
94 extern int			_kern_dup(int fd);
95 extern status_t		_kern_lock_node(int fd);
96 extern status_t		_kern_unlock_node(int fd);
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif	/* _KERNEL_SYSCALLS_H */
103