Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F131809877
D3236.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D3236.diff
View Options
Index: head/sys/compat/cloudabi/cloudabi_fd.c
===================================================================
--- head/sys/compat/cloudabi/cloudabi_fd.c
+++ head/sys/compat/cloudabi/cloudabi_fd.c
@@ -120,10 +120,24 @@
cloudabi_sys_fd_create2(struct thread *td,
struct cloudabi_sys_fd_create2_args *uap)
{
+ struct filecaps fcaps1 = {}, fcaps2 = {};
int fds[2];
int error;
switch (uap->type) {
+ case CLOUDABI_FILETYPE_FIFO:
+ /*
+ * CloudABI pipes are unidirectional. Restrict rights on
+ * the pipe to simulate this.
+ */
+ cap_rights_init(&fcaps1.fc_rights, CAP_EVENT, CAP_FCNTL,
+ CAP_FSTAT, CAP_READ);
+ fcaps1.fc_fcntls = CAP_FCNTL_SETFL;
+ cap_rights_init(&fcaps2.fc_rights, CAP_EVENT, CAP_FCNTL,
+ CAP_FSTAT, CAP_WRITE);
+ fcaps2.fc_fcntls = CAP_FCNTL_SETFL;
+ error = kern_pipe(td, fds, 0, &fcaps1, &fcaps2);
+ break;
case CLOUDABI_FILETYPE_SOCKET_DGRAM:
error = kern_socketpair(td, AF_UNIX, SOCK_DGRAM, 0, fds);
break;
Index: head/sys/compat/linux/linux_file.c
===================================================================
--- head/sys/compat/linux/linux_file.c
+++ head/sys/compat/linux/linux_file.c
@@ -1582,7 +1582,7 @@
printf(ARGS(pipe, "*"));
#endif
- error = kern_pipe2(td, fildes, 0);
+ error = kern_pipe(td, fildes, 0, NULL, NULL);
if (error)
return (error);
@@ -1609,7 +1609,7 @@
flags |= O_NONBLOCK;
if ((args->flags & LINUX_O_CLOEXEC) != 0)
flags |= O_CLOEXEC;
- error = kern_pipe2(td, fildes, flags);
+ error = kern_pipe(td, fildes, flags, NULL, NULL);
if (error)
return (error);
Index: head/sys/kern/sys_pipe.c
===================================================================
--- head/sys/kern/sys_pipe.c
+++ head/sys/kern/sys_pipe.c
@@ -397,14 +397,8 @@
* the zone pick up the pieces via pipeclose().
*/
int
-kern_pipe(struct thread *td, int fildes[2])
-{
-
- return (kern_pipe2(td, fildes, 0));
-}
-
-int
-kern_pipe2(struct thread *td, int fildes[2], int flags)
+kern_pipe(struct thread *td, int fildes[2], int flags, struct filecaps *fcaps1,
+ struct filecaps *fcaps2)
{
struct file *rf, *wf;
struct pipe *rpipe, *wpipe;
@@ -414,13 +408,13 @@
pipe_paircreate(td, &pp);
rpipe = &pp->pp_rpipe;
wpipe = &pp->pp_wpipe;
- error = falloc(td, &rf, &fd, flags);
+ error = falloc_caps(td, &rf, &fd, flags, fcaps1);
if (error) {
pipeclose(rpipe);
pipeclose(wpipe);
return (error);
}
- /* An extra reference on `rf' has been held for us by falloc(). */
+ /* An extra reference on `rf' has been held for us by falloc_caps(). */
fildes[0] = fd;
fflags = FREAD | FWRITE;
@@ -434,7 +428,7 @@
* side while we are blocked trying to allocate the write side.
*/
finit(rf, fflags, DTYPE_PIPE, rpipe, &pipeops);
- error = falloc(td, &wf, &fd, flags);
+ error = falloc_caps(td, &wf, &fd, flags, fcaps2);
if (error) {
fdclose(td, rf, fildes[0]);
fdrop(rf, td);
@@ -442,7 +436,7 @@
pipeclose(wpipe);
return (error);
}
- /* An extra reference on `wf' has been held for us by falloc(). */
+ /* An extra reference on `wf' has been held for us by falloc_caps(). */
finit(wf, fflags, DTYPE_PIPE, wpipe, &pipeops);
fdrop(wf, td);
fildes[1] = fd;
@@ -458,7 +452,7 @@
int error;
int fildes[2];
- error = kern_pipe(td, fildes);
+ error = kern_pipe(td, fildes, 0, NULL, NULL);
if (error)
return (error);
@@ -475,7 +469,7 @@
if (uap->flags & ~(O_CLOEXEC | O_NONBLOCK))
return (EINVAL);
- error = kern_pipe2(td, fildes, uap->flags);
+ error = kern_pipe(td, fildes, uap->flags, NULL, NULL);
if (error)
return (error);
error = copyout(fildes, uap->fildes, 2 * sizeof(int));
Index: head/sys/sys/syscallsubr.h
===================================================================
--- head/sys/sys/syscallsubr.h
+++ head/sys/sys/syscallsubr.h
@@ -35,6 +35,7 @@
#include <sys/mount.h>
struct file;
+struct filecaps;
enum idtype;
struct itimerval;
struct image_args;
@@ -150,8 +151,8 @@
enum uio_seg pathseg, int flags, int mode);
int kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg,
int name, u_long flags);
-int kern_pipe(struct thread *td, int fildes[2]);
-int kern_pipe2(struct thread *td, int fildes[2], int flags);
+int kern_pipe(struct thread *td, int fildes[2], int flags,
+ struct filecaps *fcaps1, struct filecaps *fcaps2);
int kern_poll(struct thread *td, struct pollfd *fds, u_int nfds,
struct timespec *tsp, sigset_t *uset);
int kern_posix_fadvise(struct thread *td, int fd, off_t offset, off_t len,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 12, 8:40 AM (12 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23616426
Default Alt Text
D3236.diff (4 KB)
Attached To
Mode
D3236: Make pipes in CloudABI work.
Attached
Detach File
Event Timeline
Log In to Comment