diff options
-rw-r--r-- | Makefile | 21 | ||||
-rwxr-xr-x | libbb/mk_loop_h.sh | 34 | ||||
-rwxr-xr-x | mk_loop_h.sh | 34 | ||||
-rw-r--r-- | real_loop.h | 37 | ||||
-rw-r--r-- | utility.c | 9 |
5 files changed, 123 insertions, 12 deletions
@@ -42,7 +42,7 @@ DODMALLOC = false # If you are running a cross compiler, you may want to set this # to something more interesting... -CROSS = +CROSS = #powerpc-linux- CC = $(CROSS)gcc STRIPTOOL = $(CROSS)strip @@ -83,12 +83,13 @@ else ifeq ($(DOSTATIC),true) LDFLAGS += --static # - #use '-ffunction-sections -fdata-sections' and '--gc-sections' if they work - #to try and strip out any unused junk. Doesn't do much for me, but you may - #want to give it a shot... + #use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they + # work) to try and strip out any unused junk. Doesn't do much for me, + # but you may want to give it a shot... # #ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \ - # -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1) + # -o /dev/null -xc /dev/null 2>/dev/null && $(LD) \ + # --gc-sections -v >/dev/null && echo 1),1) # CFLAGS += -ffunction-sections -fdata-sections # LDFLAGS += --gc-sections #endif @@ -106,7 +107,8 @@ ifdef BB_INIT_SCRIPT CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' endif -all: busybox busybox.links doc + +all: loop.h busybox busybox.links doc doc: olddoc @@ -154,7 +156,7 @@ docs/busybox/busybox.html: docs/busybox.sgml -busybox: $(OBJECTS) +busybox: $(OBJECTS) $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) $(STRIP) @@ -164,6 +166,11 @@ busybox.links: busybox.def.h nfsmount.o cmdedit.o: %.o: %.h $(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile +utility.o: + +loop.h: + @./mk_loop_h.sh + test tests: cd tests && $(MAKE) all diff --git a/libbb/mk_loop_h.sh b/libbb/mk_loop_h.sh new file mode 100755 index 000000000..c33c010ca --- /dev/null +++ b/libbb/mk_loop_h.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Figure out (i) the type of dev_t (ii) the defines for loop stuff +# + +rm -f loop.h + +# Since 1.3.79 there is an include file <asm/posix_types.h> +# that defines __kernel_dev_t. +# (The file itself appeared in 1.3.78, but there it defined __dev_t.) +# If it exists, we use it, or, rather, <linux/posix_types.h> which +# avoids namespace pollution. Otherwise we guess that __kernel_dev_t +# is an unsigned short (which is true on i386, but false on alpha). + +if [ -f /usr/include/linux/posix_types.h ]; then + echo '#include <linux/posix_types.h>' >> loop.h + echo '#undef dev_t' >> loop.h + echo '#define dev_t __kernel_dev_t' >> loop.h +else + echo '#undef dev_t' >> loop.h + echo '#define dev_t unsigned short' >> loop.h +fi + +# Next we have to find the loop stuff itself. +# First try kernel source, then a private version. + +if [ -f /usr/include/linux/loop.h ]; then + echo '#include <linux/loop.h>' >> loop.h +else + echo '#include "real_loop.h"' >> loop.h +fi + +echo '#undef dev_t' >> loop.h + diff --git a/mk_loop_h.sh b/mk_loop_h.sh new file mode 100755 index 000000000..c33c010ca --- /dev/null +++ b/mk_loop_h.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Figure out (i) the type of dev_t (ii) the defines for loop stuff +# + +rm -f loop.h + +# Since 1.3.79 there is an include file <asm/posix_types.h> +# that defines __kernel_dev_t. +# (The file itself appeared in 1.3.78, but there it defined __dev_t.) +# If it exists, we use it, or, rather, <linux/posix_types.h> which +# avoids namespace pollution. Otherwise we guess that __kernel_dev_t +# is an unsigned short (which is true on i386, but false on alpha). + +if [ -f /usr/include/linux/posix_types.h ]; then + echo '#include <linux/posix_types.h>' >> loop.h + echo '#undef dev_t' >> loop.h + echo '#define dev_t __kernel_dev_t' >> loop.h +else + echo '#undef dev_t' >> loop.h + echo '#define dev_t unsigned short' >> loop.h +fi + +# Next we have to find the loop stuff itself. +# First try kernel source, then a private version. + +if [ -f /usr/include/linux/loop.h ]; then + echo '#include <linux/loop.h>' >> loop.h +else + echo '#include "real_loop.h"' >> loop.h +fi + +echo '#undef dev_t' >> loop.h + diff --git a/real_loop.h b/real_loop.h new file mode 100644 index 000000000..1bd7fa87a --- /dev/null +++ b/real_loop.h @@ -0,0 +1,37 @@ +/* + * include/linux/loop.h + * + * Written by Theodore Ts'o, 3/29/93. + * + * Copyright 1993 by Theodore Ts'o. Redistribution of this file is + * permitted under the GNU Public License. + */ + +#define LO_NAME_SIZE 64 +#define LO_KEY_SIZE 32 + +struct loop_info { + int lo_number; /* ioctl r/o */ + dev_t lo_device; /* ioctl r/o */ + unsigned long lo_inode; /* ioctl r/o */ + dev_t lo_rdevice; /* ioctl r/o */ + int lo_offset; + int lo_encrypt_type; + int lo_encrypt_key_size; /* ioctl w/o */ + int lo_flags; /* ioctl r/o */ + char lo_name[LO_NAME_SIZE]; + unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ + unsigned long lo_init[2]; + char reserved[4]; +}; + +#define LO_CRYPT_NONE 0 +#define LO_CRYPT_XOR 1 +#define LO_CRYPT_DES 2 +#define LO_CRYPT_IDEA 3 +#define MAX_LO_CRYPT 4 + +#define LOOP_SET_FD 0x4C00 +#define LOOP_CLR_FD 0x4C01 +#define LOOP_SET_STATUS 0x4C02 +#define LOOP_GET_STATUS 0x4C03 @@ -53,11 +53,6 @@ #include <sys/ioctl.h> #include <sys/utsname.h> /* for uname(2) */ -#if defined BB_FEATURE_MOUNT_LOOP -#include <fcntl.h> -#include <linux/loop.h> /* Pull in loop device support */ -#endif - /* Busybox mount uses either /proc/filesystems or /dev/mtab to get the * list of available filesystems used for the -t auto option */ #if defined BB_FEATURE_USE_PROCFS && defined BB_FEATURE_USE_DEVPS_PATCH @@ -1459,7 +1454,11 @@ extern int vdprintf(int d, const char *format, va_list ap) } #endif /* BB_SYSLOGD */ + #if defined BB_FEATURE_MOUNT_LOOP +#include <fcntl.h> +#include "loop.h" /* Pull in loop device support */ + extern int del_loop(const char *device) { int fd; |