[OPW,kernel,3/3] fs: pstore: Replace timespec with timespec64
diff mbox

Message ID 1414662162-10988-4-git-send-email-somyaanand214@gmail.com
State New, archived
Headers show

Commit Message

Somya Anand Oct. 30, 2014, 9:42 a.m. UTC
32-bit systems using 'struct timespec' will break in the year 2038,
so we have to replace that code with more appropriate types.

pstore_mkfile(..) is modified to use 'struct timespec64' instead of
'struct timespec'.

getnstimeofday64() is used instead of __getnstimeofday() as it uses
'struct timespec64'.

Signed-off-by: Somya Anand <somyaanand214@gmail.com>
---
 fs/pstore/inode.c    | 2 +-
 fs/pstore/internal.h | 2 +-
 fs/pstore/platform.c | 2 +-
 fs/pstore/ram.c      | 8 ++++----
 4 files changed, 7 insertions(+), 7 deletions(-)

Comments

Arnd Bergmann Oct. 30, 2014, 11:45 a.m. UTC | #1
On Thursday 30 October 2014 15:12:42 Somya Anand wrote:
> @@ -198,11 +198,11 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
>                                      bool compressed)
>  {
>         char *hdr;
> -       struct timespec timestamp;
> +       struct timespec64 timestamp;
>         size_t len;
> -
> +       getnstimeofday64(&timestamp);
>         /* Report zeroed timestamp if called before timekeeping has resumed. */
> -       if (__getnstimeofday(&timestamp)) {
> +       if (timestamp.tv_sec) {
>                 timestamp.tv_sec = 0;
>                 timestamp.tv_nsec = 0;
>         }

Please have a look at getnstimeofday64 and __getnstimeofday to see the
difference regarding what happens when timekeeping is suspended.

	Arnd

Patch
diff mbox

diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index fafb7a0..ce1a093 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -277,7 +277,7 @@  int pstore_is_mounted(void)
  */
 int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
 		  char *data, bool compressed, size_t size,
-		  struct timespec time, struct pstore_info *psi)
+		  struct timespec64 time, struct pstore_info *psi)
 {
 	struct dentry		*root = pstore_sb->s_root;
 	struct dentry		*dentry;
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index 3b3d305..29778d1 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -51,7 +51,7 @@  extern void	pstore_set_kmsg_bytes(int);
 extern void	pstore_get_records(int);
 extern int	pstore_mkfile(enum pstore_type_id, char *psname, u64 id,
 			      int count, char *data, bool compressed,
-			      size_t size, struct timespec time,
+			      size_t size, struct timespec64 time,
 			      struct pstore_info *psi);
 extern int	pstore_is_mounted(void);
 
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 0a9b72c..bc55527 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -475,7 +475,7 @@  void pstore_get_records(int quiet)
 	u64			id;
 	int			count;
 	enum pstore_type_id	type;
-	struct timespec		time;
+	struct timespec64		time;
 	int			failed = 0, rc;
 	bool			compressed;
 	int			unzipped_len = -1;
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 3b57443..85cd7a8 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -135,7 +135,7 @@  ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
 	return prz;
 }
 
-static void ramoops_read_kmsg_hdr(char *buffer, struct timespec *time,
+static void ramoops_read_kmsg_hdr(char *buffer, struct timespec64 *time,
 				  bool *compressed)
 {
 	char data_type;
@@ -198,11 +198,11 @@  static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
 				     bool compressed)
 {
 	char *hdr;
-	struct timespec timestamp;
+	struct timespec64 timestamp;
 	size_t len;
-
+	getnstimeofday64(&timestamp);
 	/* Report zeroed timestamp if called before timekeeping has resumed. */
-	if (__getnstimeofday(&timestamp)) {
+	if (timestamp.tv_sec) {
 		timestamp.tv_sec = 0;
 		timestamp.tv_nsec = 0;
 	}