diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d479f500..8a7d40a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#1100](https://github.com/Azure/azure-storage-fuse/issues/1100) If content-encoding is set in blob then transport layer compression shall be disabled. - Subdir mount is not able to list blobs correctly when virtual-directory is turned on. - Adding support to pass down uid/gid values supplied in mount to libfuse. +- [#1102](https://github.com/Azure/azure-storage-fuse/issues/1102) Remove nanoseconds from file times as storage does not provide that granularity. **Features** - Added new CLI parameter "--sync-to-flush". Once configured sync() call on file will force upload a file to storage container. As this is file handle based api, if file was not in file-cache it will first download and then upload the file. diff --git a/component/libfuse/libfuse2_handler.go b/component/libfuse/libfuse2_handler.go index 47dd4c627..2794a7d74 100644 --- a/component/libfuse/libfuse2_handler.go +++ b/component/libfuse/libfuse2_handler.go @@ -311,13 +311,13 @@ func (lf *Libfuse) fillStat(attr *internal.ObjAttr, stbuf *C.stat_t) { } (*stbuf).st_atim.tv_sec = C.long(attr.Atime.Unix()) - (*stbuf).st_atim.tv_nsec = C.long(attr.Atime.UnixNano()) + (*stbuf).st_atim.tv_nsec = 0 (*stbuf).st_ctim.tv_sec = C.long(attr.Ctime.Unix()) - (*stbuf).st_ctim.tv_nsec = C.long(attr.Ctime.UnixNano()) + (*stbuf).st_ctim.tv_nsec = 0 (*stbuf).st_mtim.tv_sec = C.long(attr.Mtime.Unix()) - (*stbuf).st_mtim.tv_nsec = C.long(attr.Mtime.UnixNano()) + (*stbuf).st_mtim.tv_nsec = 0 } // File System Operations diff --git a/component/libfuse/libfuse2_handler_test_wrapper.go b/component/libfuse/libfuse2_handler_test_wrapper.go index 8cbf60a73..5c78244b4 100644 --- a/component/libfuse/libfuse2_handler_test_wrapper.go +++ b/component/libfuse/libfuse2_handler_test_wrapper.go @@ -202,6 +202,14 @@ func testCreate(suite *libfuseTestSuite) { err := libfuse_create(path, 0775, info) suite.assert.Equal(C.int(0), err) + + option := internal.GetAttrOptions{Name: name} + suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) + stbuf := &C.stat_t{} + err = libfuse2_getattr(path, stbuf) + suite.assert.Equal(C.int(0), err) + suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) + suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) } func testCreateError(suite *libfuseTestSuite) { diff --git a/component/libfuse/libfuse_handler.go b/component/libfuse/libfuse_handler.go index 57cd12310..1ffd89d50 100644 --- a/component/libfuse/libfuse_handler.go +++ b/component/libfuse/libfuse_handler.go @@ -343,13 +343,13 @@ func (lf *Libfuse) fillStat(attr *internal.ObjAttr, stbuf *C.stat_t) { } (*stbuf).st_atim.tv_sec = C.long(attr.Atime.Unix()) - (*stbuf).st_atim.tv_nsec = C.long(attr.Atime.UnixNano()) + (*stbuf).st_atim.tv_nsec = 0 (*stbuf).st_ctim.tv_sec = C.long(attr.Ctime.Unix()) - (*stbuf).st_ctim.tv_nsec = C.long(attr.Ctime.UnixNano()) + (*stbuf).st_ctim.tv_nsec = 0 (*stbuf).st_mtim.tv_sec = C.long(attr.Mtime.Unix()) - (*stbuf).st_mtim.tv_nsec = C.long(attr.Mtime.UnixNano()) + (*stbuf).st_mtim.tv_nsec = 0 } // File System Operations diff --git a/component/libfuse/libfuse_handler_test_wrapper.go b/component/libfuse/libfuse_handler_test_wrapper.go index 4ff4d094b..0c8b66545 100644 --- a/component/libfuse/libfuse_handler_test_wrapper.go +++ b/component/libfuse/libfuse_handler_test_wrapper.go @@ -186,6 +186,13 @@ func testCreate(suite *libfuseTestSuite) { err := libfuse_create(path, 0775, info) suite.assert.Equal(C.int(0), err) + option := internal.GetAttrOptions{Name: name} + suite.mock.EXPECT().GetAttr(option).Return(&internal.ObjAttr{}, nil) + stbuf := &C.stat_t{} + err = libfuse_getattr(path, stbuf, &C.fuse_file_info_t{}) + suite.assert.Equal(C.int(0), err) + suite.assert.Equal(stbuf.st_mtim.tv_nsec, C.long(0)) + suite.assert.NotEqual(stbuf.st_mtim.tv_sec, C.long(0)) } func testCreateError(suite *libfuseTestSuite) {