lib/nfs/Connection: use nfs_fstat64_async()
This is 64-bit-safe and anyway, nfs_fstat_async() doesn't work with NFSv4.
This commit is contained in:
parent
67f01fbdb6
commit
9947d3e67f
|
@ -74,7 +74,7 @@ NfsConnection::CancellableCallback::Stat(nfs_context *ctx,
|
|||
{
|
||||
assert(connection.GetEventLoop().IsInside());
|
||||
|
||||
int result = nfs_fstat_async(ctx, fh, Callback, this);
|
||||
int result = nfs_fstat64_async(ctx, fh, Callback, this);
|
||||
if (result < 0)
|
||||
throw NfsClientError(ctx, "nfs_fstat_async() failed");
|
||||
}
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
#include "event/Call.hxx"
|
||||
#include "util/ASCII.hxx"
|
||||
|
||||
#include <nfsc/libnfs.h> // for struct nfs_stat_64
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h> // for S_ISREG()
|
||||
|
||||
NfsFileReader::NfsFileReader() noexcept
|
||||
:defer_open(nfs_get_event_loop(), BIND_THIS_METHOD(OnDeferredOpen))
|
||||
|
@ -180,7 +183,7 @@ NfsFileReader::OpenCallback(nfsfh *_fh) noexcept
|
|||
}
|
||||
|
||||
inline void
|
||||
NfsFileReader::StatCallback(const struct stat *_st) noexcept
|
||||
NfsFileReader::StatCallback(const struct nfs_stat_64 *_st) noexcept
|
||||
{
|
||||
assert(connection != nullptr);
|
||||
assert(fh != nullptr);
|
||||
|
@ -195,12 +198,12 @@ NfsFileReader::StatCallback(const struct stat *_st) noexcept
|
|||
const auto *st = _st;
|
||||
#endif
|
||||
|
||||
if (!S_ISREG(st->st_mode)) {
|
||||
if (!S_ISREG(st->nfs_mode)) {
|
||||
OnNfsFileError(std::make_exception_ptr(std::runtime_error("Not a regular file")));
|
||||
return;
|
||||
}
|
||||
|
||||
OnNfsFileOpen(st->st_size);
|
||||
OnNfsFileOpen(st->nfs_size);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -219,7 +222,7 @@ NfsFileReader::OnNfsCallback(unsigned status, void *data) noexcept
|
|||
break;
|
||||
|
||||
case State::STAT:
|
||||
StatCallback((const struct stat *)data);
|
||||
StatCallback((const struct nfs_stat_64 *)data);
|
||||
break;
|
||||
|
||||
case State::READ:
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
#include <span>
|
||||
#include <string>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
struct nfsfh;
|
||||
struct nfs_stat_64;
|
||||
class NfsConnection;
|
||||
|
||||
/**
|
||||
|
@ -126,7 +125,7 @@ private:
|
|||
void CancelOrClose() noexcept;
|
||||
|
||||
void OpenCallback(nfsfh *_fh) noexcept;
|
||||
void StatCallback(const struct stat *st) noexcept;
|
||||
void StatCallback(const struct nfs_stat_64 *st) noexcept;
|
||||
|
||||
/* virtual methods from NfsLease */
|
||||
void OnNfsConnectionReady() noexcept final;
|
||||
|
|
Loading…
Reference in New Issue