1.1 --- a/libfsserver/include/fsserver/block_file_opener.h Wed Feb 09 22:30:29 2022 +0100
1.2 +++ b/libfsserver/include/fsserver/block_file_opener.h Thu Feb 10 17:55:05 2022 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * An opener for a file employing a rewritable memory area.
1.6 *
1.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -41,7 +41,7 @@
1.13
1.14 virtual long get_fileid(const char *path, flags_t flags, fileid_t *fileid);
1.15
1.16 - virtual long make_accessor(const char *path, flags_t flags, fileid_t fileid, Accessor **accessor);
1.17 + virtual long make_accessor(flags_t flags, fileid_t fileid, Accessor **accessor);
1.18 };
1.19
1.20 // vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/libfsserver/include/fsserver/ext2_file_opener.h Wed Feb 09 22:30:29 2022 +0100
2.2 +++ b/libfsserver/include/fsserver/ext2_file_opener.h Thu Feb 10 17:55:05 2022 +0100
2.3 @@ -40,9 +40,9 @@
2.4
2.5 /* Convenience methods determining different object types. */
2.6
2.7 - virtual bool accessing_directory(const char *path, flags_t flags, fileid_t fileid);
2.8 + virtual bool accessing_directory(flags_t flags, fileid_t fileid);
2.9
2.10 - virtual bool accessing_file(const char *path, flags_t flags, fileid_t fileid);
2.11 + virtual bool accessing_file(flags_t flags, fileid_t fileid);
2.12
2.13 public:
2.14 explicit Ext2FileOpener(ResourceRegistry *registry, Ext2FileOperations *ops, user_t user)
2.15 @@ -56,19 +56,17 @@
2.16
2.17 virtual long get_fileid(const char *path, flags_t flags, fileid_t *fileid);
2.18
2.19 - virtual long make_accessor(const char *path, flags_t flags, fileid_t fileid,
2.20 + virtual long make_accessor(flags_t flags, fileid_t fileid,
2.21 Accessor **accessor);
2.22
2.23 - virtual long make_directory_accessor(const char *path, flags_t flags,
2.24 - fileid_t fileid,
2.25 + virtual long make_directory_accessor(flags_t flags, fileid_t fileid,
2.26 DirectoryAccessor **accessor);
2.27
2.28 - virtual long remove_object(const char *path, fileid_t fileid);
2.29 + virtual long remove_object(fileid_t fileid);
2.30
2.31 - virtual long rename_object(const char *source, fileid_t source_fileid,
2.32 - const char *target);
2.33 + virtual long rename_object(const char *source, const char *target);
2.34
2.35 - virtual long unlink_object(const char *path, fileid_t fileid);
2.36 + virtual long unlink_object(fileid_t parent_fileid, fileid_t fileid);
2.37 };
2.38
2.39 // vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/libfsserver/include/fsserver/file_opening.h Wed Feb 09 22:30:29 2022 +0100
3.2 +++ b/libfsserver/include/fsserver/file_opening.h Thu Feb 10 17:55:05 2022 +0100
3.3 @@ -31,27 +31,25 @@
3.4 class FileOpening
3.5 {
3.6 public:
3.7 - virtual bool accessing_directory(const char *path, flags_t flags, fileid_t fileid) = 0;
3.8 + virtual bool accessing_directory(flags_t flags, fileid_t fileid) = 0;
3.9
3.10 - virtual bool accessing_file(const char *path, flags_t flags, fileid_t fileid) = 0;
3.11 + virtual bool accessing_file(flags_t flags, fileid_t fileid) = 0;
3.12
3.13 virtual long get_fileid(const char *path, flags_t flags, fileid_t *fileid) = 0;
3.14
3.15 virtual long get_parent(const char *path, fileid_t *fileid);
3.16
3.17 - virtual long make_accessor(const char *path, flags_t flags, fileid_t fileid,
3.18 + virtual long make_accessor(flags_t flags, fileid_t fileid,
3.19 Accessor **accessor) = 0;
3.20
3.21 - virtual long make_directory_accessor(const char *path, flags_t flags,
3.22 - fileid_t fileid,
3.23 + virtual long make_directory_accessor(flags_t flags, fileid_t fileid,
3.24 DirectoryAccessor **accessor) = 0;
3.25
3.26 - virtual long remove_object(const char *path, fileid_t fileid) = 0;
3.27 + virtual long remove_object(fileid_t fileid) = 0;
3.28
3.29 - virtual long rename_object(const char *source, fileid_t source_fileid,
3.30 - const char *target) = 0;
3.31 + virtual long rename_object(const char *source, const char *target) = 0;
3.32
3.33 - virtual long unlink_object(const char *path, fileid_t fileid) = 0;
3.34 + virtual long unlink_object(fileid_t parent_fileid, fileid_t fileid) = 0;
3.35 };
3.36
3.37 // vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/libfsserver/include/fsserver/host_file_opener.h Wed Feb 09 22:30:29 2022 +0100
4.2 +++ b/libfsserver/include/fsserver/host_file_opener.h Thu Feb 10 17:55:05 2022 +0100
4.3 @@ -32,6 +32,7 @@
4.4 /* Collection data types. */
4.5
4.6 typedef std::map<std::string, fileid_t> HostFileIdentifiers;
4.7 +typedef std::map<fileid_t, std::string> HostFilePaths;
4.8
4.9
4.10
4.11 @@ -45,14 +46,17 @@
4.12 /* File identifier register. */
4.13
4.14 HostFileIdentifiers _fileids;
4.15 + HostFilePaths _paths;
4.16
4.17 virtual fileid_t _get_fileid(const char *path, bool create);
4.18
4.19 + virtual const char *_get_path(fileid_t fileid);
4.20 +
4.21 /* Convenience methods determining different object types. */
4.22
4.23 - virtual bool accessing_directory(const char *path, flags_t flags, fileid_t fileid);
4.24 + virtual bool accessing_directory(flags_t flags, fileid_t fileid);
4.25
4.26 - virtual bool accessing_file(const char *path, flags_t flags, fileid_t fileid);
4.27 + virtual bool accessing_file(flags_t flags, fileid_t fileid);
4.28
4.29 public:
4.30 explicit HostFileOpener(ResourceRegistry *registry)
4.31 @@ -66,19 +70,17 @@
4.32
4.33 virtual long get_fileid(const char *path, flags_t flags, fileid_t *fileid);
4.34
4.35 - virtual long make_accessor(const char *path, flags_t flags, fileid_t fileid,
4.36 + virtual long make_accessor(flags_t flags, fileid_t fileid,
4.37 Accessor **accessor);
4.38
4.39 - virtual long make_directory_accessor(const char *path, flags_t flags,
4.40 - fileid_t fileid,
4.41 + virtual long make_directory_accessor(flags_t flags, fileid_t fileid,
4.42 DirectoryAccessor **accessor);
4.43
4.44 - virtual long remove_object(const char *path, fileid_t fileid);
4.45 + virtual long remove_object(fileid_t fileid);
4.46
4.47 - virtual long rename_object(const char *source, fileid_t source_fileid,
4.48 - const char *target);
4.49 + virtual long rename_object(const char *source, const char *target);
4.50
4.51 - virtual long unlink_object(const char *path, fileid_t fileid);
4.52 + virtual long unlink_object(fileid_t parent_fileid, fileid_t fileid);
4.53 };
4.54
4.55 // vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/libfsserver/include/fsserver/resource_registry.h Wed Feb 09 22:30:29 2022 +0100
5.2 +++ b/libfsserver/include/fsserver/resource_registry.h Thu Feb 10 17:55:05 2022 +0100
5.3 @@ -1,7 +1,7 @@
5.4 /*
5.5 * A registry of filesystem object resources.
5.6 *
5.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
5.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
5.9 *
5.10 * This program is free software; you can redistribute it and/or
5.11 * modify it under the terms of the GNU General Public License as
5.12 @@ -41,22 +41,18 @@
5.13
5.14 /* Provider initialisation methods. */
5.15
5.16 - long make_directory_provider(FileOpening *opening, const char *path,
5.17 - flags_t flags, fileid_t fileid,
5.18 - Provider **provider);
5.19 + long make_directory_provider(FileOpening *opening, flags_t flags,
5.20 + fileid_t fileid, Provider **provider);
5.21
5.22 - long make_file_provider(FileOpening *opening, const char *path,
5.23 - flags_t flags, fileid_t fileid,
5.24 - Provider **provider);
5.25 + long make_file_provider(FileOpening *opening, flags_t flags,
5.26 + fileid_t fileid, Provider **provider);
5.27
5.28 - long make_provider(FileOpening *opening, const char *path,
5.29 - flags_t flags, fileid_t fileid,
5.30 - Provider **provider);
5.31 + long make_provider(FileOpening *opening, flags_t flags,
5.32 + fileid_t fileid, Provider **provider);
5.33
5.34 /* Provider manipulation methods. */
5.35
5.36 - long _remove_provider(FileOpening *opening, const char *path,
5.37 - fileid_t fileid);
5.38 + long _remove_provider(FileOpening *opening, const char *path, fileid_t fileid);
5.39
5.40 public:
5.41 explicit ResourceRegistry(Pages *pages);
6.1 --- a/libfsserver/include/fsserver/test_file_opener.h Wed Feb 09 22:30:29 2022 +0100
6.2 +++ b/libfsserver/include/fsserver/test_file_opener.h Thu Feb 10 17:55:05 2022 +0100
6.3 @@ -34,9 +34,9 @@
6.4
6.5 /* Convenience methods determining different object types. */
6.6
6.7 - virtual bool accessing_directory(const char *path, flags_t flags, fileid_t fileid);
6.8 + virtual bool accessing_directory(flags_t flags, fileid_t fileid);
6.9
6.10 - virtual bool accessing_file(const char *path, flags_t flags, fileid_t fileid);
6.11 + virtual bool accessing_file(flags_t flags, fileid_t fileid);
6.12
6.13 public:
6.14 explicit TestFileOpener(ResourceRegistry *registry, offset_t file_size=0);
6.15 @@ -47,19 +47,17 @@
6.16
6.17 virtual long get_fileid(const char *path, flags_t flags, fileid_t *fileid);
6.18
6.19 - virtual long make_accessor(const char *path, flags_t flags, fileid_t fileid,
6.20 + virtual long make_accessor(flags_t flags, fileid_t fileid,
6.21 Accessor **accessor);
6.22
6.23 - virtual long make_directory_accessor(const char *path, flags_t flags,
6.24 - fileid_t fileid,
6.25 + virtual long make_directory_accessor(flags_t flags, fileid_t fileid,
6.26 DirectoryAccessor **accessor);
6.27
6.28 - virtual long remove_object(const char *path, fileid_t fileid);
6.29 + virtual long remove_object(fileid_t fileid);
6.30
6.31 - virtual long rename_object(const char *source, fileid_t source_fileid,
6.32 - const char *target);
6.33 + virtual long rename_object(const char *source, const char *target);
6.34
6.35 - virtual long unlink_object(const char *path, fileid_t fileid);
6.36 + virtual long unlink_object(fileid_t parent_fileid, fileid_t fileid);
6.37 };
6.38
6.39 // vim: tabstop=4 expandtab shiftwidth=4
7.1 --- a/libfsserver/lib/files/block_file_opener.cc Wed Feb 09 22:30:29 2022 +0100
7.2 +++ b/libfsserver/lib/files/block_file_opener.cc Thu Feb 10 17:55:05 2022 +0100
7.3 @@ -1,7 +1,7 @@
7.4 /*
7.5 * An opener for a file employing a rewritable memory area.
7.6 *
7.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
7.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
7.9 *
7.10 * This program is free software; you can redistribute it and/or
7.11 * modify it under the terms of the GNU General Public License as
7.12 @@ -57,9 +57,14 @@
7.13
7.14 /* Return a new accessor for 'fileid'. */
7.15
7.16 -long BlockFileOpener::make_accessor(const char *path, flags_t flags,
7.17 - fileid_t fileid, Accessor **accessor)
7.18 +long BlockFileOpener::make_accessor(flags_t flags, fileid_t fileid,
7.19 + Accessor **accessor)
7.20 {
7.21 + const char *path = _get_path(fileid);
7.22 +
7.23 + if (path == NULL)
7.24 + return -L4_ENOENT;
7.25 +
7.26 FILE *fp = fopen(path, "r");
7.27
7.28 if (fp == NULL)
8.1 --- a/libfsserver/lib/files/ext2_file_opener.cc Wed Feb 09 22:30:29 2022 +0100
8.2 +++ b/libfsserver/lib/files/ext2_file_opener.cc Thu Feb 10 17:55:05 2022 +0100
8.3 @@ -38,17 +38,17 @@
8.4
8.5 /* Test if a directory is being accessed. */
8.6
8.7 -bool Ext2FileOpener::accessing_directory(const char *path, flags_t flags, fileid_t fileid)
8.8 +bool Ext2FileOpener::accessing_directory(flags_t flags, fileid_t fileid)
8.9 {
8.10 - (void) path; (void) flags;
8.11 + (void) flags;
8.12 return _ops->is_directory((ext2_ino_t) fileid);
8.13 }
8.14
8.15 /* Test if a file is being accessed. */
8.16
8.17 -bool Ext2FileOpener::accessing_file(const char *path, flags_t flags, fileid_t fileid)
8.18 +bool Ext2FileOpener::accessing_file(flags_t flags, fileid_t fileid)
8.19 {
8.20 - (void) path; (void) flags;
8.21 + (void) flags;
8.22 return _ops->is_file((ext2_ino_t) fileid);
8.23 }
8.24
8.25 @@ -96,10 +96,10 @@
8.26
8.27 /* Return a new accessor for 'fileid'. */
8.28
8.29 -long Ext2FileOpener::make_accessor(const char *path, flags_t flags,
8.30 - fileid_t fileid, Accessor **accessor)
8.31 +long Ext2FileOpener::make_accessor(flags_t flags, fileid_t fileid,
8.32 + Accessor **accessor)
8.33 {
8.34 - (void) path; (void) flags;
8.35 + (void) flags;
8.36
8.37 ext2_file_t file;
8.38 long err = _ops->open_file((ext2_ino_t) fileid, &file);
8.39 @@ -113,11 +113,10 @@
8.40
8.41 /* Return a directory object reference for the given file identifier. */
8.42
8.43 -long Ext2FileOpener::make_directory_accessor(const char *path, flags_t flags,
8.44 - fileid_t fileid,
8.45 +long Ext2FileOpener::make_directory_accessor(flags_t flags, fileid_t fileid,
8.46 DirectoryAccessor **accessor)
8.47 {
8.48 - (void) path; (void) flags;
8.49 + (void) flags;
8.50
8.51 *accessor = new Ext2DirectoryAccessor(_ops, fileid);
8.52 return L4_EOK;
8.53 @@ -125,22 +124,22 @@
8.54
8.55 /* Remove a filesystem object. */
8.56
8.57 -long Ext2FileOpener::remove_object(const char *path, fileid_t fileid)
8.58 +long Ext2FileOpener::remove_object(fileid_t fileid)
8.59 {
8.60 - (void) path;
8.61 -
8.62 return _ops->remove((ext2_ino_t) fileid);
8.63 }
8.64
8.65 /* Rename a filesystem object, placing source inside the parent of target. */
8.66
8.67 -long Ext2FileOpener::rename_object(const char *source, fileid_t source_fileid,
8.68 - const char *target)
8.69 +long Ext2FileOpener::rename_object(const char *source, const char *target)
8.70 {
8.71 - (void) source;
8.72 + fileid_t source_fileid, source_parent, target_parent;
8.73 + long err;
8.74
8.75 - fileid_t source_parent, target_parent;
8.76 - long err;
8.77 + err = get_fileid(source, 0, &source_fileid);
8.78 +
8.79 + if (err)
8.80 + return err;
8.81
8.82 err = get_parent(source, &source_parent);
8.83
8.84 @@ -159,15 +158,9 @@
8.85
8.86 /* Unlink a filesystem object. */
8.87
8.88 -long Ext2FileOpener::unlink_object(const char *path, fileid_t fileid)
8.89 +long Ext2FileOpener::unlink_object(fileid_t parent_fileid, fileid_t fileid)
8.90 {
8.91 - fileid_t parent;
8.92 - long err = get_parent(path, &parent);
8.93 -
8.94 - if (err)
8.95 - return err;
8.96 -
8.97 - return _ops->unlink((ext2_ino_t) parent, (ext2_ino_t) fileid);
8.98 + return _ops->unlink((ext2_ino_t) parent_fileid, (ext2_ino_t) fileid);
8.99 }
8.100
8.101 // vim: tabstop=4 expandtab shiftwidth=4
9.1 --- a/libfsserver/lib/files/host_file_opener.cc Wed Feb 09 22:30:29 2022 +0100
9.2 +++ b/libfsserver/lib/files/host_file_opener.cc Thu Feb 10 17:55:05 2022 +0100
9.3 @@ -36,9 +36,15 @@
9.4 {
9.5 }
9.6
9.7 -bool HostFileOpener::accessing_directory(const char *path, flags_t flags, fileid_t fileid)
9.8 +bool HostFileOpener::accessing_directory(flags_t flags, fileid_t fileid)
9.9 {
9.10 - (void) flags; (void) fileid;
9.11 + (void) flags;
9.12 +
9.13 + const char *path = _get_path(fileid);
9.14 +
9.15 + if (path == NULL)
9.16 + return false;
9.17 +
9.18 struct stat st;
9.19
9.20 if (stat(path, &st))
9.21 @@ -47,11 +53,16 @@
9.22 return (st.st_mode & S_IFDIR) ? true : false;
9.23 }
9.24
9.25 -bool HostFileOpener::accessing_file(const char *path, flags_t flags, fileid_t fileid)
9.26 +bool HostFileOpener::accessing_file(flags_t flags, fileid_t fileid)
9.27 {
9.28 - (void) flags; (void) fileid;
9.29 + (void) flags;
9.30 struct stat st;
9.31
9.32 + const char *path = _get_path(fileid);
9.33 +
9.34 + if (path == NULL)
9.35 + return false;
9.36 +
9.37 if (stat(path, &st))
9.38 return false;
9.39
9.40 @@ -99,19 +110,37 @@
9.41 fileid_t fileid = _fileids.size();
9.42
9.43 _fileids[s] = fileid;
9.44 + _paths[fileid] = s;
9.45
9.46 return fileid;
9.47 }
9.48
9.49 +const char *HostFileOpener::_get_path(fileid_t fileid)
9.50 +{
9.51 + std::lock_guard<std::mutex> guard(_lock);
9.52 +
9.53 + HostFilePaths::iterator it = _paths.find(fileid);
9.54 +
9.55 + if (it != _paths.end())
9.56 + return it->second.c_str();
9.57 + else
9.58 + return NULL;
9.59 +}
9.60 +
9.61 /* Return a new accessor for 'fileid'. */
9.62
9.63 -long HostFileOpener::make_accessor(const char *path, flags_t flags,
9.64 - fileid_t fileid, Accessor **accessor)
9.65 +long HostFileOpener::make_accessor(flags_t flags, fileid_t fileid,
9.66 + Accessor **accessor)
9.67 {
9.68 // NOTE: Not testing for create or write flags.
9.69
9.70 (void) flags;
9.71
9.72 + const char *path = _get_path(fileid);
9.73 +
9.74 + if (path == NULL)
9.75 + return -L4_ENOENT;
9.76 +
9.77 FILE *fp = fopen(path, "r");
9.78
9.79 if (fp == NULL)
9.80 @@ -123,11 +152,15 @@
9.81
9.82 /* Return a directory accessor for 'fileid'. */
9.83
9.84 -long HostFileOpener::make_directory_accessor(const char *path, flags_t flags,
9.85 - fileid_t fileid,
9.86 +long HostFileOpener::make_directory_accessor(flags_t flags, fileid_t fileid,
9.87 DirectoryAccessor **accessor)
9.88 {
9.89 - (void) flags; (void) fileid;
9.90 + (void) flags;
9.91 +
9.92 + const char *path = _get_path(fileid);
9.93 +
9.94 + if (path == NULL)
9.95 + return -L4_ENOENT;
9.96
9.97 *accessor = new HostDirectoryAccessor(path);
9.98 return L4_EOK;
9.99 @@ -135,19 +168,16 @@
9.100
9.101 /* Remove a filesystem object. */
9.102
9.103 -long HostFileOpener::remove_object(const char *path, fileid_t fileid)
9.104 +long HostFileOpener::remove_object(fileid_t fileid)
9.105 {
9.106 - (void) path; (void) fileid;
9.107 + (void) fileid;
9.108 return L4_EOK;
9.109 }
9.110
9.111 /* Rename a filesystem object, placing source inside the parent of target. */
9.112
9.113 -long HostFileOpener::rename_object(const char *source, fileid_t source_fileid,
9.114 - const char *target)
9.115 +long HostFileOpener::rename_object(const char *source, const char *target)
9.116 {
9.117 - (void) source_fileid;
9.118 -
9.119 /* NOTE: Should propagate a more meaningful error. */
9.120
9.121 if (rename(source, target))
9.122 @@ -158,11 +188,16 @@
9.123
9.124 /* Unlink a filesystem object. */
9.125
9.126 -long HostFileOpener::unlink_object(const char *path, fileid_t fileid)
9.127 +long HostFileOpener::unlink_object(fileid_t parent_fileid, fileid_t fileid)
9.128 {
9.129 - /* Ignore the fileid and always use the path. */
9.130 + /* Ignore the parent and always use the path. */
9.131 +
9.132 + (void) parent_fileid;
9.133
9.134 - (void) fileid;
9.135 + const char *path = _get_path(fileid);
9.136 +
9.137 + if (path == NULL)
9.138 + return -L4_ENOENT;
9.139
9.140 // NOTE: Return code may need converting.
9.141
9.142 @@ -180,6 +215,11 @@
9.143 if (it != _fileids.end())
9.144 _fileids.erase(it);
9.145
9.146 + HostFilePaths::iterator pit = _paths.find(fileid);
9.147 +
9.148 + if (pit != _paths.end())
9.149 + _paths.erase(pit);
9.150 +
9.151 return L4_EOK;
9.152 }
9.153
10.1 --- a/libfsserver/lib/files/test_file_opener.cc Wed Feb 09 22:30:29 2022 +0100
10.2 +++ b/libfsserver/lib/files/test_file_opener.cc Thu Feb 10 17:55:05 2022 +0100
10.3 @@ -1,7 +1,7 @@
10.4 /*
10.5 * An opener for a test file containing generated content.
10.6 *
10.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
10.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
10.9 *
10.10 * This program is free software; you can redistribute it and/or
10.11 * modify it under the terms of the GNU General Public License as
10.12 @@ -35,15 +35,15 @@
10.13 {
10.14 }
10.15
10.16 -bool TestFileOpener::accessing_directory(const char *path, flags_t flags, fileid_t fileid)
10.17 +bool TestFileOpener::accessing_directory(flags_t flags, fileid_t fileid)
10.18 {
10.19 - (void) path; (void) flags; (void) fileid;
10.20 + (void) flags; (void) fileid;
10.21 return false;
10.22 }
10.23
10.24 -bool TestFileOpener::accessing_file(const char *path, flags_t flags, fileid_t fileid)
10.25 +bool TestFileOpener::accessing_file(flags_t flags, fileid_t fileid)
10.26 {
10.27 - (void) path; (void) flags; (void) fileid;
10.28 + (void) flags; (void) fileid;
10.29 return true;
10.30 }
10.31
10.32 @@ -61,46 +61,44 @@
10.33
10.34 /* Return a new accessor for 'fileid'. */
10.35
10.36 -long TestFileOpener::make_accessor(const char *path, flags_t flags,
10.37 - fileid_t fileid, Accessor **accessor)
10.38 +long TestFileOpener::make_accessor(flags_t flags, fileid_t fileid,
10.39 + Accessor **accessor)
10.40 {
10.41 - (void) flags; (void) path;
10.42 + (void) flags;
10.43 *accessor = new TestFileAccessor(fileid, _file_size);
10.44 return L4_EOK;
10.45 }
10.46
10.47 /* Return a new directory accessor for 'fileid'. */
10.48
10.49 -long TestFileOpener::make_directory_accessor(const char *path, flags_t flags,
10.50 - fileid_t fileid,
10.51 +long TestFileOpener::make_directory_accessor(flags_t flags, fileid_t fileid,
10.52 DirectoryAccessor **accessor)
10.53 {
10.54 - (void) flags; (void) path; (void) fileid; (void) accessor;
10.55 + (void) flags; (void) fileid; (void) accessor;
10.56 return -L4_EIO;
10.57 }
10.58
10.59 /* Remove a filesystem object. */
10.60
10.61 -long TestFileOpener::remove_object(const char *path, fileid_t fileid)
10.62 +long TestFileOpener::remove_object(fileid_t fileid)
10.63 {
10.64 - (void) path; (void) fileid;
10.65 + (void) fileid;
10.66 return L4_EOK;
10.67 }
10.68
10.69 /* Rename a filesystem object, placing source inside the parent of target. */
10.70
10.71 -long TestFileOpener::rename_object(const char *source, fileid_t source_fileid,
10.72 - const char *target)
10.73 +long TestFileOpener::rename_object(const char *source, const char *target)
10.74 {
10.75 - (void) source; (void) source_fileid; (void) target;
10.76 + (void) source; (void) target;
10.77 return -L4_EIO;
10.78 }
10.79
10.80 /* Unlink a filesystem object. */
10.81
10.82 -long TestFileOpener::unlink_object(const char *path, fileid_t fileid)
10.83 +long TestFileOpener::unlink_object(fileid_t parent_fileid, fileid_t fileid)
10.84 {
10.85 - (void) path; (void) fileid;
10.86 + (void) parent_fileid; (void) fileid;
10.87 return -L4_EIO;
10.88 }
10.89
11.1 --- a/libfsserver/lib/generic/resource_registry.cc Wed Feb 09 22:30:29 2022 +0100
11.2 +++ b/libfsserver/lib/generic/resource_registry.cc Thu Feb 10 17:55:05 2022 +0100
11.3 @@ -49,14 +49,14 @@
11.4 /* Make a directory provider. */
11.5
11.6 long ResourceRegistry::make_directory_provider(FileOpening *opening,
11.7 - const char *path, flags_t flags,
11.8 + flags_t flags,
11.9 fileid_t fileid,
11.10 Provider **provider)
11.11 {
11.12 /* Make an accessor and a provider to encapsulate it. */
11.13
11.14 DirectoryAccessor *accessor;
11.15 - long err = opening->make_directory_accessor(path, flags, fileid, &accessor);
11.16 + long err = opening->make_directory_accessor(flags, fileid, &accessor);
11.17
11.18 if (err)
11.19 return err;
11.20 @@ -68,14 +68,14 @@
11.21 /* Make a file provider. */
11.22
11.23 long ResourceRegistry::make_file_provider(FileOpening *opening,
11.24 - const char *path, flags_t flags,
11.25 + flags_t flags,
11.26 fileid_t fileid,
11.27 Provider **provider)
11.28 {
11.29 /* Make an accessor, page mapper, and a provider to encapsulate them. */
11.30
11.31 Accessor *accessor;
11.32 - long err = opening->make_accessor(path, flags, fileid, &accessor);
11.33 + long err = opening->make_accessor(flags, fileid, &accessor);
11.34
11.35 if (err)
11.36 return err;
11.37 @@ -88,16 +88,16 @@
11.38 /* Make a provider of the appropriate type. */
11.39
11.40 long ResourceRegistry::make_provider(FileOpening *opening,
11.41 - const char *path, flags_t flags,
11.42 + flags_t flags,
11.43 fileid_t fileid,
11.44 Provider **provider)
11.45 {
11.46 long err = -L4_EIO;
11.47
11.48 - if (opening->accessing_directory(path, flags, fileid))
11.49 - err = make_directory_provider(opening, path, flags, fileid, provider);
11.50 - else if (opening->accessing_file(path, flags, fileid))
11.51 - err = make_file_provider(opening, path, flags, fileid, provider);
11.52 + if (opening->accessing_directory(flags, fileid))
11.53 + err = make_directory_provider(opening, flags, fileid, provider);
11.54 + else if (opening->accessing_file(flags, fileid))
11.55 + err = make_file_provider(opening, flags, fileid, provider);
11.56
11.57 if (err)
11.58 return err;
11.59 @@ -160,7 +160,7 @@
11.60 /* Make a new provider if necessary. */
11.61
11.62 if (err == -L4_ENOENT)
11.63 - err = make_provider(opening, path, flags, fileid, &provider);
11.64 + err = make_provider(opening, flags, fileid, &provider);
11.65
11.66 if (err)
11.67 return err;
11.68 @@ -200,9 +200,16 @@
11.69 if (err && (err != -L4_ENOENT))
11.70 return err;
11.71
11.72 + fileid_t parent_fileid;
11.73 +
11.74 + err = opening->get_parent(path, &parent_fileid);
11.75 +
11.76 + if (err)
11.77 + return err;
11.78 +
11.79 /* Unlink the object regardless of whether it can be removed. */
11.80
11.81 - err = opening->unlink_object(path, fileid);
11.82 + err = opening->unlink_object(parent_fileid, fileid);
11.83
11.84 if (err)
11.85 return err;
11.86 @@ -210,7 +217,7 @@
11.87 /* Without a provider being active, remove the object directly. */
11.88
11.89 if (err)
11.90 - return opening->remove_object(path, fileid);
11.91 + return opening->remove_object(fileid);
11.92
11.93 /* With a provider active, request the object's removal upon closure. */
11.94
11.95 @@ -240,7 +247,7 @@
11.96 directory. An empty directory will be replaced by the source
11.97 directory. */
11.98
11.99 - if (opening->accessing_directory(source, 0, source_fileid))
11.100 + if (opening->accessing_directory(0, source_fileid))
11.101 {
11.102 err = opening->get_fileid(target, 0, &target_fileid);
11.103
11.104 @@ -253,7 +260,7 @@
11.105 {
11.106 /* NOTE: Should really use the equivalent of ENOTDIR. */
11.107
11.108 - if (!opening->accessing_directory(target, 0, target_fileid))
11.109 + if (!opening->accessing_directory(0, target_fileid))
11.110 return -L4_EIO;
11.111
11.112 /* NOTE: Test for empty directory. */
11.113 @@ -269,13 +276,13 @@
11.114 /* The source directory is moved within the filesystem to the parent of
11.115 the indicated target. */
11.116
11.117 - return opening->rename_object(source, source_fileid, target);
11.118 + return opening->rename_object(source, target);
11.119 }
11.120
11.121 /* If source is a file, the target must be a new or existing file, not a
11.122 directory. An existing file will be replaced. */
11.123
11.124 - else if (opening->accessing_file(source, 0, source_fileid))
11.125 + else if (opening->accessing_file(0, source_fileid))
11.126 {
11.127 err = opening->get_fileid(target, 0, &target_fileid);
11.128
11.129 @@ -286,7 +293,7 @@
11.130 {
11.131 /* NOTE: Should really use the equivalent of EISDIR. */
11.132
11.133 - if (!opening->accessing_file(target, 0, target_fileid))
11.134 + if (!opening->accessing_file(0, target_fileid))
11.135 return -L4_EIO;
11.136
11.137 /* The existing file will be removed. */
11.138 @@ -300,7 +307,7 @@
11.139 /* The source file is moved within the filesystem to the parent of the
11.140 indicated target. */
11.141
11.142 - return opening->rename_object(source, source_fileid, target);
11.143 + return opening->rename_object(source, target);
11.144 }
11.145
11.146 /* NOTE: Other object types are to be supported. */