1.1 --- a/libfsclient/lib/src/file.cc Wed Mar 02 23:23:37 2022 +0100
1.2 +++ b/libfsclient/lib/src/file.cc Wed Mar 02 23:53:42 2022 +0100
1.3 @@ -113,6 +113,30 @@
1.4 file_init(file);
1.5 }
1.6
1.7 +/* Make a directory in the filesystem. This is a convenience function invoking
1.8 + file_context and file_context_mkdir. */
1.9 +
1.10 +long file_mkdir(const char *filename, mode_t mode, l4_cap_idx_t server)
1.11 +{
1.12 + file_t context;
1.13 + long err;
1.14 +
1.15 + err = file_context(&context, server);
1.16 + if (err)
1.17 + return err;
1.18 +
1.19 + if (!file_string_set(&context, filename, 0, NULL))
1.20 + return -L4_ENOMEM;
1.21 +
1.22 + err = file_context_mkdir(systypes_to_sys_mode(mode), &context);
1.23 +
1.24 + /* Close the context, although a separate mechanism could permit contexts to
1.25 + remove several files. */
1.26 +
1.27 + file_close(&context);
1.28 + return err;
1.29 +}
1.30 +
1.31 /* Open a file using the given structure, indicating the filename and
1.32 filesystem server. The file_mmap function should be used to obtain access to
1.33 memory providing file data. This is a convenience function invoking
1.34 @@ -249,6 +273,14 @@
1.35 return ipc_attach_dataspace(file->ref, size, (void **) &file->memory);
1.36 }
1.37
1.38 +/* Make a directory using the given context. */
1.39 +
1.40 +long file_context_mkdir(mode_t mode, file_t *context)
1.41 +{
1.42 + client_OpenerContext openercontext(context->ref);
1.43 + return openercontext.mkdir(mode);
1.44 +}
1.45 +
1.46 /* Open a file using the given structure and context. */
1.47
1.48 long file_context_open(file_t *file, flags_t flags, file_t *context)