git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: stdin/stdout into process
[lunaix-os.git]
/
lunaix-os
/
kernel
/
fs
/
vfs.c
diff --git
a/lunaix-os/kernel/fs/vfs.c
b/lunaix-os/kernel/fs/vfs.c
index 1104d9b5533d9673f58722162c091a8da1d3c6ad..11896ec6730e4377a24d3d4d72b7644622663c51 100644
(file)
--- a/
lunaix-os/kernel/fs/vfs.c
+++ b/
lunaix-os/kernel/fs/vfs.c
@@
-945,7
+945,7
@@
__DEFINE_LXSYSCALL1(int, fsync, int, fildes)
}
int
}
int
-
__
vfs_dup_fd(struct v_fd* old, struct v_fd** new)
+vfs_dup_fd(struct v_fd* old, struct v_fd** new)
{
int errno = 0;
struct v_fd* copied = cake_grab(fd_pile);
{
int errno = 0;
struct v_fd* copied = cake_grab(fd_pile);
@@
-953,10
+953,13
@@
__vfs_dup_fd(struct v_fd* old, struct v_fd** new)
memcpy(copied, old, sizeof(struct v_fd));
old->file->ref_count++;
memcpy(copied, old, sizeof(struct v_fd));
old->file->ref_count++;
+ *new = copied;
+
return errno;
}
return errno;
}
-__DEFINE_LXSYSCALL2(int, dup2, int, oldfd, int, newfd)
+int
+vfs_dup2(int oldfd, int newfd)
{
if (newfd == oldfd) {
return newfd;
{
if (newfd == oldfd) {
return newfd;
@@
-964,7
+967,7
@@
__DEFINE_LXSYSCALL2(int, dup2, int, oldfd, int, newfd)
int errno;
struct v_fd *oldfd_s, *newfd_s;
int errno;
struct v_fd *oldfd_s, *newfd_s;
- if (!GET_FD(oldfd, oldfd_s) || TEST_FD(newfd)) {
+ if (!GET_FD(oldfd, oldfd_s) ||
!
TEST_FD(newfd)) {
errno = EBADF;
goto done;
}
errno = EBADF;
goto done;
}
@@
-973,7
+976,7
@@
__DEFINE_LXSYSCALL2(int, dup2, int, oldfd, int, newfd)
goto done;
}
goto done;
}
- if (!(errno =
__
vfs_dup_fd(oldfd_s, &newfd_s))) {
+ if (!(errno = vfs_dup_fd(oldfd_s, &newfd_s))) {
__current->fdtable->fds[newfd] = newfd_s;
return newfd;
}
__current->fdtable->fds[newfd] = newfd_s;
return newfd;
}
@@
-982,6
+985,11
@@
done:
return DO_STATUS(errno);
}
return DO_STATUS(errno);
}
+__DEFINE_LXSYSCALL2(int, dup2, int, oldfd, int, newfd)
+{
+ return vfs_dup2(oldfd, newfd);
+}
+
__DEFINE_LXSYSCALL1(int, dup, int, oldfd)
{
int errno, newfd;
__DEFINE_LXSYSCALL1(int, dup, int, oldfd)
{
int errno, newfd;
@@
-989,7
+997,7
@@
__DEFINE_LXSYSCALL1(int, dup, int, oldfd)
if (!GET_FD(oldfd, oldfd_s)) {
errno = EBADF;
} else if (!(errno = vfs_alloc_fdslot(&newfd)) &&
if (!GET_FD(oldfd, oldfd_s)) {
errno = EBADF;
} else if (!(errno = vfs_alloc_fdslot(&newfd)) &&
- !(errno =
__
vfs_dup_fd(oldfd_s, &newfd_s))) {
+ !(errno = vfs_dup_fd(oldfd_s, &newfd_s))) {
__current->fdtable->fds[newfd] = newfd_s;
return newfd;
}
__current->fdtable->fds[newfd] = newfd_s;
return newfd;
}