1.1 --- a/libfsserver/include/fsserver/opener_resource.h Mon Oct 11 23:56:21 2021 +0200
1.2 +++ b/libfsserver/include/fsserver/opener_resource.h Wed Oct 13 00:50:33 2021 +0200
1.3 @@ -52,6 +52,10 @@
1.4 offset_t *size, l4_cap_idx_t *cap,
1.5 object_flags_t *object_flags);
1.6
1.7 + /* Retrieval methods. */
1.8 +
1.9 + virtual long get_parent(const char *path, fileid_t *fileid);
1.10 +
1.11 /* Notification methods. */
1.12
1.13 virtual long notify_parent(const char *path);
2.1 --- a/libfsserver/lib/files/opener_resource.cc Mon Oct 11 23:56:21 2021 +0200
2.2 +++ b/libfsserver/lib/files/opener_resource.cc Wed Oct 13 00:50:33 2021 +0200
2.3 @@ -48,14 +48,11 @@
2.4
2.5
2.6
2.7 -/* Obtain any active parent directory for a path, notifying its subscribers of
2.8 - the file opening event. */
2.9 +/* Obtain the identifier for any active parent directory for a path. */
2.10
2.11 -long OpenerResource::notify_parent(const char *path)
2.12 +long OpenerResource::get_parent(const char *path, fileid_t *fileid)
2.13 {
2.14 char *sep = strrchr(path, (int) '/');
2.15 - DirectoryProvider *provider;
2.16 - fileid_t fileid;
2.17 long err;
2.18
2.19 /* For top-level paths, use the empty string to get the root directory.
2.20 @@ -63,16 +60,30 @@
2.21 identifier. */
2.22
2.23 if (sep == NULL)
2.24 - err = get_fileid("", 0, &fileid);
2.25 + err = get_fileid("", 0, fileid);
2.26 else
2.27 {
2.28 char *parent = strndup(path, sep - path + 1);
2.29
2.30 parent[sep - path] = '\0';
2.31 - err = get_fileid(parent, 0, &fileid);
2.32 + err = get_fileid(parent, 0, fileid);
2.33 free(parent);
2.34 }
2.35
2.36 + return err;
2.37 +}
2.38 +
2.39 +/* Obtain any active parent directory for a path, notifying its subscribers of
2.40 + the file opening event. */
2.41 +
2.42 +long OpenerResource::notify_parent(const char *path)
2.43 +{
2.44 + DirectoryProvider *provider;
2.45 + fileid_t fileid;
2.46 + long err;
2.47 +
2.48 + err = get_parent(path, &fileid);
2.49 +
2.50 if (err)
2.51 return err;
2.52
2.53 @@ -98,7 +109,8 @@
2.54 long OpenerResource::open(const char *path, flags_t flags, offset_t *size,
2.55 l4_cap_idx_t *cap, object_flags_t *object_flags)
2.56 {
2.57 - /* Obtain an identifier for the file, even for new files. */
2.58 + /* Obtain an identifier for the file, even for new files (subject to use of
2.59 + the appropriate flag). */
2.60
2.61 fileid_t fileid;
2.62 long err = get_fileid(path, flags, &fileid);