commit 1d0b8e5a345ffd9777d579813e47efddc539c74d
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Mon Feb 12 14:31:32 2007 -0500
endianness
diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index 9d9035b..0780aae 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -31,6 +31,8 @@ static int unionfs_readdir(struct file *file, void *dirent,
filldir_t filldir)
char *name = NULL;
int namelen, magic;
unsigned int d_type;
+ __le32 le32;
+ __le64 le64;
if ((err = unionfs_file_revalidate(file, 0)))
goto out;
@@ -66,24 +68,26 @@ static int unionfs_readdir(struct file *file, void *dirent,
filldir_t filldir)
oldfs = get_fs();
set_fs(KERNEL_DS);
- err = odf_file->f_op->read(odf_file, (char*)&magic,
- sizeof(int), &odf_file->f_pos);
- if (err != sizeof(int)) {
+ err = odf_file->f_op->read(odf_file, (char*)&le32,
+ sizeof(__le32), &odf_file->f_pos);
+ if (err != sizeof(__le32)) {
err = -EIO;
goto out;
}
+ magic = le32_to_cpu(le32);
/* check if we're reading at the correct offset */
if (magic != ODF_DIRENT_MAGIC) {
err = -EFAULT;
goto out;
}
- err = odf_file->f_op->read(odf_file, (char*)&namelen,
- sizeof(int), &odf_file->f_pos);
- if (err != sizeof(int)) {
+ err = odf_file->f_op->read(odf_file, (char*)&le32,
+ sizeof(__le32), &odf_file->f_pos);
+ if (err != sizeof(__le32)) {
err = -EIO;
goto out;
}
+ namelen = le32_to_cpu(le32);
if (namelen <= 0) {
err = -EFAULT;
goto out;
@@ -101,18 +105,20 @@ static int unionfs_readdir(struct file *file, void
*dirent, filldir_t filldir)
goto out;
}
- err = odf_file->f_op->read(odf_file, (char*)&ino,
- sizeof(u64), &odf_file->f_pos);
- if (err != sizeof(u64)) {
+ err = odf_file->f_op->read(odf_file, (char*)&le64,
+ sizeof(__le64), &odf_file->f_pos);
+ if (err != sizeof(__le64)) {
err = -EIO;
goto out;
}
- err = odf_file->f_op->read(odf_file, (char*)&d_type,
- sizeof(unsigned int), &odf_file->f_pos);
- if (err != sizeof(unsigned int)) {
+ ino = le64_to_cpu(le64);
+ err = odf_file->f_op->read(odf_file, (char*)&le32,
+ sizeof(__le32), &odf_file->f_pos);
+ if (err != sizeof(__le32)) {
err = -EIO;
goto out;
}
+ d_type = le32_to_cpu(le32);
set_fs(oldfs);
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index 00ed474..2444178 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -149,6 +149,8 @@ static int readdir_util_callback(void *dirent, const char
*name, int namelen,
int whiteout = 0, magic = ODF_DIRENT_MAGIC;
struct filldir_node *found;
struct odf_dentry_info *odi = NULL;
+ __le32 le32;
+ __le64 le64;
mm_segment_t oldfs;
if (buf->mode == RD_CHECK_EMPTY)
@@ -156,9 +158,9 @@ static int readdir_util_callback(void *dirent, const char
*name, int namelen,
else
buf->filldir_called++;
- if (name[0] == '.'
- && (namelen == 1 || (name[1] == '.' && namelen == 2))
- && buf->mode == RD_CHECK_EMPTY)
+ if (name[0] == '.' &&
+ (namelen == 1 || (name[1] == '.' && namelen == 2)) &&
+ buf->mode == RD_CHECK_EMPTY)
goto out;
/* check odf */
@@ -187,25 +189,29 @@ static int readdir_util_callback(void *dirent, const char
*name, int namelen,
oldfs = get_fs();
set_fs(KERNEL_DS);
- err = buf->filp->f_op->write(buf->filp, (char*)&magic,
- sizeof(int), &buf->filp->f_pos);
- if (err != sizeof(int))
+ le32 = cpu_to_le32(magic);
+ err = buf->filp->f_op->write(buf->filp, (char*)&le32,
+ sizeof(__le32), &buf->filp->f_pos);
+ if (err != sizeof(__le32))
goto out;
- err = buf->filp->f_op->write(buf->filp, (char*)&namelen,
- sizeof(int), &buf->filp->f_pos);
- if (err != sizeof(int))
+ le32 = cpu_to_le32(namelen);
+ err = buf->filp->f_op->write(buf->filp, (char*)&le32,
+ sizeof(__le32), &buf->filp->f_pos);
+ if (err != sizeof(__le32))
goto out;
err = buf->filp->f_op->write(buf->filp, (char*)name,
namelen, &buf->filp->f_pos);
if (err != namelen)
goto out;
- err = buf->filp->f_op->write(buf->filp, (char*)&ino,
- sizeof(u64), &buf->filp->f_pos);
- if (err != sizeof(u64))
+ le64 = cpu_to_le64(ino);
+ err = buf->filp->f_op->write(buf->filp, (char*)&le64,
+ sizeof(__le64), &buf->filp->f_pos);
+ if (err != sizeof(__le64))
goto out;
- err =buf->filp->f_op->write(buf->filp, (char*)&d_type,
- sizeof(unsigned int), &buf->filp->f_pos);
- if (err != sizeof(unsigned int))
+ le32 = cpu_to_le32(d_type);
+ err =buf->filp->f_op->write(buf->filp, (char*)&le32,
+ sizeof(__le32), &buf->filp->f_pos);
+ if (err != sizeof(__le32))
goto out;
set_fs(oldfs);
err = 0;
@@ -410,11 +416,9 @@ int odf_cache_dir(struct dentry *d_upper, struct dentry
*d_odf)
}
out:
- if (buf) {
- if (buf->rdstate)
- free_rdstate(buf->rdstate);
- kfree(buf);
- }
+ if (buf && buf->rdstate)
+ free_rdstate(buf->rdstate);
+ kfree(buf);
if (odf_file)
filp_close(odf_file, NULL);
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index eaeb2be..6f9c86f 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -337,7 +337,7 @@ struct odf_dentry_info *odf_ic_dir(struct dentry *dir)
}
memset(name,0,6);
- sprintf(name, "%d", breakdown[0]);
+ sprintf(name, "%x", breakdown[0]);
odis[0] = __odf_lookup(odi_ic, name, strlen(name), ODF_LOOKUP_DIR,
NULL);
if (IS_ERR(odis[0])) {
err = PTR_ERR(odis[0]);
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs