Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin Centralize time printing and deal with ctime possibly r...



details:   https://anonhg.NetBSD.org/src/rev/54f6feba098e
branches:  trunk
changeset: 751459:54f6feba098e
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Feb 04 23:55:42 2010 +0000

description:
Centralize time printing and deal with ctime possibly returning NULL.

diffstat:

 sbin/fsck/fsutil.c       |  16 ++++++++++++++--
 sbin/fsck/fsutil.h       |   3 ++-
 sbin/fsck_ext2fs/inode.c |  10 +++-------
 sbin/fsck_ext2fs/pass1.c |  11 +++++------
 sbin/fsck_ffs/inode.c    |  10 +++-------
 sbin/fsck_lfs/inode.c    |   8 ++------
 6 files changed, 29 insertions(+), 29 deletions(-)

diffs (191 lines):

diff -r bbdb7e29c9e9 -r 54f6feba098e sbin/fsck/fsutil.c
--- a/sbin/fsck/fsutil.c        Thu Feb 04 22:56:11 2010 +0000
+++ b/sbin/fsck/fsutil.c        Thu Feb 04 23:55:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fsutil.c,v 1.18 2008/03/16 23:17:55 lukem Exp $        */
+/*     $NetBSD: fsutil.c,v 1.19 2010/02/04 23:55:42 christos Exp $     */
 
 /*
  * Copyright (c) 1990, 1993
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fsutil.c,v 1.18 2008/03/16 23:17:55 lukem Exp $");
+__RCSID("$NetBSD: fsutil.c,v 1.19 2010/02/04 23:55:42 christos Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -244,3 +244,15 @@
         */
        return (origname);
 }
