1.1 --- a/libfsclient/lib/src/client.cc Tue Aug 10 23:41:57 2021 +0200
1.2 +++ b/libfsclient/lib/src/client.cc Wed Aug 11 00:51:09 2021 +0200
1.3 @@ -25,6 +25,8 @@
1.4 #include <stdlib.h>
1.5 #include <string.h>
1.6
1.7 +#include <systypes/fcntl.h>
1.8 +
1.9 #include "client.h"
1.10
1.11
1.12 @@ -236,6 +238,38 @@
1.13
1.14
1.15
1.16 +/* Open a directory. */
1.17 +
1.18 +file_t *client_opendir(const char *name)
1.19 +{
1.20 + l4_cap_idx_t server = l4re_env_get_cap("server");
1.21 +
1.22 + return client_opendir_using(name, server);
1.23 +}
1.24 +
1.25 +/* Open a directory using a named capability. */
1.26 +
1.27 +file_t *client_opendir_using(const char *name, l4_cap_idx_t server)
1.28 +{
1.29 + file_t *file = client_open_using(name, O_DIRECTORY, server);
1.30 +
1.31 + if (file == NULL)
1.32 + return NULL;
1.33 +
1.34 + /* Set blocking read mode to be able to conveniently read directory entries
1.35 + from the stream. */
1.36 +
1.37 + if (client_set_blocking(file, NOTIFY_CONTENT_AVAILABLE | NOTIFY_PEER_CLOSED))
1.38 + {
1.39 + client_close(file);
1.40 + return NULL;
1.41 + }
1.42 +
1.43 + return file;
1.44 +}
1.45 +
1.46 +
1.47 +
1.48 /* Open a pipe object. */
1.49
1.50 long client_pipe(file_t **reader, file_t **writer)