update appropriate timestamps after each operation. cvs works much

better now with dtfs /tmp
This commit is contained in:
pooka 2006-10-27 14:03:52 +00:00
parent dee13e6f7d
commit 8fdf9afc13
3 changed files with 35 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dtfs.h,v 1.3 2006/10/26 22:53:25 pooka Exp $ */
/* $NetBSD: dtfs.h,v 1.4 2006/10/27 14:03:52 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -99,6 +99,7 @@ void dtfs_adddent(struct puffs_node *, struct dtfs_dirent *);
void dtfs_removedent(struct puffs_node *, struct dtfs_dirent *);
void dtfs_baseattrs(struct vattr *, enum vtype, int32_t, ino_t);
void dtfs_updatetimes(struct puffs_node *, int, int, int);
#define DTFS_CTOF(a) ((struct dtfs_file *)(((struct puffs_node *)a)->pn_data))

View File

@ -1,4 +1,4 @@
/* $NetBSD: dtfs_subr.c,v 1.4 2006/10/27 12:26:25 pooka Exp $ */
/* $NetBSD: dtfs_subr.c,v 1.5 2006/10/27 14:03:52 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -272,6 +272,8 @@ dtfs_adddent(struct puffs_node *pn_dir, struct dtfs_dirent *dent)
dent->dfd_parent = pn_dir;
if (dent->dfd_node->pn_type == VDIR)
file->df_dotdot = pn_dir;
dtfs_updatetimes(pn_dir, 0, 1, 1);
}
/* remove & lower link count */
@ -285,4 +287,23 @@ dtfs_removedent(struct puffs_node *pn_dir, struct dtfs_dirent *dent)
pn_dir->pn_va.va_nlink--;
pn_file->pn_va.va_nlink--;
assert(pn_dir->pn_va.va_nlink >= 2);
dtfs_updatetimes(pn_dir, 0, 1, 1);
}
void
dtfs_updatetimes(struct puffs_node *pn, int doatime, int doctime, int domtime)
{
struct timeval tv;
struct timespec ts;
gettimeofday(&tv, NULL);
TIMEVAL_TO_TIMESPEC(&tv, &ts);
if (doatime)
pn->pn_va.va_atime = ts;
if (doctime)
pn->pn_va.va_ctime = ts;
if (domtime)
pn->pn_va.va_mtime = ts;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dtfs_vnops.c,v 1.5 2006/10/27 12:26:25 pooka Exp $ */
/* $NetBSD: dtfs_vnops.c,v 1.6 2006/10/27 14:03:52 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -196,6 +196,8 @@ dtfs_readdir(struct puffs_usermount *pi, void *opc,
if (pn->pn_type != VDIR)
return ENOTDIR;
dtfs_updatetimes(pn, 1, 0, 0);
again:
if (*readoff == DENT_DOT || *readoff == DENT_DOTDOT) {
puffs_gendotdent(&dent, pn->pn_va.va_fileid, *readoff, reslen);
@ -250,6 +252,8 @@ dtfs_rename(struct puffs_usermount *pu, void *opc, void *src,
free(dfd_src->dfd_name);
dfd_src->dfd_name = estrdup(pcn_targ->pcn_name);
dtfs_updatetimes(src, 0, 1, 0);
return 0;
}
@ -265,6 +269,8 @@ dtfs_link(struct puffs_usermount *pu, void *opc, void *targ,
dfd->dfd_name = estrdup(pcn->pcn_name);
dtfs_adddent(pn_dir, dfd);
dtfs_updatetimes(targ, 0, 1, 0);
return 0;
}
@ -348,6 +354,8 @@ dtfs_read(struct puffs_usermount *pu, void *opc, uint8_t *buf,
memcpy(buf, df->df_data + offset, xfer);
*resid -= xfer;
dtfs_updatetimes(pn, 1, 0, 0);
return 0;
}
@ -371,6 +379,8 @@ dtfs_write(struct puffs_usermount *pu, void *opc, uint8_t *buf,
memcpy(df->df_data + offset, buf, *resid);
*resid = 0;
dtfs_updatetimes(pn, 0, 1, 1);
return 0;
}