Added dup(2).
This commit is contained in:
parent
5bde040295
commit
05196f49b2
|
@ -84,7 +84,6 @@ int close(int);
|
||||||
size_t confstr(int, char*, size_t);
|
size_t confstr(int, char*, size_t);
|
||||||
char* crypt(const char*, const char*);
|
char* crypt(const char*, const char*);
|
||||||
char* ctermid(char*);
|
char* ctermid(char*);
|
||||||
int dup(int);
|
|
||||||
int dup2(int, int);
|
int dup2(int, int);
|
||||||
void encrypt(char [64], int);
|
void encrypt(char [64], int);
|
||||||
int execl(const char*, const char*, ...);
|
int execl(const char*, const char*, ...);
|
||||||
|
@ -159,6 +158,7 @@ extern char* optarg;
|
||||||
extern int opterr, optind, optopt;
|
extern int opterr, optind, optopt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int dup(int);
|
||||||
void _exit(int);
|
void _exit(int);
|
||||||
pid_t fork(void);
|
pid_t fork(void);
|
||||||
pid_t getpid(void);
|
pid_t getpid(void);
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace Maxsi
|
||||||
DEFN_SYSCALL3(ssize_t, SysRead, 18, int, void*, size_t);
|
DEFN_SYSCALL3(ssize_t, SysRead, 18, int, void*, size_t);
|
||||||
DEFN_SYSCALL3(ssize_t, SysWrite, 19, int, const void*, size_t);
|
DEFN_SYSCALL3(ssize_t, SysWrite, 19, int, const void*, size_t);
|
||||||
DEFN_SYSCALL1(int, SysPipe, 20, int*);
|
DEFN_SYSCALL1(int, SysPipe, 20, int*);
|
||||||
|
DEFN_SYSCALL1(int, SysDup, 21, int);
|
||||||
|
|
||||||
size_t Print(const char* Message)
|
size_t Print(const char* Message)
|
||||||
{
|
{
|
||||||
|
@ -78,6 +79,10 @@ namespace Maxsi
|
||||||
return SysPipe(pipefd);
|
return SysPipe(pipefd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" int dup(int fd)
|
||||||
|
{
|
||||||
|
return SysDup(fd);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,10 +117,19 @@ namespace Sortix
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SysDup(int fd)
|
||||||
|
{
|
||||||
|
Process* process = CurrentProcess();
|
||||||
|
Device* dev = process->descriptors.Get(fd);
|
||||||
|
if ( !dev ) { return -1; /* TODO: EBADF */ }
|
||||||
|
return process->descriptors.Allocate(dev);
|
||||||
|
}
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
Syscall::Register(SYSCALL_WRITE, (void*) SysWrite);
|
Syscall::Register(SYSCALL_WRITE, (void*) SysWrite);
|
||||||
Syscall::Register(SYSCALL_READ, (void*) SysRead);
|
Syscall::Register(SYSCALL_READ, (void*) SysRead);
|
||||||
|
Syscall::Register(SYSCALL_DUP, (void*) SysDup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,8 @@
|
||||||
#define SYSCALL_READ 18
|
#define SYSCALL_READ 18
|
||||||
#define SYSCALL_WRITE 19
|
#define SYSCALL_WRITE 19
|
||||||
#define SYSCALL_PIPE 20
|
#define SYSCALL_PIPE 20
|
||||||
#define SYSCALL_MAX_NUM 21 /* index of highest constant + 1 */
|
#define SYSCALL_DUP 21
|
||||||
|
#define SYSCALL_MAX_NUM 22 /* index of highest constant + 1 */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue