svn commit: r285931 - head/sys/compat/cloudabi

Ed Schouten ed at FreeBSD.org
Tue Jul 28 06:50:48 UTC 2015


Author: ed
Date: Tue Jul 28 06:50:47 2015
New Revision: 285931
URL: https://svnweb.freebsd.org/changeset/base/285931

Log:
  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.

Modified:
  head/sys/compat/cloudabi/cloudabi_file.c

Modified: head/sys/compat/cloudabi/cloudabi_file.c
==============================================================================
--- head/sys/compat/cloudabi/cloudabi_file.c	Tue Jul 28 06:36:49 2015	(r285930)
+++ head/sys/compat/cloudabi/cloudabi_file.c	Tue Jul 28 06:50:47 2015	(r285931)
@@ -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


More information about the svn-src-head mailing list