Skip to content

Commit

Permalink
Merge pull request elfmz#2566 from elfmz/fix-new-nfs
Browse files Browse the repository at this point in the history
fixing build with recent libnfs
  • Loading branch information
elfmz authored Dec 14, 2024
2 parents e13a9e2 + bbf73ee commit 9ef3316
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion NetRocks/src/Protocol/NFS/ProtocolNFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,11 @@ class NFSFileIO : public IFileReader, public IFileWriter

virtual size_t Read(void *buf, size_t len)
{
#ifdef LIBNFS_API_V2
const auto rc = nfs_read(_nfs->ctx, _file, (char *)buf, len);
#else
const auto rc = nfs_read(_nfs->ctx, _file, len, (char *)buf);
#endif
if (rc < 0)
throw ProtocolError("Read file error", errno);
// uncomment to simulate connection stuck if ( (rand()%100) == 0) sleep(60);
Expand All @@ -518,7 +522,11 @@ class NFSFileIO : public IFileReader, public IFileWriter
virtual void Write(const void *buf, size_t len)
{
if (len > 0) for (;;) {
const auto rc = nfs_write(_nfs->ctx, _file, len, (char *)buf);
#ifdef LIBNFS_API_V2
const auto rc = nfs_write(_nfs->ctx, _file, (const char *)buf, len);
#else
const auto rc = nfs_write(_nfs->ctx, _file, len, (const char *)buf);
#endif
if (rc <= 0)
throw ProtocolError("Write file error", errno);
if ((size_t)rc >= len)
Expand Down

0 comments on commit 9ef3316

Please sign in to comment.