sahlberg / fuse-nfs

A FUSE module for NFSv3/4
GNU General Public License v3.0
172 stars 41 forks source link

Android: stat struct [patch]? #3

Closed ghost closed 8 years ago

ghost commented 8 years ago

In fuse/fuse-nfs.c: function fuse_nfs_getattr You use st_atim, but this member structure isn't defined in the android header files.

I've changed st_atim.tv_sec to st_atime and st_atim.tv_nsec to st_atime_nsec. It compiled and tested it on my device and worked (could mount nfs on my phone). I know not only there need to be tests but it must compile on all the platforms you support. So I don't know if this "solution" doesn't break on your main platforms.

In any case, this works(?) when using the cross compiler for android:

diff --git a/fuse/fuse-nfs.c b/fuse/fuse-nfs.c
index fb5457b..29e0db6 100644
--- a/fuse/fuse-nfs.c
+++ b/fuse/fuse-nfs.c
@@ -50,12 +50,12 @@ static int fuse_nfs_getattr(const char *path, struct stat *stbuf)
        stbuf->st_size         = nfs_st.nfs_size;
        stbuf->st_blksize      = nfs_st.nfs_blksize;
        stbuf->st_blocks       = nfs_st.nfs_blocks;
-       stbuf->st_atim.tv_sec  = nfs_st.nfs_atime;
-       stbuf->st_atim.tv_nsec = nfs_st.nfs_atime_nsec;
-       stbuf->st_mtim.tv_sec  = nfs_st.nfs_mtime;
-       stbuf->st_mtim.tv_nsec = nfs_st.nfs_mtime_nsec;
-       stbuf->st_ctim.tv_sec  = nfs_st.nfs_ctime;
-       stbuf->st_ctim.tv_nsec = nfs_st.nfs_ctime_nsec;
+       stbuf->st_atime        = nfs_st.nfs_atime;
+       stbuf->st_atime_nsec   = nfs_st.nfs_atime_nsec;
+       stbuf->st_mtime        = nfs_st.nfs_mtime;
+       stbuf->st_mtime_nsec   = nfs_st.nfs_mtime_nsec;
+       stbuf->st_ctime        = nfs_st.nfs_ctime;
+       stbuf->st_ctime_nsec   = nfs_st.nfs_ctime_nsec;

        return ret;
 }
sahlberg commented 8 years ago

Thanks.

I have checked in a configure test for linux 2.6+ stat structure and fallback to st_atime[_nsec] if not present. Please try.

On Tue, Oct 4, 2016 at 10:57 AM, nocturnalowl notifications@github.com wrote:

In fuse/fuse-nfs.c: function fuse_nfs_getattr You use st_atim, but this member structure isn't defined in the android header files.

I've changed st_atim.tv_sec to st_atime and st_atim.tv_nsec to st_atime_nsec. It compiled and tested it on my device and worked (could mount nfs on my phone). I know not only there need to be tests but it must compile on all the platforms you support.

In any case, this works(?) when using the cross compiler for android:

diff --git a/fuse/fuse-nfs.c b/fuse/fuse-nfs.c index fb5457b..29e0db6 100644 --- a/fuse/fuse-nfs.c +++ b/fuse/fuse-nfs.c @@ -50,12 +50,12 @@ static int fuse_nfs_getattr(const char path, struct stat stbuf) stbuf->st_size = nfs_st.nfs_size; stbuf->st_blksize = nfs_st.nfs_blksize; stbuf->st_blocks = nfs_st.nfs_blocks;

  • stbuf->st_atim.tv_sec = nfs_st.nfs_atime;
  • stbuf->st_atim.tv_nsec = nfs_st.nfs_atime_nsec;
  • stbuf->st_mtim.tv_sec = nfs_st.nfs_mtime;
  • stbuf->st_mtim.tv_nsec = nfs_st.nfs_mtime_nsec;
  • stbuf->st_ctim.tv_sec = nfs_st.nfs_ctime;
  • stbuf->st_ctim.tv_nsec = nfs_st.nfs_ctime_nsec;
  • stbuf->st_atime = nfs_st.nfs_atime;
  • stbuf->st_atime_nsec = nfs_st.nfs_atime_nsec;
  • stbuf->st_mtime = nfs_st.nfs_mtime;
  • stbuf->st_mtime_nsec = nfs_st.nfs_mtime_nsec;
  • stbuf->st_ctime = nfs_st.nfs_ctime;

    stbuf->st_ctime_nsec = nfs_st.nfs_ctime_nsec;

    return ret;

    }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sahlberg/fuse-nfs/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AAeNkNdwqSt6LTCyJ0NDKVO7m5ZdvelCks5qwpOdgaJpZM4KN-Rv .

ghost commented 8 years ago

Works. You can close this issue.

Thanks