[klibc] [PATCH] btrfs support

Benjamin Cama benoar at free.fr
Sun Apr 25 13:39:05 PDT 2010


Hi,

Le jeudi 22 avril 2010 à 03:55 +0200, maximilian attems a écrit :
> On Sat, 03 Apr 2010, Benjamin Cama wrote:
> > I tried to follow "upstream" as much as possible, letting every comment
> > in place, etc. I think it's clearer to indicate that this code is only
> > copy and paste, and to indicate from where it comes. Hence my remark at
> > the top indicating it comes from fs/btrfs/ctree.h.
> 
> had the userspace btrfs include from blkid,
> as it was known to work, so no point in changing that.

I never looked at blkid, didn't know it handled that. Still, I
would /prefer/ real upstream to be sure of format change (even if it's
unlikely now). But that's not a very important matter anyway.

> > > > +
> > > > +	if (!memcmp(&sb->magic, BTRFS_MAGIC, sizeof(BTRFS_MAGIC)-1)) {
> > > > +		*bytes = (unsigned long long)__le64_to_cpu(sb->total_bytes);
> > > > +		return 1;
> > > > +	}
> > > 
> > > why the le64_to_cpu call ?
> > 
> > Well, so that the size is correctly read regarding the endianness ?...
> > Or I didn't understand your question.
> 
> cool for spelling it out,
> mind to send a follow up patch on current klibc git?

Following is the endianness fix. Tested OK on both little endian (amd64)
and big endian (powerpc).

Regards,
benjamin

Signed-off-by: Benjamin Cama <benoar at free.fr>
---
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 6aa82fc..e5a8156 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -460,7 +460,7 @@ static int btrfs_image(const void *buf, unsigned long long *bytes)
 	    (const struct btrfs_super_block *)buf;
 
 	if (!memcmp(sb->magic, BTRFS_MAGIC, BTRFS_MAGIC_L)) {
-		*bytes = sb->total_bytes;
+		*bytes = (unsigned long long)__le64_to_cpu(sb->total_bytes);
 		return 1;
 	}
 	return 0;




More information about the klibc mailing list