Commit df5acb11 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] hfs endianness annotations

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a56f626b
...@@ -85,7 +85,8 @@ int hfs_brec_find(struct hfs_find_data *fd) ...@@ -85,7 +85,8 @@ int hfs_brec_find(struct hfs_find_data *fd)
{ {
struct hfs_btree *tree; struct hfs_btree *tree;
struct hfs_bnode *bnode; struct hfs_bnode *bnode;
u32 data, nidx, parent; u32 nidx, parent;
__be32 data;
int height, res; int height, res;
tree = fd->tree; tree = fd->tree;
......
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
* Accesses memory in 32-bit aligned chunks of 32-bits and thus * Accesses memory in 32-bit aligned chunks of 32-bits and thus
* may read beyond the 'size'th bit. * may read beyond the 'size'th bit.
*/ */
static u32 hfs_find_set_zero_bits(u32 *bitmap, u32 size, u32 offset, u32 *max) static u32 hfs_find_set_zero_bits(__be32 *bitmap, u32 size, u32 offset, u32 *max)
{ {
u32 *curr, *end; __be32 *curr, *end;
u32 val, mask, start, len; u32 mask, start, len, n;
__be32 val;
int i; int i;
len = *max; len = *max;
...@@ -42,11 +43,11 @@ static u32 hfs_find_set_zero_bits(u32 *bitmap, u32 size, u32 offset, u32 *max) ...@@ -42,11 +43,11 @@ static u32 hfs_find_set_zero_bits(u32 *bitmap, u32 size, u32 offset, u32 *max)
/* scan the first partial u32 for zero bits */ /* scan the first partial u32 for zero bits */
val = *curr; val = *curr;
if (~val) { if (~val) {
val = be32_to_cpu(val); n = be32_to_cpu(val);
i = offset % 32; i = offset % 32;
mask = (1U << 31) >> i; mask = (1U << 31) >> i;
for (; i < 32; mask >>= 1, i++) { for (; i < 32; mask >>= 1, i++) {
if (!(val & mask)) if (!(n & mask))
goto found; goto found;
} }
} }
...@@ -55,10 +56,10 @@ static u32 hfs_find_set_zero_bits(u32 *bitmap, u32 size, u32 offset, u32 *max) ...@@ -55,10 +56,10 @@ static u32 hfs_find_set_zero_bits(u32 *bitmap, u32 size, u32 offset, u32 *max)
while (++curr < end) { while (++curr < end) {
val = *curr; val = *curr;
if (~val) { if (~val) {
val = be32_to_cpu(val); n = be32_to_cpu(val);
mask = 1 << 31; mask = 1 << 31;
for (i = 0; i < 32; mask >>= 1, i++) { for (i = 0; i < 32; mask >>= 1, i++) {
if (!(val & mask)) if (!(n & mask))
goto found; goto found;
} }
} }
...@@ -72,38 +73,38 @@ static u32 hfs_find_set_zero_bits(u32 *bitmap, u32 size, u32 offset, u32 *max) ...@@ -72,38 +73,38 @@ static u32 hfs_find_set_zero_bits(u32 *bitmap, u32 size, u32 offset, u32 *max)
/* do any partial u32 at the start */ /* do any partial u32 at the start */
len = min(size - start, len); len = min(size - start, len);
while (1) { while (1) {
val |= mask; n |= mask;
if (++i >= 32) if (++i >= 32)
break; break;
mask >>= 1; mask >>= 1;
if (!--len || val & mask) if (!--len || n & mask)
goto done; goto done;
} }
if (!--len) if (!--len)
goto done; goto done;
*curr++ = cpu_to_be32(val); *curr++ = cpu_to_be32(n);
/* do full u32s */ /* do full u32s */
while (1) { while (1) {
val = be32_to_cpu(*curr); n = be32_to_cpu(*curr);
if (len < 32) if (len < 32)
break; break;
if (val) { if (n) {
len = 32; len = 32;
break; break;
} }
*curr++ = 0xffffffffU; *curr++ = cpu_to_be32(0xffffffff);
len -= 32; len -= 32;
} }
/* do any partial u32 at end */ /* do any partial u32 at end */
mask = 1U << 31; mask = 1U << 31;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (val & mask) if (n & mask)
break; break;
val |= mask; n |= mask;
mask >>= 1; mask >>= 1;
} }
done: done:
*curr = cpu_to_be32(val); *curr = cpu_to_be32(n);
*max = (curr - bitmap) * 32 + i - start; *max = (curr - bitmap) * 32 + i - start;
return start; return start;
} }
...@@ -191,7 +192,7 @@ u32 hfs_vbm_search_free(struct super_block *sb, u32 goal, u32 *num_bits) ...@@ -191,7 +192,7 @@ u32 hfs_vbm_search_free(struct super_block *sb, u32 goal, u32 *num_bits)
*/ */
int hfs_clear_vbm_bits(struct super_block *sb, u16 start, u16 count) int hfs_clear_vbm_bits(struct super_block *sb, u16 start, u16 count)
{ {
u32 *curr; __be32 *curr;
u32 mask; u32 mask;
int i, len; int i, len;
......
...@@ -29,7 +29,7 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, ...@@ -29,7 +29,7 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf,
u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off) u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off)
{ {
u16 data; __be16 data;
// optimize later... // optimize later...
hfs_bnode_read(node, &data, off, 2); hfs_bnode_read(node, &data, off, 2);
return be16_to_cpu(data); return be16_to_cpu(data);
...@@ -72,9 +72,9 @@ void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len) ...@@ -72,9 +72,9 @@ void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len)
void hfs_bnode_write_u16(struct hfs_bnode *node, int off, u16 data) void hfs_bnode_write_u16(struct hfs_bnode *node, int off, u16 data)
{ {
data = cpu_to_be16(data); __be16 v = cpu_to_be16(data);
// optimize later... // optimize later...
hfs_bnode_write(node, &data, off, 2); hfs_bnode_write(node, &v, off, 2);
} }
void hfs_bnode_write_u8(struct hfs_bnode *node, int off, u8 data) void hfs_bnode_write_u8(struct hfs_bnode *node, int off, u8 data)
...@@ -136,7 +136,7 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len) ...@@ -136,7 +136,7 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len)
void hfs_bnode_dump(struct hfs_bnode *node) void hfs_bnode_dump(struct hfs_bnode *node)
{ {
struct hfs_bnode_desc desc; struct hfs_bnode_desc desc;
u32 cnid; __be32 cnid;
int i, off, key_off; int i, off, key_off;
dprint(DBG_BNODE_MOD, "bnode: %d\n", node->this); dprint(DBG_BNODE_MOD, "bnode: %d\n", node->this);
...@@ -173,7 +173,7 @@ void hfs_bnode_unlink(struct hfs_bnode *node) ...@@ -173,7 +173,7 @@ void hfs_bnode_unlink(struct hfs_bnode *node)
{ {
struct hfs_btree *tree; struct hfs_btree *tree;
struct hfs_bnode *tmp; struct hfs_bnode *tmp;
u32 cnid; __be32 cnid;
tree = node->tree; tree = node->tree;
if (node->prev) { if (node->prev) {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
/* Get the length and offset of the given record in the given node */ /* Get the length and offset of the given record in the given node */
u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off) u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off)
{ {
u16 retval[2]; __be16 retval[2];
u16 dataoff; u16 dataoff;
dataoff = node->tree->node_size - (rec + 2) * 2; dataoff = node->tree->node_size - (rec + 2) * 2;
...@@ -55,7 +55,7 @@ int hfs_brec_insert(struct hfs_find_data *fd, void *entry, int entry_len) ...@@ -55,7 +55,7 @@ int hfs_brec_insert(struct hfs_find_data *fd, void *entry, int entry_len)
int size, key_len, rec; int size, key_len, rec;
int data_off, end_off; int data_off, end_off;
int idx_rec_off, data_rec_off, end_rec_off; int idx_rec_off, data_rec_off, end_rec_off;
u32 cnid; __be32 cnid;
tree = fd->tree; tree = fd->tree;
if (!fd->bnode) { if (!fd->bnode) {
...@@ -391,7 +391,7 @@ int hfs_brec_update_parent(struct hfs_find_data *fd) ...@@ -391,7 +391,7 @@ int hfs_brec_update_parent(struct hfs_find_data *fd)
node = parent; node = parent;
if (new_node) { if (new_node) {
u32 cnid; __be32 cnid;
fd->bnode = hfs_bnode_find(tree, new_node->parent); fd->bnode = hfs_bnode_find(tree, new_node->parent);
/* create index key and entry */ /* create index key and entry */
...@@ -423,7 +423,7 @@ int hfs_btree_inc_height(struct hfs_btree *tree) ...@@ -423,7 +423,7 @@ int hfs_btree_inc_height(struct hfs_btree *tree)
struct hfs_bnode *node, *new_node; struct hfs_bnode *node, *new_node;
struct hfs_bnode_desc node_desc; struct hfs_bnode_desc node_desc;
int key_size, rec; int key_size, rec;
u32 cnid; __be32 cnid;
node = NULL; node = NULL;
if (tree->root) { if (tree->root) {
......
...@@ -154,7 +154,7 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx) ...@@ -154,7 +154,7 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx)
struct hfs_btree *tree = prev->tree; struct hfs_btree *tree = prev->tree;
struct hfs_bnode *node; struct hfs_bnode *node;
struct hfs_bnode_desc desc; struct hfs_bnode_desc desc;
u32 cnid; __be32 cnid;
node = hfs_bnode_create(tree, idx); node = hfs_bnode_create(tree, idx);
if (IS_ERR(node)) if (IS_ERR(node))
......
...@@ -125,11 +125,11 @@ extern int hfs_brec_goto(struct hfs_find_data *, int); ...@@ -125,11 +125,11 @@ extern int hfs_brec_goto(struct hfs_find_data *, int);
struct hfs_bnode_desc { struct hfs_bnode_desc {
u32 next; /* (V) Number of the next node at this level */ __be32 next; /* (V) Number of the next node at this level */
u32 prev; /* (V) Number of the prev node at this level */ __be32 prev; /* (V) Number of the prev node at this level */
u8 type; /* (F) The type of node */ u8 type; /* (F) The type of node */
u8 height; /* (F) The level of this node (leaves=1) */ u8 height; /* (F) The level of this node (leaves=1) */
u16 num_recs; /* (V) The number of records in this node */ __be16 num_recs; /* (V) The number of records in this node */
u16 reserved; u16 reserved;
} __packed; } __packed;
...@@ -139,20 +139,20 @@ struct hfs_bnode_desc { ...@@ -139,20 +139,20 @@ struct hfs_bnode_desc {
#define HFS_NODE_LEAF 0xFF /* A leaf (ndNHeight==1) node */ #define HFS_NODE_LEAF 0xFF /* A leaf (ndNHeight==1) node */
struct hfs_btree_header_rec { struct hfs_btree_header_rec {
u16 depth; /* (V) The number of levels in this B-tree */ __be16 depth; /* (V) The number of levels in this B-tree */
u32 root; /* (V) The node number of the root node */ __be32 root; /* (V) The node number of the root node */
u32 leaf_count; /* (V) The number of leaf records */ __be32 leaf_count; /* (V) The number of leaf records */
u32 leaf_head; /* (V) The number of the first leaf node */ __be32 leaf_head; /* (V) The number of the first leaf node */
u32 leaf_tail; /* (V) The number of the last leaf node */ __be32 leaf_tail; /* (V) The number of the last leaf node */
u16 node_size; /* (F) The number of bytes in a node (=512) */ __be16 node_size; /* (F) The number of bytes in a node (=512) */
u16 max_key_len; /* (F) The length of a key in an index node */ __be16 max_key_len; /* (F) The length of a key in an index node */
u32 node_count; /* (V) The total number of nodes */ __be32 node_count; /* (V) The total number of nodes */
u32 free_nodes; /* (V) The number of unused nodes */ __be32 free_nodes; /* (V) The number of unused nodes */
u16 reserved1; u16 reserved1;
u32 clump_size; /* (F) clump size. not usually used. */ __be32 clump_size; /* (F) clump size. not usually used. */
u8 btree_type; /* (F) BTree type */ u8 btree_type; /* (F) BTree type */
u8 reserved2; u8 reserved2;
u32 attributes; /* (F) attributes */ __be32 attributes; /* (F) attributes */
u32 reserved3[16]; u32 reserved3[16];
} __packed; } __packed;
......
...@@ -35,7 +35,7 @@ void hfs_cat_build_key(btree_key *key, u32 parent, struct qstr *name) ...@@ -35,7 +35,7 @@ void hfs_cat_build_key(btree_key *key, u32 parent, struct qstr *name)
int hfs_cat_build_record(hfs_cat_rec *rec, u32 cnid, struct inode *inode) int hfs_cat_build_record(hfs_cat_rec *rec, u32 cnid, struct inode *inode)
{ {
u32 mtime = hfs_mtime(); __be32 mtime = hfs_mtime();
memset(rec, 0, sizeof(*rec)); memset(rec, 0, sizeof(*rec));
if (S_ISDIR(inode->i_mode)) { if (S_ISDIR(inode->i_mode)) {
......
...@@ -279,13 +279,13 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type) ...@@ -279,13 +279,13 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type)
int res, i; int res, i;
if (type == HFS_FK_DATA) { if (type == HFS_FK_DATA) {
total_blocks = file->PyLen; total_blocks = be32_to_cpu(file->PyLen);
extent = file->ExtRec; extent = file->ExtRec;
} else { } else {
total_blocks = file->RPyLen; total_blocks = be32_to_cpu(file->RPyLen);
extent = file->RExtRec; extent = file->RExtRec;
} }
total_blocks = be32_to_cpu(total_blocks) / HFS_SB(sb)->alloc_blksz; total_blocks /= HFS_SB(sb)->alloc_blksz;
if (!total_blocks) if (!total_blocks)
return 0; return 0;
......
...@@ -91,45 +91,45 @@ struct hfs_name { ...@@ -91,45 +91,45 @@ struct hfs_name {
} __packed; } __packed;
struct hfs_point { struct hfs_point {
u16 v; __be16 v;
u16 h; __be16 h;
} __packed; } __packed;
struct hfs_rect { struct hfs_rect {
u16 top; __be16 top;
u16 left; __be16 left;
u16 bottom; __be16 bottom;
u16 right; __be16 right;
} __packed; } __packed;
struct hfs_finfo { struct hfs_finfo {
u32 fdType; __be32 fdType;
u32 fdCreator; __be32 fdCreator;
u16 fdFlags; __be16 fdFlags;
struct hfs_point fdLocation; struct hfs_point fdLocation;
u16 fdFldr; __be16 fdFldr;
} __packed; } __packed;
struct hfs_fxinfo { struct hfs_fxinfo {
u16 fdIconID; __be16 fdIconID;
u8 fdUnused[8]; u8 fdUnused[8];
u16 fdComment; __be16 fdComment;
u32 fdPutAway; __be32 fdPutAway;
} __packed; } __packed;
struct hfs_dinfo { struct hfs_dinfo {
struct hfs_rect frRect; struct hfs_rect frRect;
u16 frFlags; __be16 frFlags;
struct hfs_point frLocation; struct hfs_point frLocation;
u16 frView; __be16 frView;
} __packed; } __packed;
struct hfs_dxinfo { struct hfs_dxinfo {
struct hfs_point frScroll; struct hfs_point frScroll;
u32 frOpenChain; __be32 frOpenChain;
u16 frUnused; __be16 frUnused;
u16 frComment; __be16 frComment;
u32 frPutAway; __be32 frPutAway;
} __packed; } __packed;
union hfs_finder_info { union hfs_finder_info {
...@@ -150,7 +150,7 @@ union hfs_finder_info { ...@@ -150,7 +150,7 @@ union hfs_finder_info {
struct hfs_cat_key { struct hfs_cat_key {
u8 key_len; /* number of bytes in the key */ u8 key_len; /* number of bytes in the key */
u8 reserved; /* padding */ u8 reserved; /* padding */
u32 ParID; /* CNID of the parent dir */ __be32 ParID; /* CNID of the parent dir */
struct hfs_name CName; /* The filename of the entry */ struct hfs_name CName; /* The filename of the entry */
} __packed; } __packed;
...@@ -158,8 +158,8 @@ struct hfs_cat_key { ...@@ -158,8 +158,8 @@ struct hfs_cat_key {
struct hfs_ext_key { struct hfs_ext_key {
u8 key_len; /* number of bytes in the key */ u8 key_len; /* number of bytes in the key */
u8 FkType; /* HFS_FK_{DATA,RSRC} */ u8 FkType; /* HFS_FK_{DATA,RSRC} */
u32 FNum; /* The File ID of the file */ __be32 FNum; /* The File ID of the file */
u16 FABN; /* allocation blocks number*/ __be16 FABN; /* allocation blocks number*/
} __packed; } __packed;
typedef union hfs_btree_key { typedef union hfs_btree_key {
...@@ -171,8 +171,8 @@ typedef union hfs_btree_key { ...@@ -171,8 +171,8 @@ typedef union hfs_btree_key {
typedef union hfs_btree_key btree_key; typedef union hfs_btree_key btree_key;
struct hfs_extent { struct hfs_extent {
u16 block; __be16 block;
u16 count; __be16 count;
}; };
typedef struct hfs_extent hfs_extent_rec[3]; typedef struct hfs_extent hfs_extent_rec[3];
...@@ -183,18 +183,18 @@ struct hfs_cat_file { ...@@ -183,18 +183,18 @@ struct hfs_cat_file {
u8 Flags; /* Flags such as read-only */ u8 Flags; /* Flags such as read-only */
s8 Typ; /* file version number = 0 */ s8 Typ; /* file version number = 0 */
struct hfs_finfo UsrWds; /* data used by the Finder */ struct hfs_finfo UsrWds; /* data used by the Finder */
u32 FlNum; /* The CNID */ __be32 FlNum; /* The CNID */
u16 StBlk; /* obsolete */ __be16 StBlk; /* obsolete */
u32 LgLen; /* The logical EOF of the data fork*/ __be32 LgLen; /* The logical EOF of the data fork*/
u32 PyLen; /* The physical EOF of the data fork */ __be32 PyLen; /* The physical EOF of the data fork */
u16 RStBlk; /* obsolete */ __be16 RStBlk; /* obsolete */
u32 RLgLen; /* The logical EOF of the rsrc fork */ __be32 RLgLen; /* The logical EOF of the rsrc fork */
u32 RPyLen; /* The physical EOF of the rsrc fork */ __be32 RPyLen; /* The physical EOF of the rsrc fork */
u32 CrDat; /* The creation date */ __be32 CrDat; /* The creation date */
u32 MdDat; /* The modified date */ __be32 MdDat; /* The modified date */
u32 BkDat; /* The last backup date */ __be32 BkDat; /* The last backup date */
struct hfs_fxinfo FndrInfo; /* more data for the Finder */ struct hfs_fxinfo FndrInfo; /* more data for the Finder */
u16 ClpSize; /* number of bytes to allocate __be16 ClpSize; /* number of bytes to allocate
when extending files */ when extending files */
hfs_extent_rec ExtRec; /* first extent record hfs_extent_rec ExtRec; /* first extent record
for the data fork */ for the data fork */
...@@ -207,13 +207,13 @@ struct hfs_cat_file { ...@@ -207,13 +207,13 @@ struct hfs_cat_file {
struct hfs_cat_dir { struct hfs_cat_dir {
s8 type; /* The type of entry */ s8 type; /* The type of entry */
u8 reserved; u8 reserved;
u16 Flags; /* flags */ __be16 Flags; /* flags */
u16 Val; /* Valence: number of files and __be16 Val; /* Valence: number of files and
dirs in the directory */ dirs in the directory */
u32 DirID; /* The CNID */ __be32 DirID; /* The CNID */
u32 CrDat; /* The creation date */ __be32 CrDat; /* The creation date */
u32 MdDat; /* The modification date */ __be32 MdDat; /* The modification date */
u32 BkDat; /* The last backup date */ __be32 BkDat; /* The last backup date */
struct hfs_dinfo UsrInfo; /* data used by the Finder */ struct hfs_dinfo UsrInfo; /* data used by the Finder */
struct hfs_dxinfo FndrInfo; /* more data used by Finder */ struct hfs_dxinfo FndrInfo; /* more data used by Finder */
u8 Resrv[16]; /* reserved by Apple */ u8 Resrv[16]; /* reserved by Apple */
...@@ -223,7 +223,7 @@ struct hfs_cat_dir { ...@@ -223,7 +223,7 @@ struct hfs_cat_dir {
struct hfs_cat_thread { struct hfs_cat_thread {
s8 type; /* The type of entry */ s8 type; /* The type of entry */
u8 reserved[9]; /* reserved by Apple */ u8 reserved[9]; /* reserved by Apple */
u32 ParID; /* CNID of parent directory */ __be32 ParID; /* CNID of parent directory */
struct hfs_name CName; /* The name of this entry */ struct hfs_name CName; /* The name of this entry */
} __packed; } __packed;
...@@ -236,43 +236,43 @@ typedef union hfs_cat_rec { ...@@ -236,43 +236,43 @@ typedef union hfs_cat_rec {
} hfs_cat_rec; } hfs_cat_rec;
struct hfs_mdb { struct hfs_mdb {
u16 drSigWord; /* Signature word indicating fs type */ __be16 drSigWord; /* Signature word indicating fs type */
u32 drCrDate; /* fs creation date/time */ __be32 drCrDate; /* fs creation date/time */
u32 drLsMod; /* fs modification date/time */ __be32 drLsMod; /* fs modification date/time */
u16 drAtrb; /* fs attributes */ __be16 drAtrb; /* fs attributes */
u16 drNmFls; /* number of files in root directory */ __be16 drNmFls; /* number of files in root directory */
u16 drVBMSt; /* location (in 512-byte blocks) __be16 drVBMSt; /* location (in 512-byte blocks)
of the volume bitmap */ of the volume bitmap */
u16 drAllocPtr; /* location (in allocation blocks) __be16 drAllocPtr; /* location (in allocation blocks)
to begin next allocation search */ to begin next allocation search */
u16 drNmAlBlks; /* number of allocation blocks */ __be16 drNmAlBlks; /* number of allocation blocks */
u32 drAlBlkSiz; /* bytes in an allocation block */ __be32 drAlBlkSiz; /* bytes in an allocation block */
u32 drClpSiz; /* clumpsize, the number of bytes to __be32 drClpSiz; /* clumpsize, the number of bytes to
allocate when extending a file */ allocate when extending a file */
u16 drAlBlSt; /* location (in 512-byte blocks) __be16 drAlBlSt; /* location (in 512-byte blocks)
of the first allocation block */ of the first allocation block */
u32 drNxtCNID; /* CNID to assign to the next __be32 drNxtCNID; /* CNID to assign to the next
file or directory created */ file or directory created */
u16 drFreeBks; /* number of free allocation blocks */ __be16 drFreeBks; /* number of free allocation blocks */
u8 drVN[28]; /* the volume label */ u8 drVN[28]; /* the volume label */
u32 drVolBkUp; /* fs backup date/time */ __be32 drVolBkUp; /* fs backup date/time */
u16 drVSeqNum; /* backup sequence number */ __be16 drVSeqNum; /* backup sequence number */
u32 drWrCnt; /* fs write count */ __be32 drWrCnt; /* fs write count */
u32 drXTClpSiz; /* clumpsize for the extents B-tree */ __be32 drXTClpSiz; /* clumpsize for the extents B-tree */
u32 drCTClpSiz; /* clumpsize for the catalog B-tree */ __be32 drCTClpSiz; /* clumpsize for the catalog B-tree */
u16 drNmRtDirs; /* number of directories in __be16 drNmRtDirs; /* number of directories in
the root directory */ the root directory */
u32 drFilCnt; /* number of files in the fs */ __be32 drFilCnt; /* number of files in the fs */
u32 drDirCnt; /* number of directories in the fs */ __be32 drDirCnt; /* number of directories in the fs */
u8 drFndrInfo[32]; /* data used by the Finder */ u8 drFndrInfo[32]; /* data used by the Finder */
u16 drEmbedSigWord; /* embedded volume signature */ __be16 drEmbedSigWord; /* embedded volume signature */
u32 drEmbedExtent; /* starting block number (xdrStABN) __be32 drEmbedExtent; /* starting block number (xdrStABN)
and number of allocation blocks and number of allocation blocks
(xdrNumABlks) occupied by embedded (xdrNumABlks) occupied by embedded
volume */ volume */
u32 drXTFlSize; /* bytes in the extents B-tree */ __be32 drXTFlSize; /* bytes in the extents B-tree */
hfs_extent_rec drXTExtRec; /* extents B-tree's first 3 extents */ hfs_extent_rec drXTExtRec; /* extents B-tree's first 3 extents */
u32 drCTFlSize; /* bytes in the catalog B-tree */ __be32 drCTFlSize; /* bytes in the catalog B-tree */
hfs_extent_rec drCTExtRec; /* catalog B-tree's first 3 extents */ hfs_extent_rec drCTExtRec; /* catalog B-tree's first 3 extents */
} __packed; } __packed;
......
...@@ -90,7 +90,7 @@ struct hfs_sb_info { ...@@ -90,7 +90,7 @@ struct hfs_sb_info {
struct buffer_head *alt_mdb_bh; /* The hfs_buffer holding struct buffer_head *alt_mdb_bh; /* The hfs_buffer holding
the alternate superblock */ the alternate superblock */
struct hfs_mdb *alt_mdb; struct hfs_mdb *alt_mdb;
u32 *bitmap; /* The page holding the __be32 *bitmap; /* The page holding the
allocation bitmap */ allocation bitmap */
struct hfs_btree *ext_tree; /* Information about struct hfs_btree *ext_tree; /* Information about
the extents b-tree */ the extents b-tree */
...@@ -129,8 +129,8 @@ struct hfs_sb_info { ...@@ -129,8 +129,8 @@ struct hfs_sb_info {
"allocation block" */ "allocation block" */
int s_quiet; /* Silent failure when int s_quiet; /* Silent failure when
changing owner or mode? */ changing owner or mode? */
u32 s_type; /* Type for new files */ __be32 s_type; /* Type for new files */
u32 s_creator; /* Creator for new files */ __be32 s_creator; /* Creator for new files */
umode_t s_file_umask; /* The umask applied to the umode_t s_file_umask; /* The umask applied to the
permissions on all files */ permissions on all files */
umode_t s_dir_umask; /* The umask applied to the umode_t s_dir_umask; /* The umask applied to the
...@@ -197,11 +197,11 @@ extern struct address_space_operations hfs_aops; ...@@ -197,11 +197,11 @@ extern struct address_space_operations hfs_aops;
extern struct address_space_operations hfs_btree_aops; extern struct address_space_operations hfs_btree_aops;
extern struct inode *hfs_new_inode(struct inode *, struct qstr *, int); extern struct inode *hfs_new_inode(struct inode *, struct qstr *, int);
extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, u32 *, u32 *); extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *);
extern int hfs_write_inode(struct inode *, int); extern int hfs_write_inode(struct inode *, int);
extern int hfs_inode_setattr(struct dentry *, struct iattr *); extern int hfs_inode_setattr(struct dentry *, struct iattr *);
extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext, extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
u32 log_size, u32 phys_size, u32 clump_size); __be32 log_size, __be32 phys_size, u32 clump_size);
extern struct inode *hfs_iget(struct super_block *, struct hfs_cat_key *, hfs_cat_rec *); extern struct inode *hfs_iget(struct super_block *, struct hfs_cat_key *, hfs_cat_rec *);
extern void hfs_clear_inode(struct inode *); extern void hfs_clear_inode(struct inode *);
extern void hfs_delete_inode(struct inode *); extern void hfs_delete_inode(struct inode *);
......
...@@ -210,14 +210,14 @@ void hfs_delete_inode(struct inode *inode) ...@@ -210,14 +210,14 @@ void hfs_delete_inode(struct inode *inode)
dprint(DBG_INODE, "delete_inode: %lu\n", inode->i_ino); dprint(DBG_INODE, "delete_inode: %lu\n", inode->i_ino);
if (S_ISDIR(inode->i_mode)) { if (S_ISDIR(inode->i_mode)) {
HFS_SB(sb)->folder_count--; HFS_SB(sb)->folder_count--;
if (HFS_I(inode)->cat_key.ParID == be32_to_cpu(HFS_ROOT_CNID)) if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID))
HFS_SB(sb)->root_dirs--; HFS_SB(sb)->root_dirs--;
set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags); set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
sb->s_dirt = 1; sb->s_dirt = 1;
return; return;
} }
HFS_SB(sb)->file_count--; HFS_SB(sb)->file_count--;
if (HFS_I(inode)->cat_key.ParID == be32_to_cpu(HFS_ROOT_CNID)) if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID))
HFS_SB(sb)->root_files--; HFS_SB(sb)->root_files--;
if (S_ISREG(inode->i_mode)) { if (S_ISREG(inode->i_mode)) {
if (!inode->i_nlink) { if (!inode->i_nlink) {
...@@ -230,9 +230,10 @@ void hfs_delete_inode(struct inode *inode) ...@@ -230,9 +230,10 @@ void hfs_delete_inode(struct inode *inode)
} }
void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext, void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
u32 log_size, u32 phys_size, u32 clump_size) __be32 __log_size, __be32 phys_size, u32 clump_size)
{ {
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
u32 log_size = be32_to_cpu(__log_size);
u16 count; u16 count;
int i; int i;
...@@ -241,7 +242,6 @@ void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext, ...@@ -241,7 +242,6 @@ void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
count += be16_to_cpu(ext[i].count); count += be16_to_cpu(ext[i].count);
HFS_I(inode)->first_blocks = count; HFS_I(inode)->first_blocks = count;
log_size = be32_to_cpu(log_size);
inode->i_size = HFS_I(inode)->phys_size = log_size; inode->i_size = HFS_I(inode)->phys_size = log_size;
inode->i_blocks = (log_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; inode->i_blocks = (log_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
HFS_I(inode)->alloc_blocks = be32_to_cpu(phys_size) / HFS_I(inode)->alloc_blocks = be32_to_cpu(phys_size) /
...@@ -370,7 +370,7 @@ struct inode *hfs_iget(struct super_block *sb, struct hfs_cat_key *key, hfs_cat_ ...@@ -370,7 +370,7 @@ struct inode *hfs_iget(struct super_block *sb, struct hfs_cat_key *key, hfs_cat_
} }
void hfs_inode_write_fork(struct inode *inode, struct hfs_extent *ext, void hfs_inode_write_fork(struct inode *inode, struct hfs_extent *ext,
u32 *log_size, u32 *phys_size) __be32 *log_size, __be32 *phys_size)
{ {
memcpy(ext, HFS_I(inode)->first_extents, sizeof(hfs_extent_rec)); memcpy(ext, HFS_I(inode)->first_extents, sizeof(hfs_extent_rec));
......
...@@ -71,7 +71,7 @@ int hfs_mdb_get(struct super_block *sb) ...@@ -71,7 +71,7 @@ int hfs_mdb_get(struct super_block *sb)
int off2, len, size, sect; int off2, len, size, sect;
sector_t part_start, part_size; sector_t part_start, part_size;
loff_t off; loff_t off;
u16 attrib; __be16 attrib;
/* set the device driver to 512-byte blocks */ /* set the device driver to 512-byte blocks */
size = sb_min_blocksize(sb, HFS_SECTOR_SIZE); size = sb_min_blocksize(sb, HFS_SECTOR_SIZE);
...@@ -164,7 +164,7 @@ int hfs_mdb_get(struct super_block *sb) ...@@ -164,7 +164,7 @@ int hfs_mdb_get(struct super_block *sb)
hfs_warn("hfs_fs: continuing without an alternate MDB\n"); hfs_warn("hfs_fs: continuing without an alternate MDB\n");
} }
HFS_SB(sb)->bitmap = (u32 *)__get_free_pages(GFP_KERNEL, PAGE_SIZE < 8192 ? 1 : 0); HFS_SB(sb)->bitmap = (__be32 *)__get_free_pages(GFP_KERNEL, PAGE_SIZE < 8192 ? 1 : 0);
if (!HFS_SB(sb)->bitmap) if (!HFS_SB(sb)->bitmap)
goto out; goto out;
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
* contiguous starting at block 1. * contiguous starting at block 1.
*/ */
struct new_pmap { struct new_pmap {
u16 pmSig; /* signature */ __be16 pmSig; /* signature */
u16 reSigPad; /* padding */ __be16 reSigPad; /* padding */
u32 pmMapBlkCnt; /* partition blocks count */ __be32 pmMapBlkCnt; /* partition blocks count */
u32 pmPyPartStart; /* physical block start of partition */ __be32 pmPyPartStart; /* physical block start of partition */
u32 pmPartBlkCnt; /* physical block count of partition */ __be32 pmPartBlkCnt; /* physical block count of partition */
u8 pmPartName[32]; /* (null terminated?) string u8 pmPartName[32]; /* (null terminated?) string
giving the name of this giving the name of this
partition */ partition */
...@@ -41,11 +41,11 @@ struct new_pmap { ...@@ -41,11 +41,11 @@ struct new_pmap {
* one of these. * one of these.
*/ */
struct old_pmap { struct old_pmap {
u16 pdSig; /* Signature bytes */ __be16 pdSig; /* Signature bytes */
struct old_pmap_entry { struct old_pmap_entry {
u32 pdStart; __be32 pdStart;
u32 pdSize; __be32 pdSize;
u32 pdFSID; __be32 pdFSID;
} pdEntry[42]; } pdEntry[42];
} __packed; } __packed;
...@@ -59,7 +59,7 @@ int hfs_part_find(struct super_block *sb, ...@@ -59,7 +59,7 @@ int hfs_part_find(struct super_block *sb,
sector_t *part_start, sector_t *part_size) sector_t *part_start, sector_t *part_size)
{ {
struct buffer_head *bh; struct buffer_head *bh;
u16 *data; __be16 *data;
int i, size, res; int i, size, res;
res = -ENOENT; res = -ENOENT;
......
...@@ -152,8 +152,7 @@ static int parse_options(char *options, struct hfs_sb_info *hsb) ...@@ -152,8 +152,7 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
hsb->s_gid = current->gid; hsb->s_gid = current->gid;
hsb->s_file_umask = 0644; hsb->s_file_umask = 0644;
hsb->s_dir_umask = 0755; hsb->s_dir_umask = 0755;
hsb->s_type = 0x3f3f3f3f; /* == '????' */ hsb->s_type = hsb->s_creator = cpu_to_be32(0x3f3f3f3f); /* == '????' */
hsb->s_creator = 0x3f3f3f3f; /* == '????' */
hsb->s_quiet = 0; hsb->s_quiet = 0;
hsb->part = -1; hsb->part = -1;
hsb->session = -1; hsb->session = -1;
...@@ -216,11 +215,11 @@ static int parse_options(char *options, struct hfs_sb_info *hsb) ...@@ -216,11 +215,11 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
} else if (!strcmp(this_char, "type") && value) { } else if (!strcmp(this_char, "type") && value) {
if (strlen(value) != 4) if (strlen(value) != 4)
return 0; return 0;
hsb->s_type = *(u32 *)value; memcpy(&hsb->s_type, value, 4);
} else if (!strcmp(this_char, "creator") && value) { } else if (!strcmp(this_char, "creator") && value) {
if (strlen(value) != 4) if (strlen(value) != 4)
return 0; return 0;
hsb->s_creator = *(u32 *)value; memcpy(&hsb->s_creator, value, 4);
/* Boolean-valued options */ /* Boolean-valued options */
} else if (!strcmp(this_char, "quiet")) { } else if (!strcmp(this_char, "quiet")) {
if (value) if (value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment