Just a bit of cleanup, remove trailing whitespace mostly. No functional changes.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24995 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2008-04-17 10:02:49 +00:00
parent 0eaadd30b2
commit b8c45ca140
13 changed files with 266 additions and 197 deletions

View File

@ -45,7 +45,7 @@ status_t set_mime_type(vnode *node, const char *filename)
if (filename[namelen-ext_len-1] != '.')
continue;
if (!strcasecmp(filename + namelen - ext_len, p->extension))
break;
}
@ -56,7 +56,7 @@ status_t set_mime_type(vnode *node, const char *filename)
}
status_t
status_t
dosfs_open_attrdir(fs_volume *_vol, fs_vnode *_node, void **_cookie)
{
nspace *vol = (nspace *)_vol->private_volume;
@ -77,13 +77,14 @@ dosfs_open_attrdir(fs_volume *_vol, fs_vnode *_node, void **_cookie)
return ENOMEM;
}
*(int32 *)(*_cookie) = 0;
UNLOCK_VOL(vol);
return 0;
}
status_t
status_t
dosfs_close_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
{
nspace *vol = (nspace *)_vol->private_volume;
@ -100,14 +101,14 @@ dosfs_close_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
}
*(int32 *)_cookie = 1;
UNLOCK_VOL(vol);
return 0;
}
status_t
status_t
dosfs_free_attrdir_cookie(fs_volume *_vol, fs_vnode *_node, void *_cookie)
{
TOUCH(_vol); TOUCH(_node);
@ -126,7 +127,7 @@ dosfs_free_attrdir_cookie(fs_volume *_vol, fs_vnode *_node, void *_cookie)
}
status_t
status_t
dosfs_rewind_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
{
TOUCH(_vol); TOUCH(_node);
@ -143,8 +144,8 @@ dosfs_rewind_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
}
status_t
dosfs_read_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie,
status_t
dosfs_read_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie,
struct dirent *entry, size_t bufsize, uint32 *num)
{
nspace *vol = (nspace *)_vol->private_volume;
@ -167,7 +168,7 @@ dosfs_read_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie,
if ((*cookie == 0) && (node->mime)) {
*num = 1;
entry->d_ino = node->vnid;
entry->d_dev = vol->id;
entry->d_reclen = 10;
@ -177,7 +178,7 @@ dosfs_read_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie,
*cookie = 1;
UNLOCK_VOL(vol);
return 0;
}
@ -191,7 +192,7 @@ dosfs_open_attr(fs_volume *_vol, fs_vnode *_node, const char *name,
if (strcmp(name, "BEOS:TYPE"))
return ENOENT;
LOCK_VOL(vol);
if (node->mime == NULL) {
@ -200,7 +201,7 @@ dosfs_open_attr(fs_volume *_vol, fs_vnode *_node, const char *name,
}
UNLOCK_VOL(vol);
*_cookie = &kBeOSTypeCookie;
return B_OK;
}
@ -220,7 +221,7 @@ dosfs_free_attr_cookie(fs_volume *_vol, fs_vnode *_node, void *cookie)
}
status_t
status_t
dosfs_read_attr_stat(fs_volume *_vol, fs_vnode *_node, void *_cookie,
struct stat *stat)
{
@ -244,7 +245,7 @@ dosfs_read_attr_stat(fs_volume *_vol, fs_vnode *_node, void *_cookie,
UNLOCK_VOL(vol);
return ENOENT;
}
stat->st_type = MIME_STRING_TYPE;
stat->st_size = strlen(node->mime) + 1;
@ -253,7 +254,7 @@ dosfs_read_attr_stat(fs_volume *_vol, fs_vnode *_node, void *_cookie,
}
status_t
status_t
dosfs_read_attr(fs_volume *_vol, fs_vnode *_node, void *_cookie, off_t pos,
void *buffer, size_t *_length)
{
@ -264,7 +265,7 @@ dosfs_read_attr(fs_volume *_vol, fs_vnode *_node, void *_cookie, off_t pos,
if (_cookie != &kBeOSTypeCookie)
return ENOENT;
LOCK_VOL(vol);
if (check_nspace_magic(vol, "dosfs_read_attr") ||
@ -291,6 +292,7 @@ dosfs_read_attr(fs_volume *_vol, fs_vnode *_node, void *_cookie, off_t pos,
return 0;
}
// suck up application attempts to set mime types; this hides an unsightly
// error message printed out by zip
status_t
@ -303,6 +305,6 @@ dosfs_write_attr(fs_volume *_vol, fs_vnode *_node, void *_cookie,
if (_cookie != &kBeOSTypeCookie)
return ENOSYS;
return B_OK;
}

View File

@ -14,7 +14,7 @@ status_t dosfs_close_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie);
status_t dosfs_free_attrdir_cookie(fs_volume *_vol, fs_vnode *_node,
void *_cookie);
status_t dosfs_rewind_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie);
status_t dosfs_read_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie,
status_t dosfs_read_attrdir(fs_volume *_vol, fs_vnode *_node, void *_cookie,
struct dirent *buf, size_t bufsize, uint32 *num);
status_t dosfs_open_attr(fs_volume *_vol, fs_vnode *_node, const char *name,
int openMode, void **_cookie);

View File

@ -3,7 +3,7 @@
This file may be used under the terms of the Be Sample Code License.
*/
#include <KernelExport.h>
#include <KernelExport.h>
#include <stdlib.h>
#include <dirent.h>
@ -90,7 +90,7 @@ _next_dirent_(struct diri *iter, struct _dirent_info_ *oinfo, char *filename,
}
return ENOENT;
}
if (buffer[0] == 0xe5) { // skip erased entries
if (start_index != 0xffff) {
dprintf("lfn entry (%s) with intervening erased entries\n", filename);
@ -99,9 +99,9 @@ _next_dirent_(struct diri *iter, struct _dirent_info_ *oinfo, char *filename,
DPRINTF(2, ("entry erased, skipping...\n"));
continue;
}
if (buffer[0xb] == 0xf) { // long file name
if ((buffer[0xc] != 0) ||
if ((buffer[0xc] != 0) ||
(buffer[0x1a] != 0) || (buffer[0x1b] != 0)) {
dprintf("invalid long file name: reserved fields munged\n");
continue;
@ -118,7 +118,7 @@ _next_dirent_(struct diri *iter, struct _dirent_info_ *oinfo, char *filename,
for (i = 1; i < 0x20; i += 2) {
if (*(uint16 *)&buffer[i] == 0xffff)
break;
*puni++ = *(uint16 *)&buffer[i];
*puni++ = *(uint16 *)&buffer[i];
if (i == 0x9) i+=3;
if (i == 0x18) i+=2;
}
@ -163,7 +163,7 @@ _next_dirent_(struct diri *iter, struct _dirent_info_ *oinfo, char *filename,
// process long name
if (start_index != 0xffff) {
if (lfn_count != 1) {
dprintf("unfinished lfn in directory\n");
dprintf("unfinished lfn in directory\n");
start_index = 0xffff;
} else {
if (unicode_to_utf8(uni, filename_len, (uint8*)filename, len)) {
@ -311,7 +311,7 @@ check_dir_empty(nspace *vol, vnode *dir)
break;
}
result = ENOTEMPTY;
result = ENOTEMPTY;
}
diri_free(&iter);
@ -458,7 +458,7 @@ erase_dir_entry(nspace *vol, vnode *node)
uint8 *buffer;
struct _dirent_info_ info;
struct diri diri;
DPRINTF(0, ("erasing directory entries %lx through %lx\n",
node->sindex, node->eindex));
buffer = diri_init(vol,VNODE_PARENT_DIR_CLUSTER(node), node->sindex, &diri);
@ -474,7 +474,7 @@ erase_dir_entry(nspace *vol, vnode *node)
if (result < 0)
return result;
if (info.sindex != node->sindex || info.eindex != node->eindex) {
// any other attributes may be in a state of flux due to wstat calls
dprintf("erase_dir_entry: directory entry doesn't match\n");
@ -564,7 +564,7 @@ find_short_name(nspace *vol, vnode *dir, const uchar *name)
struct diri diri;
uint8 *buffer;
status_t result = ENOENT;
buffer = diri_init(vol, dir->cluster, 0, &diri);
while (buffer) {
if (buffer[0] == 0)
@ -669,7 +669,7 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct _entry_info_ *info,
// if at end of directory, last_entry flag will be true as it should be
diri_free(&diri);
if (error != B_OK && error != ENOENT)
return error;
@ -691,7 +691,7 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct _entry_info_ *info,
DPRINTF(0, ("_create_dir_entry_: out of space in root directory\n"));
return ENOSPC;
}
// otherwise grow directory to fit
clusters_needed = ((*ne + 1) * 0x20 +
vol->bytes_per_sector*vol->sectors_per_cluster - 1) /
@ -759,7 +759,7 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct _entry_info_ *info,
buffer[0x1e] = (i >> 16) & 0xff;
buffer[0x1f] = (i >> 24) & 0xff;
diri_mark_dirty(&diri);
if (last_entry) {
// add end of directory markers to the rest of the
// cluster; need to clear all the other entries or else
@ -769,7 +769,7 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct _entry_info_ *info,
diri_mark_dirty(&diri);
}
}
diri_free(&diri);
return 0;
@ -804,10 +804,10 @@ is_filename_legal(const char *name)
{
unsigned int i;
unsigned int len = strlen(name);
if (len <= 0)
return false;
// names ending with a dot are not allowed
if (name[len - 1] == '.')
return false;
@ -883,7 +883,7 @@ create_dir_entry(nspace *vol, vnode *dir, vnode *node, const char *name,
error = B_OK;
else
error = find_short_name(vol, dir, nshort);
if (error == B_OK) {
do {
memcpy(nshort, tshort, 11);
@ -922,7 +922,7 @@ create_dir_entry(nspace *vol, vnode *dir, vnode *node, const char *name,
}
status_t
status_t
dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
uint32 *_flags, bool reenter)
{
@ -980,7 +980,7 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
result = ENOENT;
goto bi;
}
while (1) {
result = _next_dirent_(&iter, &info, filename, 512);
if (result < 0) {
@ -1033,7 +1033,7 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
* vol->sectors_per_cluster * vol->bytes_per_sector;
}
if (entry->cluster) {
entry->end_cluster = get_nth_fat_entry(vol, info.cluster,
entry->end_cluster = get_nth_fat_entry(vol, info.cluster,
(entry->st_size + vol->bytes_per_sector * vol->sectors_per_cluster - 1) /
vol->bytes_per_sector / vol->sectors_per_cluster - 1);
} else
@ -1064,7 +1064,7 @@ bi:
}
status_t
status_t
dosfs_walk(fs_volume *_vol, fs_vnode *_dir, const char *file, ino_t *_vnid)
{
/* Starting at the base, find file in the subdir, and return path
@ -1097,7 +1097,7 @@ dosfs_walk(fs_volume *_vol, fs_vnode *_dir, const char *file, ino_t *_vnid)
}
status_t
status_t
dosfs_access(fs_volume *_vol, fs_vnode *_node, int mode)
{
status_t result = B_OK;
@ -1133,7 +1133,7 @@ dosfs_access(fs_volume *_vol, fs_vnode *_node, int mode)
}
status_t
status_t
dosfs_readlink(fs_volume *_vol, fs_vnode *_node, char *buf, size_t *bufsize)
{
TOUCH(_vol); TOUCH(_node); TOUCH(buf); TOUCH(bufsize);
@ -1145,7 +1145,7 @@ dosfs_readlink(fs_volume *_vol, fs_vnode *_node, char *buf, size_t *bufsize)
}
status_t
status_t
dosfs_opendir(fs_volume *_vol, fs_vnode *_node, void **_cookie)
{
nspace *vol = (nspace*)_vol->private_volume;
@ -1190,7 +1190,7 @@ dosfs_opendir(fs_volume *_vol, fs_vnode *_node, void **_cookie)
cookie->current_index = 0;
result = B_NO_ERROR;
bi:
*_cookie = (void*)cookie;
@ -1203,8 +1203,8 @@ bi:
}
status_t
dosfs_readdir(fs_volume *_vol, fs_vnode *_dir, void *_cookie,
status_t
dosfs_readdir(fs_volume *_vol, fs_vnode *_dir, void *_cookie,
struct dirent *entry, size_t bufsize, uint32 *num)
{
int result = ENOENT;
@ -1214,7 +1214,7 @@ dosfs_readdir(fs_volume *_vol, fs_vnode *_dir, void *_cookie,
struct diri diri;
LOCK_VOL(vol);
if (check_nspace_magic(vol, "dosfs_readdir") ||
check_vnode_magic(dir, "dosfs_readdir") ||
check_dircookie_magic(cookie, "dosfs_readdir")) {
@ -1260,7 +1260,7 @@ dosfs_readdir(fs_volume *_vol, fs_vnode *_dir, void *_cookie,
if (dir->vnid == vol->root_vnode.vnid)
cookie->current_index += 2;
if (result == B_NO_ERROR) {
*num = 1;
entry->d_dev = vol->id;
@ -1282,7 +1282,7 @@ bi:
return result;
}
status_t
dosfs_rewinddir(fs_volume *_vol, fs_vnode *_node, void* _cookie)
@ -1310,7 +1310,7 @@ dosfs_rewinddir(fs_volume *_vol, fs_vnode *_node, void* _cookie)
}
status_t
status_t
dosfs_closedir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
{
TOUCH(_vol); TOUCH(_node); TOUCH(_cookie);
@ -1321,7 +1321,7 @@ dosfs_closedir(fs_volume *_vol, fs_vnode *_node, void *_cookie)
}
status_t
status_t
dosfs_free_dircookie(fs_volume *_vol, fs_vnode *_node, void *_cookie)
{
nspace *vol = (nspace *)_vol->private_volume;

View File

@ -12,13 +12,13 @@ status_t findfile_case(nspace *vol, vnode *dir, const char *file,
status_t findfile_nocase(nspace *vol, vnode *dir, const char *file,
ino_t *vnid, vnode **node);
status_t findfile_nocase_duplicates(nspace *vol, vnode *dir, const char *file,
ino_t *vnid, vnode **node, bool *dups_exist);
ino_t *vnid, vnode **node, bool *dups_exist);
status_t findfile_case_duplicates(nspace *vol, vnode *dir, const char *file,
ino_t *vnid, vnode **node, bool *dups_exist);
ino_t *vnid, vnode **node, bool *dups_exist);
status_t erase_dir_entry(nspace *vol, vnode *node);
status_t compact_directory(nspace *vol, vnode *dir);
status_t create_volume_label(nspace *vol, const char name[11], uint32 *index);
status_t create_dir_entry(nspace *vol, vnode *dir, vnode *node,
status_t create_dir_entry(nspace *vol, vnode *dir, vnode *node,
const char *name, uint32 *ns, uint32 *ne);
status_t dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node,

View File

@ -335,12 +335,12 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
of sectors. They say that they have 196576 sectors but they
really only have 196192. This check is a work-around for their
brain-deadness.
*/
*/
unsigned char bogus_zip_data[] = {
0x00, 0x02, 0x04, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00,
0xf8, 0xc0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00
};
if (memcmp(buf+0x0b, bogus_zip_data, sizeof(bogus_zip_data)) == 0 &&
vol->total_sectors == 196576 &&
((off_t)geo.sectors_per_track *
@ -370,8 +370,8 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
vol->root_vnode.st_size = vol->root_sectors * vol->bytes_per_sector;
vol->data_start = vol->root_start + vol->root_sectors;
vol->total_clusters = (vol->total_sectors - vol->data_start) / vol->sectors_per_cluster;
vol->total_clusters = (vol->total_sectors - vol->data_start) / vol->sectors_per_cluster;
// XXX: uncertain about border cases; win32 sdk says cutoffs are at
// at ff6/ff7 (or fff6/fff7), but that doesn't make much sense
if (vol->total_clusters > 0xff1)
@ -389,7 +389,7 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
}
// perform sanity checks on the FAT
// the media descriptor in active FAT should match the one in the BPB
if ((err = read_pos(vol->fd, vol->bytes_per_sector*(vol->reserved_sectors + vol->active_fat * vol->sectors_per_fat), (void *)buf, 0x200)) != 0x200) {
dprintf("dosfs: error reading FAT\n");
@ -417,7 +417,7 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
dprintf("dosfs error: media descriptor mismatch in fat # %ld (%x != %x)\n", i, buf2[0], vol->media_descriptor);
goto error;
}
#if 0
#if 0
// checking for exact matches of fats is too
// restrictive; allow these to go through in
// case the fat is corrupted for some reason
@ -474,13 +474,13 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
uint32 free_count, last_allocated;
err = get_fsinfo(vol, &free_count, &last_allocated);
if (err >= 0) {
if (free_count < vol->total_clusters)
if (free_count < vol->total_clusters)
vol->free_clusters = free_count;
else {
dprintf("free cluster count from fsinfo block invalid %lx\n", free_count);
err = -1;
}
if (last_allocated < vol->total_clusters)
if (last_allocated < vol->total_clusters)
vol->last_allocated = last_allocated; //update to a closer match
}
if (err < 0) {
@ -541,7 +541,7 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
if (!memcmp(vol->vol_label, "__RO__ ", 11)) {
vol->flags |= B_FS_IS_READONLY;
}
*newVol = vol;
return B_NO_ERROR;
@ -584,7 +584,7 @@ dosfs_identify_partition(int fd, partition_data *partition, void **_cookie)
uint32 sectors_per_fat;
char name[12];
identify_cookie *cookie;
// read in the boot sector
if (read_pos(fd, 0, (void*)buf, 512) != 512) {
return -1;
@ -638,7 +638,7 @@ dosfs_identify_partition(int fd, partition_data *partition, void **_cookie)
}
}
}
cookie = (identify_cookie *)malloc(sizeof(identify_cookie));
if (!cookie)
return -1;
@ -729,11 +729,11 @@ dosfs_mount(fs_volume *_vol, const char *device, uint32 flags,
char name[32];
if (check_nspace_magic(vol, "dosfs_mount")) return EINVAL;
*_rootID = vol->root_vnode.vnid;
_vol->private_volume = (void *)vol;
_vol->ops = &gFATVolumeOps;
// You MUST do this. Create the vnode for the root.
result = publish_vnode(_vol, *_rootID, (void*)&(vol->root_vnode),
&gFATVnodeOps, make_mode(vol, &vol->root_vnode), 0);
@ -776,7 +776,7 @@ update_fsinfo(nspace *vol)
&& (vol->flags & B_FS_IS_READONLY) == 0) {
uchar *buffer;
int32 tid = cache_start_transaction(vol->fBlockCache);
if ((buffer = (uchar *)block_cache_get_writable_etc(vol->fBlockCache,
if ((buffer = (uchar *)block_cache_get_writable_etc(vol->fBlockCache,
vol->fsinfo_sector, 0, vol->bytes_per_sector, tid)) != NULL) {
if ((read32(buffer,0) == 0x41615252) && (read32(buffer,0x1e4) == 0x61417272) && (read16(buffer,0x1fe) == 0xaa55)) {
//number of free clusters
@ -784,7 +784,7 @@ update_fsinfo(nspace *vol)
buffer[0x1e9] = ((vol->free_clusters >> 8) & 0xff);
buffer[0x1ea] = ((vol->free_clusters >> 16) & 0xff);
buffer[0x1eb] = ((vol->free_clusters >> 24) & 0xff);
//cluster number of most recently allocated cluster
//cluster number of most recently allocated cluster
buffer[0x1ec] = (vol->last_allocated & 0xff);
buffer[0x1ed] = ((vol->last_allocated >> 8) & 0xff);
buffer[0x1ee] = ((vol->last_allocated >> 16) & 0xff);
@ -804,19 +804,21 @@ update_fsinfo(nspace *vol)
}
}
static status_t get_fsinfo(nspace *vol, uint32 *free_count, uint32 *last_allocated)
static status_t
get_fsinfo(nspace *vol, uint32 *free_count, uint32 *last_allocated)
{
uchar *buffer;
int32 result;
if ((vol->fat_bits != 32) || (vol->fsinfo_sector == 0xffff))
return B_ERROR;
if ((buffer = (uchar *)block_cache_get_etc(vol->fBlockCache, vol->fsinfo_sector, 0, vol->bytes_per_sector)) == NULL) {
dprintf("get_fsinfo: error getting fsinfo sector %x\n", vol->fsinfo_sector);
return EIO;
}
if ((read32(buffer,0) == 0x41615252) && (read32(buffer,0x1e4) == 0x61417272) && (read16(buffer,0x1fe) == 0xaa55)) {
*free_count = read32(buffer,0x1e8);
*last_allocated = read32(buffer,0x1ec);
@ -831,7 +833,7 @@ static status_t get_fsinfo(nspace *vol, uint32 *free_count, uint32 *last_allocat
}
static status_t
static status_t
dosfs_unmount(fs_volume *_vol)
{
int result = B_NO_ERROR;
@ -839,16 +841,16 @@ dosfs_unmount(fs_volume *_vol)
nspace* vol = (nspace*)_vol->private_volume;
LOCK_VOL(vol);
if (check_nspace_magic(vol, "dosfs_unmount")) {
UNLOCK_VOL(vol);
return EINVAL;
}
DPRINTF(0, ("dosfs_unmount volume %lx\n", vol->id));
update_fsinfo(vol);
// Unlike in BeOS, we need to put the reference to our root node ourselves
put_vnode(_vol, vol->root_vnode.vnid);
block_cache_delete(vol->fBlockCache, true);
@ -880,8 +882,9 @@ dosfs_unmount(fs_volume *_vol)
return result;
}
// dosfs_read_fs_stat - Fill in fs_info struct for device.
static status_t
static status_t
dosfs_read_fs_stat(fs_volume *_vol, struct fs_info * fss)
{
nspace* vol = (nspace*)_vol->private_volume;
@ -897,16 +900,16 @@ dosfs_read_fs_stat(fs_volume *_vol, struct fs_info * fss)
DPRINTF(1, ("dosfs_read_fs_stat called\n"));
// fss->dev and fss->root filled in by kernel
// File system flags.
fss->flags = vol->flags;
// FS block size.
fss->block_size = vol->bytes_per_sector * vol->sectors_per_cluster;
// IO size - specifies buffer size for file copying
fss->io_size = 65536;
// Total blocks
fss->total_blocks = vol->total_clusters;
@ -933,12 +936,13 @@ dosfs_read_fs_stat(fs_volume *_vol, struct fs_info * fss)
// File system name
strcpy(fss->fsh_name, "fat");
UNLOCK_VOL(vol);
return B_OK;
}
static status_t
dosfs_write_fs_stat(fs_volume *_vol, const struct fs_info * fss, uint32 mask)
{
@ -1025,18 +1029,18 @@ dosfs_write_fs_stat(fs_volume *_vol, const struct fs_info * fss, uint32 mask)
if (result == 0)
memcpy(vol->vol_label, name, 11);
}
if (vol->fs_flags & FS_FLAGS_OP_SYNC)
_dosfs_sync(vol);
bi: UNLOCK_VOL(vol);
return result;
}
static status_t
dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, ulong code,
static status_t
dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, ulong code,
void *buf, size_t len)
{
status_t result = B_OK;
@ -1079,7 +1083,7 @@ dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, ulong code,
dprintf("root vnode id = %Lx\n", vol->root_vnode.vnid);
dprintf("volume label [%11.11s]\n", vol->vol_label);
break;
case 100001 :
dprintf("vnode id %Lx, dir vnid = %Lx\n", node->vnid, node->dir_vnid);
dprintf("si = %lx, ei = %lx\n", node->sindex, node->eindex);
@ -1131,12 +1135,12 @@ dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void *cookie, ulong code,
}
status_t
status_t
_dosfs_sync(nspace *vol)
{
if (check_nspace_magic(vol, "dosfs_sync"))
return EINVAL;
update_fsinfo(vol);
block_cache_sync(vol->fBlockCache);
@ -1144,14 +1148,14 @@ _dosfs_sync(nspace *vol)
}
static status_t
static status_t
dosfs_sync(fs_volume *_vol)
{
nspace *vol = (nspace *)_vol->private_volume;
status_t err;
DPRINTF(0, ("dosfs_sync called on volume %lx\n", vol->id));
LOCK_VOL(vol);
err = _dosfs_sync(vol);
UNLOCK_VOL(vol);
@ -1160,7 +1164,7 @@ dosfs_sync(fs_volume *_vol)
}
static status_t
static status_t
dosfs_fsync(fs_volume *_vol, fs_vnode *_node)
{
nspace *vol = (nspace *)_vol->private_volume;

View File

@ -84,7 +84,7 @@ typedef struct vnode {
* on the disk (or at least in the cache) so that get_next_dirent continues
* to function properly
*/
uint32 sindex, eindex; // starting and ending index of directory entry
uint32 sindex, eindex; // starting and ending index of directory entry
uint32 cluster; // starting cluster of the data
uint32 mode; // dos-style attributes
off_t st_size; // in bytes
@ -98,7 +98,7 @@ typedef struct vnode {
#if TRACK_FILENAME
char *filename;
#endif
#endif
} vnode;
// mode bits
@ -122,7 +122,7 @@ typedef struct _nspace
char device[256];
uint32 flags; // see <fcntl.be.h> for modes
void *fBlockCache;
// info from bpb
uint32 bytes_per_sector;
uint32 sectors_per_cluster;

View File

@ -570,7 +570,7 @@ const uint16 sjis81tou[] = {
0x6DC6, 0x6DEC, 0x6DDE, 0x6DCC, 0x6DE8, 0x6DD2, 0x6DC5, 0x6DFA, 0x6DD9, 0x6DE4, 0x6DD5, 0x6DEA, 0x6DEE, 0x6E2D, 0x6E6E, 0x6E2E,
0x6E19, 0x6E72, 0x6E5F, 0x6E3E, 0x6E23, 0x6E6B, 0x6E2B, 0x6E76, 0x6E4D, 0x6E1F, 0x6E43, 0x6E3A, 0x6E4E, 0x6E24, 0x6EFF, 0x6E1D,
0x6E38, 0x6E82, 0x6EAA, 0x6E98, 0x6EC9, 0x6EB7, 0x6ED3, 0x6EBD, 0x6EAF, 0x6EC4, 0x6EB2, 0x6ED4, 0x6ED5, 0x6E8F, 0x6EA5, 0x6EC2,
0x6E9F, 0x6F41, 0x6F11, 0x704C, 0x6EEC, 0x6EF8, 0x6EFE, 0x6F3F, 0x6EF2, 0x6F31, 0x6EEF, 0x6F32, 0x6ECC, 0x0000, 0x0000, 0x0000,
0x6E9F, 0x6F41, 0x6F11, 0x704C, 0x6EEC, 0x6EF8, 0x6EFE, 0x6F3F, 0x6EF2, 0x6F31, 0x6EEF, 0x6F32, 0x6ECC, 0x0000, 0x0000, 0x0000,
0xFFFF
};
@ -830,7 +830,7 @@ const uint16 sjise0tou[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xFFFF
};
@ -871,7 +871,7 @@ const table_segment sjistables[] = { {sjis00tou, 0x0000},
str[3] = 0x80 | (val&0x3f);\
uni_str += 2; str += 4;\
}\
}
}
// Pierre's Uber Macro
#define u_hostendian_to_utf8(str, uni_str)\
@ -925,7 +925,7 @@ const table_segment sjistables[] = { {sjis00tou, 0x0000},
}
// Count the number of bytes of a UTF-8 character
#define utf8_char_len(c) ((((int32)0xE5000000 >> ((c >> 3) & 0x1E)) & 3) + 1)
#define utf8_char_len(c) ((((int32)0xE5000000 >> ((c >> 3) & 0x1E)) & 3) + 1)
// converts LENDIAN unicode to utf8
static status_t
@ -939,7 +939,7 @@ _lendian_unicode_to_utf8(
int32 dstLimit = *dstLen;
int32 srcCount = 0;
int32 dstCount = 0;
for (srcCount = 0; srcCount < srcLimit; srcCount += 2) {
uint16 *UNICODE = (uint16 *)&src[srcCount];
uchar utf8[4];
@ -965,7 +965,7 @@ _lendian_unicode_to_utf8(
}
// utf8 to LENDIAN unicode
static status_t
static status_t
_utf8_to_lendian_unicode(
const char *src,
int32 *srcLen,
@ -984,7 +984,7 @@ _utf8_to_lendian_unicode(
int err_flag;
if ((srcCount + utf8_char_len(src[srcCount])) > srcLimit)
break;
break;
utf8_to_u_hostendian(UTF8, UNICODE, err_flag);
if(err_flag == 1)
@ -1023,10 +1023,10 @@ _one_to_utf8(
uint16 *UNICODE = &unicode;
uchar utf8[4];
uchar *UTF8 = utf8;
*(uint32 *)utf8 = 0;
u_hostendian_to_utf8(UTF8, UNICODE);
int32 utf8Len = UTF8 - utf8;
if ((dstCount + utf8Len) > dstLimit)
break;
@ -1057,13 +1057,13 @@ _utf8_to_sjis_bendian(
while ((srcCount < srcLimit) && (dstCount < dstLimit)) {
if ((srcCount + utf8_char_len(src[srcCount])) > srcLimit)
break;
break;
uint16 unicode;
uint16 *UNICODE = &unicode;
int err_flag;
bool multibyte = false;
const uint16 *table = NULL;
const uint16 *table = NULL;
uchar *UTF8 = (uchar *)src + srcCount;
utf8_to_u_hostendian(UTF8, UNICODE, err_flag);
@ -1077,7 +1077,7 @@ _utf8_to_sjis_bendian(
uint16 offset = sjistables[t].offset;
if (offset == 0x0000)
dst[dstCount] = i;
dst[dstCount] = i;
else {
if ((dstCount + 1) < dstLimit) {
uint16 sjis = offset + i;
@ -1127,7 +1127,7 @@ inline bool is_initial_sjis_byte(uchar c)
// takes a unicode name of unilen uchar's and converts to a utf8 name of at
// most utf8len uint8's
status_t unicode_to_utf8(const uchar *uni, uint32 unilen, uint8 *utf8,
status_t unicode_to_utf8(const uchar *uni, uint32 unilen, uint8 *utf8,
uint32 utf8len)
{
status_t result;
@ -1259,7 +1259,7 @@ status_t munge_short_name_sjis(uchar nshort[11], uint64 value)
if (nshort[i] == ' ') break;
if (is_initial_sjis_byte(nshort[i])) i++;
}
memcpy(nshort + last, buffer, len);
memset(nshort + last + len, ' ', 8 - (last + len));
@ -1459,8 +1459,8 @@ bi:
dprintf("generate_short_name_sjis error: %lx (%s)\n", result, strerror(result));
}
free(sjis);
free(sjis);
return result;
}
@ -1514,7 +1514,7 @@ status_t msdos_to_utf8(uchar *msdos, uchar *utf8, uint32 utf8len, bool toLower)
pos = 0;
for (i=0;i<8;i++) {
if (msdos[i] == ' ') break;
normalized[pos++] = ((i == 0) && (msdos[i] == 5)) ? 0xe5 :
normalized[pos++] = ((i == 0) && (msdos[i] == 5)) ? 0xe5 :
(toLower ? tolower(msdos[i]) : msdos[i]);
}
@ -1539,24 +1539,24 @@ bool requires_munged_short_name(const uchar *utf8name, const uchar nshort[11], i
int i, len;
if (encoding != MS_DOS_CONVERSION) return true;
for ( ; *utf8name != 0; utf8name++) {
if (!BEGINS_UTF8CHAR(*utf8name)) continue;
if (*utf8name == '.') break;
leading++;
if (leading > 8) return true;
if ((nshort[leading - 1] == '_') && (*utf8name != '_')) return true;
if ((nshort[leading - 1] == '_') && (*utf8name != '_')) return true;
}
if (*utf8name != 0) {
utf8name++;
for ( ; *utf8name != 0; utf8name++) {
if (!BEGINS_UTF8CHAR(*utf8name)) continue;
if (*utf8name == '.') return true;
trailing++;
if (trailing > 3) return true;
if ((nshort[leading + trailing - 1] == '_') && (*utf8name != '_')) return true;
if ((nshort[leading + trailing - 1] == '_') && (*utf8name != '_')) return true;
}
}
@ -1567,7 +1567,7 @@ bool requires_munged_short_name(const uchar *utf8name, const uchar nshort[11], i
for (i = 8, len = 0; i < 11; i++)
if (nshort[i] != ' ') len++;
if (len != trailing) return true;
return false;
}

View File

@ -2,7 +2,7 @@
Copyright 1999-2001, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
*/
#include <KernelExport.h>
#include <KernelExport.h>
#include <fs_cache.h>
#include <stdlib.h>
@ -21,16 +21,17 @@
#define DPRINTF(a,b) if (debug_fat > (a)) dprintf b
static status_t mirror_fats(nspace *vol, uint32 sector, uint8 *buffer, int32 tid)
static status_t
mirror_fats(nspace *vol, uint32 sector, uint8 *buffer, int32 tid)
{
uint32 i;
char *buf = buffer;
if (!vol->fat_mirrored)
return B_OK;
sector -= vol->active_fat * vol->sectors_per_fat;
for (i=0;i<vol->fat_count;i++) {
char *blockData;
if (i == vol->active_fat)
@ -40,11 +41,13 @@ static status_t mirror_fats(nspace *vol, uint32 sector, uint8 *buffer, int32 tid
buf += vol->bytes_per_sector;
block_cache_put(vol->fBlockCache, sector + i*vol->sectors_per_fat);
}
return B_OK;
}
static int32 _count_free_clusters_fat32(nspace *vol)
static int32
_count_free_clusters_fat32(nspace *vol)
{
int32 count = 0;
const uint8 *block;
@ -53,7 +56,7 @@ static int32 _count_free_clusters_fat32(nspace *vol)
uint32 cur_sector;
cur_sector = vol->reserved_sectors + vol->active_fat * vol->sectors_per_fat;
for(fat_sector = 0; fat_sector < vol->sectors_per_fat; fat_sector++) {
block = (uint8 *)block_cache_get(vol->fBlockCache, cur_sector);
if(block == NULL) {
@ -79,7 +82,8 @@ static int32 _count_free_clusters_fat32(nspace *vol)
enum { _IOCTL_COUNT_FREE_, _IOCTL_GET_ENTRY_, _IOCTL_SET_ENTRY_, _IOCTL_ALLOCATE_N_ENTRIES_ };
static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, int32 _tid)
static int32
_fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, int32 _tid)
{
int32 result = 0;
uint32 n = 0, first = 0, last = 0;
@ -97,15 +101,15 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
if (check_nspace_magic(vol, "_fat_ioctl_")) return EINVAL;
DPRINTF(3, ("_fat_ioctl_: action %lx, cluster %lx, N %lx\n", action, cluster, N));
if (action == _IOCTL_COUNT_FREE_) {
if(vol->fat_bits == 32)
// use a optimized version of the cluster counting algorithms
return _count_free_clusters_fat32(vol);
else
else
cluster = 2;
}
if (action == _IOCTL_ALLOCATE_N_ENTRIES_)
cluster = vol->last_allocated;
@ -120,7 +124,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
sector = vol->reserved_sectors + vol->active_fat * vol->sectors_per_fat +
off / vol->bytes_per_sector;
off %= vol->bytes_per_sector;
if (action != _IOCTL_SET_ENTRY_ && action != _IOCTL_ALLOCATE_N_ENTRIES_) {
block1 = (uint8 *)block_cache_get(vol->fBlockCache, sector);
} else {
@ -128,12 +132,12 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
tid = cache_start_transaction(vol->fBlockCache);
block1 = (uint8 *)block_cache_get_writable(vol->fBlockCache, sector, tid);
}
if (block1 == NULL) {
DPRINTF(0, ("_fat_ioctl_: error reading fat (sector %lx)\n", sector));
return EIO;
}
for (i=0;i<vol->total_clusters;i++) {
ASSERT(IS_DATA_CLUSTER(cluster));
ASSERT(off == ((cluster * vol->fat_bits / 8) % vol->bytes_per_sector));
@ -144,7 +148,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
block2 = (uint8 *)block_cache_get(vol->fBlockCache, ++sector);
else
block2 = (uint8 *)block_cache_get_writable(vol->fBlockCache, ++sector, tid);
if (block2 == NULL) {
DPRINTF(0, ("_fat_ioctl_: error reading fat (sector %lx)\n", sector));
result = EIO;
@ -186,7 +190,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
block1[off+1] |= (ormask >> 8);
}
}
if (off == vol->bytes_per_sector - 1) {
off = (cluster & 1) ? 1 : 0;
block_cache_put(vol->fBlockCache, sector - 1);
@ -216,7 +220,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
}
if (((action == _IOCTL_ALLOCATE_N_ENTRIES_) && (val == 0)) ||
(action == _IOCTL_SET_ENTRY_)) {
ASSERT((V & 0xf0000000) == 0);
ASSERT((V & 0xf0000000) == 0);
*(uint32 *)&block1[off] = B_HOST_TO_LENDIAN_INT32(V);
// block1[off] = V & 0xff;
// block1[off+1] = (V >> 8) & 0xff;
@ -265,7 +269,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
// iterate cluster and sector if needed
if (++cluster == vol->total_clusters + 2) {
block_cache_put(vol->fBlockCache, sector);
cluster = 2;
off = 2 * vol->fat_bits / 8;
sector = vol->reserved_sectors + vol->active_fat * vol->sectors_per_fat;
@ -278,17 +282,17 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
if (off >= vol->bytes_per_sector) {
block_cache_put(vol->fBlockCache, sector);
off -= vol->bytes_per_sector;
off -= vol->bytes_per_sector;
sector++;
ASSERT(sector < vol->reserved_sectors + (vol->active_fat + 1) * vol->sectors_per_fat);
if (action != _IOCTL_SET_ENTRY_ && action != _IOCTL_ALLOCATE_N_ENTRIES_)
block1 = (uint8 *)block_cache_get(vol->fBlockCache, sector);
else
block1 = (uint8 *)block_cache_get_writable(vol->fBlockCache, sector, tid);
}
if (block1 == NULL) {
DPRINTF(0, ("_fat_ioctl_: error reading fat (sector %lx)\n", sector));
result = EIO;
@ -297,7 +301,7 @@ static int32 _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster, int32 N, in
}
bi:
if (block1)
if (block1)
block_cache_put(vol->fBlockCache, sector);
if (_tid == -1 && tid > 0)
cache_end_transaction(vol->fBlockCache, tid, NULL, NULL);
@ -323,12 +327,16 @@ bi:
return result;
}
int32 count_free_clusters(nspace *vol)
int32
count_free_clusters(nspace *vol)
{
return _fat_ioctl_(vol, _IOCTL_COUNT_FREE_, 0, 0, -1);
}
static int32 get_fat_entry(nspace *vol, uint32 cluster)
static int32
get_fat_entry(nspace *vol, uint32 cluster)
{
int32 value = _fat_ioctl_(vol, _IOCTL_GET_ENTRY_, cluster, 0, -1);
@ -340,7 +348,7 @@ static int32 get_fat_entry(nspace *vol, uint32 cluster)
if (value > 0x0ffffff7)
return END_FAT_ENTRY;
if (value > 0x0ffffff0)
return BAD_FAT_ENTRY;
@ -348,13 +356,17 @@ static int32 get_fat_entry(nspace *vol, uint32 cluster)
return BAD_FAT_ENTRY;
}
static status_t set_fat_entry(nspace *vol, uint32 cluster, int32 value)
static status_t
set_fat_entry(nspace *vol, uint32 cluster, int32 value)
{
return _fat_ioctl_(vol, _IOCTL_SET_ENTRY_, cluster, value, -1);
}
// traverse n fat entries
int32 get_nth_fat_entry(nspace *vol, int32 cluster, uint32 n)
int32
get_nth_fat_entry(nspace *vol, int32 cluster, uint32 n)
{
if (check_nspace_magic(vol, "get_nth_fat_entry")) return EINVAL;
@ -366,19 +378,21 @@ int32 get_nth_fat_entry(nspace *vol, int32 cluster, uint32 n)
}
ASSERT(cluster != 0);
return cluster;
}
// count number of clusters in fat chain starting at given cluster
// should only be used for calculating directory sizes because it doesn't
// return proper error codes
uint32 count_clusters(nspace *vol, int32 cluster)
uint32
count_clusters(nspace *vol, int32 cluster)
{
int32 count = 0;
DPRINTF(2, ("count_clusters %lx\n", cluster));
if (check_nspace_magic(vol, "count_clusters")) return 0;
// not intended for use on root directory
@ -408,7 +422,9 @@ uint32 count_clusters(nspace *vol, int32 cluster)
return 0;
}
status_t clear_fat_chain(nspace *vol, uint32 cluster)
status_t
clear_fat_chain(nspace *vol, uint32 cluster)
{
int32 c;
status_t result;
@ -442,7 +458,9 @@ status_t clear_fat_chain(nspace *vol, uint32 cluster)
return 0;
}
status_t allocate_n_fat_entries(nspace *vol, int32 n, int32 *start)
status_t
allocate_n_fat_entries(nspace *vol, int32 n, int32 *start)
{
int32 c;
@ -463,13 +481,15 @@ status_t allocate_n_fat_entries(nspace *vol, int32 n, int32 *start)
return 0;
}
status_t set_fat_chain_length(nspace *vol, vnode *node, uint32 clusters)
status_t
set_fat_chain_length(nspace *vol, vnode *node, uint32 clusters)
{
status_t result;
int32 i, c, n;
DPRINTF(1, ("set_fat_chain_length: %Lx to %lx clusters (%lx)\n", node->vnid, clusters, node->cluster));
if (IS_FIXED_ROOT(node->cluster) || (!IS_DATA_CLUSTER(node->cluster) && (node->cluster != 0))) {
DPRINTF(0, ("set_fat_chain_length called on invalid cluster (%lx)\n", node->cluster));
return EINVAL;
@ -570,7 +590,9 @@ status_t set_fat_chain_length(nspace *vol, vnode *node, uint32 clusters)
return clear_fat_chain(vol, n);
}
void dump_fat_chain(nspace *vol, uint32 cluster)
void
dump_fat_chain(nspace *vol, uint32 cluster)
{
dprintf("fat chain: %lx", cluster);
while (IS_DATA_CLUSTER(cluster)) {

View File

@ -1363,6 +1363,7 @@ dosfs_remove_vnode(fs_volume *_vol, fs_vnode *_node, bool reenter)
return B_OK;
}
// get rid of node or directory
static status_t
do_unlink(fs_volume *_vol, fs_vnode *_dir, const char *name, bool is_file)
@ -1475,6 +1476,7 @@ bi:
return result;
}
status_t
dosfs_unlink(fs_volume *vol, fs_vnode *dir, const char *name)
{

View File

@ -49,8 +49,8 @@ csi_to_block(struct csi *csi)
if (IS_FIXED_ROOT(csi->cluster))
return csi->vol->root_start + csi->sector;
return csi->vol->data_start +
(off_t)(csi->cluster - 2)* csi->vol->sectors_per_cluster +
return csi->vol->data_start +
(off_t)(csi->cluster - 2)* csi->vol->sectors_per_cluster +
csi->sector;
}
@ -61,9 +61,9 @@ init_csi(nspace *vol, uint32 cluster, uint32 sector, struct csi *csi)
int ret;
if ((ret = _validate_cs_(vol,cluster,sector)) != 0)
return ret;
csi->vol = vol; csi->cluster = cluster; csi->sector = sector;
return 0;
}
@ -76,13 +76,13 @@ iter_csi(struct csi *csi, int sectors)
if (sectors < 0)
return EINVAL;
if (sectors == 0)
return 0;
if (IS_FIXED_ROOT(csi->cluster)) {
csi->sector += sectors;
if (csi->sector < csi->vol->root_sectors)
if (csi->sector < csi->vol->root_sectors)
return 0;
} else {
csi->sector += sectors;
@ -103,7 +103,7 @@ iter_csi(struct csi *csi, int sectors)
}
csi->sector = 0xffff;
return -1;
}
@ -147,7 +147,7 @@ csi_mark_block_dirty(struct csi *csi, int32 tid)
// TODO : block_cache doesn't implement this
//block_cache_set_dirty(csi->vol->fBlockCache, csi_to_block(csi), true, tid);
return B_OK;
}
@ -162,7 +162,7 @@ csi_read_blocks(struct csi *csi, uint8 *buffer, ssize_t len)
status_t err;
char *buf = buffer;
int32 i;
ASSERT(len >= csi->vol->bytes_per_sector);
if (_validate_cs_(csi->vol, csi->cluster, csi->sector) != 0)
@ -247,13 +247,13 @@ csi_write_block(struct csi *csi, uint8 *buffer)
off_t block;
int32 tid;
char *blockData;
block = csi_to_block(csi);
ASSERT(_validate_cs_(csi->vol, csi->cluster, csi->sector) == 0);
if (_validate_cs_(csi->vol, csi->cluster, csi->sector) != 0)
return EINVAL;
tid = cache_start_transaction(csi->vol->fBlockCache);
blockData = block_cache_get_writable_etc(csi->vol->fBlockCache, block, 0, 1, tid);
memcpy(blockData, buffer, csi->vol->bytes_per_sector);
@ -293,7 +293,7 @@ diri_init(nspace *vol, uint32 cluster, uint32 index, struct diri *diri)
&& iter_csi(&(diri->csi), diri->current_index
/ (vol->bytes_per_sector / 0x20)) != 0)
return NULL;
diri->tid = cache_start_transaction(diri->csi.vol->fBlockCache);
if (diri->tid < B_OK)
return NULL;
@ -322,7 +322,7 @@ diri_free(struct diri *diri)
if (diri->current_block)
_diri_release_current_block_(diri);
cache_end_transaction(diri->csi.vol->fBlockCache, diri->tid, NULL, NULL);
return 0;
@ -333,7 +333,7 @@ uint8 *
diri_current_entry(struct diri *diri)
{
if (check_diri_magic(diri, "diri_current_entry")) return NULL;
if (diri->current_block == NULL)
return NULL;
@ -346,7 +346,7 @@ uint8 *
diri_next_entry(struct diri *diri)
{
if (check_diri_magic(diri, "diri_next_entry")) return NULL;
if (diri->current_block == NULL)
return NULL;
@ -358,7 +358,7 @@ diri_next_entry(struct diri *diri)
if (diri->current_block == NULL)
return NULL;
}
return diri->current_block
+ (diri->current_index % (diri->csi.vol->bytes_per_sector / 0x20))*0x20;
}

View File

@ -1,7 +1,7 @@
/*
Copyright 1999-2001, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
extended: 2001-12-11 by Marcus Overhagen
*/

View File

@ -19,7 +19,8 @@ static int32 tzoffset = -1; /* in minutes */
#ifdef DEBUG
int _assert_(char *a, int b, char *c)
int
_assert_(char *a, int b, char *c)
{
dprintf("tripped assertion in %s/%d (%s)\n", a, b, c);
kernel_debugger("tripped assertion");
@ -28,12 +29,15 @@ int _assert_(char *a, int b, char *c)
#endif
static void print_byte(uint8 c)
static void
print_byte(uint8 c)
{
dprintf("%c", ((c >= ' ') && (c <= '~')) ? c : '.');
}
void dump_bytes(uint8 *buffer, uint32 count)
void
dump_bytes(uint8 *buffer, uint32 count)
{
uint32 i, j, k;
for (i=0;i<0x10;i++)
@ -52,16 +56,20 @@ void dump_bytes(uint8 *buffer, uint32 count)
}
}
void dump_directory(uint8 *buffer)
void
dump_directory(uint8 *buffer)
{
dump_bytes(buffer, 32);
}
static void get_tzoffset()
static void
get_tzoffset()
{
rtc_info info;
if (tzoffset != -1)
if (tzoffset != -1)
return;
if (get_rtc_info(&info) < 0) {
@ -71,6 +79,7 @@ static void get_tzoffset()
}
}
// If divisible by 4, but not divisible by 100, but divisible by 400, it's a leap year
// 1996 is leap, 1900 is not, 2000 is, 2100 is not
#define IS_LEAP_YEAR(y) ((((y) % 4) == 0) && (((y) % 100) || ((((y)) % 400) == 0)))
@ -88,7 +97,8 @@ static int leaps(int yr, int mon)
static int daze[] = { 0,0,31,59,90,120,151,181,212,243,273,304,334,0,0,0 };
time_t dos2time_t(uint32 t)
time_t
dos2time_t(uint32 t)
{
time_t days;
@ -103,7 +113,9 @@ time_t dos2time_t(uint32 t)
return (((days * 24) + ((t>>11)&31)) * 60 + ((t>>5)&63) + tzoffset) * 60 + 2*(t&31);
}
uint32 time_t2dos(time_t s)
uint32
time_t2dos(time_t s)
{
uint32 t, d, y;
int days;
@ -141,7 +153,9 @@ bi:
return t + (d << 16) + (y << 25);
}
uint8 hash_msdos_name(const char *name)
uint8
hash_msdos_name(const char *name)
{
const uint8 *p = (const uint8 *)name;
int i;

View File

@ -16,7 +16,7 @@ There are three ways to encode a vnode id:
directory it appears in. This is used for files with data.
2. Combine the starting cluster of the directory the entry appears in with the
index of the entry in the directory. This is used for 0-byte files.
3. A unique number that doesn't match any possible values from encodings 1 or
3. A unique number that doesn't match any possible values from encodings 1 or
2.
With the first encoding, the vnode id is invalidated (i.e. no longer describes
@ -73,7 +73,7 @@ void dump_vcache(nspace *vol)
uint32 i;
struct vcache_entry *c;
dprintf("vnid cache size %lx, cur vnid = %Lx\n"
"vnid loc\n",
"vnid loc\n",
vol->vcache.cache_size, vol->vcache.cur_vnid);
for (i=0;i<vol->vcache.cache_size;i++)
for (c = vol->vcache.by_vnid[i];c;c=c->next_vnid)
@ -118,7 +118,9 @@ status_t init_vcache(nspace *vol)
return 0;
}
status_t uninit_vcache(nspace *vol)
status_t
uninit_vcache(nspace *vol)
{
uint32 i, count = 0;
struct vcache_entry *c, *n;
@ -147,7 +149,9 @@ status_t uninit_vcache(nspace *vol)
return 0;
}
ino_t generate_unique_vnid(nspace *vol)
ino_t
generate_unique_vnid(nspace *vol)
{
DPRINTF(0, ("generate_unique_vnid\n"));
/* only one thread per volume will be in here at any given time anyway
@ -155,7 +159,9 @@ ino_t generate_unique_vnid(nspace *vol)
return vol->vcache.cur_vnid++;
}
static status_t _add_to_vcache_(nspace *vol, ino_t vnid, ino_t loc)
static status_t
_add_to_vcache_(nspace *vol, ino_t vnid, ino_t loc)
{
int hash1 = hash(vnid), hash2 = hash(loc);
struct vcache_entry *e, *c, *p;
@ -205,7 +211,9 @@ static status_t _add_to_vcache_(nspace *vol, ino_t vnid, ino_t loc)
return B_OK;
}
static status_t _remove_from_vcache_(nspace *vol, ino_t vnid)
static status_t
_remove_from_vcache_(nspace *vol, ino_t vnid)
{
int hash1 = hash(vnid), hash2;
struct vcache_entry *c, *p, *e;
@ -252,7 +260,9 @@ static status_t _remove_from_vcache_(nspace *vol, ino_t vnid)
return 0;
}
static struct vcache_entry *_find_vnid_in_vcache_(nspace *vol, ino_t vnid)
static struct vcache_entry *
_find_vnid_in_vcache_(nspace *vol, ino_t vnid)
{
int hash1 = hash(vnid);
struct vcache_entry *c;
@ -268,7 +278,9 @@ static struct vcache_entry *_find_vnid_in_vcache_(nspace *vol, ino_t vnid)
return c;
}
static struct vcache_entry *_find_loc_in_vcache_(nspace *vol, ino_t loc)
static struct vcache_entry *
_find_loc_in_vcache_(nspace *vol, ino_t loc)
{
int hash2 = hash(loc);
struct vcache_entry *c;
@ -284,7 +296,9 @@ static struct vcache_entry *_find_loc_in_vcache_(nspace *vol, ino_t loc)
return c;
}
status_t add_to_vcache(nspace *vol, ino_t vnid, ino_t loc)
status_t
add_to_vcache(nspace *vol, ino_t vnid, ino_t loc)
{
status_t result;
@ -296,8 +310,10 @@ status_t add_to_vcache(nspace *vol, ino_t vnid, ino_t loc)
return result;
}
/* XXX: do this in a smarter fashion */
static status_t _update_loc_in_vcache_(nspace *vol, ino_t vnid, ino_t loc)
static status_t
_update_loc_in_vcache_(nspace *vol, ino_t vnid, ino_t loc)
{
status_t result;
@ -308,7 +324,9 @@ static status_t _update_loc_in_vcache_(nspace *vol, ino_t vnid, ino_t loc)
return result;
}
status_t remove_from_vcache(nspace *vol, ino_t vnid)
status_t
remove_from_vcache(nspace *vol, ino_t vnid)
{
status_t result;
@ -320,7 +338,9 @@ status_t remove_from_vcache(nspace *vol, ino_t vnid)
return result;
}
status_t vcache_vnid_to_loc(nspace *vol, ino_t vnid, ino_t *loc)
status_t
vcache_vnid_to_loc(nspace *vol, ino_t vnid, ino_t *loc)
{
struct vcache_entry *e;
@ -335,7 +355,9 @@ status_t vcache_vnid_to_loc(nspace *vol, ino_t vnid, ino_t *loc)
return (e) ? B_OK : ENOENT;
}
status_t vcache_loc_to_vnid(nspace *vol, ino_t loc, ino_t *vnid)
status_t
vcache_loc_to_vnid(nspace *vol, ino_t loc, ino_t *vnid)
{
struct vcache_entry *e;
@ -350,7 +372,9 @@ status_t vcache_loc_to_vnid(nspace *vol, ino_t loc, ino_t *vnid)
return (e) ? B_OK : ENOENT;
}
status_t vcache_set_entry(nspace *vol, ino_t vnid, ino_t loc)
status_t
vcache_set_entry(nspace *vol, ino_t vnid, ino_t loc)
{
struct vcache_entry *e;
status_t result = B_OK;
@ -385,7 +409,8 @@ status_t vcache_set_entry(nspace *vol, ino_t vnid, ino_t loc)
#if DEBUG
int debug_dfvnid(int argc, char **argv)
int
debug_dfvnid(int argc, char **argv)
{
int i;
nspace *vol;