+++ /dev/null
-#ifndef __LUNAIX_FCTRL_H
-#define __LUNAIX_FCTRL_H
-
-#include <lunaix/dirent.h>
-#include <lunaix/syscall.h>
-#include <stddef.h>
-
-__LXSYSCALL2(int, open, const char*, path, int, options)
-
-__LXSYSCALL1(int, mkdir, const char*, path)
-__LXSYSCALL2(int, unlinkat, int, fd, const char*, pathname)
-
-__LXSYSCALL2(int, sys_readdir, int, fd, struct dirent*, dent)
-
-__LXSYSCALL4(int,
- readlinkat,
- int,
- dirfd,
- const char*,
- pathname,
- char*,
- buf,
- size_t,
- size)
-
-__LXSYSCALL3(int, realpathat, int, fd, char*, buf, size_t, size)
-
-__LXSYSCALL4(int,
- mount,
- const char*,
- source,
- const char*,
- target,
- const char*,
- fstype,
- int,
- options)
-
-__LXSYSCALL1(int, unmount, const char*, target)
-
-__LXSYSCALL4(int,
- getxattr,
- const char*,
- path,
- const char*,
- name,
- void*,
- value,
- size_t,
- len)
-
-__LXSYSCALL4(int,
- setxattr,
- const char*,
- path,
- const char*,
- name,
- void*,
- value,
- size_t,
- len)
-
-__LXSYSCALL4(int,
- fgetxattr,
- int,
- fd,
- const char*,
- name,
- void*,
- value,
- size_t,
- len)
-
-__LXSYSCALL4(int,
- fsetxattr,
- int,
- fd,
- const char*,
- name,
- void*,
- value,
- size_t,
- len)
-
-#endif /* __LUNAIX_FCTRL_H */
#ifndef __LUNAIX_FOPTIONS_H
#define __LUNAIX_FOPTIONS_H
-#define FO_CREATE 0x1
-#define FO_APPEND 0x2
-#define FO_DIRECT 0x4
-
-#define FSEEK_SET 0x1
-#define FSEEK_CUR 0x2
-#define FSEEK_END 0x3
-
-#define MNT_RO 0x1
+#include <usr/fcntl_defs.h>
#endif /* __LUNAIX_FOPTIONS_H */
#ifndef __LUNAIX_IOCTL_H
#define __LUNAIX_IOCTL_H
-#include <lunaix/syscall.h>
-
-#define IOREQ(cmd, arg_num) ((((cmd)&0xffff) << 8) | ((arg_num)&0xff))
-
-#define IOCMD(req) ((req) >> 8)
-
-#define IOARGNUM(req) ((req)&0xff)
-
-#define TIOCGPGRP IOREQ(1, 0)
-#define TIOCSPGRP IOREQ(1, 1)
-#define TIOCCLSBUF IOREQ(2, 0)
-#define TIOCFLUSH IOREQ(3, 0)
-
-__LXSYSCALL2_VARG(int, ioctl, int, fd, int, req);
+#include <usr/sys/ioctl_defs.h>
#endif /* __LUNAIX_IOCTL_H */
+++ /dev/null
-#ifndef __LUNAIX_UNISTD_H
-#define __LUNAIX_UNISTD_H
-
-#include <lunaix/syscall.h>
-#include <lunaix/types.h>
-#include <stddef.h>
-
-__LXSYSCALL(pid_t, fork)
-
-__LXSYSCALL1(int, sbrk, void*, addr)
-
-__LXSYSCALL1(void*, brk, unsigned long, size)
-
-__LXSYSCALL(pid_t, getpid)
-
-__LXSYSCALL(pid_t, getppid)
-
-__LXSYSCALL(pid_t, getpgid)
-
-__LXSYSCALL2(pid_t, setpgid, pid_t, pid, pid_t, pgid)
-
-__LXSYSCALL1(void, _exit, int, status)
-
-__LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
-
-__LXSYSCALL(int, pause)
-
-__LXSYSCALL2(int, kill, pid_t, pid, int, signum)
-
-__LXSYSCALL1(unsigned int, alarm, unsigned int, seconds)
-
-__LXSYSCALL2(int, link, const char*, oldpath, const char*, newpath)
-
-__LXSYSCALL1(int, rmdir, const char*, pathname)
-
-__LXSYSCALL3(int, read, int, fd, void*, buf, unsigned int, count)
-
-__LXSYSCALL3(int, write, int, fd, void*, buf, unsigned int, count)
-
-__LXSYSCALL3(int, readlink, const char*, path, char*, buf, size_t, size)
-
-__LXSYSCALL3(int, lseek, int, fd, int, offset, int, options)
-
-__LXSYSCALL1(int, unlink, const char*, pathname)
-
-__LXSYSCALL1(int, close, int, fd)
-
-__LXSYSCALL2(int, dup2, int, oldfd, int, newfd)
-
-__LXSYSCALL1(int, dup, int, oldfd)
-
-__LXSYSCALL1(int, fsync, int, fildes)
-
-__LXSYSCALL2(int, symlink, const char*, pathname, const char*, link_target)
-
-__LXSYSCALL1(int, chdir, const char*, path)
-
-__LXSYSCALL1(int, fchdir, int, fd)
-
-__LXSYSCALL2(char*, getcwd, char*, buf, size_t, size)
-
-__LXSYSCALL2(int, rename, const char*, oldpath, const char*, newpath)
-
-#endif /* __LUNAIX_UNISTD_H */
+++ /dev/null
-#ifndef __LUNAIX_LXSIGNAL_H
-#define __LUNAIX_LXSIGNAL_H
-
-#include <lunaix/types.h>
-
-int
-signal_send(pid_t pid, int signum);
-
-#endif /* __LUNAIX_LXSIGNAL_H */
#ifndef __LUNAIX_SIGNAL_H
#define __LUNAIX_SIGNAL_H
-#include <lunaix/syscall.h>
+#include <usr/signal_defs.h>
#define _SIG_NUM 16
#define _SIG_PENDING(bitmap, sig) ((bitmap) & (1 << (sig)))
-#define _SIGSEGV 1
-#define _SIGALRM 2
-#define _SIGCHLD 3
-#define _SIGCLD _SIGCHLD
-#define _SIGINT 4
-#define _SIGKILL 5
-#define _SIGSTOP 6
-#define _SIGCONT 7
-#define _SIGTERM 8
+#define _SIGSEGV SIGSEGV
+#define _SIGALRM SIGALRM
+#define _SIGCHLD SIGCHLD
+#define _SIGCLD SIGCLD
+#define _SIGINT SIGINT
+#define _SIGKILL SIGKILL
+#define _SIGSTOP SIGSTOP
+#define _SIGCONT SIGCONT
+#define _SIGTERM SIGTERM
#define __SIGNAL(num) (1 << (num))
#define __SIGSET(bitmap, num) (bitmap = bitmap | __SIGNAL(num))
#define _SIGNAL_UNMASKABLE (__SIGNAL(_SIGKILL) | __SIGNAL(_SIGSTOP))
-#define _SIG_BLOCK 1
-#define _SIG_UNBLOCK 2
-#define _SIG_SETMASK 3
-
-typedef unsigned int sigset_t;
-typedef void (*sighandler_t)(int);
-
-__LXSYSCALL2(int, signal, int, signum, sighandler_t, handler);
-
-__LXSYSCALL1(int, sigpending, sigset_t, *set);
-__LXSYSCALL1(int, sigsuspend, const sigset_t, *mask);
-
-__LXSYSCALL3(int,
- sigprocmask,
- int,
- how,
- const sigset_t,
- *set,
- sigset_t,
- *oldset);
+#define _SIG_BLOCK SIG_BLOCK
+#define _SIG_UNBLOCK SIG_UNBLOCK
+#define _SIG_SETMASK SIG_SETMASK
#endif /* __LUNAIX_SIGNAL_H */
return (rettype)v;
#define __LXSYSCALL(rettype, name) \
- static rettype name() \
+ rettype name() \
{ \
___DOINT33(__SYSCALL_##name, rettype) \
}
#define __LXSYSCALL1(rettype, name, t1, p1) \
- static rettype name(__PARAM_MAP1(t1, p1)) \
+ rettype name(__PARAM_MAP1(t1, p1)) \
{ \
asm("" ::"b"(p1)); \
___DOINT33(__SYSCALL_##name, rettype) \
}
#define __LXSYSCALL2(rettype, name, t1, p1, t2, p2) \
- static rettype name(__PARAM_MAP2(t1, p1, t2, p2)) \
+ rettype name(__PARAM_MAP2(t1, p1, t2, p2)) \
{ \
asm("\n" ::"b"(p1), "c"(p2)); \
___DOINT33(__SYSCALL_##name, rettype) \
}
#define __LXSYSCALL3(rettype, name, t1, p1, t2, p2, t3, p3) \
- static rettype name(__PARAM_MAP3(t1, p1, t2, p2, t3, p3)) \
+ rettype name(__PARAM_MAP3(t1, p1, t2, p2, t3, p3)) \
{ \
asm("\n" ::"b"(p1), "c"(p2), "d"(p3)); \
___DOINT33(__SYSCALL_##name, rettype) \
}
#define __LXSYSCALL4(rettype, name, t1, p1, t2, p2, t3, p3, t4, p4) \
- static rettype name(__PARAM_MAP4(t1, p1, t2, p2, t3, p3, t4, p4)) \
+ rettype name(__PARAM_MAP4(t1, p1, t2, p2, t3, p3, t4, p4)) \
{ \
asm("\n" ::"b"(p1), "c"(p2), "d"(p3), "D"(p4)); \
___DOINT33(__SYSCALL_##name, rettype) \
}
#define __LXSYSCALL5(rettype, name, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5) \
- static rettype name(__PARAM_MAP5(t1, p1, t2, p2, t3, p3, t4, p4, t5, p5)) \
+ rettype name(__PARAM_MAP5(t1, p1, t2, p2, t3, p3, t4, p4, t5, p5)) \
{ \
asm("" ::"r"(p5), "b"(p1), "c"(p2), "d"(p3), "D"(p4), "S"(p5)); \
___DOINT33(__SYSCALL_##name, rettype) \
}
#define __LXSYSCALL2_VARG(rettype, name, t1, p1, t2, p2) \
- __attribute__((noinline)) static rettype name( \
- __PARAM_MAP2(t1, p1, t2, p2), ...) \
+ __attribute__((noinline)) rettype name(__PARAM_MAP2(t1, p1, t2, p2), ...) \
{ \
/* No inlining! This depends on the call frame assumption */ \
void* _last = (void*)&p2 + sizeof(void*); \
#include <stdint.h>
#include <usr/sys/types.h>
-#define PEXITTERM 0x100
-#define PEXITSTOP 0x200
-#define PEXITSIG 0x400
-
-#define PEXITNUM(flag, code) (flag | (code & 0xff))
-
-#define WNOHANG 1
-#define WUNTRACED 2
-#define WEXITSTATUS(wstatus) ((wstatus & 0xff))
-#define WIFSTOPPED(wstatus) ((wstatus & PEXITSTOP))
-#define WIFEXITED(wstatus) \
- ((wstatus & PEXITTERM) && ((char)WEXITSTATUS(wstatus) >= 0))
-
-#define WIFSIGNALED(wstatus) ((wstatus & PEXITSIG))
-
#define PACKED __attribute__((packed))
// TODO: WTERMSIG
--- /dev/null
+#ifndef __LUNAIX_SYS_ERRNO_H
+#define __LUNAIX_SYS_ERRNO_H
+
+int
+geterrno();
+
+#define errno (geterrno())
+
+#endif /* __LUNAIX_ERRNO_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_FCNTL_H
+#define __LUNAIX_SYS_FCNTL_H
+
+#include <usr/fcntl_defs.h>
+#include <usr/sys/types.h>
+
+int
+open(const char* path, int flags);
+
+#endif /* __LUNAIX_FCNTL_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_FCNTL_DEFS_H
+#define __LUNAIX_SYS_FCNTL_DEFS_H
+
+#define FO_CREATE 0x1
+#define FO_APPEND 0x2
+#define FO_DIRECT 0x4
+
+#define FSEEK_SET 0x1
+#define FSEEK_CUR 0x2
+#define FSEEK_END 0x3
+
+#define MNT_RO 0x1
+
+#endif /* __LUNAIX_FNCTL_DEFS_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_SIGNAL_H
+#define __LUNAIX_SYS_SIGNAL_H
+
+#include <usr/signal_defs.h>
+#include <usr/sys/types.h>
+
+int
+signal(int signum, sighandler_t handler);
+
+int
+sigpending(sigset_t* set);
+
+int
+sigsuspend(const sigset_t* mask);
+
+int
+sigprocmask(int how, const sigset_t* set, sigset_t* oldset);
+
+#endif /* __LUNAIX_SIGNAL_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_SIGNAL_DEFS_H
+#define __LUNAIX_SYS_SIGNAL_DEFS_H
+
+#define SIGSEGV 1
+#define SIGALRM 2
+#define SIGCHLD 3
+#define SIGCLD SIGCHLD
+#define SIGINT 4
+#define SIGKILL 5
+#define SIGSTOP 6
+#define SIGCONT 7
+#define SIGTERM 8
+
+#define SIG_BLOCK 1
+#define SIG_UNBLOCK 2
+#define SIG_SETMASK 3
+
+typedef unsigned int sigset_t;
+typedef void (*sighandler_t)(int);
+
+#endif /* __LUNAIX_SIGNAL_DEFS_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_DIRENT_H
+#define __LUNAIX_SYS_DIRENT_H
+
+#include <usr/sys/dirent_defs.h>
+
+int
+sys_readdir(int fd, struct lx_dirent* dirent);
+
+#endif /* __LUNAIX_DIRENT_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_DIRENT_DEFS_H
+#define __LUNAIX_SYS_DIRENT_DEFS_H
+
+#define DIRENT_NAME_MAX_LEN 256
+
+#define DT_FILE 0x0
+#define DT_DIR 0x1
+#define DT_SYMLINK 0x2
+#define DT_PIPE 0x2
+
+struct lx_dirent
+{
+ unsigned int d_type;
+ unsigned int d_offset;
+ unsigned int d_nlen;
+ char d_name[DIRENT_NAME_MAX_LEN];
+};
+
+#endif /* __LUNAIX_DIRENT_DEFS_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_IOCTL_H
+#define __LUNAIX_SYS_IOCTL_H
+
+int
+ioctl(int fd, int req, ...);
+
+#endif /* __LUNAIX_IOCTL_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_IOCTL_DEFS_H
+#define __LUNAIX_SYS_IOCTL_DEFS_H
+
+#define IOREQ(cmd, arg_num) ((((cmd)&0xffff) << 8) | ((arg_num)&0xff))
+
+#define IOCMD(req) ((req) >> 8)
+
+#define IOARGNUM(req) ((req)&0xff)
+
+#define TIOCGPGRP IOREQ(1, 0)
+#define TIOCSPGRP IOREQ(1, 1)
+#define TIOCCLSBUF IOREQ(2, 0)
+#define TIOCFLUSH IOREQ(3, 0)
+
+#endif /* __LUNAIX_IOCTL_DEFS_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_LUNAIX_H
+#define __LUNAIX_SYS_LUNAIX_H
+
+#include <usr/sys/types.h>
+
+void
+yield();
+
+pid_t
+wait(int* status);
+
+pid_t
+waitpid(pid_t pid, int* status, int flags);
+
+void
+syslog(int level, const char* fmt, ...);
+
+int
+realpathat(int fd, char* buf, size_t size);
+
+#endif /* __LUNAIX_LUNAIX_H */
--- /dev/null
+#ifndef __LUNAIX_SYS_MOUNT_H
+#define __LUNAIX_SYS_MOUNT_H
+
+#include <usr/sys/types.h>
+
+int
+mount(const char* source, const char* target, const char* fstype, int flags);
+
+int
+unmount(const char* target);
+
+static inline int
+umount(const char* target)
+{
+ return unmount(target);
+}
+#endif /* __LUNAIX_MOUNT_H */
#ifndef __LUNAIX_SYS_TYPES_H
#define __LUNAIX_SYS_TYPES_H
+#define PEXITTERM 0x100
+#define PEXITSTOP 0x200
+#define PEXITSIG 0x400
+
+#define PEXITNUM(flag, code) (flag | (code & 0xff))
+
+#define WNOHANG 1
+#define WUNTRACED 2
+#define WEXITSTATUS(wstatus) ((wstatus & 0xff))
+#define WIFSTOPPED(wstatus) ((wstatus & PEXITSTOP))
+#define WIFEXITED(wstatus) \
+ ((wstatus & PEXITTERM) && ((char)WEXITSTATUS(wstatus) >= 0))
+
+#define WIFSIGNALED(wstatus) ((wstatus & PEXITSIG))
+
typedef signed long ssize_t;
typedef int pid_t;
--- /dev/null
+#ifndef __LUNAIX_SYS_UNISTD_H
+#define __LUNAIX_SYS_UNISTD_H
+
+#include <usr/sys/types.h>
+
+pid_t
+fork();
+
+pid_t
+getpid();
+
+pid_t
+getppid();
+
+pid_t
+getpgid();
+
+pid_t
+setpgid(pid_t pid, pid_t pgid);
+
+int
+sbrk(void* addr);
+
+void*
+brk(size_t size);
+
+void
+_exit(int status);
+
+unsigned int
+sleep(unsigned int);
+
+int
+pause();
+
+int
+kill(pid_t pid, int signum);
+
+unsigned int
+alarm(unsigned int seconds);
+
+int
+link(const char* oldpath, const char* newpath);
+
+int
+rmdir(const char* pathname);
+
+int
+read(int fd, void* buf, size_t size);
+
+int
+write(int fd, void* buf, size_t size);
+
+int
+readlink(const char* path, char* buffer, size_t size);
+
+int
+readlinkat(int dirfd, const char* pathname, char* buffer, size_t size);
+
+int
+lseek(int fd, off_t offset, int mode);
+
+int
+unlink(const char* pathname);
+
+int
+unlinat(int fd, const char* pathname);
+
+int
+mkdir(const char* path);
+
+int
+close(int fd);
+
+int
+dup2(int oldfd, int newfd);
+
+int
+dup(int oldfd);
+
+int
+fsync(int fd);
+
+int
+symlink(const char* pathname, const char* linktarget);
+
+int
+chdir(const char* path);
+
+int
+fchdir(int fd);
+
+char*
+getcwd(char* buf, size_t size);
+
+int
+rename(const char* oldpath, const char* newpath);
+
+int
+getxattr(const char* path, const char* name, void* value, size_t len);
+
+int
+setxattr(const char* path, const char* name, void* value, size_t len);
+
+int
+fgetxattr(int fd, const char* name, void* value, size_t len);
+
+int
+fsetxattr(int fd, const char* name, void* value, size_t len);
+
+#endif /* __LUNAIX_UNISTD_H */
#include <arch/x86/interrupts.h>
#include <lunaix/common.h>
-#include <lunaix/lxsignal.h>
#include <lunaix/mm/mm.h>
#include <lunaix/mm/pmm.h>
#include <lunaix/mm/region.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/sched.h>
+#include <lunaix/signal.h>
#include <lunaix/status.h>
#include <lunaix/syslog.h>
-#include <lunaix/dirent.h>
-#include <lunaix/fctrl.h>
-#include <lunaix/lunaix.h>
-#include <lunaix/lunistd.h>
+#include <usr/errno.h>
+#include <usr/fcntl.h>
+#include <usr/sys/dirent.h>
+#include <usr/unistd.h>
void
_readdir_main()
{
int fd = open("/dev/./../dev/.", 0);
if (fd == -1) {
- printf("fail to open (%d)\n", geterrno());
+ printf("fail to open (%d)\n", errno);
return;
}
char path[129];
int len = realpathat(fd, path, 128);
if (len < 0) {
- printf("fail to read (%d)\n", geterrno());
+ printf("fail to read (%d)\n", errno);
} else {
path[len] = 0;
printf("%s\n", path);
}
- struct dirent ent = { .d_offset = 0 };
+ struct lx_dirent ent = { .d_offset = 0 };
while (sys_readdir(fd, &ent) == 1) {
printf("%s\n", ent.d_name);
-#include <lunaix/fctrl.h>
-#include <lunaix/foptions.h>
#include <lunaix/input.h>
-#include <lunaix/lunaix.h>
-#include <lunaix/lunistd.h>
+
#include <ulibc/stdio.h>
+#include <usr/errno.h>
+#include <usr/fcntl.h>
+#include <usr/sys/lunaix.h>
+#include <usr/unistd.h>
#define STDIN 1
#define STDOUT 0
int fd = open("/dev/input/i8042-kbd", 0);
if (fd < 0) {
- printf("fail to open (%d)", geterrno());
+ printf("fail to open (%d)", errno);
return;
}
-#include <lunaix/fctrl.h>
-#include <lunaix/foptions.h>
-#include <lunaix/lunaix.h>
-#include <lunaix/lunistd.h>
#include <ulibc/stdio.h>
+#include <usr/errno.h>
+#include <usr/fcntl.h>
+#include <usr/sys/lunaix.h>
+#include <usr/unistd.h>
void
_iotest_main()
char read_out[256];
// 切换工作目录至 /dev
- int errno = chdir("/dev");
- if (errno) {
+ int status = chdir("/dev");
+ if (status) {
write(stdout, "fail to chdir", 15);
return;
}
int fd = open("./sda", 0);
if (fd < 0) {
- printf("fail to open (%d)\n", geterrno());
+ printf("fail to open (%d)\n", errno);
return;
}
-#include <lunaix/lunaix.h>
-#include <lunaix/lunistd.h>
-#include <lunaix/signal.h>
#include <lunaix/spike.h>
-#include <lunaix/types.h>
+
#include <ulibc/stdio.h>
+#include <usr/signal.h>
+#include <usr/sys/lunaix.h>
+#include <usr/unistd.h>
+
void __USER__
sigchild_handler(int signum)
{
void __USER__
_signal_demo_main()
{
- signal(_SIGCHLD, sigchild_handler);
- signal(_SIGSEGV, sigsegv_handler);
- signal(_SIGALRM, sigalrm_handler);
+ signal(SIGCHLD, sigchild_handler);
+ signal(SIGSEGV, sigsegv_handler);
+ signal(SIGALRM, sigalrm_handler);
alarm(5);
for (int i = 0; i < 5; i++) {
pid_t pid = 0;
if (!(pid = fork())) {
- signal(_SIGSEGV, sigsegv_handler);
+ signal(SIGSEGV, sigsegv_handler);
sleep(i);
if (i == 3) {
i = *(int*)0xdeadc0de; // seg fault!
-#include <lunaix/fctrl.h>
-#include <lunaix/foptions.h>
#include <lunaix/ioctl.h>
-#include <lunaix/lunaix.h>
-#include <lunaix/lunistd.h>
-#include <lunaix/signal.h>
#include <lunaix/status.h>
+#include <usr/fcntl.h>
+#include <usr/signal.h>
+#include <usr/sys/dirent.h>
+#include <usr/sys/lunaix.h>
#include <usr/sys/mann.h>
+#include <usr/unistd.h>
#include <klibc/string.h>
#include <ulibc/stdio.h>
if (fd < 0) {
sh_printerr();
} else {
- struct dirent ent = { .d_offset = 0 };
+ struct lx_dirent ent = { .d_offset = 0 };
int status;
while ((status = sys_readdir(fd, &ent)) == 1) {
if (ent.d_type == DT_DIR) {
if (fd < 0) {
sh_printerr();
} else {
- ptr_t p = mmap(NULL, 2048, 0, 0, fd, 0);
+ void* p = mmap(NULL, 2048, 0, 0, fd, 0);
if ((int)p < 0) {
sh_printerr();
} else {
char buf[512];
char *cmd, *argpart;
pid_t p;
- signal(_SIGINT, sigint_handle);
+ signal(SIGINT, sigint_handle);
// set our shell as foreground process
// (unistd.h:tcsetpgrp is essentially a wrapper of this)
#include <lunaix/device.h>
-#include <lunaix/dirent.h>
#include <lunaix/fs.h>
#include <lunaix/fs/devfs.h>
#include <lunaix/spike.h>
+#include <usr/sys/dirent_defs.h>
+
extern struct v_inode_ops devfs_inode_ops;
extern struct v_file_ops devfs_file_ops;
-#include <lunaix/dirent.h>
#include <lunaix/fs.h>
#include <lunaix/fs/iso9660.h>
#include <lunaix/mm/cake.h>
#include <klibc/string.h>
+#include <usr/sys/dirent_defs.h>
+
extern struct cake_pile* drec_cache_pile;
void
*/
#include <klibc/string.h>
-#include <lunaix/dirent.h>
#include <lunaix/foptions.h>
#include <lunaix/fs.h>
#include <lunaix/mm/cake.h>
#include <lunaix/fs/twifs.h>
+#include <usr/sys/dirent_defs.h>
+
static struct cake_pile* dnode_pile;
static struct cake_pile* inode_pile;
static struct cake_pile* file_pile;
const int len,
const int dtype)
{
- struct dirent* dent = (struct dirent*)dctx->cb_data;
+ struct lx_dirent* dent = (struct lx_dirent*)dctx->cb_data;
strncpy(dent->d_name, name, DIRENT_NAME_MAX_LEN);
dent->d_nlen = len;
dent->d_type = dtype;
}
-__DEFINE_LXSYSCALL2(int, sys_readdir, int, fd, struct dirent*, dent)
+__DEFINE_LXSYSCALL2(int, sys_readdir, int, fd, struct lx_dirent*, dent)
{
struct v_fd* fd_s;
int errno;
#include <hal/cpu.h>
#include <lunaix/clock.h>
-#include <lunaix/lunaix.h>
-#include <lunaix/lunistd.h>
#include <lunaix/lxconsole.h>
#include <lunaix/mm/kalloc.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/syslog.h>
#include <lunaix/timer.h>
+#include <usr/sys/lunaix.h>
+#include <usr/unistd.h>
+
extern uint8_t __kernel_start;
LOG_MODULE("INIT")
#include <lunaix/block.h>
#include <lunaix/common.h>
-#include <lunaix/fctrl.h>
#include <lunaix/foptions.h>
#include <lunaix/fs.h>
#include <lunaix/fs/twifs.h>
-#include <lunaix/lunaix.h>
-#include <lunaix/lunistd.h>
#include <lunaix/lxconsole.h>
#include <lunaix/mm/cake.h>
#include <lunaix/mm/pmm.h>
#include <lunaix/syslog.h>
#include <lunaix/types.h>
+#include <usr/fcntl.h>
+#include <usr/sys/lunaix.h>
+#include <usr/unistd.h>
+
#include <sdbg/protocol.h>
#include <hal/acpi/acpi.h>
-#include <klibc/string.h>
-#include <lunaix/lunistd.h>
-#include <lunaix/lxsignal.h>
#include <lunaix/process.h>
#include <lunaix/sched.h>
#include <lunaix/signal.h>
#include <lunaix/status.h>
#include <lunaix/syscall.h>
+#include <klibc/string.h>
+
extern struct scheduler sched_ctx; /* kernel/sched.c */
void __USER__
-#include <lunaix/dirent.h>
#include <lunaix/fs/taskfs.h>
#include <lunaix/fs/twimap.h>
#include <lunaix/mm/valloc.h>
#include <klibc/stdio.h>
#include <klibc/string.h>
+#include <usr/sys/dirent_defs.h>
+
#define COUNTER_MASK ((1 << 16) - 1)
static struct hbucket* attr_export_table;
#include <lunaix/mm/valloc.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/sched.h>
+#include <lunaix/signal.h>
#include <lunaix/tty/console.h>
#include <lunaix/tty/tty.h>
-#include <lunaix/lxsignal.h>
-
static struct console lx_console;
int
#include <klibc/stdio.h>
-#include <lunaix/lunistd.h>
#include <lunaix/spike.h>
#include <ulibc/stdio.h>
+#include <usr/unistd.h>
+
// This is VERY bad implementation as it mixes both kernel and user space
// code together. It is here however, just for the convenience of our testing
// program.
--- /dev/null
+#include <lunaix/syscall.h>
+#include <usr/sys/dirent.h>
+
+__LXSYSCALL2(int, sys_readdir, int, fd, struct lx_dirent*, dent)
--- /dev/null
+#include <lunaix/syscall.h>
+#include <usr/errno.h>
+
+__LXSYSCALL(int, geterrno);
\ No newline at end of file
--- /dev/null
+#include <lunaix/syscall.h>
+#include <usr/fcntl.h>
+
+__LXSYSCALL2(int, open, const char*, path, int, options)
--- /dev/null
+#include <lunaix/syscall.h>
+#include <usr/sys/ioctl.h>
+
+__LXSYSCALL2_VARG(int, ioctl, int, fd, int, req);
\ No newline at end of file
-#ifndef __LUNAIX_LUNAIX_H
-#define __LUNAIX_LUNAIX_H
-
#include <lunaix/syscall.h>
-#include <lunaix/types.h>
+#include <usr/sys/lunaix.h>
__LXSYSCALL(void, yield);
__LXSYSCALL3(pid_t, waitpid, pid_t, pid, int*, status, int, options);
-__LXSYSCALL(int, geterrno);
-
__LXSYSCALL2_VARG(void, syslog, int, level, const char*, fmt);
-#endif /* __LUNAIX_LUNAIX_H */
+__LXSYSCALL3(int, realpathat, int, fd, char*, buf, size_t, size)
--- /dev/null
+#include <lunaix/syscall.h>
+#include <usr/sys/mount.h>
+
+__LXSYSCALL4(int,
+ mount,
+ const char*,
+ source,
+ const char*,
+ target,
+ const char*,
+ fstype,
+ int,
+ options)
+
+__LXSYSCALL1(int, unmount, const char*, target)
\ No newline at end of file
--- /dev/null
+#include <lunaix/syscall.h>
+#include <usr/signal.h>
+
+__LXSYSCALL2(int, signal, int, signum, sighandler_t, handler);
+
+__LXSYSCALL1(int, sigpending, sigset_t, *set);
+__LXSYSCALL1(int, sigsuspend, const sigset_t, *mask);
+
+__LXSYSCALL3(int,
+ sigprocmask,
+ int,
+ how,
+ const sigset_t,
+ *set,
+ sigset_t,
+ *oldset);
--- /dev/null
+#include <lunaix/syscall.h>
+#include <usr/unistd.h>
+
+__LXSYSCALL(pid_t, fork)
+
+__LXSYSCALL1(int, sbrk, void*, addr)
+
+__LXSYSCALL1(void*, brk, unsigned long, size)
+
+__LXSYSCALL(pid_t, getpid)
+
+__LXSYSCALL(pid_t, getppid)
+
+__LXSYSCALL(pid_t, getpgid)
+
+__LXSYSCALL2(pid_t, setpgid, pid_t, pid, pid_t, pgid)
+
+__LXSYSCALL1(void, _exit, int, status)
+
+__LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
+
+__LXSYSCALL(int, pause)
+
+__LXSYSCALL2(int, kill, pid_t, pid, int, signum)
+
+__LXSYSCALL1(unsigned int, alarm, unsigned int, seconds)
+
+__LXSYSCALL2(int, link, const char*, oldpath, const char*, newpath)
+
+__LXSYSCALL1(int, rmdir, const char*, pathname)
+
+__LXSYSCALL3(int, read, int, fd, void*, buf, size_t, count)
+
+__LXSYSCALL3(int, write, int, fd, void*, buf, size_t, count)
+
+__LXSYSCALL3(int, readlink, const char*, path, char*, buf, size_t, size)
+
+__LXSYSCALL3(int, lseek, int, fd, off_t, offset, int, options)
+
+__LXSYSCALL1(int, unlink, const char*, pathname)
+
+__LXSYSCALL1(int, close, int, fd)
+
+__LXSYSCALL2(int, dup2, int, oldfd, int, newfd)
+
+__LXSYSCALL1(int, dup, int, oldfd)
+
+__LXSYSCALL1(int, fsync, int, fildes)
+
+__LXSYSCALL2(int, symlink, const char*, pathname, const char*, link_target)
+
+__LXSYSCALL1(int, chdir, const char*, path)
+
+__LXSYSCALL1(int, fchdir, int, fd)
+
+__LXSYSCALL2(char*, getcwd, char*, buf, size_t, size)
+
+__LXSYSCALL2(int, rename, const char*, oldpath, const char*, newpath)
+
+__LXSYSCALL4(int,
+ getxattr,
+ const char*,
+ path,
+ const char*,
+ name,
+ void*,
+ value,
+ size_t,
+ len)
+
+__LXSYSCALL4(int,
+ setxattr,
+ const char*,
+ path,
+ const char*,
+ name,
+ void*,
+ value,
+ size_t,
+ len)
+
+__LXSYSCALL4(int,
+ fgetxattr,
+ int,
+ fd,
+ const char*,
+ name,
+ void*,
+ value,
+ size_t,
+ len)
+
+__LXSYSCALL4(int,
+ fsetxattr,
+ int,
+ fd,
+ const char*,
+ name,
+ void*,
+ value,
+ size_t,
+ len)
+
+__LXSYSCALL4(int,
+ readlinkat,
+ int,
+ dirfd,
+ const char*,
+ pathname,
+ char*,
+ buf,
+ size_t,
+ size)
+
+__LXSYSCALL2(int, unlinkat, int, fd, const char*, pathname)
+
+__LXSYSCALL1(int, mkdir, const char*, path)
\ No newline at end of file