mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
kernel/libroot: add pipe2() from POSIX.1-2024
this adds a parameter to the create_pipe syscall. Adjust strace. Change-Id: I83e9f039eb28c862458654b66c03e2e21a258822 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8513 Reviewed-by: waddlesplash <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
parent
30179dd326
commit
11cd4af6e1
@ -341,6 +341,7 @@ extern int fchdir(int fd);
|
||||
extern char *getcwd(char *buffer, size_t size);
|
||||
|
||||
extern int pipe(int fildes[2]);
|
||||
extern int pipe2(int fildes[2], int flags);
|
||||
extern int dup(int fd);
|
||||
extern int dup2(int fd1, int fd2);
|
||||
extern int close(int fd);
|
||||
|
@ -206,7 +206,7 @@ status_t _user_unlink(int fd, const char *path);
|
||||
status_t _user_rename(int oldFD, const char *oldpath, int newFD,
|
||||
const char *newpath);
|
||||
status_t _user_create_fifo(int fd, const char *path, mode_t perms);
|
||||
status_t _user_create_pipe(int *fds);
|
||||
status_t _user_create_pipe(int *fds, int flags);
|
||||
status_t _user_access(int fd, const char *path, int mode,
|
||||
bool effectiveUserGroup);
|
||||
ssize_t _user_select(int numfds, fd_set *readSet, fd_set *writeSet,
|
||||
|
@ -295,7 +295,7 @@ extern status_t _kern_unlink(int fd, const char *path);
|
||||
extern status_t _kern_rename(int oldDir, const char *oldpath, int newDir,
|
||||
const char *newpath);
|
||||
extern status_t _kern_create_fifo(int fd, const char *path, mode_t perms);
|
||||
extern status_t _kern_create_pipe(int *fds);
|
||||
extern status_t _kern_create_pipe(int *fds, int flags);
|
||||
extern status_t _kern_access(int fd, const char *path, int mode,
|
||||
bool effectiveUserGroup);
|
||||
extern ssize_t _kern_select(int numfds, struct fd_set *readSet,
|
||||
|
@ -93,5 +93,10 @@ patch_fcntl()
|
||||
fcntl->GetParameter("argument")->SetHandler(
|
||||
new TypeHandlerSelector(kFcntlTypeHandlers,
|
||||
1, TypeHandlerFactory<void *>::Create()));
|
||||
|
||||
Syscall *createPipe = get_syscall("_kern_create_pipe");
|
||||
createPipe->ParameterAt(0)->SetOut(true);
|
||||
createPipe->ParameterAt(0)->SetCount(2);
|
||||
createPipe->GetParameter("flags")->SetHandler(new FlagsTypeHandler(kOpenFlags));
|
||||
}
|
||||
|
||||
|
@ -124,10 +124,6 @@ patch_network()
|
||||
shutdown->GetParameter("how")->SetHandler(
|
||||
new EnumTypeHandler(kShutdownHowMap));
|
||||
|
||||
Syscall *createPipe = get_syscall("_kern_create_pipe");
|
||||
createPipe->ParameterAt(0)->SetOut(true);
|
||||
createPipe->ParameterAt(0)->SetCount(2);
|
||||
|
||||
Syscall *socketPair = get_syscall("_kern_socketpair");
|
||||
socketPair->ParameterAt(3)->SetOut(true);
|
||||
socketPair->ParameterAt(3)->SetCount(2);
|
||||
|
@ -9579,8 +9579,12 @@ _user_create_fifo(int fd, const char* userPath, mode_t perms)
|
||||
|
||||
|
||||
status_t
|
||||
_user_create_pipe(int* userFDs)
|
||||
_user_create_pipe(int* userFDs, int flags)
|
||||
{
|
||||
// check acceptable flags
|
||||
if ((flags & ~(O_NONBLOCK | O_CLOEXEC)) != 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// rootfs should support creating FIFOs, but let's be sure
|
||||
if (!HAS_FS_CALL(sRoot, create_special_node))
|
||||
return B_UNSUPPORTED;
|
||||
@ -9606,10 +9610,11 @@ _user_create_pipe(int* userFDs)
|
||||
// Everything looks good so far. Open two FDs for reading respectively
|
||||
// writing, O_NONBLOCK to avoid blocking on open with O_RDONLY
|
||||
int fds[2];
|
||||
fds[0] = open_vnode(vnode, O_RDONLY | O_NONBLOCK, false);
|
||||
fds[1] = open_vnode(vnode, O_WRONLY, false);
|
||||
// Reset O_NONBLOCK
|
||||
common_fcntl(fds[0], F_SETFL, 0, false);
|
||||
fds[0] = open_vnode(vnode, O_RDONLY | O_NONBLOCK | flags, false);
|
||||
fds[1] = open_vnode(vnode, O_WRONLY | flags, false);
|
||||
// Reset O_NONBLOCK if requested
|
||||
if ((flags & O_NONBLOCK) == 0)
|
||||
common_fcntl(fds[0], F_SETFL, flags & O_NONBLOCK, false);
|
||||
|
||||
FDCloser closer0(fds[0], false);
|
||||
FDCloser closer1(fds[1], false);
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
|
||||
int
|
||||
pipe(int streams[2])
|
||||
pipe2(int streams[2], int flags)
|
||||
{
|
||||
status_t error = _kern_create_pipe(streams);
|
||||
status_t error = _kern_create_pipe(streams, flags);
|
||||
if (error != B_OK) {
|
||||
__set_errno(error);
|
||||
return -1;
|
||||
@ -21,3 +21,10 @@ pipe(int streams[2])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
pipe(int streams[2])
|
||||
{
|
||||
return pipe2(streams, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user