summaryrefslogtreecommitdiffstats
path: root/sys/compat/cloudabi
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2015-08-05 16:15:43 +0000
committered <ed@FreeBSD.org>2015-08-05 16:15:43 +0000
commit7bdbb524eb816b9c6fee47fc94bf48b6c42a516a (patch)
tree8712d384843791a9ef3c669af1cbcd5cd7837925 /sys/compat/cloudabi
parentef4a614a3cfdda0102531205fee20c15c74bc3fd (diff)
downloadFreeBSD-src-7bdbb524eb816b9c6fee47fc94bf48b6c42a516a.zip
FreeBSD-src-7bdbb524eb816b9c6fee47fc94bf48b6c42a516a.tar.gz
Make fcntl(F_SETFL) work.
The stat_put() system call can be used to modify file descriptor attributes, such as flags, but also Capsicum permission bits. Support for changing Capsicum bits will be added as soon as its dependent changes have been pushed through code review. Obtained from: https://github.com/NuxiNL/freebsd
Diffstat (limited to 'sys/compat/cloudabi')
-rw-r--r--sys/compat/cloudabi/cloudabi_fd.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sys/compat/cloudabi/cloudabi_fd.c b/sys/compat/cloudabi/cloudabi_fd.c
index 03d65bd..1fed2e7 100644
--- a/sys/compat/cloudabi/cloudabi_fd.c
+++ b/sys/compat/cloudabi/cloudabi_fd.c
@@ -503,9 +503,26 @@ int
cloudabi_sys_fd_stat_put(struct thread *td,
struct cloudabi_sys_fd_stat_put_args *uap)
{
+ cloudabi_fdstat_t fsb;
+ int error, oflags;
- /* Not implemented. */
- return (ENOSYS);
+ error = copyin(uap->buf, &fsb, sizeof(fsb));
+ if (error != 0)
+ return (error);
+
+ if (uap->flags == CLOUDABI_FDSTAT_FLAGS) {
+ /* Convert flags. */
+ oflags = 0;
+ if (fsb.fs_flags & CLOUDABI_FDFLAG_APPEND)
+ oflags |= O_APPEND;
+ if (fsb.fs_flags & CLOUDABI_FDFLAG_NONBLOCK)
+ oflags |= O_NONBLOCK;
+ if (fsb.fs_flags & (CLOUDABI_FDFLAG_SYNC |
+ CLOUDABI_FDFLAG_DSYNC | CLOUDABI_FDFLAG_RSYNC))
+ oflags |= O_SYNC;
+ return (kern_fcntl(td, uap->fd, F_SETFL, oflags));
+ }
+ return (EINVAL);
}
int
OpenPOWER on IntegriCloud