summaryrefslogtreecommitdiffstats
path: root/fs/hostfs/hostfs_kern.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-06-12 15:31:17 +0200
committerArnd Bergmann <arnd@arndb.de>2019-12-18 18:07:32 +0100
commitbca302651af496615829be13165552a2c160a1a1 (patch)
tree57e77738a2f94df8af441e5c9a6893fd7f0b4ac2 /fs/hostfs/hostfs_kern.c
parentpacket: clarify timestamp overflow (diff)
downloadlinux-bca302651af496615829be13165552a2c160a1a1.tar.xz
linux-bca302651af496615829be13165552a2c160a1a1.zip
hostfs: pass 64-bit timestamps to/from user space
The use of 'struct timespec' is deprecated in the kernel, so we want to avoid the conversions from/to the proper timespec64 structure. On the user space side, we have a 'struct timespec' that is defined by the C library and that will be incompatible with the kernel's view on 32-bit architectures once they move to a 64-bit time_t, breaking the shared binary layout of hostfs_iattr and hostfs_stat. This changes the two structures to use a new hostfs_timespec structure with fixed 64-bit seconds/nanoseconds for passing the timestamps between hostfs_kern.c and hostfs_user.c. With a new enough user space side, this will allow timestamps beyond year 2038. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'fs/hostfs/hostfs_kern.c')
-rw-r--r--fs/hostfs/hostfs_kern.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 5a7eb0c79839..e6b8c49076bb 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -549,9 +549,9 @@ static int read_name(struct inode *ino, char *name)
set_nlink(ino, st.nlink);
i_uid_write(ino, st.uid);
i_gid_write(ino, st.gid);
- ino->i_atime = timespec_to_timespec64(st.atime);
- ino->i_mtime = timespec_to_timespec64(st.mtime);
- ino->i_ctime = timespec_to_timespec64(st.ctime);
+ ino->i_atime = (struct timespec64){ st.atime.tv_sec, st.atime.tv_nsec };
+ ino->i_mtime = (struct timespec64){ st.mtime.tv_sec, st.mtime.tv_nsec };
+ ino->i_ctime = (struct timespec64){ st.ctime.tv_sec, st.ctime.tv_nsec };
ino->i_size = st.size;
ino->i_blocks = st.blocks;
return 0;
@@ -820,15 +820,18 @@ static int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
}
if (attr->ia_valid & ATTR_ATIME) {
attrs.ia_valid |= HOSTFS_ATTR_ATIME;
- attrs.ia_atime = timespec64_to_timespec(attr->ia_atime);
+ attrs.ia_atime = (struct hostfs_timespec)
+ { attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec };
}
if (attr->ia_valid & ATTR_MTIME) {
attrs.ia_valid |= HOSTFS_ATTR_MTIME;
- attrs.ia_mtime = timespec64_to_timespec(attr->ia_mtime);
+ attrs.ia_mtime = (struct hostfs_timespec)
+ { attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec };
}
if (attr->ia_valid & ATTR_CTIME) {
attrs.ia_valid |= HOSTFS_ATTR_CTIME;
- attrs.ia_ctime = timespec64_to_timespec(attr->ia_ctime);
+ attrs.ia_ctime = (struct hostfs_timespec)
+ { attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec };
}
if (attr->ia_valid & ATTR_ATIME_SET) {
attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;