diff options
author | Ed Schouten <ed@FreeBSD.org> | 2015-07-28 06:50:47 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2015-07-28 06:50:47 +0000 |
commit | 29515a68a5dec8dcfeec9b306fd396330fb0d9c9 (patch) | |
tree | e1f6fb4e3ee397ce6d1b34fd30366cb1452582c3 /sys/compat/cloudabi | |
parent | cec575201a4c9c10aa39dda868fbed5c64908c17 (diff) | |
download | src-29515a68a5dec8dcfeec9b306fd396330fb0d9c9.tar.gz src-29515a68a5dec8dcfeec9b306fd396330fb0d9c9.zip |
Implement directory and FIFO creation.
The file_create() system call can be used to create files of a given
type. Right now it can only be used to create directories and FIFOs. As
CloudABI does not expose filesystem permissions, this system call lacks
a mode argument. Simply use 0777 or 0666 depending on the file type.
Notes
Notes:
svn path=/head/; revision=285931
Diffstat (limited to 'sys/compat/cloudabi')
-rw-r--r-- | sys/compat/cloudabi/cloudabi_file.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sys/compat/cloudabi/cloudabi_file.c b/sys/compat/cloudabi/cloudabi_file.c index 3f917a0d84d8..72902ee20638 100644 --- a/sys/compat/cloudabi/cloudabi_file.c +++ b/sys/compat/cloudabi/cloudabi_file.c @@ -137,9 +137,31 @@ int cloudabi_sys_file_create(struct thread *td, struct cloudabi_sys_file_create_args *uap) { + char *path; + int error; - /* Not implemented. */ - return (ENOSYS); + error = copyin_path(uap->path, uap->pathlen, &path); + if (error != 0) + return (error); + + /* + * CloudABI processes cannot interact with UNIX credentials and + * permissions. Depend on the umask that is set prior to + * execution to restrict the file permissions. + */ + switch (uap->type) { + case CLOUDABI_FILETYPE_DIRECTORY: + error = kern_mkdirat(td, uap->fd, path, UIO_SYSSPACE, 0777); + break; + case CLOUDABI_FILETYPE_FIFO: + error = kern_mkfifoat(td, uap->fd, path, UIO_SYSSPACE, 0666); + break; + default: + error = EINVAL; + break; + } + cloudabi_freestr(path); + return (error); } int |