[haiku-commits] haiku: hrev49140 - src/add-ons/kernel/file_systems/fat

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 2 May 2015 15:51:30 +0200 (CEST)

hrev49140 adds 3 changesets to branch 'master'
old head: 51b75965cd8c5b1cc192eb7572f5ba3c074edf27
new head: 52bf63bbbb868d5b7221102f0fba52b883970dce
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=52bf63bbbb86+%5E51b75965cd8c

----------------------------------------------------------------------------

110eea4517ad: fat: Print format, whitespace and style cleanup only.

I took the liberty to convert most of the debug output from hex to
decimal as unprefixed hex values are rather confusing.

09592b1dccf4: fat: Fix stack corruption on 64 bit due to wrong count type.

On 64 bit platforms a 64 bit size_t was written at the (incorrect)
uint32 on the stack, causing the adjacent bytes variable to be
clobbered. Because of this, the vectors wouldn't actually be filled
with any file data, making the content of files inacessible.

52bf63bbbb86: fat: Fix compiler warnings.

[ Michael Lotz <mmlr@xxxxxxxx> ]

----------------------------------------------------------------------------

11 files changed, 284 insertions(+), 221 deletions(-)
src/add-ons/kernel/file_systems/fat/Jamfile | 2 +-
src/add-ons/kernel/file_systems/fat/dir.c | 87 +++++-----
src/add-ons/kernel/file_systems/fat/dlist.c | 19 ++-
src/add-ons/kernel/file_systems/fat/dosfs.c | 160 ++++++++++---------
src/add-ons/kernel/file_systems/fat/dosfs.h | 8 +-
.../kernel/file_systems/fat/encodings.cpp | 13 +-
src/add-ons/kernel/file_systems/fat/fat.c | 81 +++++-----
src/add-ons/kernel/file_systems/fat/file.c | 80 ++++++----
src/add-ons/kernel/file_systems/fat/iter.c | 4 +-
src/add-ons/kernel/file_systems/fat/util.c | 13 +-
src/add-ons/kernel/file_systems/fat/vcache.c | 38 +++--

############################################################################

Commit: 110eea4517ade1a0d69a82271d1106cfd68fa5c6
URL: http://cgit.haiku-os.org/haiku/commit/?id=110eea4517ad
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat May 2 09:57:31 2015 UTC

fat: Print format, whitespace and style cleanup only.

I took the liberty to convert most of the debug output from hex to
decimal as unprefixed hex values are rather confusing.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/fat/Jamfile
b/src/add-ons/kernel/file_systems/fat/Jamfile
index 4b2cb09..b08c69c 100644
--- a/src/add-ons/kernel/file_systems/fat/Jamfile
+++ b/src/add-ons/kernel/file_systems/fat/Jamfile
@@ -16,5 +16,5 @@ KernelAddon fat :
mime_table.c
util.c
vcache.c
- version.c
+ version.c
;
diff --git a/src/add-ons/kernel/file_systems/fat/dir.c
b/src/add-ons/kernel/file_systems/fat/dir.c
index 96753be..ff3b881 100644
--- a/src/add-ons/kernel/file_systems/fat/dir.c
+++ b/src/add-ons/kernel/file_systems/fat/dir.c
@@ -79,8 +79,8 @@ _next_dirent_(struct diri *iter, struct _dirent_info_ *oinfo,
char *filename,
% (iter->csi.vol->bytes_per_sector / 0x20)) * 0x20;

