20#include "pedigree/kernel/Subsystem.h"
21#include "pedigree/kernel/process/Process.h"
22#include "pedigree/kernel/processor/Processor.h"
23#include "pedigree/kernel/syscallError.h"
25#include <FileDescriptor.h>
26#include <PosixSubsystem.h>
29#include "file-syscalls.h"
30#include "modules/Module.h"
31#include "modules/system/vfs/Pipe.h"
32#include "modules/system/vfs/VFS.h"
33#include "pipe-syscalls.h"
35int posix_pipe(
int filedes[2]) {
36 return posix_pipe2(filedes, 0);
39int posix_pipe2(
int filedes[2],
int flags) {
40 if (flags & ~(O_CLOEXEC | O_NONBLOCK)) {
41 SYSCALL_ERROR(InvalidArgument);
46 PosixSubsystem::SafeWrite)) {
47 F_NOTICE(
"pipe -> invalid address");
48 SYSCALL_ERROR(BadAddress);
57 ERROR(
"No subsystem for the process!");
61 size_t readFd = pSubsystem->
getFd();
62 size_t writeFd = pSubsystem->
getFd();
67 int descriptorFlags = (flags & O_CLOEXEC) ? FD_CLOEXEC : 0;
68 int statusFlags = flags & O_NONBLOCK;
73 new FileDescriptor(p, 0, writeFd, descriptorFlags, O_WRONLY | statusFlags);
79 F_NOTICE(
"pipe: returning " << readFd <<
" and " << writeFd <<
".");
size_t getFd(size_t minimum=0)
void addFileDescriptor(size_t fd, FileDescriptor *pFd)
static bool checkAddress(uintptr_t addr, size_t extent, size_t flags)
static ProcessorInformation & information()