From: "Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
y2038@lists.linaro.org, Jeff Layton <jlayton@redhat.com>,
Jan Kara <jack@suse.cz>, Deepa Dinamani <deepa.kernel@gmail.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] hfs: stop using timespec based interfaces
Date: Tue, 31 Jul 2018 20:37:57 -0300 [thread overview]
Message-ID: <20180731233756.24555xk6dvs5hfjb@eaf> (raw)
In-Reply-To: <20180619160223.4108556-1-arnd@arndb.de>
If you decide to go with this series after all:
On Tue, Jun 19, 2018 at 06:02:07PM +0200, Arnd Bergmann wrote:
> The native HFS timestamps overflow in year 2040, two years after the Unix
> y2038 overflow. However, the way that the conversion between on-disk
> timestamps and in-kernel timestamps was implemented, 64-bit machines
> actually ended up converting negative UTC timestamps (1902 through 1969)
> into times between 2038 and 2106.
>
> Rather than making all machines faithfully represent timestamps in the
> ancient past but break after 2040, this changes the file system to
> always use the unsigned UTC interpretation, reading back times between
> 1970 and 2106.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> fs/hfs/hfs_fs.h | 6 ++++--
> fs/hfs/inode.c | 4 ++--
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
> index 6d0783e2e276..ff432931a5b1 100644
> --- a/fs/hfs/hfs_fs.h
> +++ b/fs/hfs/hfs_fs.h
> @@ -245,6 +245,8 @@ extern void hfs_mark_mdb_dirty(struct super_block *sb);
> * Unix: unsigned lil-endian since 00:00 GMT, Jan. 1, 1970
> * mac: unsigned big-endian since 00:00 GMT, Jan. 1, 1904
> *
> + * We treat all timestamps before 1970 as times after 2038, so this
^^^^
Same as the hfsplus patch, I find this confusing. I think it should say 2040.
Everything else looks good.
Reviewed-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
> + * actually works until year 2106
> */
> #define __hfs_u_to_mtime(sec) cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60)
> #define __hfs_m_to_utime(sec) (be32_to_cpu(sec) - 2082844800U + sys_tz.tz_minuteswest * 60)
> @@ -252,9 +254,9 @@ extern void hfs_mark_mdb_dirty(struct super_block *sb);
> #define HFS_I(inode) (container_of(inode, struct hfs_inode_info, vfs_inode))
> #define HFS_SB(sb) ((struct hfs_sb_info *)(sb)->s_fs_info)
>
> -#define hfs_m_to_utime(time) (struct timespec){ .tv_sec = __hfs_m_to_utime(time) }
> +#define hfs_m_to_utime(time) (struct timespec64){ .tv_sec = __hfs_m_to_utime(time) }
> #define hfs_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec)
> -#define hfs_mtime() __hfs_u_to_mtime(get_seconds())
> +#define hfs_mtime() __hfs_u_to_mtime(ktime_get_real_seconds())
>
> static inline const char *hfs_mdb_name(struct super_block *sb)
> {
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index 2a16111d312f..b3309b83371a 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -351,7 +351,7 @@ static int hfs_read_inode(struct inode *inode, void *data)
> inode->i_mode &= ~hsb->s_file_umask;
> inode->i_mode |= S_IFREG;
> inode->i_ctime = inode->i_atime = inode->i_mtime =
> - timespec_to_timespec64(hfs_m_to_utime(rec->file.MdDat));
> + hfs_m_to_utime(rec->file.MdDat);
> inode->i_op = &hfs_file_inode_operations;
> inode->i_fop = &hfs_file_operations;
> inode->i_mapping->a_ops = &hfs_aops;
> @@ -362,7 +362,7 @@ static int hfs_read_inode(struct inode *inode, void *data)
> HFS_I(inode)->fs_blocks = 0;
> inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask);
> inode->i_ctime = inode->i_atime = inode->i_mtime =
> - timespec_to_timespec64(hfs_m_to_utime(rec->dir.MdDat));
> + hfs_m_to_utime(rec->dir.MdDat);
> inode->i_op = &hfs_dir_inode_operations;
> inode->i_fop = &hfs_dir_operations;
> break;
> --
> 2.9.0
>
prev parent reply other threads:[~2018-07-31 23:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 16:02 [PATCH 1/3] hfs: stop using timespec based interfaces Arnd Bergmann
2018-06-19 16:02 ` [PATCH 2/3] hfsplus: " Arnd Bergmann
2018-06-24 3:11 ` Ernesto A. Fernández
2018-06-19 16:02 ` [PATCH 3/3] hfsplus: return inode birthtime for statx Arnd Bergmann
2018-06-20 22:45 ` Ernesto A. Fernández
2018-06-22 14:32 ` Arnd Bergmann
2018-06-19 17:03 ` [PATCH 1/3] hfs: stop using timespec based interfaces Viacheslav Dubeyko
2018-06-19 19:42 ` Arnd Bergmann
2018-06-20 16:55 ` Viacheslav Dubeyko
2018-06-20 19:55 ` Arnd Bergmann
2018-06-22 14:19 ` Arnd Bergmann
2018-07-31 23:37 ` Ernesto A. Fernández [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180731233756.24555xk6dvs5hfjb@eaf \
--to=ernesto.mnd.fernandez@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=deepa.kernel@gmail.com \
--cc=jack@suse.cz \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=y2038@lists.linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).