diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/nfs/Connection.cxx | 29 | ||||
-rw-r--r-- | src/lib/nfs/Connection.hxx | 2 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/nfs/Connection.cxx b/src/lib/nfs/Connection.cxx index 6b2ef6c3c..664374707 100644 --- a/src/lib/nfs/Connection.cxx +++ b/src/lib/nfs/Connection.cxx @@ -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()); diff --git a/src/lib/nfs/Connection.hxx b/src/lib/nfs/Connection.hxx index 8dee93e10..89d5e0cff 100644 --- a/src/lib/nfs/Connection.hxx +++ b/src/lib/nfs/Connection.hxx @@ -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; |