Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Use nanotime() to update the time fields in filesystems....
details: https://anonhg.NetBSD.org/src/rev/a2779fc7273d
branches: trunk
changeset: 584288:a2779fc7273d
user: christos <christos%NetBSD.org@localhost>
date: Mon Sep 12 16:24:41 2005 +0000
description:
Use nanotime() to update the time fields in filesystems. Convert the code
from macros to real functions. Original patch and review from chuq.
Note: ext2fs only keeps seconds in the on-disk inode, and msdosfs does not
have enough precision for all fields, so this is not very useful for those
two.
diffstat:
sys/fs/msdosfs/denode.h | 20 +++---------
sys/fs/msdosfs/direntry.h | 4 +-
sys/fs/msdosfs/msdosfs_conv.c | 6 +-
sys/fs/msdosfs/msdosfs_vnops.c | 60 ++++++++++++++++++++++++------------
sys/ufs/ext2fs/ext2fs_extern.h | 4 +-
sys/ufs/ext2fs/ext2fs_inode.c | 10 +----
sys/ufs/ext2fs/ext2fs_subr.c | 33 +++++++++++++++++++-
sys/ufs/ext2fs/ext2fs_vnops.c | 8 +---
sys/ufs/ffs/ffs_extern.h | 7 +++-
sys/ufs/ffs/ffs_inode.c | 10 +----
sys/ufs/ffs/ffs_subr.c | 37 +++++++++++++++++++++-
sys/ufs/lfs/lfs.h | 43 ++------------------------
sys/ufs/lfs/lfs_extern.h | 6 +-
sys/ufs/lfs/lfs_inode.c | 10 +----
sys/ufs/lfs/lfs_segment.c | 8 +---
sys/ufs/lfs/lfs_vnops.c | 68 ++++++++++++++++++++++++++++++++---------
sys/ufs/ufs/inode.h | 62 +++++++------------------------------
sys/ufs/ufs/ufs_vnops.c | 30 ++++++------------
18 files changed, 220 insertions(+), 206 deletions(-)
diffs (truncated from 942 to 300 lines):
diff -r 2da1ba0affc0 -r a2779fc7273d sys/fs/msdosfs/denode.h
--- a/sys/fs/msdosfs/denode.h Mon Sep 12 16:21:56 2005 +0000
+++ b/sys/fs/msdosfs/denode.h Mon Sep 12 16:24:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: denode.h,v 1.7 2005/08/29 23:57:35 xtraeme Exp $ */
+/* $NetBSD: denode.h,v 1.8 2005/09/12 16:24:41 christos Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -225,20 +225,8 @@
#define DETOV(de) ((de)->de_vnode)
#define DETIMES(dep, acc, mod, cre, gmtoff) \
- if ((dep)->de_flag & (DE_UPDATE | DE_CREATE | DE_ACCESS)) { \
- (dep)->de_flag |= DE_MODIFIED; \
- if ((dep)->de_flag & DE_UPDATE) { \
- unix2dostime((mod), gmtoff, &(dep)->de_MDate, &(dep)->de_MTime, NULL); \
- (dep)->de_Attributes |= ATTR_ARCHIVE; \
- } \
- if (!((dep)->de_pmp->pm_flags & MSDOSFSMNT_NOWIN95)) { \
- if ((dep)->de_flag & DE_ACCESS) \
- unix2dostime((acc), gmtoff, &(dep)->de_ADate, NULL, NULL); \
- if ((dep)->de_flag & DE_CREATE) \
- unix2dostime((cre), gmtoff, &(dep)->de_CDate, &(dep)->de_CTime, &(dep)->de_CHun); \
- } \
- (dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS); \
- }
+ while ((dep)->de_flag & (DE_UPDATE | DE_CREATE | DE_ACCESS)) \
+ msdosfs_detimes(dep, acc, mod, cre, gmtoff)
/*
* This overlays the fid structure (see mount.h)
@@ -313,4 +301,6 @@
int findwin95(struct denode *);
int msdosfs_gop_alloc(struct vnode *, off_t, off_t, int, struct ucred *);
void msdosfs_gop_markupdate(struct vnode *, int);
+void msdosfs_detimes(struct denode *, const struct timespec *,
+ const struct timespec *, const struct timespec *, int);
#endif /* _KERNEL */
diff -r 2da1ba0affc0 -r a2779fc7273d sys/fs/msdosfs/direntry.h
--- a/sys/fs/msdosfs/direntry.h Mon Sep 12 16:21:56 2005 +0000
+++ b/sys/fs/msdosfs/direntry.h Mon Sep 12 16:24:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: direntry.h,v 1.3 2005/08/29 23:57:35 xtraeme Exp $ */
+/* $NetBSD: direntry.h,v 1.4 2005/09/12 16:24:41 christos Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -119,7 +119,7 @@
#define DD_YEAR_SHIFT 9
#ifdef _KERNEL
-void unix2dostime(struct timespec *tsp, int gmtoff, u_int16_t *ddp,
+void unix2dostime(const struct timespec *tsp, int gmtoff, u_int16_t *ddp,
u_int16_t *dtp, u_int8_t *dhp);
void dos2unixtime(u_int dd, u_int dt, u_int dh, int gmtoff,
struct timespec *tsp);
diff -r 2da1ba0affc0 -r a2779fc7273d sys/fs/msdosfs/msdosfs_conv.c
--- a/sys/fs/msdosfs/msdosfs_conv.c Mon Sep 12 16:21:56 2005 +0000
+++ b/sys/fs/msdosfs/msdosfs_conv.c Mon Sep 12 16:24:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_conv.c,v 1.3 2005/02/26 22:58:55 perry Exp $ */
+/* $NetBSD: msdosfs_conv.c,v 1.4 2005/09/12 16:24:41 christos Exp $ */
/*-
* Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.3 2005/02/26 22:58:55 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.4 2005/09/12 16:24:41 christos Exp $");
/*
* System include files.
@@ -97,7 +97,7 @@
*/
void
unix2dostime(tsp, gmtoff, ddp, dtp, dhp)
- struct timespec *tsp;
+ const struct timespec *tsp;
int gmtoff;
u_int16_t *ddp;
u_int16_t *dtp;
diff -r 2da1ba0affc0 -r a2779fc7273d sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c Mon Sep 12 16:21:56 2005 +0000
+++ b/sys/fs/msdosfs/msdosfs_vnops.c Mon Sep 12 16:24:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vnops.c,v 1.19 2005/09/10 18:35:56 christos Exp $ */
+/* $NetBSD: msdosfs_vnops.c,v 1.20 2005/09/12 16:24:41 christos Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.19 2005/09/10 18:35:56 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.20 2005/09/12 16:24:41 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -116,7 +116,6 @@
struct denode *dep;
struct denode *pdep = VTODE(ap->a_dvp);
int error;
- struct timespec ts;
#ifdef MSDOSFS_DEBUG
printf("msdosfs_create(cnp %p, vap %p\n", cnp, ap->a_vap);
@@ -155,8 +154,7 @@
ndirent.de_devvp = pdep->de_devvp;
ndirent.de_pmp = pdep->de_pmp;
ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
- TIMEVAL_TO_TIMESPEC(&time, &ts);
- DETIMES(&ndirent, &ts, &ts, &ts, pdep->de_pmp->pm_gmtoff);
+ DETIMES(&ndirent, NULL, NULL, NULL, pdep->de_pmp->pm_gmtoff);
if ((error = createde(&ndirent, pdep, &dep, cnp)) != 0)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
@@ -216,13 +214,10 @@
} */ *ap = v;
struct vnode *vp = ap->a_vp;
struct denode *dep = VTODE(vp);
- struct timespec ts;
simple_lock(&vp->v_interlock);
- if (vp->v_usecount > 1) {
- TIMEVAL_TO_TIMESPEC(&time, &ts);
- DETIMES(dep, &ts, &ts, &ts, dep->de_pmp->pm_gmtoff);
- }
+ if (vp->v_usecount > 1)
+ DETIMES(dep, NULL, NULL, NULL, dep->de_pmp->pm_gmtoff);
simple_unlock(&vp->v_interlock);
return (0);
}
@@ -282,12 +277,10 @@
struct msdosfsmount *pmp = dep->de_pmp;
struct vattr *vap = ap->a_vap;
mode_t mode;
- struct timespec ts;
u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
ino_t fileid;
- TIMEVAL_TO_TIMESPEC(&time, &ts);
- DETIMES(dep, &ts, &ts, &ts, pmp->pm_gmtoff);
+ DETIMES(dep, NULL, NULL, NULL, pmp->pm_gmtoff);
vap->va_fsid = dep->de_dev;
/*
* The following computation of the fileid must be the same as that
@@ -708,15 +701,11 @@
struct direntry *dirp;
struct denode *dep;
int error;
- struct timespec ts;
if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)
return (0);
dep = VTODE(ap->a_vp);
- TIMEVAL_TO_TIMESPEC(&time, &ts);
- DETIMES(dep,
- ap->a_access ? ap->a_access : &ts,
- ap->a_modify ? ap->a_modify : &ts, &ts, dep->de_pmp->pm_gmtoff);
+ DETIMES(dep, ap->a_access, ap->a_modify, NULL, dep->de_pmp->pm_gmtoff);
if ((dep->de_flag & DE_MODIFIED) == 0)
return (0);
dep->de_flag &= ~DE_MODIFIED;
@@ -1216,7 +1205,6 @@
struct direntry *denp;
struct msdosfsmount *pmp = pdep->de_pmp;
struct buf *bp;
- struct timespec ts;
int async = pdep->de_pmp->pm_mountp->mnt_flag & MNT_ASYNC;
/*
@@ -1240,8 +1228,7 @@
memset(&ndirent, 0, sizeof(ndirent));
ndirent.de_pmp = pmp;
ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
- TIMEVAL_TO_TIMESPEC(&time, &ts);
- DETIMES(&ndirent, &ts, &ts, &ts, pmp->pm_gmtoff);
+ DETIMES(&ndirent, NULL, NULL, NULL, pmp->pm_gmtoff);
/*
* Now fill the cluster with the "." and ".." entries. And write
@@ -1852,6 +1839,37 @@
/* NOTREACHED */
}
+void
+msdosfs_detimes(struct denode *dep, const struct timespec *acc,
+ const struct timespec *mod, const struct timespec *cre, int gmtoff)
+{
+ struct timespec *ts = NULL, tsb;
+
+ KASSERT(dep->de_flag & (DE_UPDATE | DE_CREATE | DE_ACCESS));
+ dep->de_flag |= DE_MODIFIED;
+ if (dep->de_flag & DE_UPDATE) {
+ if (mod == NULL)
+ mod = ts == NULL ? (ts = nanotime(&tsb)) : ts;
+ unix2dostime(mod, gmtoff, &dep->de_MDate, &dep->de_MTime, NULL);
+ dep->de_Attributes |= ATTR_ARCHIVE;
+ }
+ if ((dep->de_pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0) {
+ if (dep->de_flag & DE_ACCESS) {
+ if (acc == NULL)
+ acc = ts == NULL ? (ts = nanotime(&tsb)) : ts;
+ unix2dostime(acc, gmtoff, &dep->de_ADate, NULL, NULL);
+ }
+ if (dep->de_flag & DE_CREATE) {
+ if (cre == NULL)
+ cre = ts == NULL ? (ts = nanotime(&tsb)) : ts;
+ unix2dostime(cre, gmtoff, &dep->de_CDate,
+ &dep->de_CTime, &dep->de_CHun);
+ }
+ }
+
+ dep->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS);
+}
+
/* Global vfs data structures for msdosfs */
int (**msdosfs_vnodeop_p)(void *);
const struct vnodeopv_entry_desc msdosfs_vnodeop_entries[] = {
diff -r 2da1ba0affc0 -r a2779fc7273d sys/ufs/ext2fs/ext2fs_extern.h
--- a/sys/ufs/ext2fs/ext2fs_extern.h Mon Sep 12 16:21:56 2005 +0000
+++ b/sys/ufs/ext2fs/ext2fs_extern.h Mon Sep 12 16:24:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_extern.h,v 1.26 2005/08/30 22:01:12 xtraeme Exp $ */
+/* $NetBSD: ext2fs_extern.h,v 1.27 2005/09/12 16:24:41 christos Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -129,6 +129,8 @@
/* ext2fs_subr.c */
int ext2fs_blkatoff(void *);
void ext2fs_fragacct(struct m_ext2fs *, int, int32_t[], int);
+void ext2fs_itimes(struct inode *, const struct timespec *,
+ const struct timespec *, const struct timespec *);
#ifdef DIAGNOSTIC
void ext2fs_checkoverlap(struct buf *, struct inode *);
#endif
diff -r 2da1ba0affc0 -r a2779fc7273d sys/ufs/ext2fs/ext2fs_inode.c
--- a/sys/ufs/ext2fs/ext2fs_inode.c Mon Sep 12 16:21:56 2005 +0000
+++ b/sys/ufs/ext2fs/ext2fs_inode.c Mon Sep 12 16:24:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_inode.c,v 1.47 2005/08/30 22:01:12 xtraeme Exp $ */
+/* $NetBSD: ext2fs_inode.c,v 1.48 2005/09/12 16:24:41 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.47 2005/08/30 22:01:12 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.48 2005/09/12 16:24:41 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -206,17 +206,13 @@
struct buf *bp;
struct inode *ip;
int error;
- struct timespec ts;
caddr_t cp;
int flags;
if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)
return (0);
ip = VTOI(ap->a_vp);
- TIMEVAL_TO_TIMESPEC(&time, &ts);
- EXT2FS_ITIMES(ip,
- ap->a_access ? ap->a_access : &ts,
- ap->a_modify ? ap->a_modify : &ts, &ts);
+ EXT2FS_ITIMES(ip, ap->a_access, ap->a_modify, NULL);
if (ap->a_flags & UPDATE_CLOSE)
flags = ip->i_flag & (IN_MODIFIED | IN_ACCESSED);
else
diff -r 2da1ba0affc0 -r a2779fc7273d sys/ufs/ext2fs/ext2fs_subr.c
--- a/sys/ufs/ext2fs/ext2fs_subr.c Mon Sep 12 16:21:56 2005 +0000
+++ b/sys/ufs/ext2fs/ext2fs_subr.c Mon Sep 12 16:24:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_subr.c,v 1.14 2005/08/30 22:01:12 xtraeme Exp $ */
+/* $NetBSD: ext2fs_subr.c,v 1.15 2005/09/12 16:24:41 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_subr.c,v 1.14 2005/08/30 22:01:12 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_subr.c,v 1.15 2005/09/12 16:24:41 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -111,6 +111,35 @@
return (0);
}
Home |
Main Index |
Thread Index |
Old Index