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
14extern "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
49struct stat;
50struct dirent;
51
52extern status_t		_kern_entry_ref_to_path(dev_t device, ino_t inode,
53						const char *leaf, char *userPath, size_t pathLength);
54extern int			_kern_open_entry_ref(dev_t device, ino_t inode,
55						const char *name, int openMode, int perms);
56extern int			_kern_open(int fd, const char *path, int openMode,
57						int perms);
58extern int			_kern_open_dir_entry_ref(dev_t device, ino_t inode,
59						const char *name);
60extern int			_kern_open_dir(int fd, const char *path);
61extern int			_kern_open_parent_dir(int fd, char *name,
62						size_t nameLength);
63extern status_t		_kern_fsync(int fd);
64extern off_t		_kern_seek(int fd, off_t pos, int seekType);
65extern status_t		_kern_create_dir_entry_ref(dev_t device, ino_t inode,
66						const char *name, int perms);
67extern status_t		_kern_create_dir(int fd, const char *path, int perms);
68extern status_t		_kern_read_link(int fd, const char *path, char *buffer,
69						size_t *_bufferSize);
70extern status_t		_kern_create_symlink(int fd, const char *path,
71						const char *toPath, int mode);
72extern status_t		_kern_unlink(int fd, const char *path);
73extern status_t		_kern_rename(int oldDir, const char *oldpath, int newDir,
74						const char *newpath);
75extern int			_kern_open_attr_dir(int fd, const char *path);
76extern status_t		_kern_remove_attr(int fd, const char *name);
77extern status_t		_kern_rename_attr(int fromFile, const char *fromName,
78						int toFile, const char *toName);
79
80// file descriptor functions
81extern ssize_t		_kern_read(int fd, off_t pos, void *buffer,
82						size_t bufferSize);
83extern ssize_t		_kern_write(int fd, off_t pos, const void *buffer,
84						size_t bufferSize);
85extern ssize_t		_kern_read_dir(int fd, struct dirent *buffer,
86						size_t bufferSize, uint32 maxCount);
87extern status_t		_kern_rewind_dir(int fd);
88extern status_t		_kern_read_stat(int fd, const char *path,
89						bool traverseLink, struct stat *stat, size_t statSize);
90extern status_t		_kern_write_stat(int fd, const char *path,
91						bool traverseLink, const struct stat *stat,
92						size_t statSize, int statMask);
93extern status_t		_kern_close(int fd);
94extern int			_kern_dup(int fd);
95extern status_t		_kern_lock_node(int fd);
96extern status_t		_kern_unlock_node(int fd);
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif	/* _KERNEL_SYSCALLS_H */
103