i considered submitting this patch anonomously since it's so ugly. the problem is that the kfs file structure depends on the architecture, because the Dentry structure has an embedded structure at a 2 byte boundary. this means that 32-bit machines will pad it out with 2 extra bytes, and 64-bit machiens will pad it with 6 extra bytes. to preserve the on-disk layout, the c structure was #pragma packed and explicit padding was added as necessary. adding proper marshalling code looked to be a bit daunting, but that seems like a better long-term solution. Reference: /n/atom/patch/applied2013/kfs64bitclean Date: Mon Oct 14 23:34:42 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/disk/kfs/portdat.h Mon Oct 14 23:31:28 2013 +++ /sys/src/cmd/disk/kfs/portdat.h Mon Oct 14 23:31:28 2013 @@ -39,7 +39,16 @@ long version; }; +/* + * oh rats! this structure deeply assumes a 32-bit machine. + * to make this work for 64-bit, without breaking old kfs + * images, some dirty tricks are necessary. first we have to + * pack the structure, but that packs too well, the short + * "badplanning" fills in the traditional hole. + */ + /* DONT TOUCH, this is the disk structure */ +#pragma pack on struct Dentry { char name[NAMELEN]; @@ -53,6 +62,7 @@ #define DREAD 0x4 #define DWRITE 0x2 #define DEXEC 0x1 + short badplanning; Qid9p1 qid; long size; long dblock[NDBLOCK]; @@ -61,6 +71,7 @@ long atime; long mtime; }; +#pragma pack off /* DONT TOUCH, this is the disk structure */ struct Tag