summaryrefslogtreecommitdiff
path: root/libbb/loop.c
diff options
context:
space:
mode:
authorEric Andersen2004-02-06 07:16:36 +0000
committerEric Andersen2004-02-06 07:16:36 +0000
commitef8cd3be17f0be6017af50f70e09093f5908c7c3 (patch)
tree8fb031797cc9e0c0a7c54ba7ef27e0948feab913 /libbb/loop.c
parent7495b0d4b1959b1391c460f24c285b46417730ea (diff)
downloadbusybox-ef8cd3be17f0be6017af50f70e09093f5908c7c3.zip
busybox-ef8cd3be17f0be6017af50f70e09093f5908c7c3.tar.gz
Make the loop support stuff be much less evil, and make it cope
with 2.6.x asm/posix_types.h, which has done singularly evil thing by yanking __kernel_dev_t and renaming it. The loop interface was really poorly designed in the first place. The new 64 bit loop interface looks to be somewhat less horrible, too bad it is only present in 2.6.x kernels. -Erik
Diffstat (limited to 'libbb/loop.c')
-rw-r--r--libbb/loop.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/libbb/loop.c b/libbb/loop.c
index 7dba3e2..4d73dc4 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -26,7 +26,40 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include "libbb.h"
-#include "loop.h" /* Pull in loop device support */
+
+/* Grumble... The 2.6.x kernel breaks asm/posix_types.h
+ * so we get to try and cope as best we can... */
+#include <linux/version.h>
+#include <asm/posix_types.h>
+#if LINUX_VERSION_CODE >= 132608
+#define __bb_kernel_dev_t __kernel_old_dev_t
+#elif LINUX_VERSION_CODE >= 0x20600
+#define __bb_kernel_dev_t __kernel_dev_t
+#else
+#define __bb_kernel_dev_t unsigned short
+#endif
+
+/* Stuff stolen from linux/loop.h */
+#define LO_NAME_SIZE 64
+#define LO_KEY_SIZE 32
+#define LOOP_SET_FD 0x4C00
+#define LOOP_CLR_FD 0x4C01
+#define LOOP_SET_STATUS 0x4C02
+#define LOOP_GET_STATUS 0x4C03
+struct loop_info {
+ int lo_number;
+ __bb_kernel_dev_t lo_device;
+ unsigned long lo_inode;
+ __bb_kernel_dev_t lo_rdevice;
+ int lo_offset;
+ int lo_encrypt_type;
+ int lo_encrypt_key_size;
+ int lo_flags;
+ char lo_name[LO_NAME_SIZE];
+ unsigned char lo_encrypt_key[LO_KEY_SIZE];
+ unsigned long lo_init[2];
+ char reserved[4];
+};
extern int del_loop(const char *device)
{