From: Deepa Dinamani <deepa.kernel@gmail.com>
To: linux@armlinux.org.uk, linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de, y2038@lists.linaro.org
Subject: [PATCH] adfs: Fill in max and min timestamps in sb
Date: Mon, 2 Sep 2019 12:12:31 -0700 [thread overview]
Message-ID: <20190902191231.13346-1-deepa.kernel@gmail.com> (raw)
Fill in the appropriate limits to avoid inconsistencies
in the vfs cached inode times when timestamps are
outside the permitted range.
Note that the min timestamp is assumed to be
01 Jan 1970 00:00:00 (Unix epoch). This is consistent
with the way we convert timestamps in adfs_adfs2unix_time().
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
---
This depends on the following patch in Arnd's y2038 tree:
https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground y2038
188d20bcd1eb ("vfs: Add file timestamp range support")
fs/adfs/adfs.h | 13 +++++++++++++
fs/adfs/inode.c | 8 ++++----
fs/adfs/super.c | 2 ++
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
index 699c4fa8b78b..504ad80072ef 100644
--- a/fs/adfs/adfs.h
+++ b/fs/adfs/adfs.h
@@ -3,6 +3,19 @@
#include <linux/fs.h>
#include <linux/adfs_fs.h>
+/*
+ * 01 Jan 1970 00:00:00 (Unix epoch) as seconds since
+ * 01 Jan 1900 00:00:00 (RISC OS epoch)
+ */
+#define RISC_OS_EPOCH_DELTA 2208988800LL
+
+/*
+ * Convert 40 bit centi seconds to seconds
+ * since 01 Jan 1900 00:00:00 (RISC OS epoch)
+ * The result is 2248-06-03 06:57:57 GMT
+ */
+#define ADFS_MAX_TIMESTAMP ((0xFFFFFFFFFFLL / 100) - RISC_OS_EPOCH_DELTA)
+
/* Internal data structures for ADFS */
#define ADFS_FREE_FRAG 0
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 5b8017ab0a98..11acd74fb099 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -162,7 +162,10 @@ static int adfs_mode2atts(struct super_block *sb, struct inode *inode,
return attr;
}
-static const s64 nsec_unix_epoch_diff_risc_os_epoch = 2208988800000000000LL;
+/* 01 Jan 1970 00:00:00 (Unix epoch) as nanoseconds since
+ * 01 Jan 1900 00:00:00 (RISC OS epoch)
+ */
+static const s64 nsec_unix_epoch_diff_risc_os_epoch = RISC_OS_EPOCH_DELTA * NSEC_PER_SEC;
/*
* Convert an ADFS time to Unix time. ADFS has a 40-bit centi-second time
@@ -173,9 +176,6 @@ static void
adfs_adfs2unix_time(struct timespec64 *tv, struct inode *inode)
{
unsigned int high, low;
- /* 01 Jan 1970 00:00:00 (Unix epoch) as nanoseconds since
- * 01 Jan 1900 00:00:00 (RISC OS epoch)
- */
s64 nsec;
if (!adfs_inode_is_stamped(inode))
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 7a3e6b394f2a..532e2afbc7a3 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -381,6 +381,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_fs_info = asb;
sb->s_magic = ADFS_SUPER_MAGIC;
sb->s_time_gran = 10000000;
+ sb->s_time_min = 0;
+ sb->s_time_max = ADFS_MAX_TIMESTAMP;
/* set default options */
asb->s_uid = GLOBAL_ROOT_UID;
--
2.17.1
reply other threads:[~2019-09-02 19:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190902191231.13346-1-deepa.kernel@gmail.com \
--to=deepa.kernel@gmail.com \
--cc=arnd@arndb.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.