From patchwork Thu Nov 12 13:40:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deng Chao X-Patchwork-Id: 56431 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp421684lbb; Thu, 12 Nov 2015 05:41:08 -0800 (PST) X-Received: by 10.68.216.36 with SMTP id on4mr23558451pbc.12.1447335668406; Thu, 12 Nov 2015 05:41:08 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vz2si20107223pbc.164.2015.11.12.05.41.07; Thu, 12 Nov 2015 05:41:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754001AbbKLNlE (ORCPT + 28 others); Thu, 12 Nov 2015 08:41:04 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:34169 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753644AbbKLNlB (ORCPT ); Thu, 12 Nov 2015 08:41:01 -0500 Received: by padhx2 with SMTP id hx2so65454395pad.1 for ; Thu, 12 Nov 2015 05:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=q8SVMgQDtMYHLHnYp1vT5qnXyj3uMrH4jARTGX911x8=; b=gCw/WFzF+QGzcImof2KNMzVHiahhijg11qlp0sEors8ezp423z7kQ3CAqc+P97GAsr JLuZUq+86viQET1ANNzPsSJicbfjOylh0yikOZ9ZIVg5XPsiO/Wk5I82vDKryDvnlqmp YKXaq0YBx+vjtSqocpYvkjSiVzkkjgmiDJcFJIF5zp05BR7BAy4apLqAx1BYHk/7yo7K cSrLl2GBHSvVRq3AdrB2yEB7t/nQ+PxExk+XTr+gQY8w7QBHtsJw+6CFfRuzUf4YZTC9 m2kDRnBE3XjKNHKUYNFi1WHFwxlRayLukVyEYP+dWWJD4fy11e+yeLx7FXU6et5c1mHe 6VaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=q8SVMgQDtMYHLHnYp1vT5qnXyj3uMrH4jARTGX911x8=; b=TI4hcKAn/Xg2LUDC/xNyokMNvNE2+7jmWovkvLq3wWTqYtfJsz3UWgQJfYF7M5MyDX AXlHBJ3hBGr2isB+tx9CpmQeSXchDCXCyUP37/QsyLiK0NFN5vyc0nzAo+3oEdnvn4zS qxiPqTEtGcLeYVqRA48LPIiRu4iDDCvvfigaSUltnecjgc+FBJnORbP+r+fLlXy3QrrS ebXO0FTXMWQGrzUr6a53RfPWCQ9pwVlIu9V+Fm+ugsgLGAoOoP8BNv+YkLpLEw9zTS0i PBVkuE9FoS+/u6qFuPHIlLDWKSLNZEGuvSJRUcH7bSp6X/z1bQEJBx4je516cuzghkxk zb7w== X-Gm-Message-State: ALoCoQl5DrHDVCbBdUKMN95zEQGbNLpAwpGJm2F9zFXezVz4+LXCwUVbxqIhcq67ETV0gNj6m5d0 X-Received: by 10.66.227.197 with SMTP id sc5mr23321152pac.157.1447335661284; Thu, 12 Nov 2015 05:41:01 -0800 (PST) Received: from localhost.localdomain ([167.160.116.42]) by smtp.gmail.com with ESMTPSA id vk10sm288062pbc.66.2015.11.12.05.40.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Nov 2015 05:41:00 -0800 (PST) From: DengChao To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: y2038@lists.linaro.org, chao.deng@linaro.org Subject: [PATCH] fs:affs:Replace time_t with time64_t Date: Thu, 12 Nov 2015 21:40:41 +0800 Message-Id: <1447335641-14768-1-git-send-email-chao.deng@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The affs code uses "time_t" and "get_seconds()". This will cause problems on 32-bit architectures in 2038 when time_t overflows. This patch replaces them with "time64_t" and "ktime_get_real_seconds()". This patch introduces expensive 64-bit divsion in "secs_to_datestamp()", considering this function is not called so often, the cost should be acceptable. Signed-off-by: DengChao --- fs/affs/affs.h | 2 +- fs/affs/amigaffs.c | 13 +++++++------ fs/affs/super.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/fs/affs/affs.h b/fs/affs/affs.h index c69a87e..cc2b2ef 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -138,7 +138,7 @@ extern int affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh); extern int affs_remove_header(struct dentry *dentry); extern u32 affs_checksum_block(struct super_block *sb, struct buffer_head *bh); extern void affs_fix_checksum(struct super_block *sb, struct buffer_head *bh); -extern void secs_to_datestamp(time_t secs, struct affs_date *ds); +extern void secs_to_datestamp(time64_t secs, struct affs_date *ds); extern umode_t prot_to_mode(u32 prot); extern void mode_to_prot(struct inode *inode); __printf(3, 4) diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index 5fa92bc..d6c7a51 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c @@ -8,6 +8,7 @@ * Please send bug reports to: hjw@zvw.de */ +#include #include "affs.h" /* @@ -366,22 +367,22 @@ affs_fix_checksum(struct super_block *sb, struct buffer_head *bh) } void -secs_to_datestamp(time_t secs, struct affs_date *ds) +secs_to_datestamp(time64_t secs, struct affs_date *ds) { u32 days; u32 minute; + s32 rem; secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60); if (secs < 0) secs = 0; - days = secs / 86400; - secs -= days * 86400; - minute = secs / 60; - secs -= minute * 60; + days = div_s64_rem(secs, 86400, &rem); + minute = rem / 60; + rem -= minute * 60; ds->days = cpu_to_be32(days); ds->mins = cpu_to_be32(minute); - ds->ticks = cpu_to_be32(secs * 50); + ds->ticks = cpu_to_be32(rem * 50); } umode_t diff --git a/fs/affs/super.c b/fs/affs/super.c index 5b50c4c..8836df5 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -32,7 +32,7 @@ affs_commit_super(struct super_block *sb, int wait) struct affs_root_tail *tail = AFFS_ROOT_TAIL(sb, bh); lock_buffer(bh); - secs_to_datestamp(get_seconds(), &tail->disk_change); + secs_to_datestamp(ktime_get_real_seconds(), &tail->disk_change); affs_fix_checksum(sb, bh); unlock_buffer(bh);