I believe there is a bug in the definition of BLKGETSIZE64 in
ext2resize-1.1.19/src/ext2_unix_io.c

I believe that this patch fixes the problem:
---8<---
--- ext2resize-1.1.19/src/ext2_unix_io.c        2004-09-30 15:04:04.000000000 
+0100
+++ ext2resize-1.1.19.works/src/ext2_unix_io.c  2005-01-11 17:56:14.000000000 
+0000
@@ -47,7 +47,7 @@
 #endif

 #ifndef BLKGETSIZE64
-#define BLKGETSIZE64 _IOR(0x12,114,sizeof(unsigned long long))
+#define BLKGETSIZE64 _IOR(0x12,114,unsigned long long)
 #endif

 struct my_cookie
---8<---

Analysis
========
This bug concealed when compiling against old versions of asm/ioctl.h.
My experiance is with debian so bear with me...

The vanilla ext2resize-1.1.19 source builds without reporting the bug on a
debian woody(stable) system where /usr/include/asm/ioctl.h
is provided provided by package libc6-dev version 2.2.5-11.5.

The vanilla ext2resize-1.1.19 source reports a bug when built on a
debian sarge(testing) system  where /usr/include/asm/ioctl.h
is provided provided by package linux-kernel-headers 2.5.999-test7-bk-16.

The diff between versions of /usr/include/asm/ioctl.h is only small and
the comments show that _IOR was changed  to trap such bugs as this
one at compile time.

---8<---
--- old-ioctl.h 2005-01-12 14:38:32.000000000 +0000
+++ /usr/include/asm/ioctl.h    2004-06-02 04:59:44.000000000 +0100
@@ -52,11 +52,21 @@
         ((nr)   << _IOC_NRSHIFT) | \
         ((size) << _IOC_SIZESHIFT))

+/* provoke compile error for invalid uses of size argument */
+extern unsigned int __invalid_size_argument_for_IOC;
+#define _IOC_TYPECHECK(t) \
+       ((sizeof(t) == sizeof(t[1]) && \
+         sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
+         sizeof(t) : __invalid_size_argument_for_IOC)
+
 /* used to create numbers */
 #define _IO(type,nr)           _IOC(_IOC_NONE,(type),(nr),0)
-#define _IOR(type,nr,size)     _IOC(_IOC_READ,(type),(nr),sizeof(size))
-#define _IOW(type,nr,size)     _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
-#define _IOWR(type,nr,size)
_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOR(type,nr,size)
_IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOW(type,nr,size)
_IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOWR(type,nr,size)
_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR_BAD(type,nr,size)
_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))

 /* used to decode ioctl numbers.. */
 #define _IOC_DIR(nr)           (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
---8<---

I hope this helps...
Alex Owen



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to