diff options
author | Thomas Guillem <thomas@gllm.fr> | 2015-11-13 17:11:03 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-20 11:29:11 +0200 |
commit | a04e01d5f58332d33a546879183e3c151b66ed5d (patch) | |
tree | 5f749a5eed0e1c25772343d8d7caa3f221b60dcb /src/lib | |
parent | b03f05f28a7f624d88209b5f9ac904d22498168c (diff) |
lib/nfs/Connection: add Lstat
Diffstat (limited to 'src/lib')
-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; |