for (; buffer != NULL; buffer = diri_next_entry(iter)) {
- DPRINTF(2, ("_next_dirent_: %lx/%lx/%lx\n", iter->csi.cluster,
- iter->csi.sector, iter->current_index));
+ DPRINTF(2, ("_next_dirent_: %" B_PRIu32 "/%" B_PRIu32 "/%"
B_PRIu32
+ "\n", iter->csi.cluster, iter->csi.sector,
iter->current_index));
if (buffer[0] == 0) { // quit if at end of table
if (start_index != 0xffff)
dprintf("lfn entry (%" B_PRIu32 ") with no
alias\n", lfn_count);
@@ -264,7 +264,7 @@ get_next_dirent(nspace *vol, vnode *dir, struct diri *iter,
ino_t *vnid,
}
}

- DPRINTF(2, ("get_next_dirent: found %s (vnid %Lx)\n", filename,
+ DPRINTF(2, ("get_next_dirent: found %s (vnid %" B_PRIdINO ")\n",
filename,
vnid != NULL ? *vnid : (ino_t)0));

return B_NO_ERROR;
@@ -364,7 +364,7 @@ findfile(nspace *vol, vnode *dir, const char *file, ino_t
*vnid,

// dprintf("findfile: %s in %Lx, case %d dups %d\n", file, dir->vnid,
check_case, check_dups);

- DPRINTF(1, ("findfile: %s in %Lx\n", file, dir->vnid));
+ DPRINTF(1, ("findfile: %s in %" B_PRIdINO "\n", file, dir->vnid));

if (dups_exist != NULL)
*dups_exist = false;
@@ -446,8 +446,8 @@ erase_dir_entry(nspace *vol, vnode *node)
struct _dirent_info_ info;
struct diri diri;

- DPRINTF(0, ("erasing directory entries %lx through %lx\n",
- node->sindex, node->eindex));
+ DPRINTF(0, ("erasing directory entries %" B_PRIu32 " through %" B_PRIu32
+ "\n", node->sindex, node->eindex));
buffer = diri_init(vol,VNODE_PARENT_DIR_CLUSTER(node), node->sindex,
&diri);

// first pass: check if the entry is still valid
@@ -493,15 +493,16 @@ compact_directory(nspace *vol, vnode *dir)
struct diri diri;
status_t error = B_ERROR; /* quiet warning */

- DPRINTF(0, ("compacting directory with vnode id %Lx\n", dir->vnid));
+ DPRINTF(0, ("compacting directory with vnode id %" B_PRIdINO "\n",
+ dir->vnid));

// root directory can't shrink in fat12 and fat16
if (IS_FIXED_ROOT(dir->cluster))
return 0;

if (diri_init(vol, dir->cluster, 0, &diri) == NULL) {
- dprintf("compact_directory: cannot open dir at cluster (%lx)\n",
- dir->cluster);
+ dprintf("compact_directory: cannot open dir at cluster (%"
B_PRIu32
+ ")\n", dir->cluster);
return EIO;
}
while (diri.current_block) {
@@ -525,10 +526,13 @@ compact_directory(nspace *vol, vnode *dir)
if (clusters == 0)
clusters = 1;

- if (clusters * vol->bytes_per_sector *
vol->sectors_per_cluster < dir->st_size) {
- DPRINTF(0, ("shrinking directory to %lx
clusters\n", clusters));
+ if (clusters * vol->bytes_per_sector *
vol->sectors_per_cluster
+ < dir->st_size) {
+ DPRINTF(0, ("shrinking directory to %" B_PRIu32
" clusters\n",
+ clusters));
error = set_fat_chain_length(vol, dir,
clusters);
- dir->st_size =
clusters*vol->bytes_per_sector*vol->sectors_per_cluster;
+ dir->st_size = clusters * vol->bytes_per_sector
+ * vol->sectors_per_cluster;
dir->iteration++;
}
break;
@@ -618,7 +622,8 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct
_entry_info_ *info,
}

if (info->cluster != 0 && !IS_DATA_CLUSTER(info->cluster)) {
- dprintf("_create_dir_entry_ for bad cluster (%lx)\n",
info->cluster);
+ dprintf("_create_dir_entry_ for bad cluster (%" B_PRIu32 ")\n",
+ info->cluster);
return EINVAL;
}

@@ -629,7 +634,8 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct
_entry_info_ *info,
*ns = 0;
last_entry = true;
if (diri_init(vol, dir->cluster, 0, &diri) == NULL) {
- dprintf("_create_dir_entry_: cannot open dir at cluster
(%lx)\n", dir->cluster);
+ dprintf("_create_dir_entry_: cannot open dir at cluster (%"
B_PRIu32
+ ")\n", dir->cluster);
return EIO;
}

@@ -667,7 +673,9 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct
_entry_info_ *info,
GENERATE_DIR_INDEX_VNID(dir->cluster, i)) == ENOENT);
}

- DPRINTF(0, ("directory entry runs from %lx to %lx (dirsize = %Lx) (is%s
last entry)\n", *ns, *ne, dir->st_size, last_entry ? "" : "n't"));
+ DPRINTF(0, ("directory entry runs from %" B_PRIu32 " to %" B_PRIu32
+ " (dirsize = %" B_PRIdOFF ") (is%s last entry)\n", *ns, *ne,
+ dir->st_size, last_entry ? "" : "n't"));

// check if the directory needs to be expanded
if (*ne * 0x20 >= dir->st_size) {
@@ -684,8 +692,9 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct
_entry_info_ *info,
vol->bytes_per_sector*vol->sectors_per_cluster - 1) /
vol->bytes_per_sector / vol->sectors_per_cluster;

- DPRINTF(0, ("expanding directory from %Lx to %lx clusters\n",
-
dir->st_size/vol->bytes_per_sector/vol->sectors_per_cluster, clusters_needed));
+ DPRINTF(0, ("expanding directory from %" B_PRIdOFF " to %"
B_PRIu32
+ " clusters\n", dir->st_size / vol->bytes_per_sector
+ / vol->sectors_per_cluster, clusters_needed));
if ((error = set_fat_chain_length(vol, dir, clusters_needed)) <
0)
return error;
dir->st_size =
vol->bytes_per_sector*vol->sectors_per_cluster*clusters_needed;
@@ -695,8 +704,8 @@ _create_dir_entry_(nspace *vol, vnode *dir, struct
_entry_info_ *info,
// starting blitting entries
buffer = diri_init(vol,dir->cluster, *ns, &diri);
if (buffer == NULL) {
- dprintf("_create_dir_entry_: cannot open dir at (%lx, %lu)\n",
- dir->cluster, *ns);
+ dprintf("_create_dir_entry_: cannot open dir at (%" B_PRIu32 ",
%"
+ B_PRIu32 ")\n", dir->cluster, *ns);
return EIO;
}
hash = hash_msdos_name(nshort);
@@ -832,7 +841,8 @@ create_dir_entry(nspace *vol, vnode *dir, vnode *node,
const char *name,
// check if name already exists
error = findfile_nocase(vol, dir, name, NULL, NULL);
if (error == B_OK) {
- DPRINTF(0, ("%s already found in directory %Lx\n", name,
dir->vnid));
+ DPRINTF(0, ("%s already found in directory %" B_PRIdINO "\n",
name,
+ dir->vnid));
return EEXIST;
}
if (error != ENOENT)
@@ -929,7 +939,7 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode
*_node, int *_type,
_node->ops = &gFATVnodeOps;
*_flags = 0;

- DPRINTF(0, ("dosfs_read_vnode (vnode id %Lx)\n", vnid));
+ DPRINTF(0, ("dosfs_read_vnode (vnode id %" B_PRIdINO ")\n", vnid));

if (vnid == vol->root_vnode.vnid) {
dprintf("??? dosfs_read_vnode called on root node ???\n");
@@ -942,14 +952,15 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode
*_node, int *_type,
loc = vnid;

if (IS_ARTIFICIAL_VNID(loc) || IS_INVALID_VNID(loc)) {
- DPRINTF(0, ("dosfs_read_vnode: unknown vnid %Lx (loc %Lx)\n",
vnid, loc));
+ DPRINTF(0, ("dosfs_read_vnode: unknown vnid %" B_PRIdINO " (loc
%"
+ B_PRIdINO ")\n", vnid, loc));
result = ENOENT;
goto bi;
}

if ((dir_vnid = dlist_find(vol, DIR_OF_VNID(loc))) == -1LL) {
- DPRINTF(0, ("dosfs_read_vnode: unknown directory at cluster
%lx\n",
- DIR_OF_VNID(loc)));
+ DPRINTF(0, ("dosfs_read_vnode: unknown directory at cluster %"
B_PRIu32
+ "\n", DIR_OF_VNID(loc)));
result = ENOENT;
goto bi;
}
@@ -957,8 +968,8 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode
*_node, int *_type,
if (diri_init(vol, DIR_OF_VNID(loc),
IS_DIR_CLUSTER_VNID(loc) ? 0 :
INDEX_OF_DIR_INDEX_VNID(loc),
&iter) == NULL) {
- dprintf("dosfs_read_vnode: error initializing directory for
vnid %Lx (loc %Lx)\n",
- vnid, loc);
+ dprintf("dosfs_read_vnode: error initializing directory for
vnid %"
+ B_PRIdINO " (loc %" B_PRIdINO ")\n", vnid, loc);
result = ENOENT;
goto bi;
}
@@ -966,8 +977,8 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode
*_node, int *_type,
while (1) {
result = _next_dirent_(&iter, &info, filename, 512);
if (result < 0) {
- dprintf("dosfs_read_vnode: error finding vnid %Lx (loc
%Lx) (%s)\n",
- vnid, loc, strerror(result));
+ dprintf("dosfs_read_vnode: error finding vnid %"
B_PRIdINO
+ " (loc %" B_PRIdINO ") (%s)\n", vnid, loc,
strerror(result));
goto bi2;
}

@@ -977,8 +988,8 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode
*_node, int *_type,
} else {
if (info.sindex == INDEX_OF_DIR_INDEX_VNID(loc))
break;
- dprintf("dosfs_read_vnode: error finding vnid %Lx (loc
%Lx) (%s)\n",
- vnid, loc, strerror(result));
+ dprintf("dosfs_read_vnode: error finding vnid %"
B_PRIdINO
+ " (loc %" B_PRIdINO ") (%s)\n", vnid, loc,
strerror(result));
result = ENOENT;
goto bi2;
}
@@ -1056,13 +1067,13 @@ dosfs_walk(fs_volume *_vol, fs_vnode *_dir, const char
*file, ino_t *_vnid)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_walk: find %Lx/%s\n", dir->vnid, file));
+ DPRINTF(0, ("dosfs_walk: find %" B_PRIdINO "/%s\n", dir->vnid, file));

result = findfile_case(vol, dir, file, _vnid, &vnode);
if (result != B_OK) {
DPRINTF(0, ("dosfs_walk (%s)\n", strerror(result)));
} else {
- DPRINTF(0, ("dosfs_walk: found vnid %Lx\n", *_vnid));
+ DPRINTF(0, ("dosfs_walk: found vnid %" B_PRIdINO "\n", *_vnid));
}

UNLOCK_VOL(vol);
@@ -1080,7 +1091,8 @@ dosfs_access(fs_volume *_vol, fs_vnode *_node, int mode)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_access (vnode id %Lx, mode %x)\n", node->vnid,
mode));
+ DPRINTF(0, ("dosfs_access (vnode id %" B_PRIdINO ", mode %o)\n",
node->vnid,
+ mode));

if (mode & W_OK) {
if (vol->flags & B_FS_IS_READONLY) {
@@ -1123,7 +1135,7 @@ dosfs_opendir(fs_volume *_vol, fs_vnode *_node, void
**_cookie)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_opendir (vnode id %Lx)\n", node->vnid));
+ DPRINTF(0, ("dosfs_opendir (vnode id %" B_PRIdINO ")\n", node->vnid));

*_cookie = NULL;

@@ -1171,7 +1183,7 @@ dosfs_readdir(fs_volume *_vol, fs_vnode *_dir, void
*_cookie,

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_readdir: vnode id %Lx, index %lx\n",
+ DPRINTF(0, ("dosfs_readdir: vnode id %" B_PRIdINO ", index %" B_PRIu32
"\n",
dir->vnid, cookie->current_index));

// simulate '.' and '..' entries for root directory
@@ -1244,7 +1256,7 @@ dosfs_rewinddir(fs_volume *_vol, fs_vnode *_node, void*
_cookie)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_rewinddir (vnode id %Lx)\n", node->vnid));
+ DPRINTF(0, ("dosfs_rewinddir (vnode id %" B_PRIdINO ")\n", node->vnid));

cookie->current_index = 0;

@@ -1274,7 +1286,8 @@ dosfs_free_dircookie(fs_volume *_vol, fs_vnode *_node,
void *_cookie)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_free_dircookie (vnode id %Lx)\n", node->vnid));
+ DPRINTF(0, ("dosfs_free_dircookie (vnode id %" B_PRIdINO ")\n",
+ node->vnid));

free(cookie);

diff --git a/src/add-ons/kernel/file_systems/fat/dlist.c
b/src/add-ons/kernel/file_systems/fat/dlist.c
index 8f39d8c..63e866c 100644
--- a/src/add-ons/kernel/file_systems/fat/dlist.c
+++ b/src/add-ons/kernel/file_systems/fat/dlist.c
@@ -73,7 +73,8 @@ dlist_realloc(nspace *vol, uint32 allocate)
{
ino_t *vnid_list;

- DPRINTF(0, ("dlist_realloc %lx -> %lx\n", vol->dlist.allocated,
allocate));
+ DPRINTF(0, ("dlist_realloc %" B_PRIu32 " -> %" B_PRIu32 "\n",
+ vol->dlist.allocated, allocate));

ASSERT(allocate != vol->dlist.allocated);
ASSERT(allocate > vol->dlist.entries);
@@ -96,7 +97,7 @@ dlist_realloc(nspace *vol, uint32 allocate)
status_t
dlist_add(nspace *vol, ino_t vnid)
{
- DPRINTF(0, ("dlist_add vnid %Lx\n", vnid));
+ DPRINTF(0, ("dlist_add vnid %" B_PRIdINO "\n", vnid));

ASSERT(IS_DIR_CLUSTER_VNID(vnid) || IS_ARTIFICIAL_VNID(vnid));
ASSERT(vnid != 0);
@@ -117,7 +118,7 @@ dlist_remove(nspace *vol, ino_t vnid)
{
uint32 i;

- DPRINTF(0, ("dlist_remove vnid %Lx\n", vnid));
+ DPRINTF(0, ("dlist_remove vnid %" B_PRIdINO "\n", vnid));

for (i=0;i<vol->dlist.entries;i++)
if (vol->dlist.vnid_list[i] == vnid)
@@ -141,7 +142,7 @@ dlist_find(nspace *vol, uint32 cluster)
{
uint32 i;

- DPRINTF(1, ("dlist_find cluster %lx\n", cluster));
+ DPRINTF(1, ("dlist_find cluster %" B_PRIu32 "\n", cluster));

ASSERT(((cluster >= 2) && (cluster < vol->total_clusters + 2)) ||
(cluster == 1));

@@ -155,7 +156,7 @@ dlist_find(nspace *vol, uint32 cluster)
return vol->dlist.vnid_list[i];
}

- DPRINTF(1, ("dlist_find cluster %lx not found\n", cluster));
+ DPRINTF(1, ("dlist_find cluster %" B_PRIu32 " not found\n", cluster));

return -1LL;
}
@@ -166,11 +167,13 @@ dlist_dump(nspace *vol)
{
uint32 i;

- dprintf("%lx/%lx dlist entries filled, QUANTUM = %x\n",
+ dprintf("%" B_PRIu32 "/%" B_PRIu32 " dlist entries filled, QUANTUM =
%u\n",
vol->dlist.entries, vol->dlist.allocated, DLIST_ENTRY_QUANTUM);

- for (i = 0; i < vol->dlist.entries; i++)
- dprintf("%s %Lx", ((i == 0) ? "entries:" : ","),
vol->dlist.vnid_list[i]);
+ for (i = 0; i < vol->dlist.entries; i++) {
+ dprintf("%s %" B_PRIdINO, i == 0 ? "entries:" : ",",
+ vol->dlist.vnid_list[i]);
+ }

dprintf("\n");
}
diff --git a/src/add-ons/kernel/file_systems/fat/dosfs.c
b/src/add-ons/kernel/file_systems/fat/dosfs.c
index f088e3a..6dc4ed2 100644
--- a/src/add-ons/kernel/file_systems/fat/dosfs.c
+++ b/src/add-ons/kernel/file_systems/fat/dosfs.c
@@ -59,29 +59,32 @@ debug_fat_nspace(int argc, char **argv)
continue;

kprintf("fat nspace @ %p\n", vol);
- kprintf("id: %lx, fd: %x, device: %s, flags %lx\n",
- vol->id, vol->fd, vol->device, vol->flags);
- kprintf("bytes/sector = %lx, sectors/cluster = %lx, reserved
sectors = %lx\n",
- vol->bytes_per_sector, vol->sectors_per_cluster,
- vol->reserved_sectors);
- kprintf("%lx fats, %lx root entries, %lx total sectors, %lx
sectors/fat\n",
- vol->fat_count, vol->root_entries_count,
vol->total_sectors,
- vol->sectors_per_fat);
- kprintf("media descriptor %x, fsinfo sector %x, %lx clusters,
%lx free\n",
- vol->media_descriptor, vol->fsinfo_sector,
vol->total_clusters,
- vol->free_clusters);
- kprintf("%x-bit fat, mirrored %x, active %x\n",
- vol->fat_bits, vol->fat_mirrored,
vol->active_fat);
- kprintf("root start %lx, %lx root sectors, root vnode @ %p\n",
- vol->root_start, vol->root_sectors,
&(vol->root_vnode));
- kprintf("label entry %lx, label %s\n", vol->vol_entry,
vol->vol_label);
- kprintf("data start %lx, last allocated %lx\n",
- vol->data_start, vol->last_allocated);
- kprintf("last fake vnid %Lx, vnid cache %lx entries @ (%p
%p)\n",
- vol->vcache.cur_vnid, vol->vcache.cache_size,
- vol->vcache.by_vnid, vol->vcache.by_loc);
- kprintf("dlist entries: %lx/%lx @ %p\n",
- vol->dlist.entries, vol->dlist.allocated,
vol->dlist.vnid_list);
+ kprintf("id: %" B_PRIdDEV ", fd: %d, device: %s, flags %"
B_PRIu32 "\n",
+ vol->id, vol->fd, vol->device, vol->flags);
+ kprintf("bytes/sector = %" B_PRIu32 ", sectors/cluster = %"
B_PRIu32
+ ", reserved sectors = %" B_PRIu32 "\n",
vol->bytes_per_sector,
+ vol->sectors_per_cluster, vol->reserved_sectors);
+ kprintf("%" B_PRIu32 " fats, %" B_PRIu32 " root entries, %"
B_PRIu32
+ " total sectors, %" B_PRIu32 " sectors/fat\n",
vol->fat_count,
+ vol->root_entries_count, vol->total_sectors,
vol->sectors_per_fat);
+ kprintf("media descriptor %" B_PRIu8 ", fsinfo sector %"
B_PRIu16
+ ", %" B_PRIu32 " clusters, %" B_PRIu32 " free\n",
+ vol->media_descriptor, vol->fsinfo_sector,
vol->total_clusters,
+ vol->free_clusters);
+ kprintf("%" B_PRIu8 "-bit fat, mirrored %s, active %" B_PRIu8
"\n",
+ vol->fat_bits, vol->fat_mirrored ? "yes" : "no",
vol->active_fat);
+ kprintf("root start %" B_PRIu8 ", %" B_PRIu8
+ " root sectors, root vnode @ %p\n", vol->root_start,
+ vol->root_sectors, &(vol->root_vnode));
+ kprintf("label entry %" B_PRIu32 ", label %s\n", vol->vol_entry,
+ vol->vol_label);
+ kprintf("data start %" B_PRIu32 ", last allocated %" B_PRIu32
"\n",
+ vol->data_start, vol->last_allocated);
+ kprintf("last fake vnid %" B_PRIdINO ", vnid cache %" B_PRIu32
+ " entries @ (%p %p)\n", vol->vcache.cur_vnid,
+ vol->vcache.cache_size, vol->vcache.by_vnid,
vol->vcache.by_loc);
+ kprintf("dlist entries: %" B_PRIu32 "/%" B_PRIu32 " @ %p\n",
+ vol->dlist.entries, vol->dlist.allocated,
vol->dlist.vnid_list);

dump_vcache(vol);
dlist_dump(vol);
@@ -108,12 +111,14 @@ debug_dvnode(int argc, char **argv)
#if TRACK_FILENAME
kprintf(" (%s)", n->filename);
#endif
- kprintf("\nvnid %Lx, dir vnid %Lx\n", n->vnid, n->dir_vnid);
- kprintf("iteration %lx, si=%lx, ei=%lx, cluster=%lx\n",
- n->iteration, n->sindex, n->eindex, n->cluster);
- kprintf("mode %lx, size %Lx, time %lx\n",
- n->mode, n->st_size, n->st_time);
- kprintf("end cluster = %lx\n", n->end_cluster);
+ kprintf("\nvnid %" B_PRIdINO ", dir vnid %" B_PRIdINO "\n",
n->vnid,
+ n->dir_vnid);
+ kprintf("iteration %" B_PRIu32 ", si=%" B_PRIu32 ", ei=%"
B_PRIu32
+ ", cluster=%" B_PRIu32 "\n", n->iteration, n->sindex,
n->eindex,
+ n->cluster);
+ kprintf("mode %#" B_PRIx32 ", size %" B_PRIdOFF ", time %"
B_PRIuTIME
+ "\n", n->mode, n->st_size, n->st_time);
+ kprintf("end cluster = %" B_PRIu32 "\n", n->end_cluster);
if (n->mime) kprintf("mime type %s\n", n->mime);
}

@@ -138,8 +143,8 @@ debug_dc2s(int argc, char **argv)

for (i=2;i<argc;i++) {
uint32 cluster = strtoul(argv[i], NULL, 0);
- kprintf("cluster %lx = block %Lx\n", cluster, vol->data_start +
- (off_t)(cluster - 2) *
vol->sectors_per_cluster);
+ kprintf("cluster %" B_PRIu32 " = block %" B_PRIdOFF "\n",
cluster,
+ vol->data_start + (off_t)(cluster - 2) *
vol->sectors_per_cluster);
}

return B_OK;
@@ -211,7 +216,7 @@ volume_init(int fd, uint8* buf,
vol->bytes_per_sector = read16(buf, 0xb);
if (vol->bytes_per_sector != 0x200 && vol->bytes_per_sector != 0x400
&& vol->bytes_per_sector != 0x800 && vol->bytes_per_sector !=
0x1000) {
- dprintf("dosfs error: unsupported bytes per sector (%lu)\n",
+ dprintf("dosfs error: unsupported bytes per sector (%" B_PRIu32
")\n",
vol->bytes_per_sector);
goto error;
}
@@ -227,7 +232,8 @@ volume_init(int fd, uint8* buf,

vol->fat_count = buf[0x10];
if (vol->fat_count == 0 || vol->fat_count > 8) {
- dprintf("dosfs error: unreasonable fat count (%lu)\n",
vol->fat_count);
+ dprintf("dosfs error: unreasonable fat count (%" B_PRIu32 ")\n",
+ vol->fat_count);
goto error;
}

@@ -267,8 +273,8 @@ volume_init(int fd, uint8* buf,

vol->root_vnode.cluster = read32(buf, 0x2c);
if (vol->root_vnode.cluster >= vol->total_clusters) {
- dprintf("dosfs error: root vnode cluster too large
(0x%lx)\n",
- vol->root_vnode.cluster);
+ dprintf("dosfs error: root vnode cluster too large
(0x%" B_PRIu32
+ ")\n", vol->root_vnode.cluster);
goto error;
}

@@ -277,7 +283,8 @@ volume_init(int fd, uint8* buf,
} else {
// fat12 & fat16
if (vol->fat_count != 2) {
- dprintf("dosfs error: claims %ld fat tables\n",
vol->fat_count);
+ dprintf("dosfs error: claims %" B_PRIu32 " fat
tables\n",
+ vol->fat_count);
goto error;
}

@@ -359,18 +366,20 @@ volume_init(int fd, uint8* buf,
uint8 mirror_media_buf[512];
for (i = 0; i < vol->fat_count; i++) {
if (i != vol->active_fat) {
- DPRINTF(1, ("checking fat #%ld\n", i));
+ DPRINTF(1, ("checking fat #%" B_PRIu32 "\n",
i));
mirror_media_buf[0] = ~media_buf[0];
if ((err = read_pos(vol->fd,
vol->bytes_per_sector
* (vol->reserved_sectors +
vol->sectors_per_fat * i),
(void *)mirror_media_buf,
0x200)) != 0x200) {
- dprintf("dosfs error: error reading FAT
%ld\n", i);
+ dprintf("dosfs error: error reading FAT
%" B_PRIu32 "\n",
+ i);
goto error;
}

if (mirror_media_buf[0] !=
vol->media_descriptor) {
dprintf("dosfs error: media descriptor
mismatch in fat # "
- "%ld (%x != %x)\n", i,
mirror_media_buf[0], vol->media_descriptor);
+ "%" B_PRIu32 " (%" B_PRIu8 " !=
%" B_PRIu8 ")\n", i,
+ mirror_media_buf[0],
vol->media_descriptor);
goto error;
}
#if 0
@@ -420,8 +429,9 @@ volume_init(int fd, uint8* buf,
diri_free(&diri);
}

- DPRINTF(0, ("root vnode id = %Lx\n", vol->root_vnode.vnid));
- DPRINTF(0, ("volume label [%s] (%lx)\n", vol->vol_label,
vol->vol_entry));
+ DPRINTF(0, ("root vnode id = %" B_PRIdINO "\n", vol->root_vnode.vnid));
+ DPRINTF(0, ("volume label [%s] (%" B_PRIu32 ")\n", vol->vol_label,
+ vol->vol_entry));

// steal a trick from bfs
if (!memcmp(vol->vol_label, "__RO__ ", 11))
@@ -458,7 +468,7 @@ volume_count_free_cluster(nspace *vol)
vol->free_clusters = free_count;
else {
dprintf("dosfs error: free cluster count from
fsinfo block "
- "invalid %lx\n", free_count);
+ "invalid %" B_PRIu32 "\n", free_count);
err = -1;
}

@@ -523,7 +533,7 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int
flags,

if (geo.bytes_per_sector != 0x200 && geo.bytes_per_sector != 0x400
&& geo.bytes_per_sector != 0x800 && geo.bytes_per_sector !=
0x1000) {
- dprintf("dosfs error: unsupported device block size (%lu)\n",
+ dprintf("dosfs error: unsupported device block size (%"
B_PRIu32 ")\n",
geo.bytes_per_sector);
goto error1;
}
@@ -618,22 +628,24 @@ mount_fat_disk(const char *path, fs_volume *_vol, const
int flags,
volume_count_free_cluster(vol);

DPRINTF(0, ("built at %s on %s\n", build_time, build_date));
- DPRINTF(0, ("mounting %s (id %lx, device %x, media descriptor %x)\n",
- vol->device, vol->id, vol->fd,
vol->media_descriptor));
- DPRINTF(0, ("%lx bytes/sector, %lx sectors/cluster\n",
- vol->bytes_per_sector,
vol->sectors_per_cluster));
- DPRINTF(0, ("%lx reserved sectors, %lx total sectors\n",
- vol->reserved_sectors, vol->total_sectors));
- DPRINTF(0, ("%lx %d-bit fats, %lx sectors/fat, %lx root entries\n",
- vol->fat_count, vol->fat_bits,
vol->sectors_per_fat,
- vol->root_entries_count));
- DPRINTF(0, ("root directory starts at sector %lx (cluster %lx), data at
sector %lx\n",
- vol->root_start, vol->root_vnode.cluster,
vol->data_start));
- DPRINTF(0, ("%lx total clusters, %lx free\n",
- vol->total_clusters, vol->free_clusters));
- DPRINTF(0, ("fat mirroring is %s, fs info sector at sector %x\n",
- (vol->fat_mirrored) ? "on" : "off",
vol->fsinfo_sector));
- DPRINTF(0, ("last allocated cluster = %lx\n", vol->last_allocated));
+ DPRINTF(0, ("mounting %s (id %" B_PRIdDEV ", device %u, media
descriptor %"
+ B_PRIu8 ")\n", vol->device, vol->id, vol->fd,
vol->media_descriptor));
+ DPRINTF(0, ("%" B_PRIu32 " bytes/sector, %" B_PRIu32 "
sectors/cluster\n",
+ vol->bytes_per_sector, vol->sectors_per_cluster));
+ DPRINTF(0, ("%" B_PRIu32 " reserved sectors, %" B_PRIu32 " total
sectors\n",
+ vol->reserved_sectors, vol->total_sectors));
+ DPRINTF(0, ("%" B_PRIu32 " %" B_PRIu8 "-bit fats, %" B_PRIu32
+ " sectors/fat, %" B_PRIu32 " root entries\n", vol->fat_count,
+ vol->fat_bits, vol->sectors_per_fat, vol->root_entries_count));
+ DPRINTF(0, ("root directory starts at sector %" B_PRIu32 " (cluster %"
+ B_PRIu32 "), data at sector %" B_PRIu32 "\n", vol->root_start,
+ vol->root_vnode.cluster, vol->data_start));
+ DPRINTF(0, ("%" B_PRIu32 " total clusters, %" B_PRIu32 " free\n",
+ vol->total_clusters, vol->free_clusters));
+ DPRINTF(0, ("fat mirroring is %s, fs info sector at sector %" B_PRIu16
"\n",
+ vol->fat_mirrored ? "on" : "off", vol->fsinfo_sector));
+ DPRINTF(0, ("last allocated cluster = %" B_PRIu32 "\n",
+ vol->last_allocated));

if (vol->fat_bits == 32) {
// now that the block cache has been initialised, we can figure
@@ -656,8 +668,9 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int
flags,
dlist_add(vol, vol->root_vnode.vnid);


- DPRINTF(0, ("root vnode id = %Lx\n", vol->root_vnode.vnid));
- DPRINTF(0, ("volume label [%s] (%lx)\n", vol->vol_label,
vol->vol_entry));
+ DPRINTF(0, ("root vnode id = %" B_PRIdINO "\n", vol->root_vnode.vnid));
+ DPRINTF(0, ("volume label [%s] (%" B_PRIu32 ")\n", vol->vol_label,
+ vol->vol_entry));

// steal a trick from bfs
if (!memcmp(vol->vol_label, "__RO__ ", 11))
@@ -866,7 +879,7 @@ dosfs_mount(fs_volume *_vol, const char *device, uint32
flags,
dprintf("error creating new vnode (%s)\n",
strerror(result));
goto error;
}
- sprintf(name, "fat lock %lx", vol->id);
+ sprintf(name, "fat lock %" B_PRIdDEV, vol->id);
recursive_lock_init_etc(&(vol->vlock), name,
MUTEX_FLAG_CLONE_NAME);

#if DEBUG
@@ -961,7 +974,7 @@ dosfs_unmount(fs_volume *_vol)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_unmount volume %lx\n", vol->id));
+ DPRINTF(0, ("dosfs_unmount volume %" B_PRIdDEV "\n", vol->id));

update_fsinfo(vol);

@@ -1218,8 +1231,8 @@ dosfs_ioctl(fs_volume *_vol, fs_vnode *_node, void
*cookie, uint32 code,
#endif

default :
- DPRINTF(0, ("dosfs_ioctl: vol %lx, vnode %Lx code =
%ld\n",
- vol->id, node->vnid, code));
+ DPRINTF(0, ("dosfs_ioctl: vol %" B_PRIdDEV ", vnode %"
B_PRIdINO
+ " code = %" B_PRIu32 "\n", vol->id, node->vnid,
code));
result = B_DEV_INVALID_IOCTL;
break;
}
@@ -1246,7 +1259,7 @@ 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));
+ DPRINTF(0, ("dosfs_sync called on volume %" B_PRIdDEV "\n", vol->id));

LOCK_VOL(vol);
err = _dosfs_sync(vol);
diff --git a/src/add-ons/kernel/file_systems/fat/dosfs.h
b/src/add-ons/kernel/file_systems/fat/dosfs.h
index 70fc386..c7dbb20 100644
--- a/src/add-ons/kernel/file_systems/fat/dosfs.h
+++ b/src/add-ons/kernel/file_systems/fat/dosfs.h
@@ -134,14 +134,14 @@ typedef struct _nspace {
bool fat_mirrored; // true if fat mirroring on
uint8 active_fat;

- uint32 root_start; // for fat12 + fat16
only
+ uint32 root_start; // for fat12 + fat16
only
uint32 root_sectors; // for fat12 + fat16 only
vnode root_vnode; // root directory
int32 vol_entry; // index in root
directory
char vol_label[12]; // lfn's need not apply

uint32 data_start;
- uint32 last_allocated; // last allocated cluster
+ uint32 last_allocated; // last allocated cluster

ino_t beos_vnid; // vnid of \BEOS
directory
bool respect_disk_image;
@@ -165,8 +165,8 @@ typedef struct _nspace {
} dlist;
} nspace;

-#define FS_FLAGS_OP_SYNC 0x1
-#define FS_FLAGS_LOCK_DOOR 0x2
+#define FS_FLAGS_OP_SYNC 0x1
+#define FS_FLAGS_LOCK_DOOR 0x2

#define LOCK_VOL(vol) \
if (vol == NULL) { dprintf("null vol\n"); return EINVAL; } else
LOCK((vol)->vlock)
diff --git a/src/add-ons/kernel/file_systems/fat/encodings.cpp
b/src/add-ons/kernel/file_systems/fat/encodings.cpp
index 1561b38..1076e0b 100644
--- a/src/add-ons/kernel/file_systems/fat/encodings.cpp
+++ b/src/add-ons/kernel/file_systems/fat/encodings.cpp
@@ -1139,7 +1139,8 @@ status_t unicode_to_utf8(const uchar *uni, uint32 unilen,
uint8 *utf8,
(int32 *)&unilen, (char *)utf8, (int32 *)&utf8len);

if (unilen < origlen) {
- dprintf("Name is too long (%lx < %lx)\n", unilen, origlen);
+ dprintf("Name is too long (%" B_PRIu32 " < %" B_PRIu32 ")\n",
unilen,
+ origlen);
return B_ERROR;
}

@@ -1209,7 +1210,8 @@ status_t utf8_to_unicode(const char *utf8, uchar *uni,
uint32 unilen)
(int32 *)&utf8len, (char *)uni, (int32 *)&unilen);

if (origlen < utf8len) {
- dprintf("Name is too long (%lx < %lx)\n", unilen, origlen);
+ dprintf("Name is too long (%" B_PRIu32 " < %" B_PRIu32 ")\n",
unilen,
+ origlen);
return B_ERROR;
}

@@ -1226,7 +1228,7 @@ status_t munge_short_name_english(uchar nshort[11],
uint64 value)

// short names must have only numbers following
// the tilde and cannot begin with 0
- sprintf(buffer, "~%Ld", value);
+ sprintf(buffer, "~%" B_PRIu64, value);
len = strlen(buffer);
i = 7 - len;

@@ -1250,7 +1252,7 @@ status_t munge_short_name_sjis(uchar nshort[11], uint64
value)

// short names must have only numbers following
// the tilde and cannot begin with 0
- sprintf(buffer, "~%Ld", value);
+ sprintf(buffer, "~%" B_PRIu64, value);
len = strlen(buffer);

last = 0;
@@ -1456,7 +1458,8 @@ generate_short_name_sjis(const uchar *utf8, const uint16
*uni,

bi:
if (result < 0) {
- dprintf("generate_short_name_sjis error: %lx (%s)\n", result,
strerror(result));
+ dprintf("generate_short_name_sjis error: %" B_PRId32 " (%s)\n",
result,
+ strerror(result));
}

free(sjis);
diff --git a/src/add-ons/kernel/file_systems/fat/fat.c
b/src/add-ons/kernel/file_systems/fat/fat.c
index 959ec1f..cb48df3 100644
--- a/src/add-ons/kernel/file_systems/fat/fat.c
+++ b/src/add-ons/kernel/file_systems/fat/fat.c
@@ -109,8 +109,8 @@ _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster,
int32 N)
ASSERT(action >= _IOCTL_COUNT_FREE_
&& action <= _IOCTL_ALLOCATE_N_ENTRIES_);

- DPRINTF(3, ("_fat_ioctl_: action %lx, cluster %ld, N %ld\n", action,
- cluster, N));
+ DPRINTF(3, ("_fat_ioctl_: action %" B_PRIu32 ", cluster %" B_PRIu32
+ ", N %" B_PRId32 "\n", action, cluster, N));

if (action == _IOCTL_COUNT_FREE_) {
if(vol->fat_bits == 32)
@@ -125,8 +125,8 @@ _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster,
int32 N)

if (action != _IOCTL_COUNT_FREE_) {
if (!IS_DATA_CLUSTER(cluster)) {
- DPRINTF(0, ("_fat_ioctl_ called with invalid cluster
(%ld)\n",
- cluster));
+ DPRINTF(0, ("_fat_ioctl_ called with invalid cluster
(%" B_PRIu32
+ ")\n", cluster));
return B_BAD_VALUE;
}
}
@@ -144,7 +144,8 @@ _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster,
int32 N)
}

if (block1 == NULL) {
- DPRINTF(0, ("_fat_ioctl_: error reading fat (sector %ld)\n",
sector));
+ DPRINTF(0, ("_fat_ioctl_: error reading fat (sector %" B_PRIu32
")\n",
+ sector));
return B_IO_ERROR;
}

@@ -164,8 +165,8 @@ _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster,
int32 N)
}

if (block2 == NULL) {
- DPRINTF(0, ("_fat_ioctl_: error reading
fat (sector %ld)\n",
- sector));
+ DPRINTF(0, ("_fat_ioctl_: error reading
fat (sector %"
+ B_PRIu32 ")\n", sector));
result = B_IO_ERROR;
sector--;
goto bi;
@@ -314,7 +315,8 @@ _fat_ioctl_(nspace *vol, uint32 action, uint32 cluster,
int32 N)
}

if (block1 == NULL) {
- DPRINTF(0, ("_fat_ioctl_: error reading fat (sector
%ld)\n", sector));
+ DPRINTF(0, ("_fat_ioctl_: error reading fat (sector %"
B_PRIu32
+ ")\n", sector));
result = B_IO_ERROR;
goto bi;
}
@@ -326,12 +328,13 @@ bi:

if (action == _IOCTL_ALLOCATE_N_ENTRIES_) {
if (result < 0) {
- DPRINTF(0, ("pooh. there is a problem. clearing chain
(%ld)\n",
- first));
+ DPRINTF(0, ("pooh. there is a problem. clearing chain
(%" B_PRIu32
+ ")\n", first));
if (first != 0)
clear_fat_chain(vol, first);
} else if (n != N) {
- DPRINTF(0, ("not enough free entries (%ld/%ld
found)\n", n, N));
+ DPRINTF(0, ("not enough free entries (%" B_PRId32 "/%"
B_PRId32
+ " found)\n", n, N));
if (first != 0)
clear_fat_chain(vol, first);
result = B_DEVICE_FULL;
@@ -343,8 +346,9 @@ bi:
}

if (result < B_OK) {
- DPRINTF(0, ("_fat_ioctl_ error: action = %lx cluster = %ld N =
%ld "
- "(%s)\n", action, cluster, N, strerror(result)));
+ DPRINTF(0, ("_fat_ioctl_ error: action = %" B_PRIu32 " cluster
= %"
+ B_PRIu32 " N = %" B_PRId32 " (%s)\n", action, cluster,
N,
+ strerror(result)));
}

return result;
@@ -375,7 +379,7 @@ get_fat_entry(nspace *vol, uint32 cluster)
if (value > 0x0ffffff0)
return BAD_FAT_ENTRY;

- DPRINTF(0, ("invalid fat entry: 0x%08lx\n", value));
+ DPRINTF(0, ("invalid fat entry: %" B_PRIu32 "\n", value));
return BAD_FAT_ENTRY;
}

@@ -411,12 +415,12 @@ count_clusters(nspace *vol, int32 cluster)
{
int32 count = 0;

- DPRINTF(2, ("count_clusters %ld\n", cluster));
+ DPRINTF(2, ("count_clusters %" B_PRId32 "\n", cluster));

// not intended for use on root directory
if (!IS_DATA_CLUSTER(cluster)) {
- DPRINTF(0, ("count_clusters called on invalid cluster (%ld)\n",
- cluster));
+ DPRINTF(0, ("count_clusters called on invalid cluster (%"
B_PRId32
+ ")\n", cluster));
return 0;
}

@@ -430,12 +434,13 @@ count_clusters(nspace *vol, int32 cluster)
cluster = get_fat_entry(vol, cluster);
}

- DPRINTF(2, ("count_clusters %ld = %ld\n", cluster, count));
+ DPRINTF(2, ("count_clusters %" B_PRId32 " = %" B_PRId32 "\n", cluster,
+ count));

if (cluster == END_FAT_ENTRY)
return count;

- dprintf("cluster = %ld\n", cluster);
+ dprintf("cluster = %" B_PRId32 "\n", cluster);
ASSERT(0);
return 0;
}
@@ -448,36 +453,36 @@ clear_fat_chain(nspace *vol, uint32 cluster)
status_t result;

if (!IS_DATA_CLUSTER(cluster)) {
- DPRINTF(0, ("clear_fat_chain called on invalid cluster (%ld)\n",
- cluster));
+ DPRINTF(0, ("clear_fat_chain called on invalid cluster (%"
B_PRIu32
+ ")\n", cluster));
return B_BAD_VALUE;
}

ASSERT(count_clusters(vol, cluster) != 0);

- DPRINTF(2, ("clearing fat chain: %ld", cluster));
+ DPRINTF(2, ("clearing fat chain: %" B_PRIu32, cluster));
while (IS_DATA_CLUSTER(cluster)) {
if ((c = get_fat_entry(vol, cluster)) < 0) {
DPRINTF(0, ("clear_fat_chain: error clearing fat entry
for cluster "
- "%ld (%s)\n", cluster, strerror(c)));
+ "%" B_PRIu32 " (%s)\n", cluster, strerror(c)));
return c;
}

if ((result = set_fat_entry(vol, cluster, 0)) != B_OK) {
DPRINTF(0, ("clear_fat_chain: error clearing fat entry
for cluster "
- "%ld (%s)\n", cluster, strerror(result)));
+ "%" B_PRIu32 " (%s)\n", cluster,
strerror(result)));
return result;
}

vol->free_clusters++;
cluster = c;
- DPRINTF(2, (", %ld", cluster));
+ DPRINTF(2, (", %" B_PRIu32, cluster));
}
DPRINTF(2, ("\n"));

if (cluster != END_FAT_ENTRY) {
- dprintf("clear_fat_chain: fat chain terminated improperly with
%ld\n",
- cluster);
+ dprintf("clear_fat_chain: fat chain terminated improperly with
%"
+ B_PRIu32 "\n", cluster);
}

return 0;
@@ -491,7 +496,7 @@ allocate_n_fat_entries(nspace *vol, int32 n, int32 *start)

ASSERT(n > 0);

- DPRINTF(2, ("allocating %ld fat entries\n", n));
+ DPRINTF(2, ("allocating %" B_PRId32 " fat entries\n", n));

c = _fat_ioctl_(vol, _IOCTL_ALLOCATE_N_ENTRIES_, 0, n);
if (c < 0)
@@ -500,7 +505,8 @@ allocate_n_fat_entries(nspace *vol, int32 n, int32 *start)
ASSERT(IS_DATA_CLUSTER(c));
ASSERT(count_clusters(vol, c) == n);

- DPRINTF(2, ("allocated %ld fat entries at %ld\n", n, c));
+ DPRINTF(2, ("allocated %" B_PRId32 " fat entries at %" B_PRId32 "\n", n,
+ c));

*start = c;
return 0;
@@ -513,13 +519,13 @@ 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 %ld clusters (%ld)\n",
node->vnid,
- clusters, node->cluster));
+ DPRINTF(1, ("set_fat_chain_length: %" B_PRIdINO " to %" B_PRIu32
+ " clusters (%" B_PRIu32 ")\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
(%ld)\n",
- node->cluster));
+ DPRINTF(0, ("set_fat_chain_length called on invalid cluster (%"
B_PRIu32
+ ")\n", node->cluster));
return B_BAD_VALUE;
}

@@ -550,7 +556,8 @@ set_fat_chain_length(nspace *vol, vnode *node, uint32
clusters)
}

if (node->cluster == 0) {
- DPRINTF(1, ("node has no clusters. adding %ld clusters\n",
clusters));
+ DPRINTF(1, ("node has no clusters. adding %" B_PRIu32 "
clusters\n",
+ clusters));

if ((result = allocate_n_fat_entries(vol, clusters, &n)) !=
B_OK)
return result;
@@ -579,7 +586,7 @@ set_fat_chain_length(nspace *vol, vnode *node, uint32
clusters)

if (clusters > i) {
// add new fat entries
- DPRINTF(1, ("adding %ld new fat entries\n", clusters - i));
+ DPRINTF(1, ("adding %" B_PRIu32 " new fat entries\n", clusters
- i));
if ((result = allocate_n_fat_entries(vol, clusters - i, &n)) !=
B_OK)
return result;

@@ -631,10 +638,10 @@ set_fat_chain_length(nspace *vol, vnode *node, uint32
clusters)
void
dump_fat_chain(nspace *vol, uint32 cluster)
{
- dprintf("fat chain: %ld", cluster);
+ dprintf("fat chain: %" B_PRIu32, cluster);
while (IS_DATA_CLUSTER(cluster)) {
cluster = get_fat_entry(vol, cluster);
- dprintf(" %ld", cluster);
+ dprintf(" %" B_PRIu32, cluster);
}

dprintf("\n");
diff --git a/src/add-ons/kernel/file_systems/fat/file.c
b/src/add-ons/kernel/file_systems/fat/file.c
index 5d5f028..e17813c 100644
--- a/src/add-ons/kernel/file_systems/fat/file.c
+++ b/src/add-ons/kernel/file_systems/fat/file.c
@@ -82,7 +82,8 @@ status_t write_vnode_entry(nspace *vol, vnode *node)
// though we do the is_vnode_removed check above

if ((node->cluster != 0) && !IS_DATA_CLUSTER(node->cluster)) {
- dprintf("write_vnode_entry called on invalid cluster (%lx)\n",
node->cluster);
+ dprintf("write_vnode_entry called on invalid cluster (%"
B_PRIu32 ")\n",
+ node->cluster);
return EINVAL;
}

@@ -136,7 +137,7 @@ dosfs_release_vnode(fs_volume *_vol, fs_vnode *_node, bool
reenter)

TOUCH(reenter);

- DPRINTF(0, ("dosfs_write_vnode (ino_t %Lx)\n", node->vnid));
+ DPRINTF(0, ("dosfs_write_vnode (ino_t %" B_PRIdINO ")\n", node->vnid));

if ((vol->fs_flags & FS_FLAGS_OP_SYNC) && node->dirty) {
LOCK_VOL(vol);
@@ -168,7 +169,7 @@ dosfs_rstat(fs_volume *_vol, fs_vnode *_node, struct stat
*st)

LOCK_VOL(vol);

- DPRINTF(1, ("dosfs_rstat (vnode id %Lx)\n", node->vnid));
+ DPRINTF(1, ("dosfs_rstat (vnode id %" B_PRIdINO ")\n", node->vnid));

st->st_dev = vol->id;
st->st_ino = node->vnid;
@@ -202,7 +203,7 @@ dosfs_wstat(fs_volume *_vol, fs_vnode *_node, const struct
stat *st,

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_wstat (vnode id %Lx)\n", node->vnid));
+ DPRINTF(0, ("dosfs_wstat (vnode id %" B_PRIdINO ")\n", node->vnid));

if (vol->flags & B_FS_IS_READONLY) {
dprintf("can't wstat on read-only volume\n");
@@ -226,7 +227,7 @@ dosfs_wstat(fs_volume *_vol, fs_vnode *_node, const struct
stat *st,
}

if (mask & B_STAT_SIZE) {
- DPRINTF(0, ("setting file size to %Lx\n", st->st_size));
+ 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");
err = EISDIR;
@@ -234,8 +235,11 @@ dosfs_wstat(fs_volume *_vol, fs_vnode *_node, const struct
stat *st,
dprintf("dosfs_wstat: desired file size exceeds fat
limit\n");
err = E2BIG;
} else {
- uint32 clusters = (st->st_size +
vol->bytes_per_sector*vol->sectors_per_cluster - 1) / vol->bytes_per_sector /
vol->sectors_per_cluster;
- DPRINTF(0, ("setting fat chain length to %lx
clusters\n", clusters));
+ uint32 clusters = (st->st_size + vol->bytes_per_sector
+ * vol->sectors_per_cluster - 1) /
vol->bytes_per_sector
+ / vol->sectors_per_cluster;
+ DPRINTF(0, ("setting fat chain length to %" B_PRIu32 "
clusters\n",
+ clusters));
if ((err = set_fat_chain_length(vol, node, clusters))
== B_OK) {
node->st_size = st->st_size;
node->iteration++;
@@ -284,7 +288,8 @@ dosfs_open(fs_volume *_vol, fs_vnode *_node, int omode,
void **_cookie)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_open: vnode id %Lx, omode %x\n", node->vnid, omode));
+ DPRINTF(0, ("dosfs_open: vnode id %" B_PRIdINO ", omode %o\n",
node->vnid,
+ omode));

if (omode & O_CREAT) {
dprintf("dosfs_open called with O_CREAT. call dosfs_create
instead!\n");
@@ -355,13 +360,15 @@ dosfs_read(fs_volume *_vol, fs_vnode *_node, void
*_cookie, off_t pos,
LOCK_VOL(vol);

if (node->mode & FAT_SUBDIR) {
- DPRINTF(0, ("dosfs_read called on subdirectory %Lx\n",
node->vnid));
+ DPRINTF(0, ("dosfs_read called on subdirectory %" B_PRIdINO
"\n",
+ node->vnid));
*len = 0;
UNLOCK_VOL(vol);
return EISDIR;
}

- DPRINTF(0, ("dosfs_read called %lx bytes at %Lx (vnode id %Lx)\n",
*len, pos, node->vnid));
+ DPRINTF(0, ("dosfs_read called %" B_PRIuSIZE " bytes at %" B_PRIdOFF
+ " (vnode id %" B_PRIdINO ")\n", *len, pos, node->vnid));

if (pos < 0) pos = 0;

@@ -477,7 +484,7 @@ bi:
if (result != B_OK) {
DPRINTF(0, ("dosfs_read (%s)\n", strerror(result)));
} else {
- DPRINTF(0, ("dosfs_read: read %lx bytes\n", *len));
+ DPRINTF(0, ("dosfs_read: read %" B_PRIuSIZE " bytes\n", *len));
}
UNLOCK_VOL(vol);

@@ -503,14 +510,17 @@ dosfs_write(fs_volume *_vol, fs_vnode *_node, void
*_cookie, off_t pos,
LOCK_VOL(vol);

if (node->mode & FAT_SUBDIR) {
- DPRINTF(0, ("dosfs_write called on subdirectory %Lx\n",
node->vnid));
+ DPRINTF(0, ("dosfs_write called on subdirectory %" B_PRIdINO
"\n",
+ node->vnid));
*len = 0;
UNLOCK_VOL(vol);
return EISDIR;

}

- DPRINTF(0, ("dosfs_write called %lx bytes at %Lx from buffer at %lx
(vnode id %Lx)\n", *len, pos, (uint32)buf, node->vnid));
+ DPRINTF(0, ("dosfs_write called %" B_PRIuSIZE " bytes at %" B_PRIdOFF
+ " from buffer at %p (vnode id %" B_PRIdINO ")\n", *len, pos,
buf,
+ node->vnid));

if ((cookie->mode & O_RWMASK) == O_RDONLY) {
dprintf("dosfs_write: called on file opened as read-only\n");
@@ -566,7 +576,8 @@ dosfs_write(fs_volume *_vol, fs_vnode *_node, void
*_cookie, off_t pos,
*/
write_vnode_entry(vol, node);

- DPRINTF(0, ("setting file size to %Lx (%lx clusters)\n",
node->st_size, clusters));
+ DPRINTF(0, ("setting file size to %" B_PRIdOFF " (%" B_PRIu32
+ " clusters)\n", node->st_size, clusters));
node->dirty = true;
file_cache_set_size(node->cache, node->st_size);
file_map_set_size(node->file_map, node->st_size);
@@ -670,7 +681,7 @@ bi:
if (result != B_OK) {
DPRINTF(0, ("dosfs_write (%s)\n", strerror(result)));
} else {
- DPRINTF(0, ("dosfs_write: wrote %lx bytes\n", *len));
+ DPRINTF(0, ("dosfs_write: wrote %" B_PRIuSIZE " bytes\n",
*len));
}
UNLOCK_VOL(vol);

@@ -686,7 +697,7 @@ dosfs_close(fs_volume *_vol, fs_vnode *_node, void *_cookie)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_close (vnode id %Lx)\n", node->vnid));
+ DPRINTF(0, ("dosfs_close (vnode id %" B_PRIdINO ")\n", node->vnid));

if ((vol->fs_flags & FS_FLAGS_OP_SYNC) && node->dirty) {
_dosfs_sync(vol);
@@ -707,7 +718,7 @@ dosfs_free_cookie(fs_volume *_vol, fs_vnode *_node, void
*_cookie)
filecookie *cookie = _cookie;
LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_free_cookie (vnode id %Lx)\n", node->vnid));
+ DPRINTF(0, ("dosfs_free_cookie (vnode id %" B_PRIdINO ")\n",
node->vnid));

free(cookie);

@@ -736,7 +747,8 @@ dosfs_create(fs_volume *_vol, fs_vnode *_dir, const char
*name, int omode,
return EINVAL;
}

- DPRINTF(0, ("dosfs_create called: %Lx/%s perms=%o omode=%o\n",
dir->vnid, name, perms, omode));
+ DPRINTF(0, ("dosfs_create called: %" B_PRIdINO "/%s perms=%o
omode=%o\n",
+ dir->vnid, name, perms, omode));

if (vol->flags & B_FS_IS_READONLY) {
dprintf("dosfs_create called on read-only volume\n");
@@ -876,10 +888,12 @@ dosfs_mkdir(fs_volume *_vol, fs_vnode *_dir, const char
*name, int perms)
return EPERM;
}*/

- DPRINTF(0, ("dosfs_mkdir called: %Lx/%s (perm %o)\n", dir->vnid, name,
perms));
+ DPRINTF(0, ("dosfs_mkdir called: %" B_PRIdINO "/%s (perm %o)\n",
dir->vnid,
+ name, perms));

if ((dir->mode & FAT_SUBDIR) == 0) {
- dprintf("dosfs_mkdir: vnode id %Lx is not a directory\n",
dir->vnid);
+ dprintf("dosfs_mkdir: vnode id %" B_PRIdINO " is not a
directory\n",
+ dir->vnid);
UNLOCK_VOL(vol);
return EINVAL;
}
@@ -1021,7 +1035,8 @@ dosfs_rename(fs_volume *_vol, fs_vnode *_odir, const char
*oldname,

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_rename called: %Lx/%s->%Lx/%s\n", odir->vnid,
oldname, ndir->vnid, newname));
+ DPRINTF(0, ("dosfs_rename called: %" B_PRIdINO "/%s->%" B_PRIdINO
"/%s\n",
+ odir->vnid, oldname, ndir->vnid, newname));

if (!oldname || !(*oldname) || !newname || !(*newname)) {
result = EINVAL;
@@ -1047,7 +1062,8 @@ dosfs_rename(fs_volume *_vol, fs_vnode *_odir, const char
*oldname,

// locate the file
if ((result = findfile_case(vol,odir,oldname,NULL,&file)) != B_OK) {
- DPRINTF(0, ("dosfs_rename: can't find file %s in directory
%Lx\n", oldname, odir->vnid));
+ DPRINTF(0, ("dosfs_rename: can't find file %s in directory %"
B_PRIdINO
+ "\n", oldname, odir->vnid));
goto bi;
}

@@ -1238,7 +1254,7 @@ dosfs_remove_vnode(fs_volume *_vol, fs_vnode *_node, bool
reenter)

LOCK_VOL(vol);

- DPRINTF(0, ("dosfs_remove_vnode (%Lx)\n", node->vnid));
+ DPRINTF(0, ("dosfs_remove_vnode (%" B_PRIdINO ")\n", node->vnid));

if (vol->flags & B_FS_IS_READONLY) {
dprintf("dosfs_remove_vnode: read-only volume\n");
@@ -1293,7 +1309,7 @@ do_unlink(fs_volume *_vol, fs_vnode *_dir, const char
*name, bool is_file)

LOCK_VOL(vol);

- DPRINTF(0, ("do_unlink %Lx/%s\n", dir->vnid, name));
+ DPRINTF(0, ("do_unlink %" B_PRIdINO "/%s\n", dir->vnid, name));

if (vol->flags & B_FS_IS_READONLY) {
dprintf("do_unlink: read-only volume\n");
@@ -1303,7 +1319,8 @@ do_unlink(fs_volume *_vol, fs_vnode *_dir, const char
*name, bool is_file)

// locate the file
if ((result = findfile_case(vol,dir,name,&vnid,&file)) != B_OK) {
- DPRINTF(0, ("do_unlink: can't find file %s in directory %Lx\n",
name, dir->vnid));
+ DPRINTF(0, ("do_unlink: can't find file %s in directory %"
B_PRIdINO
+ "\n", name, dir->vnid));
result = ENOENT;
goto bi;
}
@@ -1509,12 +1526,14 @@ dosfs_get_file_map(fs_volume *_vol, fs_vnode *_node,
off_t pos, size_t len,
*_count = 0;

if (node->mode & FAT_SUBDIR) {
- DPRINTF(0, ("dosfs_get_file_map called on subdirectory %Lx\n",
node->vnid));
+ DPRINTF(0, ("dosfs_get_file_map called on subdirectory %"
B_PRIdINO
+ "\n", node->vnid));
UNLOCK_VOL(vol);
return EISDIR;
}

- DPRINTF(0, ("dosfs_get_file_map called %lx bytes at %Lx (vnode id
%Lx)\n", len, pos, node->vnid));
+ DPRINTF(0, ("dosfs_get_file_map called %" B_PRIuSIZE " bytes at %"
B_PRIdOFF
+ " (vnode id %" B_PRIdINO ")\n", len, pos, node->vnid));

if (pos < 0) pos = 0;

@@ -1533,7 +1552,8 @@ dosfs_get_file_map(fs_volume *_vol, fs_vnode *_node,
off_t pos, size_t len,
diff /= vol->bytes_per_sector; /* convert to sectors */

if ((result = init_csi(vol, cluster1, 0, &iter)) != B_OK) {
- dprintf("dosfs_get_file_map: invalid starting cluster (%lx)\n",
cluster1);
+ dprintf("dosfs_get_file_map: invalid starting cluster (%"
B_PRIu32
+ ")\n", cluster1);
goto bi;
}

diff --git a/src/add-ons/kernel/file_systems/fat/util.c
b/src/add-ons/kernel/file_systems/fat/util.c
index 7bab5e3..62cedbb 100644
--- a/src/add-ons/kernel/file_systems/fat/util.c
+++ b/src/add-ons/kernel/file_systems/fat/util.c
@@ -42,17 +42,18 @@ void
dump_bytes(uint8 *buffer, uint32 count)
{
uint32 i, j, k;
- for (i=0;i<0x10;i++)
- dprintf(" %lX ", i);
+ for (i = 0; i < 0x10; i++)
+ dprintf(" %" B_PRIu32 " ", i);
+
dprintf("\n");
- for (i=0;i<count;i+=0x10) {
+ for (i = 0; i < count; i += 0x10) {
j = (i + 0x10 > count) ? count - i : 0x10;
- for (k=i;k<i+j;k++)
+ for (k = i; k < i + j; k++)
dprintf("%2.2X ", buffer[k]);
- for (;k<i+0x10;k++)
+ for (; k < i + 0x10; k++)
dprintf(" ");
dprintf(" ");
- for (k=i;k<i+j;k++)
+ for (k = i; k < i + j; k++)
print_byte(buffer[k]);
dprintf("\n");
}
diff --git a/src/add-ons/kernel/file_systems/fat/vcache.c
b/src/add-ons/kernel/file_systems/fat/vcache.c
index ab35d39..6fc0a02 100644
--- a/src/add-ons/kernel/file_systems/fat/vcache.c
+++ b/src/add-ons/kernel/file_systems/fat/vcache.c
@@ -79,12 +79,11 @@ dump_vcache(nspace *vol)
{
uint32 i;
struct vcache_entry *c;
- kprintf("vnid cache size %lx, cur vnid = %Lx\n"
- "vnid loc\n",
- vol->vcache.cache_size, vol->vcache.cur_vnid);
+ kprintf("vnid cache size %" B_PRIu32 ", cur vnid = %" B_PRIdINO "\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)
- kprintf("%16Lx %16Lx\n", c->vnid, c->loc);
+ kprintf("%16" B_PRIdINO " %16" B_PRIdINO "\n", c->vnid,
c->loc);
}
}

@@ -118,11 +117,11 @@ init_vcache(nspace *vol)
return ENOMEM;
}

- sprintf(name, "fat cache %lx", vol->id);
+ sprintf(name, "fat cache %" B_PRIdDEV, vol->id);
rw_lock_init(&vol->vcache.lock, "fat cache");

- DPRINTF(0, ("init_vcache: initialized vnid cache with %lx entries\n",
- vol->vcache.cache_size));
+ DPRINTF(0, ("init_vcache: initialized vnid cache with %" B_PRIu32
+ " entries\n", vol->vcache.cache_size));

return 0;
}
@@ -148,7 +147,7 @@ uninit_vcache(nspace *vol)
}
}

- DPRINTF(0, ("%lx vcache entries removed\n", count));
+ DPRINTF(0, ("%" B_PRIu32 " vcache entries removed\n", count));

free(vol->vcache.by_vnid); vol->vcache.by_vnid = NULL;
free(vol->vcache.by_loc); vol->vcache.by_loc = NULL;
@@ -174,7 +173,7 @@ _add_to_vcache_(nspace *vol, ino_t vnid, ino_t loc)
int hash1 = hash(vnid), hash2 = hash(loc);
struct vcache_entry *e, *c, *p;

- DPRINTF(0, ("add_to_vcache %Lx/%Lx\n", vnid, loc));
+ DPRINTF(0, ("add_to_vcache %" B_PRIdINO "/%" B_PRIdINO "\n", vnid,
loc));

ASSERT(vnid != loc);

@@ -226,7 +225,7 @@ _remove_from_vcache_(nspace *vol, ino_t vnid)
int hash1 = hash(vnid), hash2;
struct vcache_entry *c, *p, *e;

- DPRINTF(0, ("remove_from_vcache %Lx\n", vnid));
+ DPRINTF(0, ("remove_from_vcache %" B_PRIdINO "\n", vnid));

c = p = vol->vcache.by_vnid[hash1];
while (c) {
@@ -352,7 +351,8 @@ vcache_vnid_to_loc(nspace *vol, ino_t vnid, ino_t *loc)
{
struct vcache_entry *e;

- DPRINTF(1, ("vcache_vnid_to_loc %Lx %lx\n", vnid, (uint32)loc));
+ DPRINTF(1, ("vcache_vnid_to_loc %" B_PRIdINO " %p\n", vnid,
+ loc));

LOCK_CACHE_R;
e = _find_vnid_in_vcache_(vol, vnid);
@@ -369,7 +369,8 @@ vcache_loc_to_vnid(nspace *vol, ino_t loc, ino_t *vnid)
{
struct vcache_entry *e;

- DPRINTF(1, ("vcache_loc_to_vnid %Lx %lx\n", loc, (uint32)vnid));
+ DPRINTF(1, ("vcache_loc_to_vnid %" B_PRIdINO " %p\n", loc,
+ vnid));

LOCK_CACHE_R;
e = _find_loc_in_vcache_(vol, loc);
@@ -387,7 +388,8 @@ vcache_set_entry(nspace *vol, ino_t vnid, ino_t loc)
struct vcache_entry *e;
status_t result = B_OK;

- DPRINTF(0, ("vcache_set_entry: %Lx -> %Lx\n", vnid, loc));
+ DPRINTF(0, ("vcache_set_entry: %" B_PRIdINO " -> %" B_PRIdINO "\n",
vnid,
+ loc));

/*if (is_vnode_removed(vol->id, vnid) > 0) {
if (!IS_ARTIFICIAL_VNID(loc))
@@ -436,9 +438,10 @@ debug_dfvnid(int argc, char **argv)
ino_t vnid = strtoull(argv[i], NULL, 0);
struct vcache_entry *e;
if ((e = _find_vnid_in_vcache_(vol, vnid)) != NULL) {
- kprintf("vnid %Lx -> loc %Lx @ %p\n", vnid, e->loc, e);
+ kprintf("vnid %" B_PRIdINO " -> loc %" B_PRIdINO " @
%p\n", vnid,
+ e->loc, e);
} else {
- kprintf("vnid %Lx not found in vnid cache\n", vnid);
+ kprintf("vnid %" B_PRIdINO " not found in vnid
cache\n", vnid);
}
}

@@ -465,9 +468,10 @@ debug_dfloc(int argc, char **argv)
ino_t loc = strtoull(argv[i], NULL, 0);
struct vcache_entry *e;
if ((e = _find_loc_in_vcache_(vol, loc)) != NULL) {
- kprintf("loc %Lx -> vnid %Lx @ %p\n", loc, e->vnid, e);
+ kprintf("loc %" B_PRIdINO " -> vnid %" B_PRIdINO " @
%p\n", loc,
+ e->vnid, e);
} else {
- kprintf("loc %Lx not found in vnid cache\n", loc);
+ kprintf("loc %" B_PRIdINO " not found in vnid cache\n",
loc);
}
}


############################################################################

Commit: 09592b1dccf44420e9cf8b3212dc372a6b4972eb
URL: http://cgit.haiku-os.org/haiku/commit/?id=09592b1dccf4
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat May 2 09:58:31 2015 UTC

fat: Fix stack corruption on 64 bit due to wrong count type.

On 64 bit platforms a 64 bit size_t was written at the (incorrect)
uint32 on the stack, causing the adjacent bytes variable to be
clobbered. Because of this, the vectors wouldn't actually be filled
with any file data, making the content of files inacessible.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/fat/file.c
b/src/add-ons/kernel/file_systems/fat/file.c
index e17813c..aa2ed8c 100644
--- a/src/add-ons/kernel/file_systems/fat/file.c
+++ b/src/add-ons/kernel/file_systems/fat/file.c
@@ -1439,7 +1439,7 @@ dosfs_read_pages(fs_volume *_vol, fs_vnode *_node, void
*_cookie, off_t pos,

while (true) {
struct file_io_vec fileVecs[8];
- uint32 fileVecCount = 8;
+ size_t fileVecCount = 8;
bool bufferOverflow;
size_t bytes = bytesLeft;

@@ -1483,7 +1483,7 @@ dosfs_write_pages(fs_volume *_vol, fs_vnode *_node, void
*_cookie, off_t pos,

while (true) {
struct file_io_vec fileVecs[8];
- uint32 fileVecCount = 8;
+ size_t fileVecCount = 8;
bool bufferOverflow;
size_t bytes = bytesLeft;


############################################################################

Revision: hrev49140
Commit: 52bf63bbbb868d5b7221102f0fba52b883970dce
URL: http://cgit.haiku-os.org/haiku/commit/?id=52bf63bbbb86
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat May 2 10:06:03 2015 UTC

fat: Fix compiler warnings.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/fat/dosfs.c
b/src/add-ons/kernel/file_systems/fat/dosfs.c
index 6dc4ed2..832700e 100644
--- a/src/add-ons/kernel/file_systems/fat/dosfs.c
+++ b/src/add-ons/kernel/file_systems/fat/dosfs.c
@@ -711,9 +711,7 @@ dosfs_identify_partition(int fd, partition_data *partition,
void **_cookie)
uint8 buf[512];
int i;
uint32 bytes_per_sector;
- uint32 sectors_per_cluster;
uint32 fatCount;
- uint32 reserved_sectors;
uint32 total_sectors;
uint32 sectors_per_fat;
char name[12];
@@ -738,13 +736,11 @@ dosfs_identify_partition(int fd, partition_data
*partition, void **_cookie)
}

// must be a power of two
- sectors_per_cluster = i = buf[0xd];
+ i = buf[0xd];
if (i != 1 && i != 2 && i != 4 && i != 8 && i != 0x10 && i != 0x20
&& i != 0x40 && i != 0x80)
return -1;

- reserved_sectors = read16(buf, 0xe);
-
fatCount = buf[0x10];
if (fatCount == 0 || fatCount > 8)
return -1;
@@ -1101,9 +1097,11 @@ dosfs_write_fs_stat(fs_volume *_vol, const struct
fs_info * fss, uint32 mask)
goto bi;
}
if ((vol->sectors_per_fat == 0 && (buffer[0x42] != 0x29
- || strncmp(buffer + 0x47, vol->vol_label, 11)
!= 0))
+ || strncmp((const char *)buffer + 0x47,
vol->vol_label, 11)
+ != 0))
|| (vol->sectors_per_fat != 0 && (buffer[0x26]
!= 0x29
- || strncmp(buffer + 0x2b, vol->vol_label, 11)
== 0))) {
+ || strncmp((const char *)buffer + 0x2b,
vol->vol_label, 11)
+ == 0))) {
dprintf("dosfs_wfsstat: label mismatch\n");
block_cache_set_dirty(vol->fBlockCache, 0,
false, -1);
result = B_ERROR;
@@ -1118,7 +1116,8 @@ dosfs_write_fs_stat(fs_volume *_vol, const struct fs_info
* fss, uint32 mask)
buffer = diri_init(vol, vol->root_vnode.cluster,
vol->vol_entry, &diri);

// check if it is the same as the old volume label
- if ((buffer == NULL) || (strncmp(buffer,
vol->vol_label, 11) == 0)) {
+ if (buffer == NULL || strncmp((const char *)buffer,
vol->vol_label,
+ 11) == 0) {
dprintf("dosfs_wfsstat: label mismatch\n");
diri_free(&diri);
result = B_ERROR;
diff --git a/src/add-ons/kernel/file_systems/fat/iter.c
b/src/add-ons/kernel/file_systems/fat/iter.c
index 54e8764..90da492 100644
--- a/src/add-ons/kernel/file_systems/fat/iter.c
+++ b/src/add-ons/kernel/file_systems/fat/iter.c
@@ -150,7 +150,7 @@ csi_read_blocks(struct csi *csi, uint8 *buffer, ssize_t len)
uint32 sectors;
off_t block;
status_t err;
- char *buf = buffer;
+ uint8 *buf = buffer;
int32 i;

ASSERT(len >= csi->vol->bytes_per_sector);
@@ -191,7 +191,7 @@ csi_write_blocks(struct csi *csi, uint8 *buffer, ssize_t
len)
uint32 sectors;
off_t block;
status_t err;
- char *buf = buffer;
+ uint8 *buf = buffer;
int32 i;

ASSERT(len >= csi->vol->bytes_per_sector);


Other related posts:

  • » [haiku-commits] haiku: hrev49140 - src/add-ons/kernel/file_systems/fat - mmlr