]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
hostfs: pass 64-bit timestamps to/from user space
authorArnd Bergmann <arnd@arndb.de>
Tue, 12 Jun 2018 13:31:17 +0000 (15:31 +0200)
committerArnd Bergmann <arnd@arndb.de>
Wed, 18 Dec 2019 17:07:32 +0000 (18:07 +0100)
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>
fs/hostfs/hostfs.h
fs/hostfs/hostfs_kern.c

index f4295aa1935031439d3b1ded21c4c78a7dc5ed7a..69cb796f62702f65c0aedfb295e2082147863762 100644 (file)
  * is on, and remove the appropriate bits from attr->ia_mode (attr is a
  * "struct iattr *"). -BlaisorBlade
  */
+struct hostfs_timespec {
+       long long tv_sec;
+       long long tv_nsec;
+};
 
 struct hostfs_iattr {
-       unsigned int    ia_valid;
-       unsigned short  ia_mode;
-       uid_t           ia_uid;
-       gid_t           ia_gid;
-       loff_t          ia_size;
-       struct timespec ia_atime;
-       struct timespec ia_mtime;
-       struct timespec ia_ctime;
+       unsigned int            ia_valid;
+       unsigned short          ia_mode;
+       uid_t                   ia_uid;
+       gid_t                   ia_gid;
+       loff_t                  ia_size;
+       struct hostfs_timespec  ia_atime;
+       struct hostfs_timespec  ia_mtime;
+       struct hostfs_timespec  ia_ctime;
 };
 
 struct hostfs_stat {
@@ -56,7 +60,7 @@ struct hostfs_stat {
        unsigned int uid;
        unsigned int gid;
        unsigned long long size;
-       struct timespec atime, mtime, ctime;
+       struct hostfs_timespec atime, mtime, ctime;
        unsigned int blksize;
        unsigned long long blocks;
        unsigned int maj;
index 5a7eb0c79839ed59830209baa94cf08afa3a351e..e6b8c49076bbcdbebad6a557c744a6c1546c385d 100644 (file)
@@ -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;