svn commit: r226621 - stable/9/sbin/tunefs

[ Available lists | Index of svn-src-all | Month of Oct 2011 | Week of 21 Oct 2011 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Kirk McKusick <mckusick@FreeBSD.org>
Date
21 Oct 2011 22:07:52
Subject
svn commit: r226621 - stable/9/sbin/tunefs
Message-ID
201110212207.p9LM7q1K043348@svn.freebsd.org


[ Hide this part ]
Author: mckusick
Date: Fri Oct 21 22:07:52 2011
New Revision: 226621
URL: http://svn.freebsd.org/changeset/base/226621

Log:
MFC 226266:
After creating a filesystem using newfs -j the time stamps are all
zero and thus report as having been made in January 1970. Apart
from looking a bit silly, it also triggers alarms from scripts
that detect weird time stamps. This update sets all 4 (or 3, in
the case of UFS1) time stamps to the current time when enabling
journaling during newfs or later when enabling it with tunefs.

Reported by: Hans Ottevanger <hans@beastielabs.net>
Approved by: re (kib)

Modified:
stable/9/sbin/tunefs/tunefs.c

Modified: stable/9/sbin/tunefs/tunefs.c
==============================================================================
--- stable/9/sbin/tunefs/tunefs.c Fri Oct 21 21:49:34 2011 (r226620)
+++ stable/9/sbin/tunefs/tunefs.c Fri Oct 21 22:07:52 2011 (r226621)
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>

/* the optimization warning string template */
@@ -923,6 +924,7 @@ journal_alloc(int64_t size)
ino_t ino;
int blks;
int mode;
+ time_t utime;
int i;

cgp = &disk.d_cg;
@@ -983,18 +985,26 @@ journal_alloc(int64_t size)
*/
dp2 = ip;
dp1 = ip;
+ time(&utime);
if (sblock.fs_magic == FS_UFS1_MAGIC) {
bzero(dp1, sizeof(*dp1));
dp1->di_size = size;
dp1->di_mode = IFREG | IREAD;
dp1->di_nlink = 1;
dp1->di_flags = SF_IMMUTABLE | SF_NOUNLINK | UF_NODUMP;
+ dp1->di_atime = utime;
+ dp1->di_mtime = utime;
+ dp1->di_ctime = utime;
} else {
bzero(dp2, sizeof(*dp2));
dp2->di_size = size;
dp2->di_mode = IFREG | IREAD;
dp2->di_nlink = 1;
dp2->di_flags = SF_IMMUTABLE | SF_NOUNLINK | UF_NODUMP;
+ dp2->di_atime = utime;
+ dp2->di_mtime = utime;
+ dp2->di_ctime = utime;
+ dp2->di_birthtime = utime;
}
for (i = 0; i < NDADDR && resid; i++, resid--) {
blk = journal_balloc();


Elapsed time: 0.152 seconds