summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-10-04 19:08:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-10-04 19:08:14 +0000
commitee3e25b09b27e8775937f070dae39a1246bb225a (patch)
tree8694b282f6d6acaaf58536884351bce19dc7c475
parent6581cfa62976b937ee24550d4b28ea1d70df2b29 (diff)
cleanup timestamp code for NT/Win95; khym@bga.com
-rw-r--r--sys/msdosfs/denode.h17
-rw-r--r--sys/msdosfs/direntry.h9
-rw-r--r--sys/msdosfs/msdosfs_conv.c6
-rw-r--r--sys/msdosfs/msdosfs_denode.c4
-rw-r--r--sys/msdosfs/msdosfs_vnops.c28
5 files changed, 42 insertions, 22 deletions
diff --git a/sys/msdosfs/denode.h b/sys/msdosfs/denode.h
index a845705f8cb..d5171d7f21e 100644
--- a/sys/msdosfs/denode.h
+++ b/sys/msdosfs/denode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: denode.h,v 1.4 1997/03/02 18:01:50 millert Exp $ */
+/* $OpenBSD: denode.h,v 1.5 1997/10/04 19:08:10 deraadt Exp $ */
/* $NetBSD: denode.h,v 1.20 1996/02/09 19:13:39 christos Exp $ */
/*-
@@ -152,10 +152,10 @@ struct denode {
pid_t de_lockwaiter; /* lock wanter */
u_char de_Name[12]; /* name, from DOS directory entry */
u_char de_Attributes; /* attributes, from directory entry */
+ u_char de_CTimeHundredth; /* creation time, 1/100th of a sec */
u_short de_CTime; /* creation time */
u_short de_CDate; /* creation date */
u_short de_ADate; /* access date */
- u_short de_ATime; /* access time */
u_short de_MTime; /* modification time */
u_short de_MDate; /* modification date */
u_short de_StartCluster; /* starting cluster of file */
@@ -188,9 +188,9 @@ struct denode {
#define DE_INTERNALIZE(dep, dp) \
(bcopy((dp)->deName, (dep)->de_Name, 11), \
(dep)->de_Attributes = (dp)->deAttributes, \
+ (dep)->de_CTimeHundredth = (dp)->deCTimeHundredth, \
(dep)->de_CTime = getushort((dp)->deCTime), \
(dep)->de_CDate = getushort((dp)->deCDate), \
- (dep)->de_ATime = getushort((dp)->deATime), \
(dep)->de_ADate = getushort((dp)->deADate), \
(dep)->de_MTime = getushort((dp)->deMTime), \
(dep)->de_MDate = getushort((dp)->deMDate), \
@@ -200,10 +200,13 @@ struct denode {
#define DE_EXTERNALIZE(dp, dep) \
(bcopy((dep)->de_Name, (dp)->deName, 11), \
(dp)->deAttributes = (dep)->de_Attributes, \
+ (dp)->deLowerCase = CASE_LOWER_BASE | CASE_LOWER_EXT, \
+ (dp)->deCTimeHundredth = (dep)->de_CTimeHundredth, \
putushort((dp)->deCTime, (dep)->de_CTime), \
putushort((dp)->deCDate, (dep)->de_CDate), \
- putushort((dp)->deATime, (dep)->de_ATime), \
putushort((dp)->deADate, (dep)->de_ADate), \
+ (dp)->deReserved[0] = 0, \
+ (dp)->deReserved[1] = 0, \
putushort((dp)->deMTime, (dep)->de_MTime), \
putushort((dp)->deMDate, (dep)->de_MDate), \
putushort((dp)->deStartCluster, (dep)->de_StartCluster), \
@@ -227,9 +230,11 @@ struct denode {
} \
if (!((dep)->de_pmp->pm_flags & MSDOSFSMNT_NOWIN95)) { \
if ((dep)->de_flag & DE_ACCESS) \
- unix2dostime((acc), &(dep)->de_ADate, &(dep)->de_ATime); \
- if ((dep)->de_flag & DE_CREATE) \
+ unix2dostime((acc), &(dep)->de_ADate, NULL); \
+ if ((dep)->de_flag & DE_CREATE) { \
unix2dostime((cre), &(dep)->de_CDate, &(dep)->de_CTime); \
+ (dep)->de_CTimeHundredth = ((cre)->tv_sec & 1 ? 100 : 0) + (cre)->tv_nsec / 10000000; \
+ } \
} \
(dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS); \
}
diff --git a/sys/msdosfs/direntry.h b/sys/msdosfs/direntry.h
index 578ab3a9363..6a6a00dc147 100644
--- a/sys/msdosfs/direntry.h
+++ b/sys/msdosfs/direntry.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: direntry.h,v 1.3 1997/02/24 14:32:47 niklas Exp $ */
+/* $OpenBSD: direntry.h,v 1.4 1997/10/04 19:08:10 deraadt Exp $ */
/* $NetBSD: direntry.h,v 1.11 1995/11/29 15:08:34 ws Exp $ */
/*-
@@ -65,11 +65,14 @@ struct direntry {
#define ATTR_VOLUME 0x08 /* entry is a volume label */
#define ATTR_DIRECTORY 0x10 /* entry is a directory name */
#define ATTR_ARCHIVE 0x20 /* file is new or modified */
- u_int8_t deReserved[2]; /* reserved */
+ u_int8_t deLowerCase; /* case for base and extension */
+#define CASE_LOWER_BASE 0x08 /* base is lower case */
+#define CASE_LOWER_EXT 0x10 /* extension is lower case */
+ u_int8_t deCTimeHundredth; /* create time, 1/100th of a sec */
u_int8_t deCTime[2]; /* create time */
u_int8_t deCDate[2]; /* create date */
u_int8_t deADate[2]; /* access date */
- u_int8_t deATime[2]; /* access time */
+ u_int8_t deReserved[2]; /* reserved */
u_int8_t deMTime[2]; /* last update time */
u_int8_t deMDate[2]; /* last update date */
u_int8_t deStartCluster[2]; /* starting cluster of file */
diff --git a/sys/msdosfs/msdosfs_conv.c b/sys/msdosfs/msdosfs_conv.c
index e31202b583f..bb439feeeae 100644
--- a/sys/msdosfs/msdosfs_conv.c
+++ b/sys/msdosfs/msdosfs_conv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_conv.c,v 1.6 1997/03/02 18:01:53 millert Exp $ */
+/* $OpenBSD: msdosfs_conv.c,v 1.7 1997/10/04 19:08:11 deraadt Exp $ */
/* $NetBSD: msdosfs_conv.c,v 1.17 1996/02/09 19:13:42 christos Exp $ */
/*-
@@ -150,7 +150,9 @@ unix2dostime(tsp, ddp, dtp)
lastddate += (year - 1980) << DD_YEAR_SHIFT;
}
}
- *dtp = lastdtime;
+
+ if (dtp != NULL)
+ *dtp = lastdtime;
*ddp = lastddate;
}
diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c
index f0d33a33de0..0fcb2580df9 100644
--- a/sys/msdosfs/msdosfs_denode.c
+++ b/sys/msdosfs/msdosfs_denode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_denode.c,v 1.4 1997/03/02 18:01:54 millert Exp $ */
+/* $OpenBSD: msdosfs_denode.c,v 1.5 1997/10/04 19:08:12 deraadt Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.22 1996/10/13 04:16:31 christos Exp $ */
/*-
@@ -241,10 +241,10 @@ deget(pmp, dirclust, diroffset, depp)
* denode
*/
ldep->de_CTime = 0x0000; /* 00:00:00 */
+ ldep->de_CTimeHundredth = 0;
ldep->de_CDate = (0 << DD_YEAR_SHIFT) | (1 << DD_MONTH_SHIFT)
| (1 << DD_DAY_SHIFT);
/* Jan 1, 1980 */
- ldep->de_ATime = ldep->de_CTime;
ldep->de_ADate = ldep->de_CDate;
ldep->de_MTime = ldep->de_CTime;
ldep->de_MDate = ldep->de_CDate;
diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c
index 98d32d4f043..e792d1b2201 100644
--- a/sys/msdosfs/msdosfs_vnops.c
+++ b/sys/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vnops.c,v 1.9 1997/07/03 17:49:53 deraadt Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.10 1997/10/04 19:08:13 deraadt Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.48 1996/03/20 00:45:43 thorpej Exp $ */
/*-
@@ -300,8 +300,14 @@ msdosfs_getattr(v)
vap->va_size = dep->de_FileSize;
dos2unixtime(dep->de_MDate, dep->de_MTime, &vap->va_mtime);
if (dep->de_pmp->pm_flags & MSDOSFSMNT_LONGNAME) {
- dos2unixtime(dep->de_ADate, dep->de_ATime, &vap->va_atime);
+ dos2unixtime(dep->de_ADate, 0, &vap->va_atime);
dos2unixtime(dep->de_CDate, dep->de_CTime, &vap->va_ctime);
+ if (dep->de_CTimeHundredth >= 100) {
+ vap->va_ctime.tv_sec++;
+ vap->va_ctime.tv_nsec = (dep->de_CTimeHundredth - 100) * 10000000;
+ } else
+ vap->va_ctime.tv_nsec = dep->de_CTimeHundredth * 10000000;
+
} else {
vap->va_atime = vap->va_mtime;
vap->va_ctime = vap->va_mtime;
@@ -371,7 +377,7 @@ msdosfs_setattr(v)
return (error);
if (!(dep->de_pmp->pm_flags & MSDOSFSMNT_NOWIN95)
&& vap->va_atime.tv_sec != VNOVAL)
- unix2dostime(&vap->va_atime, &dep->de_ADate, &dep->de_ATime);
+ unix2dostime(&vap->va_atime, &dep->de_ADate, NULL);
if (vap->va_mtime.tv_sec != VNOVAL)
unix2dostime(&vap->va_mtime, &dep->de_MDate, &dep->de_MTime);
dep->de_Attributes |= ATTR_ARCHIVE;
@@ -1232,18 +1238,22 @@ struct {
} dosdirtemplate = {
{ ". ", " ", /* the . entry */
ATTR_DIRECTORY, /* file attribute */
- { 0, 0 }, /* reserved */
+ CASE_LOWER_BASE | CASE_LOWER_EXT, /* lower case */
+ 0, /* create time 100ths */
{ 0, 0 }, { 0, 0 }, /* create time & date */
- { 0, 0 }, { 0, 0 }, /* access time & date */
+ { 0, 0 }, /* access date */
+ { 0, 0 }, /* reserved */
{ 210, 4 }, { 210, 4 }, /* modify time & date */
{ 0, 0 }, /* startcluster */
{ 0, 0, 0, 0 } /* filesize */
},
{ ".. ", " ", /* the .. entry */
ATTR_DIRECTORY, /* file attribute */
- { 0, 0 }, /* reserved */
+ CASE_LOWER_BASE | CASE_LOWER_EXT, /* lower case */
+ 0, /* create time 100ths */
{ 0, 0 }, { 0, 0 }, /* create time & date */
- { 0, 0 }, { 0, 0 }, /* access time & date */
+ { 0, 0 }, /* access date */
+ { 0, 0 }, /* reserved */
{ 210, 4 }, { 210, 4 }, /* modify time & date */
{ 0, 0 }, /* startcluster */
{ 0, 0, 0, 0 } /* filesize */
@@ -1310,15 +1320,15 @@ msdosfs_mkdir(v)
putushort(denp[0].deStartCluster, newcluster);
putushort(denp[0].deCDate, ndirent.de_CDate);
putushort(denp[0].deCTime, ndirent.de_CTime);
+ denp[0].deCTimeHundredth = ndirent.de_CTimeHundredth;
putushort(denp[0].deADate, ndirent.de_ADate);
- putushort(denp[0].deATime, ndirent.de_ATime);
putushort(denp[0].deMDate, ndirent.de_MDate);
putushort(denp[0].deMTime, ndirent.de_MTime);
putushort(denp[1].deStartCluster, pdep->de_StartCluster);
putushort(denp[1].deCDate, ndirent.de_CDate);
putushort(denp[1].deCTime, ndirent.de_CTime);
+ denp[1].deCTimeHundredth = ndirent.de_CTimeHundredth;
putushort(denp[1].deADate, ndirent.de_ADate);
- putushort(denp[1].deATime, ndirent.de_ATime);
putushort(denp[1].deMDate, ndirent.de_MDate);
putushort(denp[1].deMTime, ndirent.de_MTime);
if ((error = bwrite(bp)) != 0)