+
+const char *
+print_mtime(time_t t)
+{
+       static char b[128];
+       char *p = ctime(&t);
+       if (p != NULL)
+               (void)snprintf(b, sizeof(b), "%12.12s %4.4s ", &p[4], &p[20]);
+       else
+               (void)snprintf(b, sizeof(b), "%lld ", (long long)t);
+       return b;
+}
diff -r bbdb7e29c9e9 -r 54f6feba098e sbin/fsck/fsutil.h
--- a/sbin/fsck/fsutil.h        Thu Feb 04 22:56:11 2010 +0000
+++ b/sbin/fsck/fsutil.h        Thu Feb 04 23:55:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fsutil.h,v 1.14 2009/10/21 01:07:46 snj Exp $  */
+/*     $NetBSD: fsutil.h,v 1.15 2010/02/04 23:55:42 christos Exp $     */
 
 /*
  * Copyright (c) 1996 Christos Zoulas.  All rights reserved.
@@ -44,6 +44,7 @@
 const char *cdevname(void);
 void setcdevname(const char *, int);
 int  hotroot(void);
+const char *print_mtime(time_t);
 
 #define CHECK_PREEN    1
 #define        CHECK_VERBOSE   2
diff -r bbdb7e29c9e9 -r 54f6feba098e sbin/fsck_ext2fs/inode.c
--- a/sbin/fsck_ext2fs/inode.c  Thu Feb 04 22:56:11 2010 +0000
+++ b/sbin/fsck_ext2fs/inode.c  Thu Feb 04 23:55:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inode.c,v 1.30 2009/10/19 18:41:08 bouyer Exp $        */
+/*     $NetBSD: inode.c,v 1.31 2010/02/04 23:55:42 christos Exp $      */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -58,7 +58,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c    8.5 (Berkeley) 2/8/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.30 2009/10/19 18:41:08 bouyer Exp $");
+__RCSID("$NetBSD: inode.c,v 1.31 2010/02/04 23:55:42 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -612,9 +612,7 @@
 pinode(ino_t ino)
 {
        struct ext2fs_dinode *dp;
-       char *p;
        struct passwd *pw;
-       time_t t;
        uid_t uid;
 
        printf(" I=%llu ", (unsigned long long)ino);
@@ -635,9 +633,7 @@
        if (preen)
                printf("%s: ", cdevname());
        printf("SIZE=%llu ", (long long)inosize(dp));
-       t = fs2h32(dp->e2di_mtime);
-       p = ctime(&t);
-       printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
+       printf("MTIME=%s ", print_mtime(fs2h32(dp->e2di_mtime)));
 }
 
 void
diff -r bbdb7e29c9e9 -r 54f6feba098e sbin/fsck_ext2fs/pass1.c
--- a/sbin/fsck_ext2fs/pass1.c  Thu Feb 04 22:56:11 2010 +0000
+++ b/sbin/fsck_ext2fs/pass1.c  Thu Feb 04 23:55:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pass1.c,v 1.20 2009/10/19 18:41:08 bouyer Exp $        */
+/*     $NetBSD: pass1.c,v 1.21 2010/02/04 23:55:42 christos Exp $      */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -58,7 +58,7 @@
 #if 0
 static char sccsid[] = "@(#)pass1.c    8.1 (Berkeley) 6/5/93";
 #else
-__RCSID("$NetBSD: pass1.c,v 1.20 2009/10/19 18:41:08 bouyer Exp $");
+__RCSID("$NetBSD: pass1.c,v 1.21 2010/02/04 23:55:42 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -201,10 +201,9 @@
        }
        lastino = inumber;
        if (dp->e2di_dtime != 0) {
-               time_t t = fs2h32(dp->e2di_dtime);
-               char *p = ctime(&t);
-               pwarn("INODE I=%llu HAS DTIME=%12.12s %4.4s",
-                   (unsigned long long)inumber, &p[4], &p[20]);
+               pwarn("INODE I=%llu HAS DTIME=%s",
+                   (unsigned long long)inumber,
+                   print_mtime(fs2h32(dp->e2di_dtime)));
                if (preen) {
                        printf(" (CORRECTED)\n");
                }
diff -r bbdb7e29c9e9 -r 54f6feba098e sbin/fsck_ffs/inode.c
--- a/sbin/fsck_ffs/inode.c     Thu Feb 04 22:56:11 2010 +0000
+++ b/sbin/fsck_ffs/inode.c     Thu Feb 04 23:55:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inode.c,v 1.62 2009/04/11 07:32:42 lukem Exp $ */
+/*     $NetBSD: inode.c,v 1.63 2010/02/04 23:55:43 christos Exp $      */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c    8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.62 2009/04/11 07:32:42 lukem Exp $");
+__RCSID("$NetBSD: inode.c,v 1.63 2010/02/04 23:55:43 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -636,9 +636,7 @@
 pinode(ino_t ino)
 {
        union dinode *dp;
-       char *p;
        struct passwd *pw;
-       time_t t;
 
        printf(" I=%llu ", (unsigned long long)ino);
        if (ino < ROOTINO || ino > maxino)
@@ -655,9 +653,7 @@
        if (preen)
                printf("%s: ", cdevname());
        printf("SIZE=%llu ", (unsigned long long)iswap64(DIP(dp, size)));
-       t = iswap32(DIP(dp, mtime));
-       p = ctime(&t);
-       printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
+       printf("MTIME=%s ", print_mtime(iswap32(DIP(dp, mtime))));
 }
 
 void
diff -r bbdb7e29c9e9 -r 54f6feba098e sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c     Thu Feb 04 22:56:11 2010 +0000
+++ b/sbin/fsck_lfs/inode.c     Thu Feb 04 23:55:42 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.40 2008/10/09 16:56:23 christos Exp $   */
+/* $NetBSD: inode.c,v 1.41 2010/02/04 23:55:43 christos Exp $   */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -520,9 +520,7 @@
 pinode(ino_t ino)
 {
        struct ufs1_dinode *dp;
-       char *p;
        struct passwd *pw;
-       time_t t;
 
        printf(" I=%llu ", (unsigned long long)ino);
        if (ino < ROOTINO || ino >= maxino)
@@ -540,9 +538,7 @@
                if (preen)
                        printf("%s: ", cdevname());
                printf("SIZE=%llu ", (unsigned long long) dp->di_size);
-               t = dp->di_mtime;
-               p = ctime(&t);
-               printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
+               printf("MTIME=%s ", print_mtime(dp->di_mtime));
        }
 }
 



Home | Main Index | Thread Index | Old Index