fat: Cleared the confusion between ctime, and crtime...

... the previous commit introduced.

* Minor cleanup, disabled the useless fs_ioctl() function.
* This closes #11120.
This commit is contained in:
Axel Dörfler
2015-06-30 13:27:02 +02:00
parent b56120409d
commit ad5d4c9944
4 changed files with 36 additions and 50 deletions
+10 -10
View File
@@ -49,7 +49,7 @@ struct _dirent_info_ {
uint32 cluster;
uint32 size;
uint32 time;
uint32 ctime;
uint32 creation_time;
};
@@ -191,12 +191,12 @@ _next_dirent_(struct diri *iter, struct _dirent_info_ *oinfo, char *filename,
oinfo->sindex = start_index;
oinfo->eindex = iter->current_index;
oinfo->mode = buffer[0xb];
oinfo->cluster = read16(buffer,0x1a);
oinfo->cluster = read16(buffer, 0x1a);
if (iter->csi.vol->fat_bits == 32)
oinfo->cluster += 0x10000*read16(buffer,0x14);
oinfo->size = read32(buffer,0x1c);
oinfo->time = read32(buffer,0x16);
oinfo->ctime = read32(buffer,0x0e);
oinfo->cluster += 0x10000 * read16(buffer, 0x14);
oinfo->size = read32(buffer, 0x1c);
oinfo->time = read32(buffer, 0x16);
oinfo->creation_time = read32(buffer, 0x0e);
}
diri_next_entry(iter);
@@ -584,7 +584,7 @@ struct _entry_info_ {
uint32 cluster;
uint32 size;
time_t time;
time_t ctime;
time_t creation_time;
};
@@ -740,7 +740,7 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct _entry_info_ *info,
memcpy(buffer, nshort, 11);
buffer[0x0b] = info->mode;
memset(buffer+0xc, 0, 0x16-0xc);
i = time_t2dos(info->ctime);
i = time_t2dos(info->creation_time);
buffer[0x0e] = i & 0xff;
buffer[0x0f] = (i >> 8) & 0xff;
buffer[0x10] = (i >> 16) & 0xff;
@@ -923,7 +923,7 @@ create_dir_entry(nspace *vol, vnode *dir, vnode *node, const char *name,
info.cluster = node->cluster;
info.size = node->st_size;
info.time = node->st_time;
info.ctime = node->st_ctim;
info.creation_time = node->st_crtim;
return _create_dir_entry_(vol, dir, &info, (char *)nshort,
(char *)nlong, len, ns, ne);
@@ -1040,7 +1040,7 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
} else
entry->end_cluster = 0;
entry->st_time = dos2time_t(info.time);
entry->st_ctim = dos2time_t(info.ctime);
entry->st_crtim = dos2time_t(info.creation_time);
#if TRACK_FILENAME
entry->filename = malloc(sizeof(filename) + 1);
if (entry->filename) strcpy(entry->filename, filename);
+15 -29
View File
@@ -664,7 +664,7 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
vol->root_vnode.sindex = vol->root_vnode.eindex = 0xffffffff;
vol->root_vnode.mode = FAT_SUBDIR;
time(&(vol->root_vnode.st_time));
vol->root_vnode.st_ctim = vol->root_vnode.st_time;
vol->root_vnode.st_crtim = vol->root_vnode.st_time;
vol->root_vnode.mime = NULL;
vol->root_vnode.dirty = false;
dlist_add(vol, vol->root_vnode.vnid);
@@ -1151,6 +1151,7 @@ bi: UNLOCK_VOL(vol);
}
#if 0
static status_t
dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, uint32 code,
void *buf, size_t len)
@@ -1159,24 +1160,11 @@ dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, uint32 code,
nspace *vol = (nspace *)_vol->private_volume;
vnode *node = (vnode *)_node->private_node;
TOUCH(cookie); TOUCH(buf); TOUCH(len);
TOUCH(cookie); TOUCH(len);
LOCK_VOL(vol);
switch (code) {
case 10002 : /* return real creation time */
if (buf) *(bigtime_t *)buf = node->st_ctim;
break;
case 10003 : /* return real last modification time */
if (buf) *(bigtime_t *)buf = node->st_time;
break;
#if 0
/*case 69666 :
result = fragment(vol, buf);
break;
*/
case 100000 :
dprintf("built at %s on %s\n", build_time, build_date);
dprintf("vol info: %s (device %x, media descriptor %x)\n", vol->device, vol->fd, vol->media_descriptor);
@@ -1213,11 +1201,9 @@ dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, uint32 code,
case 100003 :
dprintf("vcache validation not yet implemented\n");
#if 0
dprintf("validating vcache for %lx\n", vol->id);
validate_vcache(vol);
dprintf("validation complete for %lx\n", vol->id);
#endif
break;
case 100004 :
@@ -1229,7 +1215,6 @@ dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, uint32 code,
dprintf("dumping dlist for %lx\n", vol->id);
dlist_dump(vol);
break;
#endif
default :
DPRINTF(0, ("dosfs_ioctl: vol %" B_PRIdDEV ", vnode %" B_PRIdINO
@@ -1242,6 +1227,7 @@ dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, uint32 code,
return result;
}
#endif
status_t
@@ -1349,23 +1335,23 @@ fs_vnode_ops gFATVnodeOps = {
&dosfs_get_file_map,
&dosfs_ioctl,
NULL, //&fs_set_flags,
NULL, //&fs_select
NULL, //&fs_deselect
NULL, // fs_ioctl()
NULL, // fs_set_flags,
NULL, // fs_select
NULL, // fs_deselect
&dosfs_fsync,
&dosfs_readlink,
NULL, //&fs_create_symlink,
NULL, // fs_create_symlink,
NULL, //&fs_link,
NULL, // fs_link,
&dosfs_unlink,
&dosfs_rename,
&dosfs_access,
&dosfs_rstat,
&dosfs_wstat,
NULL, // &fs_preallocate,
NULL, // fs_preallocate,
/* file operations */
&dosfs_create,
@@ -1392,7 +1378,7 @@ fs_vnode_ops gFATVnodeOps = {
&dosfs_rewind_attrdir,
/* attribute operations */
NULL, //&fs_create_attr,
NULL, // fs_create_attr,
&dosfs_open_attr,
&dosfs_close_attr,
&dosfs_free_attr_cookie,
@@ -1400,9 +1386,9 @@ fs_vnode_ops gFATVnodeOps = {
&dosfs_write_attr,
&dosfs_read_attr_stat,
NULL, //&fs_write_attr_stat,
NULL, //&fs_rename_attr,
NULL, //&fs_remove_attr,
NULL, // fs_write_attr_stat,
NULL, // fs_rename_attr,
NULL, // fs_remove_attr,
};
+1 -1
View File
@@ -86,7 +86,7 @@ typedef struct vnode {
uint32 mode; // dos-style attributes
off_t st_size; // in bytes
time_t st_time;
time_t st_ctim;
time_t st_crtim;
uint32 end_cluster; // last cluster of the data
+10 -10
View File
@@ -95,7 +95,7 @@ status_t write_vnode_entry(nspace *vol, vnode *node)
buffer[0x0b] = node->mode; // file attributes
memset(buffer+0xc, 0, 0x16-0xc);
i = time_t2dos(node->st_ctim);
i = time_t2dos(node->st_crtim);
buffer[0x0e] = i & 0xff;
buffer[0x0f] = (i >> 8) & 0xff;
buffer[0x10] = (i >> 16) & 0xff;
@@ -188,9 +188,9 @@ dosfs_rstat(fs_volume *_vol, fs_vnode *_node, struct stat *st)
st->st_blksize = 0x10000; /* this value was chosen arbitrarily */
st->st_atim.tv_sec = st->st_mtim.tv_sec = st->st_ctim.tv_sec
= node->st_time;
st->st_crtim.tv_sec = node->st_crtim;
st->st_atim.tv_nsec = st->st_mtim.tv_nsec = st->st_ctim.tv_nsec
= st->st_crtim.tv_nsec = 0;
st->st_crtim.tv_sec = node->st_ctim;
UNLOCK_VOL(vol);
@@ -223,7 +223,7 @@ dosfs_wstat(fs_volume *_vol, fs_vnode *_node, const struct stat *st,
return EPERM;
}
if (mask & B_STAT_MODE) {
if ((mask & B_STAT_MODE) != 0) {
DPRINTF(0, ("setting file mode to %o\n", st->st_mode));
if (st->st_mode & S_IWUSR)
node->mode &= ~FAT_READ_ONLY;
@@ -232,7 +232,7 @@ dosfs_wstat(fs_volume *_vol, fs_vnode *_node, const struct stat *st,
dirty = true;
}
if (mask & B_STAT_SIZE) {
if ((mask & B_STAT_SIZE) != 0) {
DPRINTF(0, ("setting file size to %" B_PRIdOFF "\n", st->st_size));
if (node->mode & FAT_SUBDIR) {
dprintf("dosfs_wstat: can't set file size of directory!\n");
@@ -256,7 +256,7 @@ dosfs_wstat(fs_volume *_vol, fs_vnode *_node, const struct stat *st,
}
}
if (mask & B_STAT_MODIFICATION_TIME) {
if ((mask & B_STAT_MODIFICATION_TIME) != 0) {
DPRINTF(0, ("setting modification time\n"));
if ((node->mode & FAT_SUBDIR) == 0)
node->mode |= FAT_ARCHIVE;
@@ -264,11 +264,11 @@ dosfs_wstat(fs_volume *_vol, fs_vnode *_node, const struct stat *st,
dirty = true;
}
if (mask & B_STAT_CREATION_TIME) {
if ((mask & B_STAT_CREATION_TIME) != 0) {
DPRINTF(0, ("setting creation time\n"));
// As a file's modification time is also set when it is created,
// the archive bit should be set automatically.
node->st_ctim = st->st_crtime;
node->st_crtim = st->st_crtime;
dirty = true;
}
@@ -832,7 +832,7 @@ dosfs_create(fs_volume *_vol, fs_vnode *_dir, const char *name, int omode,
dummy.mode = 0;
dummy.st_size = 0;
time(&(dummy.st_time));
dummy.st_ctim = dummy.st_time;
dummy.st_crtim = dummy.st_time;
if ((result = create_dir_entry(vol, dir, &dummy, name, &(dummy.sindex), &(dummy.eindex))) != B_OK) {
dprintf("dosfs_create: error creating directory entry for %s (%s)\n", name, strerror(result));
@@ -935,7 +935,7 @@ dosfs_mkdir(fs_volume *_vol, fs_vnode *_dir, const char *name, int perms)
}
dummy.st_size = vol->bytes_per_sector*vol->sectors_per_cluster;
time(&(dummy.st_time));
dummy.st_ctim = dummy.st_time;
dummy.st_crtim = dummy.st_time;
dummy.vnid = GENERATE_DIR_CLUSTER_VNID(dummy.dir_vnid, dummy.cluster);
// XXX: dangerous construct
@@ -976,7 +976,7 @@ dosfs_mkdir(fs_volume *_vol, fs_vnode *_dir, const char *name, int perms)
buffer[0x17] = (i >> 8) & 0xff;
buffer[0x18] = (i >> 16) & 0xff;
buffer[0x19] = (i >> 24) & 0xff;
i = time_t2dos(dir->st_ctim);
i = time_t2dos(dir->st_crtim);
buffer[0x2e] = i & 0xff;
buffer[0x2f] = (i >> 8) & 0xff;
buffer[0x30] = (i >> 16) & 0xff;