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

This commit is contained in:
cinap_lenrek 2015-06-04 04:34:08 +02:00
parent e83ef3d1e2
commit 16b3a688c3
4 changed files with 43 additions and 31 deletions

View file

@ -150,7 +150,8 @@ struct Dosdir{
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 chatty;
extern int errno;
extern int readonly;
extern char *deffile;
extern int trspaces;
extern int trspaces;

View file

@ -329,6 +329,9 @@ mkdentry(Xfs *xf, Dosptr *ndp, char *name, char *sname, int longtype, int nattr,
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 @@ rwstat(void)
* 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];

View file

@ -1721,6 +1721,7 @@ puttime(Dosdir *d, long s)
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 @@ bootsecdump32(int fd, Xfs *xf, Dosboot32 *b32)
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 @@ dirdump(void *vdbuf)
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 @@ dirdump(void *vdbuf)
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);

View file

@ -176,7 +176,7 @@ io(int srvfd)
if(write(srvfd, mdata, n) != n)
panic("mount write");
}
chat("server shut down");
chat("server shut down\n");
}
void