diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 892e2228dea..29a63cb669b 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1090,6 +1090,22 @@ int Process::sys$fcntl(int fd, int cmd, dword arg) // NOTE: The FD flags are not shared between FileDescriptor objects. // This means that dup() doesn't copy the FD_CLOEXEC flag! switch (cmd) { + case F_DUPFD: { + int arg_fd = (int)arg; + if (arg_fd < 0) + return -EINVAL; + int new_fd = -1; + for (int i = arg_fd; i < (int)m_max_open_file_descriptors; ++i) { + if (!m_fds[i]) { + new_fd = i; + break; + } + } + if (new_fd == -1) + return -EMFILE; + m_fds[new_fd].set(descriptor); + break; + } case F_GETFD: return m_fds[fd].flags; case F_SETFD: diff --git a/Kernel/sync.sh b/Kernel/sync.sh index f7a313fc107..37fc24edbcc 100755 --- a/Kernel/sync.sh +++ b/Kernel/sync.sh @@ -3,6 +3,11 @@ rm -vf _fs_contents cp -vp _fs_contents.stock _fs_contents mkdir -vp mnt mount -o loop _fs_contents mnt/ +mkdir -vp mnt/dev +mknod mnt/dev/tty0 c 4 0 +mknod mnt/dev/tty1 c 4 1 +mknod mnt/dev/tty2 c 4 2 +mknod mnt/dev/tty3 c 4 3 cp -R ../Base/* mnt/ cp -v ../Userland/sh mnt/bin/sh cp -v ../Userland/id mnt/bin/id diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp index 195a787e143..b28df2a161c 100644 --- a/LibC/stdlib.cpp +++ b/LibC/stdlib.cpp @@ -29,6 +29,7 @@ void __malloc_init() void* malloc(size_t size) { if ((nextptr + size) > endptr) { + fprintf(stderr, "Unable to serve malloc() request with size %u\n", size); volatile char* crashme = (char*)0xc007d00d; *crashme = 0; }