shithub: riscv

Download patch

ref: 16b3a688c304bd94935288509af79ed39cb2a427
parent: e83ef3d1e24e5248e4cdd86aec6f8710ad929be9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Jun 4 00:34:08 EDT 2015

dossrv: maintain file creation date/time on disk, fsinfo sector can be 0 (disabled)

--- a/sys/src/cmd/dossrv/dat.h
+++ b/sys/src/cmd/dossrv/dat.h
@@ -150,7 +150,8 @@
 	uchar	ext[3];
 	uchar	attr;
 	uchar	reserved[1];
-	uchar	ctime[3];		/* creation time */
+	uchar	ctimetenth;
+	uchar	ctime[2];		/* creation time */
 	uchar	cdate[2];		/* creation date */
 	uchar	adate[2];		/* last access date */
 	uchar	hstart[2];		/* high bits of start for fat32 */
@@ -252,4 +253,4 @@
 extern int	errno;
 extern int	readonly;
 extern char	*deffile;
-extern int trspaces;
\ No newline at end of file
+extern int trspaces;
--- a/sys/src/cmd/dossrv/dosfs.c
+++ b/sys/src/cmd/dossrv/dosfs.c
@@ -329,6 +329,9 @@
 
 	nd->attr = nattr;
 	puttime(nd, 0);
+	PSHORT(nd->cdate, GSHORT(nd->date));
+	PSHORT(nd->ctime, GSHORT(nd->time));
+	nd->ctimetenth = 0;
 	putstart(xf, nd, start);
 	nd->length[0] = length;
 	nd->length[1] = length>>8;
@@ -873,7 +876,8 @@
 		 * copy invisible fields
 		 */
 		d = dp->d;
-		for(i = 0; i < 2; i++)
+		d->ctimetenth = od.ctimetenth;
+		for(i = 0; i < nelem(od.ctime); i++)
 			d->ctime[i] = od.ctime[i];
 		for(i = 0; i < nelem(od.cdate); i++)
 			d->cdate[i] = od.cdate[i];
--- a/sys/src/cmd/dossrv/dossubs.c
+++ b/sys/src/cmd/dossrv/dossubs.c
@@ -1721,6 +1721,7 @@
 	PSHORT(d->time, x);
 	x = ((t->year-80)<<9) | ((t->mon+1)<<5) | t->mday;
 	PSHORT(d->date, x);
+	PSHORT(d->adate, x);
 }
 
 long
@@ -1821,34 +1822,40 @@
 	bootdump32(fd, b32);
 	res = GSHORT(b32->nresrv);
 	bsec = GSHORT(b32->backupboot);
-	if(bsec < res && bsec != 0){
-		p1 = getsect(xf, bsec);
-		if(p1 == nil)
-			fprint(fd, "\ncouldn't get backup boot sector: %r\n");
-		else{
-			fprint(fd, "\nbackup boot\n");
-			bootdump32(fd, (Dosboot32*)p1->iobuf);
-			putsect(p1);
+	if(bsec != 0 && bsec != 0xffff){
+		if(bsec >= res)
+			fprint(fd, "bad backup boot sector: %d reserved %d\n", bsec, res);
+		else {
+			p1 = getsect(xf, bsec);
+			if(p1 == nil)
+				fprint(fd, "\ncouldn't get backup boot sector: %r\n");
+			else{
+				fprint(fd, "\nbackup boot\n");
+				bootdump32(fd, (Dosboot32*)p1->iobuf);
+				putsect(p1);
+			}
 		}
-	}else if(bsec != 0xffff)
-		fprint(fd, "bad backup boot sector: %d reserved %d\n", bsec, res);
+	}
 	fisec = GSHORT(b32->infospec);
-	if(fisec < res && fisec != 0){
-		p1 = getsect(xf, fisec);
-		if(p1 == nil)
-			fprint(fd, "\ncouldn't get fat info sector: %r\n");
-		else{
-			fprint(fd, "\nfat info %d\n", fisec);
-			fi = (Fatinfo*)p1->iobuf;
-			fprint(fd, "sig1: 0x%lux sb 0x%lux\n", GLONG(fi->sig1), FATINFOSIG1);
-			fprint(fd, "sig: 0x%lux sb 0x%lux\n", GLONG(fi->sig), FATINFOSIG);
-			fprint(fd, "freeclust: %lud\n", GLONG(fi->freeclust));
-			fprint(fd, "nextfree: %lud\n", GLONG(fi->nextfree));
-			fprint(fd, "reserved: %lud %lud %lud\n", GLONG(fi->resrv), GLONG(fi->resrv+4), GLONG(fi->resrv+8));
-			putsect(p1);
+	if(fisec != 0 && fisec != 0xffff){
+		if(fisec >= res)
+			fprint(2, "bad fat info sector: %d reserved %d\n", fisec, res);
+		else {
+			p1 = getsect(xf, fisec);
+			if(p1 == nil)
+				fprint(fd, "\ncouldn't get fat info sector: %r\n");
+			else{
+				fprint(fd, "\nfat info %d\n", fisec);
+				fi = (Fatinfo*)p1->iobuf;
+				fprint(fd, "sig1: 0x%lux sb 0x%lux\n", GLONG(fi->sig1), FATINFOSIG1);
+				fprint(fd, "sig: 0x%lux sb 0x%lux\n", GLONG(fi->sig), FATINFOSIG);
+				fprint(fd, "freeclust: %lud\n", GLONG(fi->freeclust));
+				fprint(fd, "nextfree: %lud\n", GLONG(fi->nextfree));
+				fprint(fd, "reserved: %lud %lud %lud\n", GLONG(fi->resrv), GLONG(fi->resrv+4), GLONG(fi->resrv+8));
+				putsect(p1);
+			}
 		}
-	}else if(fisec != 0xffff)
-		fprint(2, "bad fat info sector: %d reserved %d\n", bsec, res);
+	}
 }
 
 void
@@ -1867,7 +1874,7 @@
 	d = vdbuf;
 
 	ebuf = buf + sizeof(buf);
-	if(d->attr == 0xf){
+	if((d->attr & 0xf) == 0xf){
 		dbuf = vdbuf;
 		name = namebuf + DOSNAMELEN;
 		*--name = '\0';
@@ -1884,7 +1891,7 @@
 		s = seprint(s, ebuf, " %2.2d.%2.2d.%2.2d", 80+(i>>9), (i>>5)&15, i&31);
 	
 		i = GSHORT(d->ctime);
-		s = seprint(s, ebuf, " %2.2d:%2.2d:%2.2d", i>>11, (i>>5)&63, (i&31)<<1);
+		s = seprint(s, ebuf, " %2.2d:%2.2d:%2.2d+%d", i>>11, (i>>5)&63, (i&31)<<1, (int)d->ctimetenth);
 		i = GSHORT(d->cdate);
 		s = seprint(s, ebuf, " %2.2d.%2.2d.%2.2d", 80+(i>>9), (i>>5)&15, i&31);
 	
--- a/sys/src/cmd/dossrv/xfssrv.c
+++ b/sys/src/cmd/dossrv/xfssrv.c
@@ -176,7 +176,7 @@
 		if(write(srvfd, mdata, n) != n)
 			panic("mount write");
 	}
-	chat("server shut down");
+	chat("server shut down\n");
 }
 
 void