Compare commits
2 Commits
e1e86ab889
...
6d821d2638
Author | SHA1 | Date | |
---|---|---|---|
6d821d2638 | |||
f35bbe52b7 |
@ -3,6 +3,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@ -137,13 +138,21 @@ int main()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(new_stderr, "Bye!\n");
|
fprintf(new_stderr, "Bye!\n\n");
|
||||||
|
|
||||||
fclose(new_stderr);
|
fclose(new_stderr);
|
||||||
|
|
||||||
execv("/bin/sym", NULL);
|
const char* pathname = "/etc";
|
||||||
|
|
||||||
perror("execv"); // If we're here, execv failed
|
printf("Creating directory %s\n", pathname);
|
||||||
|
|
||||||
|
if (mkdir(pathname, 0) < 0)
|
||||||
|
{
|
||||||
|
perror("mkdir");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Success!!");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#define SYS_fcntl 13
|
#define SYS_fcntl 13
|
||||||
#define SYS_mprotect 14
|
#define SYS_mprotect 14
|
||||||
#define SYS_clock 15
|
#define SYS_clock 15
|
||||||
|
#define SYS_mkdir 17
|
||||||
|
|
||||||
#ifndef __want_syscalls
|
#ifndef __want_syscalls
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
18
libs/libc/include/sys/stat.h
Normal file
18
libs/libc/include/sys/stat.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _SYS_STAT_H
|
||||||
|
#define _SYS_STAT_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Creates a new directory at the path pathname. FIXME: For now, mode is ignored. */
|
||||||
|
int mkdir(const char* pathname, mode_t mode);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -13,4 +13,7 @@ typedef long int ssize_t;
|
|||||||
/* The type of an offset into a file. */
|
/* The type of an offset into a file. */
|
||||||
typedef long int off_t;
|
typedef long int off_t;
|
||||||
|
|
||||||
|
/* The type of a file's mode. */
|
||||||
|
typedef unsigned short mode_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,5 +1,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@ -14,12 +15,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, cmd);
|
va_start(ap, cmd);
|
||||||
long result;
|
long result = syscall(SYS_fcntl, fd, cmd, va_arg(ap, uintptr_t));
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case F_DUPFD: result = syscall(SYS_fcntl, fd, cmd, va_arg(ap, int)); break;
|
|
||||||
default: result = syscall(SYS_fcntl, fd, cmd, 0); break;
|
|
||||||
}
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return (int)result;
|
return (int)result;
|
||||||
}
|
}
|
||||||
|
11
libs/libc/src/sys/stat.cpp
Normal file
11
libs/libc/src/sys/stat.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
int mkdir(const char* pathname, mode_t)
|
||||||
|
{
|
||||||
|
return (int)syscall(SYS_mkdir, pathname);
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,7 @@ extern "C"
|
|||||||
case SYS_exit:
|
case SYS_exit:
|
||||||
case SYS_close:
|
case SYS_close:
|
||||||
case SYS_exec:
|
case SYS_exec:
|
||||||
|
case SYS_mkdir:
|
||||||
case SYS_sleep: result = __luna_syscall1(number, va_arg(ap, arg)); break;
|
case SYS_sleep: result = __luna_syscall1(number, va_arg(ap, arg)); break;
|
||||||
case SYS_munmap:
|
case SYS_munmap:
|
||||||
case SYS_open: {
|
case SYS_open: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user