Commit a04e01d5 authored by Thomas Guillem's avatar Thomas Guillem Committed by Max Kellermann

lib/nfs/Connection: add Lstat

parent b03f05f2
......@@ -54,6 +54,18 @@ NfsConnection::CancellableCallback::Stat(nfs_context *ctx,
}
inline void
NfsConnection::CancellableCallback::Lstat(nfs_context *ctx,
const char *path)
{
assert(connection.GetEventLoop().IsInside());
int result = nfs_lstat64_async(ctx, path, Callback, this);
if (result < 0)
throw FormatRuntimeError("nfs_lstat64_async() failed: %s",
nfs_get_error(ctx));
}
inline void
NfsConnection::CancellableCallback::OpenDirectory(nfs_context *ctx,
const char *path)
{
......@@ -232,6 +244,23 @@ NfsConnection::Stat(const char *path, NfsCallback &callback)
}
void
NfsConnection::Lstat(const char *path, NfsCallback &callback)
{
assert(GetEventLoop().IsInside());
assert(!callbacks.Contains(callback));
auto &c = callbacks.Add(callback, *this, false);
try {
c.Lstat(context, path);
} catch (...) {
callbacks.Remove(c);
throw;
}
ScheduleSocket();
}
void
NfsConnection::OpenDirectory(const char *path, NfsCallback &callback)
{
assert(GetEventLoop().IsInside());
......
......@@ -66,6 +66,7 @@ class NfsConnection : SocketMonitor {
open(_open), close_fh(nullptr) {}
void Stat(nfs_context *context, const char *path);
void Lstat(nfs_context *context, const char *path);
void OpenDirectory(nfs_context *context, const char *path);
void Open(nfs_context *context, const char *path, int flags);
void Stat(nfs_context *context, struct nfsfh *fh);
......@@ -175,6 +176,7 @@ public:
void RemoveLease(NfsLease &lease) noexcept;
void Stat(const char *path, NfsCallback &callback);
void Lstat(const char *path, NfsCallback &callback);
void OpenDirectory(const char *path, NfsCallback &callback);
const struct nfsdirent *ReadDirectory(struct nfsdir *dir) noexcept;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment