storage/nfs: implement follow

This commit is contained in:
Thomas Guillem 2015-11-13 17:12:10 +01:00 committed by Max Kellermann
parent a04e01d5f5
commit 735f62be0c

View File

@ -267,10 +267,13 @@ Copy(StorageFileInfo &info, const struct nfs_stat_64 &st) noexcept
class NfsGetInfoOperation final : public BlockingNfsOperation {
const char *const path;
StorageFileInfo info;
bool follow;
public:
NfsGetInfoOperation(NfsConnection &_connection, const char *_path)
:BlockingNfsOperation(_connection), path(_path) {}
NfsGetInfoOperation(NfsConnection &_connection, const char *_path,
bool _follow)
:BlockingNfsOperation(_connection), path(_path),
follow(_follow) {}
const StorageFileInfo &GetInfo() const {
return info;
@ -278,7 +281,10 @@ public:
protected:
void Start() override {
connection.Stat(path, *this);
if (follow)
connection.Stat(path, *this);
else
connection.Lstat(path, *this);
}
void HandleResult(gcc_unused unsigned status, void *data) noexcept override {
@ -287,13 +293,13 @@ protected:
};
StorageFileInfo
NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow)
NfsStorage::GetInfo(const char *uri_utf8, bool follow)
{
const std::string path = UriToNfsPath(uri_utf8);
WaitConnected();
NfsGetInfoOperation operation(*connection, path.c_str());
NfsGetInfoOperation operation(*connection, path.c_str(), follow);
operation.Run();
return operation.GetInfo();
}