diff --git a/lib/libufs/inode.c b/lib/libufs/inode.c index bc4d99c66203..a93e1b085342 100644 --- a/lib/libufs/inode.c +++ b/lib/libufs/inode.c @@ -57,7 +57,8 @@ getinode(struct uufsd *disk, union dinodep *dp, ino_t inum) ino_t min, max; caddr_t inoblock; struct fs *fs; - struct timespec now; + struct timespec time; + time_t now; ERROR(disk, NULL); @@ -70,10 +71,11 @@ getinode(struct uufsd *disk, union dinodep *dp, ino_t inum) min = disk->d_inomin; max = disk->d_inomax; - if (clock_gettime(CLOCK_REALTIME_FAST, &now) != 0) { - ERROR(disk, "cannot get current time of day"); - return (-1); - } + if (clock_gettime(CLOCK_REALTIME_FAST, &time) == 0 && + time.tv_sec > fs->fs_time) + now = time.tv_sec; + else + now = fs->fs_time; if (inum >= min && inum < max) goto gotit; bread(disk, fsbtodb(fs, ino_to_fsba(fs, inum)), inoblock, @@ -83,7 +85,7 @@ getinode(struct uufsd *disk, union dinodep *dp, ino_t inum) gotit: switch (disk->d_ufs) { case 1: disk->d_dp.dp1 = &((struct ufs1_dinode *)inoblock)[inum - min]; - if (ffs_oldfscompat_inode_read(fs, disk->d_dp, now.tv_sec)) + if (ffs_oldfscompat_inode_read(fs, disk->d_dp, now)) putinode(disk); if (dp != NULL) *dp = disk->d_dp; @@ -93,8 +95,7 @@ gotit: switch (disk->d_ufs) { if (dp != NULL) *dp = disk->d_dp; if (ffs_verify_dinode_ckhash(fs, disk->d_dp.dp2) == 0) { - if (ffs_oldfscompat_inode_read(fs, disk->d_dp, - now.tv_sec)) + if (ffs_oldfscompat_inode_read(fs, disk->d_dp, now)) putinode(disk); return (0); } diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index b30e3aa5068b..f8e32bf4b157 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -647,7 +647,8 @@ setinodebuf(int cg, ino_t inosused) * If for some reason getting the time fails, we will use * the last time that the superblock was updated. */ - if (clock_gettime(CLOCK_REALTIME_FAST, &time) == 0) + if (clock_gettime(CLOCK_REALTIME_FAST, &time) == 0 && + time.tv_sec > sblock.fs_time) now = time.tv_sec; else now = sblock.fs_time; diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 8ac2075f8db8..11afa99bea76 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -189,8 +189,10 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struct fs *fs, ino_t ino) { struct ufs1_dinode *dip1; struct ufs2_dinode *dip2; + time_t now; int error; + now = time_second > fs->fs_time ? time_second : fs->fs_time; if (I_IS_UFS1(ip)) { dip1 = ip->i_din1; *dip1 = @@ -203,7 +205,7 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struct fs *fs, ino_t ino) ip->i_gen = dip1->di_gen; ip->i_uid = dip1->di_uid; ip->i_gid = dip1->di_gid; - if (ffs_oldfscompat_inode_read(fs, ip->i_dp, time_second) && + if (ffs_oldfscompat_inode_read(fs, ip->i_dp, now) && fs->fs_ronly == 0) UFS_INODE_SET_FLAG(ip, IN_MODIFIED); return (0); @@ -225,8 +227,7 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struct fs *fs, ino_t ino) ip->i_gen = dip2->di_gen; ip->i_uid = dip2->di_uid; ip->i_gid = dip2->di_gid; - if (ffs_oldfscompat_inode_read(fs, ip->i_dp, time_second) && - fs->fs_ronly == 0) + if (ffs_oldfscompat_inode_read(fs, ip->i_dp, now) && fs->fs_ronly == 0) UFS_INODE_SET_FLAG(ip, IN_MODIFIED); return (0); }