Commit 8784a0db authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] romfs endianness annotations

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 46eec798
......@@ -95,15 +95,16 @@ static inline struct romfs_inode_info *ROMFS_I(struct inode *inode)
return list_entry(inode, struct romfs_inode_info, vfs_inode);
}
static __s32
static __u32
romfs_checksum(void *data, int size)
{
__s32 sum, *ptr;
__u32 sum;
__be32 *ptr;
sum = 0; ptr = data;
size>>=2;
while (size>0) {
sum += ntohl(*ptr++);
sum += be32_to_cpu(*ptr++);
size--;
}
return sum;
......@@ -131,7 +132,7 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent)
}
rsb = (struct romfs_super_block *)bh->b_data;
sz = ntohl(rsb->size);
sz = be32_to_cpu(rsb->size);
if (rsb->word0 != ROMSB_WORD0 || rsb->word1 != ROMSB_WORD1
|| sz < ROMFH_SIZE) {
if (!silent)
......@@ -292,7 +293,7 @@ romfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
offset = i->i_ino & ROMFH_MASK;
if (romfs_copyfrom(i, &ri, offset, ROMFH_SIZE) <= 0)
goto out;
offset = ntohl(ri.spec) & ROMFH_MASK;
offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
}
/* Not really failsafe, but we are read-only... */
......@@ -316,9 +317,9 @@ romfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
romfs_copyfrom(i, fsname, offset+ROMFH_SIZE, j);
ino = offset;
nextfh = ntohl(ri.next);
nextfh = be32_to_cpu(ri.next);
if ((nextfh & ROMFH_TYPE) == ROMFH_HRD)
ino = ntohl(ri.spec);
ino = be32_to_cpu(ri.spec);
if (filldir(dirent, fsname, j, offset, ino,
romfs_dtype_table[nextfh & ROMFH_TYPE]) < 0) {
goto out;
......@@ -349,7 +350,7 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
goto out;
maxoff = romfs_maxsize(dir->i_sb);
offset = ntohl(ri.spec) & ROMFH_MASK;
offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
/* OK, now find the file whose name is in "dentry" in the
* directory specified by "dir". */
......@@ -382,12 +383,12 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
}
}
/* next entry */
offset = ntohl(ri.next) & ROMFH_MASK;
offset = be32_to_cpu(ri.next) & ROMFH_MASK;
}
/* Hard link handling */
if ((ntohl(ri.next) & ROMFH_TYPE) == ROMFH_HRD)
offset = ntohl(ri.spec) & ROMFH_MASK;
if ((be32_to_cpu(ri.next) & ROMFH_TYPE) == ROMFH_HRD)
offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
if ((inode = iget(dir->i_sb, offset)))
goto outi;
......@@ -495,15 +496,15 @@ romfs_read_inode(struct inode *i)
}
/* XXX: do romfs_checksum here too (with name) */
nextfh = ntohl(ri.next);
nextfh = be32_to_cpu(ri.next);
if ((nextfh & ROMFH_TYPE) != ROMFH_HRD)
break;
ino = ntohl(ri.spec) & ROMFH_MASK;
ino = be32_to_cpu(ri.spec) & ROMFH_MASK;
}
i->i_nlink = 1; /* Hard to decide.. */
i->i_size = ntohl(ri.size);
i->i_size = be32_to_cpu(ri.size);
i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0;
i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0;
i->i_uid = i->i_gid = 0;
......@@ -544,7 +545,7 @@ romfs_read_inode(struct inode *i)
break;
default:
/* depending on MBZ for sock/fifos */
nextfh = ntohl(ri.spec);
nextfh = be32_to_cpu(ri.spec);
init_special_inode(i, ino,
MKDEV(nextfh>>16,nextfh&0xffff));
}
......
......@@ -12,27 +12,27 @@
#define __mkw(h,l) (((h)&0x00ff)<< 8|((l)&0x00ff))
#define __mkl(h,l) (((h)&0xffff)<<16|((l)&0xffff))
#define __mk4(a,b,c,d) htonl(__mkl(__mkw(a,b),__mkw(c,d)))
#define __mk4(a,b,c,d) cpu_to_be32(__mkl(__mkw(a,b),__mkw(c,d)))
#define ROMSB_WORD0 __mk4('-','r','o','m')
#define ROMSB_WORD1 __mk4('1','f','s','-')
/* On-disk "super block" */
struct romfs_super_block {
__u32 word0;
__u32 word1;
__u32 size;
__u32 checksum;
__be32 word0;
__be32 word1;
__be32 size;
__be32 checksum;
char name[0]; /* volume name */
};
/* On disk inode */
struct romfs_inode {
__u32 next; /* low 4 bits see ROMFH_ */
__u32 spec;
__u32 size;
__u32 checksum;
__be32 next; /* low 4 bits see ROMFH_ */
__be32 spec;
__be32 size;
__be32 checksum;
char name[0];
};
......
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