mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 01:32:14 -05:00
Add fcntl() F_DUPFD which is slightly different from dup2().
This commit is contained in:
parent
6cedb88153
commit
2cf477a151
Notes:
sideshowbarker
2024-07-19 16:10:05 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2cf477a1512
3 changed files with 22 additions and 0 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue