Skip to content

Commit

Permalink
[nfs] - make impl compatible with latest libnfs and avoid usage of of…
Browse files Browse the repository at this point in the history
…f64_t and size_t
  • Loading branch information
Memphiz committed May 4, 2012
1 parent 9347332 commit 23ce80d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
36 changes: 18 additions & 18 deletions xbmc/filesystem/DllLibNfs.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class DllLibNfsInterface
virtual void free_nfs_srvr_list(struct nfs_server_list *srv)=0; virtual void free_nfs_srvr_list(struct nfs_server_list *srv)=0;
virtual struct nfs_context *nfs_init_context(void)=0; virtual struct nfs_context *nfs_init_context(void)=0;
virtual void nfs_destroy_context(struct nfs_context *nfs)=0; virtual void nfs_destroy_context(struct nfs_context *nfs)=0;
virtual size_t nfs_get_readmax(struct nfs_context *nfs)=0; virtual uint64_t nfs_get_readmax(struct nfs_context *nfs)=0;
virtual size_t nfs_get_writemax(struct nfs_context *nfs)=0; virtual uint64_t nfs_get_writemax(struct nfs_context *nfs)=0;
virtual char *nfs_get_error(struct nfs_context *nfs)=0; virtual char *nfs_get_error(struct nfs_context *nfs)=0;
virtual int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh)=0; virtual int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh)=0;
virtual int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh)=0; virtual int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh)=0;
Expand All @@ -57,8 +57,8 @@ class DllLibNfsInterface
virtual int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname)=0; virtual int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname)=0;
virtual int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st)=0; virtual int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st)=0;
virtual int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st)=0; virtual int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st)=0;
virtual int nfs_truncate(struct nfs_context *nfs, const char *path, off64_t length)=0; virtual int nfs_truncate(struct nfs_context *nfs, const char *path, uint64_t length)=0;
virtual int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, off64_t length)=0; virtual int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length)=0;
virtual int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir)=0; virtual int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir)=0;
virtual int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs)=0; virtual int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs)=0;
virtual int nfs_chmod(struct nfs_context *nfs, const char *path, int mode)=0; virtual int nfs_chmod(struct nfs_context *nfs, const char *path, int mode)=0;
Expand All @@ -73,12 +73,12 @@ class DllLibNfsInterface
virtual int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid)=0; virtual int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid)=0;
virtual int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid)=0; virtual int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid)=0;
virtual int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh)=0; virtual int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh)=0;
virtual int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf)=0; virtual int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf)=0;
virtual int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf)=0; virtual int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf)=0;
virtual int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh)=0; virtual int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh)=0;
virtual int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, off64_t offset, size_t count, char *buf)=0; virtual int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf)=0;
virtual int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, off64_t offset, size_t count, char *buf)=0; virtual int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf)=0;
virtual int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, off64_t offset, int whence, off64_t *current_offset)=0; virtual int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, int whence, uint64_t *current_offset)=0;
}; };


class DllLibNfs : public DllDynamic, DllLibNfsInterface class DllLibNfs : public DllDynamic, DllLibNfsInterface
Expand All @@ -90,8 +90,8 @@ class DllLibNfs : public DllDynamic, DllLibNfsInterface
DEFINE_METHOD1(struct exportnode *, mount_getexports, (const char *p1)) DEFINE_METHOD1(struct exportnode *, mount_getexports, (const char *p1))
DEFINE_METHOD1(void, mount_free_export_list, (struct exportnode *p1)) DEFINE_METHOD1(void, mount_free_export_list, (struct exportnode *p1))
DEFINE_METHOD1(void, nfs_destroy_context, (struct nfs_context *p1)) DEFINE_METHOD1(void, nfs_destroy_context, (struct nfs_context *p1))
DEFINE_METHOD1(size_t, nfs_get_readmax, (struct nfs_context *p1)) DEFINE_METHOD1(uint64_t, nfs_get_readmax, (struct nfs_context *p1))
DEFINE_METHOD1(size_t, nfs_get_writemax, (struct nfs_context *p1)) DEFINE_METHOD1(uint64_t, nfs_get_writemax, (struct nfs_context *p1))
DEFINE_METHOD1(char *, nfs_get_error, (struct nfs_context *p1)) DEFINE_METHOD1(char *, nfs_get_error, (struct nfs_context *p1))
DEFINE_METHOD2(struct nfsdirent *, nfs_readdir, (struct nfs_context *p1, struct nfsdir *p2)) DEFINE_METHOD2(struct nfsdirent *, nfs_readdir, (struct nfs_context *p1, struct nfsdir *p2))
DEFINE_METHOD2(int, nfs_fsync, (struct nfs_context *p1, struct nfsfh *p2)) DEFINE_METHOD2(int, nfs_fsync, (struct nfs_context *p1, struct nfsfh *p2))
Expand All @@ -103,8 +103,8 @@ class DllLibNfs : public DllDynamic, DllLibNfsInterface
DEFINE_METHOD3(int, nfs_mount, (struct nfs_context *p1, const char *p2, const char *p3)) DEFINE_METHOD3(int, nfs_mount, (struct nfs_context *p1, const char *p2, const char *p3))
DEFINE_METHOD3(int, nfs_stat, (struct nfs_context *p1, const char *p2, struct stat *p3)) DEFINE_METHOD3(int, nfs_stat, (struct nfs_context *p1, const char *p2, struct stat *p3))
DEFINE_METHOD3(int, nfs_fstat, (struct nfs_context *p1, struct nfsfh *p2, struct stat *p3)) DEFINE_METHOD3(int, nfs_fstat, (struct nfs_context *p1, struct nfsfh *p2, struct stat *p3))
DEFINE_METHOD3(int, nfs_truncate, (struct nfs_context *p1, const char *p2, off64_t p3)) DEFINE_METHOD3(int, nfs_truncate, (struct nfs_context *p1, const char *p2, uint64_t p3))
DEFINE_METHOD3(int, nfs_ftruncate, (struct nfs_context *p1, struct nfsfh *p2, off64_t p3)) DEFINE_METHOD3(int, nfs_ftruncate, (struct nfs_context *p1, struct nfsfh *p2, uint64_t p3))
DEFINE_METHOD3(int, nfs_opendir, (struct nfs_context *p1, const char *p2, struct nfsdir **p3)) DEFINE_METHOD3(int, nfs_opendir, (struct nfs_context *p1, const char *p2, struct nfsdir **p3))
DEFINE_METHOD3(int, nfs_statvfs, (struct nfs_context *p1, const char *p2, struct statvfs *p3)) DEFINE_METHOD3(int, nfs_statvfs, (struct nfs_context *p1, const char *p2, struct statvfs *p3))
DEFINE_METHOD3(int, nfs_chmod, (struct nfs_context *p1, const char *p2, int p3)) DEFINE_METHOD3(int, nfs_chmod, (struct nfs_context *p1, const char *p2, int p3))
Expand All @@ -116,15 +116,15 @@ class DllLibNfs : public DllDynamic, DllLibNfsInterface
DEFINE_METHOD3(int, nfs_rename, (struct nfs_context *p1, const char *p2, const char *p3)) DEFINE_METHOD3(int, nfs_rename, (struct nfs_context *p1, const char *p2, const char *p3))
DEFINE_METHOD3(int, nfs_link, (struct nfs_context *p1, const char *p2, const char *p3)) DEFINE_METHOD3(int, nfs_link, (struct nfs_context *p1, const char *p2, const char *p3))
DEFINE_METHOD4(int, nfs_open, (struct nfs_context *p1, const char *p2, int p3, struct nfsfh **p4)) DEFINE_METHOD4(int, nfs_open, (struct nfs_context *p1, const char *p2, int p3, struct nfsfh **p4))
DEFINE_METHOD4(int, nfs_read, (struct nfs_context *p1, struct nfsfh *p2, size_t p3, char *p4)) DEFINE_METHOD4(int, nfs_read, (struct nfs_context *p1, struct nfsfh *p2, uint64_t p3, char *p4))
DEFINE_METHOD4(int, nfs_write, (struct nfs_context *p1, struct nfsfh *p2, size_t p3, char *p4)) DEFINE_METHOD4(int, nfs_write, (struct nfs_context *p1, struct nfsfh *p2, uint64_t p3, char *p4))
DEFINE_METHOD4(int, nfs_creat, (struct nfs_context *p1, const char *p2, int p3, struct nfsfh **p4)) DEFINE_METHOD4(int, nfs_creat, (struct nfs_context *p1, const char *p2, int p3, struct nfsfh **p4))
DEFINE_METHOD4(int, nfs_readlink, (struct nfs_context *p1, const char *p2, char *p3, int p4)) DEFINE_METHOD4(int, nfs_readlink, (struct nfs_context *p1, const char *p2, char *p3, int p4))
DEFINE_METHOD4(int, nfs_chown, (struct nfs_context *p1, const char *p2, int p3, int p4)) DEFINE_METHOD4(int, nfs_chown, (struct nfs_context *p1, const char *p2, int p3, int p4))
DEFINE_METHOD4(int, nfs_fchown, (struct nfs_context *p1, struct nfsfh *p2, int p3, int p4)) DEFINE_METHOD4(int, nfs_fchown, (struct nfs_context *p1, struct nfsfh *p2, int p3, int p4))
DEFINE_METHOD5(int, nfs_pread, (struct nfs_context *p1, struct nfsfh *p2, off64_t p3, size_t p4, char *p5)) DEFINE_METHOD5(int, nfs_pread, (struct nfs_context *p1, struct nfsfh *p2, uint64_t p3, uint64_t p4, char *p5))
DEFINE_METHOD5(int, nfs_pwrite, (struct nfs_context *p1, struct nfsfh *p2, off64_t p3, size_t p4, char *p5)) DEFINE_METHOD5(int, nfs_pwrite, (struct nfs_context *p1, struct nfsfh *p2, uint64_t p3, uint64_t p4, char *p5))
DEFINE_METHOD5(int, nfs_lseek, (struct nfs_context *p1, struct nfsfh *p2, off64_t p3, int p4, off64_t *p5)) DEFINE_METHOD5(int, nfs_lseek, (struct nfs_context *p1, struct nfsfh *p2, uint64_t p3, int p4, uint64_t *p5))






Expand Down
10 changes: 5 additions & 5 deletions xbmc/filesystem/NFSFile.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void CNfsConnection::resetKeepAlive(struct nfsfh *_pFileHandle)
//we were before //we were before
void CNfsConnection::keepAlive(struct nfsfh *_pFileHandle) void CNfsConnection::keepAlive(struct nfsfh *_pFileHandle)
{ {
off64_t offset = 0; uint64_t offset = 0;
char buffer[32]; char buffer[32];
CLog::Log(LOGNOTICE, "NFS: sending keep alive after %i s.",KEEP_ALIVE_TIMEOUT/2); CLog::Log(LOGNOTICE, "NFS: sending keep alive after %i s.",KEEP_ALIVE_TIMEOUT/2);
CSingleLock lock(*this); CSingleLock lock(*this);
Expand Down Expand Up @@ -461,7 +461,7 @@ CNFSFile::~CNFSFile()
int64_t CNFSFile::GetPosition() int64_t CNFSFile::GetPosition()
{ {
int ret = 0; int ret = 0;
off64_t offset = 0; uint64_t offset = 0;
CSingleLock lock(gNfsConnection); CSingleLock lock(gNfsConnection);


if (gNfsConnection.GetNfsContext() == NULL || m_pFileHandle == NULL) return 0; if (gNfsConnection.GetNfsContext() == NULL || m_pFileHandle == NULL) return 0;
Expand Down Expand Up @@ -587,7 +587,7 @@ unsigned int CNFSFile::Read(void *lpBuf, int64_t uiBufSize)


if (m_pFileHandle == NULL || m_pNfsContext == NULL ) return 0; if (m_pFileHandle == NULL || m_pNfsContext == NULL ) return 0;


numberOfBytesRead = gNfsConnection.GetImpl()->nfs_read(m_pNfsContext, m_pFileHandle, (size_t)uiBufSize, (char *)lpBuf); numberOfBytesRead = gNfsConnection.GetImpl()->nfs_read(m_pNfsContext, m_pFileHandle, uiBufSize, (char *)lpBuf);


lock.Leave();//no need to keep the connection lock after that lock.Leave();//no need to keep the connection lock after that


Expand All @@ -605,7 +605,7 @@ unsigned int CNFSFile::Read(void *lpBuf, int64_t uiBufSize)
int64_t CNFSFile::Seek(int64_t iFilePosition, int iWhence) int64_t CNFSFile::Seek(int64_t iFilePosition, int iWhence)
{ {
int ret = 0; int ret = 0;
off64_t offset = 0; uint64_t offset = 0;


CSingleLock lock(gNfsConnection); CSingleLock lock(gNfsConnection);
if (m_pFileHandle == NULL || m_pNfsContext == NULL) return -1; if (m_pFileHandle == NULL || m_pNfsContext == NULL) return -1;
Expand Down Expand Up @@ -667,7 +667,7 @@ int CNFSFile::Write(const void* lpBuf, int64_t uiBufSize)
//write chunk //write chunk
writtenBytes = gNfsConnection.GetImpl()->nfs_write(m_pNfsContext, writtenBytes = gNfsConnection.GetImpl()->nfs_write(m_pNfsContext,
m_pFileHandle, m_pFileHandle,
(size_t)chunkSize, chunkSize,
(char *)lpBuf + numberOfBytesWritten); (char *)lpBuf + numberOfBytesWritten);
//decrease left bytes //decrease left bytes
leftBytes-= writtenBytes; leftBytes-= writtenBytes;
Expand Down
8 changes: 4 additions & 4 deletions xbmc/filesystem/NFSFile.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class CNfsConnection : public CCriticalSection
~CNfsConnection(); ~CNfsConnection();
bool Connect(const CURL &url, CStdString &relativePath); bool Connect(const CURL &url, CStdString &relativePath);
struct nfs_context *GetNfsContext(){return m_pNfsContext;} struct nfs_context *GetNfsContext(){return m_pNfsContext;}
size_t GetMaxReadChunkSize(){return m_readChunkSize;} uint64_t GetMaxReadChunkSize(){return m_readChunkSize;}
size_t GetMaxWriteChunkSize(){return m_writeChunkSize;} uint64_t GetMaxWriteChunkSize(){return m_writeChunkSize;}
DllLibNfs *GetImpl(){return m_pLibNfs;} DllLibNfs *GetImpl(){return m_pLibNfs;}
std::list<CStdString> GetExportList(const CURL &url); std::list<CStdString> GetExportList(const CURL &url);
//this functions splits the url into the exportpath (feed to mount) and the rest of the path //this functions splits the url into the exportpath (feed to mount) and the rest of the path
Expand Down Expand Up @@ -96,8 +96,8 @@ class CNfsConnection : public CCriticalSection
CStdString m_exportPath;//current connected export path CStdString m_exportPath;//current connected export path
CStdString m_hostName;//current connected host CStdString m_hostName;//current connected host
CStdString m_resolvedHostName;//current connected host - as ip CStdString m_resolvedHostName;//current connected host - as ip
size_t m_readChunkSize;//current read chunksize of connected server uint64_t m_readChunkSize;//current read chunksize of connected server
size_t m_writeChunkSize;//current write chunksize of connected server uint64_t m_writeChunkSize;//current write chunksize of connected server
int m_OpenConnections;//number of open connections int m_OpenConnections;//number of open connections
unsigned int m_IdleTimeout;//timeout for idle connection close and dyunload unsigned int m_IdleTimeout;//timeout for idle connection close and dyunload
tFileKeepAliveMap m_KeepAliveTimeouts;//mapping filehandles to its idle timeout tFileKeepAliveMap m_KeepAliveTimeouts;//mapping filehandles to its idle timeout
Expand Down

0 comments on commit 23ce80d

Please sign in to comment.