diff --git a/dokan_fuse/include/fuse_win.h b/dokan_fuse/include/fuse_win.h index 681f1dd66..5e63ff42f 100644 --- a/dokan_fuse/include/fuse_win.h +++ b/dokan_fuse/include/fuse_win.h @@ -101,14 +101,19 @@ struct flock { ///////////////////////////////////////////////////////////////////// #if defined(_MSC_VER) //UNIX compatibility +typedef struct timespec timestruc_t; typedef unsigned int mode_t; +typedef unsigned short nlink_t; typedef unsigned int pid_t; typedef unsigned int gid_t; typedef unsigned int uid_t; +typedef unsigned int blksize_t; +typedef unsigned __int64 blkcnt_t; typedef unsigned int uint32_t; typedef unsigned __int64 uint64_t; typedef __int64 int64_t; + //OCTAL constants! #define S_IFLNK 0120000 #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) @@ -154,7 +159,36 @@ struct flock { #else #define FUSE_OFF_T __int64 -#define FUSE_STAT _stati64 +// #define FUSE_STAT _stati64 +// use stat from cygwin instead for having more members and +// being more compatible +// stat ported from cygwin sys/stat.h +struct stat64_cygwin +{ + dev_t st_dev; + uint64_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + FUSE_OFF_T st_size; + timestruc_t st_atim; + timestruc_t st_mtim; + timestruc_t st_ctim; + blksize_t st_blksize; + blkcnt_t st_blocks; + timestruc_t st_birthtim; +}; +/* The following breaks struct stat definiton in native Windows stats.h +* So whenever referencing st_atime|st_ctime|st_mtime, replacing is needed. +*/ +/* +#define st_atime st_atim.tv_sec +#define st_ctime st_ctim.tv_sec +#define st_mtime st_mtim.tv_sec +*/ +#define FUSE_STAT stat64_cygwin #if 0 struct stat64 { dev_t st_dev; diff --git a/dokan_fuse/include/utils.h b/dokan_fuse/include/utils.h index 3899f1c26..e6fb56145 100644 --- a/dokan_fuse/include/utils.h +++ b/dokan_fuse/include/utils.h @@ -40,12 +40,12 @@ template void convertStatlikeBuf(const struct FUSE_STAT *stbuf, const s find_data->nFileSizeLow=(DWORD) stbuf->st_size; find_data->nFileSizeHigh=stbuf->st_size>>32; #endif - if (stbuf->st_ctime!=0) - find_data->ftCreationTime=unixTimeToFiletime(stbuf->st_ctime); - if (stbuf->st_atime!=0) - find_data->ftLastAccessTime=unixTimeToFiletime(stbuf->st_atime); - if (stbuf->st_mtime!=0) - find_data->ftLastWriteTime=unixTimeToFiletime(stbuf->st_mtime); + if (stbuf->st_ctim.tv_sec!=0) + find_data->ftCreationTime=unixTimeToFiletime(stbuf->st_ctim.tv_sec); + if (stbuf->st_atim.tv_sec!=0) + find_data->ftLastAccessTime=unixTimeToFiletime(stbuf->st_atim.tv_sec); + if (stbuf->st_mtim.tv_sec!=0) + find_data->ftLastWriteTime=unixTimeToFiletime(stbuf->st_mtim.tv_sec); //TODO: add support for read-only files - try to derive it from file's owner? std::string fname=extract_file_name(name); diff --git a/dokan_fuse/src/fusemain.cpp b/dokan_fuse/src/fusemain.cpp index 8342b75ee..d399fff46 100644 --- a/dokan_fuse/src/fusemain.cpp +++ b/dokan_fuse/src/fusemain.cpp @@ -794,18 +794,18 @@ int impl_fuse_context::set_file_time(PCWSTR file_name, const FILETIME* creation_ struct timespec tv[2]={0}; //TODO: support nanosecond resolution //Access time - CHECKED(helper_set_time_struct(last_access_time,st.st_atime,&(tv[0].tv_sec))); + CHECKED(helper_set_time_struct(last_access_time,st.st_atim.tv_sec,&(tv[0].tv_sec))); //Modification time - CHECKED(helper_set_time_struct(last_write_time,st.st_mtime,&(tv[1].tv_sec))); + CHECKED(helper_set_time_struct(last_write_time,st.st_mtim.tv_sec,&(tv[1].tv_sec))); return ops_.utimens(fname.c_str(),tv); } else { struct utimbuf ut={0}; //Access time - CHECKED(helper_set_time_struct(last_access_time,st.st_atime,&(ut.actime))); + CHECKED(helper_set_time_struct(last_access_time,st.st_atim.tv_sec,&(ut.actime))); //Modification time - CHECKED(helper_set_time_struct(last_write_time,st.st_mtime,&(ut.modtime))); + CHECKED(helper_set_time_struct(last_write_time,st.st_mtim.tv_sec,&(ut.modtime))); return ops_.utime(fname.c_str(),&ut); }