diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-09-21 02:04:51 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-09-21 02:04:51 +0000 |
commit | 624cc771da4ac5f15ec16a2b0f10feeef0b125c7 (patch) | |
tree | 159ab99cb2f1e14218204306c1be24f0b6c85745 | |
parent | 8847b9a03afd59a4d4f833be12937b38216799d3 (diff) | |
download | busybox-w32-624cc771da4ac5f15ec16a2b0f10feeef0b125c7.tar.gz busybox-w32-624cc771da4ac5f15ec16a2b0f10feeef0b125c7.tar.bz2 busybox-w32-624cc771da4ac5f15ec16a2b0f10feeef0b125c7.zip |
More portable handling of loop header files, as done in util-linux
-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 | |||
42 | 42 | ||
43 | # If you are running a cross compiler, you may want to set this | 43 | # If you are running a cross compiler, you may want to set this |
44 | # to something more interesting... | 44 | # to something more interesting... |
45 | CROSS = | 45 | CROSS = #powerpc-linux- |
46 | CC = $(CROSS)gcc | 46 | CC = $(CROSS)gcc |
47 | STRIPTOOL = $(CROSS)strip | 47 | STRIPTOOL = $(CROSS)strip |
48 | 48 | ||
@@ -83,12 +83,13 @@ else | |||
83 | ifeq ($(DOSTATIC),true) | 83 | ifeq ($(DOSTATIC),true) |
84 | LDFLAGS += --static | 84 | LDFLAGS += --static |
85 | # | 85 | # |
86 | #use '-ffunction-sections -fdata-sections' and '--gc-sections' if they work | 86 | #use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they |
87 | #to try and strip out any unused junk. Doesn't do much for me, but you may | 87 | # work) to try and strip out any unused junk. Doesn't do much for me, |
88 | #want to give it a shot... | 88 | # but you may want to give it a shot... |
89 | # | 89 | # |
90 | #ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \ | 90 | #ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \ |
91 | # -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1) | 91 | # -o /dev/null -xc /dev/null 2>/dev/null && $(LD) \ |
92 | # --gc-sections -v >/dev/null && echo 1),1) | ||
92 | # CFLAGS += -ffunction-sections -fdata-sections | 93 | # CFLAGS += -ffunction-sections -fdata-sections |
93 | # LDFLAGS += --gc-sections | 94 | # LDFLAGS += --gc-sections |
94 | #endif | 95 | #endif |
@@ -106,7 +107,8 @@ ifdef BB_INIT_SCRIPT | |||
106 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' | 107 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' |
107 | endif | 108 | endif |
108 | 109 | ||
109 | all: busybox busybox.links doc | 110 | |
111 | all: loop.h busybox busybox.links doc | ||
110 | 112 | ||
111 | doc: olddoc | 113 | doc: olddoc |
112 | 114 | ||
@@ -154,7 +156,7 @@ docs/busybox/busybox.html: docs/busybox.sgml | |||
154 | 156 | ||
155 | 157 | ||
156 | 158 | ||
157 | busybox: $(OBJECTS) | 159 | busybox: $(OBJECTS) |
158 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) | 160 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) |
159 | $(STRIP) | 161 | $(STRIP) |
160 | 162 | ||
@@ -164,6 +166,11 @@ busybox.links: busybox.def.h | |||
164 | nfsmount.o cmdedit.o: %.o: %.h | 166 | nfsmount.o cmdedit.o: %.o: %.h |
165 | $(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile | 167 | $(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile |
166 | 168 | ||
169 | utility.o: | ||
170 | |||
171 | loop.h: | ||
172 | @./mk_loop_h.sh | ||
173 | |||
167 | test tests: | 174 | test tests: |
168 | cd tests && $(MAKE) all | 175 | cd tests && $(MAKE) all |
169 | 176 | ||
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 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Figure out (i) the type of dev_t (ii) the defines for loop stuff | ||
4 | # | ||
5 | |||
6 | rm -f loop.h | ||
7 | |||
8 | # Since 1.3.79 there is an include file <asm/posix_types.h> | ||
9 | # that defines __kernel_dev_t. | ||
10 | # (The file itself appeared in 1.3.78, but there it defined __dev_t.) | ||
11 | # If it exists, we use it, or, rather, <linux/posix_types.h> which | ||
12 | # avoids namespace pollution. Otherwise we guess that __kernel_dev_t | ||
13 | # is an unsigned short (which is true on i386, but false on alpha). | ||
14 | |||
15 | if [ -f /usr/include/linux/posix_types.h ]; then | ||
16 | echo '#include <linux/posix_types.h>' >> loop.h | ||
17 | echo '#undef dev_t' >> loop.h | ||
18 | echo '#define dev_t __kernel_dev_t' >> loop.h | ||
19 | else | ||
20 | echo '#undef dev_t' >> loop.h | ||
21 | echo '#define dev_t unsigned short' >> loop.h | ||
22 | fi | ||
23 | |||
24 | # Next we have to find the loop stuff itself. | ||
25 | # First try kernel source, then a private version. | ||
26 | |||
27 | if [ -f /usr/include/linux/loop.h ]; then | ||
28 | echo '#include <linux/loop.h>' >> loop.h | ||
29 | else | ||
30 | echo '#include "real_loop.h"' >> loop.h | ||
31 | fi | ||
32 | |||
33 | echo '#undef dev_t' >> loop.h | ||
34 | |||
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 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Figure out (i) the type of dev_t (ii) the defines for loop stuff | ||
4 | # | ||
5 | |||
6 | rm -f loop.h | ||
7 | |||
8 | # Since 1.3.79 there is an include file <asm/posix_types.h> | ||
9 | # that defines __kernel_dev_t. | ||
10 | # (The file itself appeared in 1.3.78, but there it defined __dev_t.) | ||
11 | # If it exists, we use it, or, rather, <linux/posix_types.h> which | ||
12 | # avoids namespace pollution. Otherwise we guess that __kernel_dev_t | ||
13 | # is an unsigned short (which is true on i386, but false on alpha). | ||
14 | |||
15 | if [ -f /usr/include/linux/posix_types.h ]; then | ||
16 | echo '#include <linux/posix_types.h>' >> loop.h | ||
17 | echo '#undef dev_t' >> loop.h | ||
18 | echo '#define dev_t __kernel_dev_t' >> loop.h | ||
19 | else | ||
20 | echo '#undef dev_t' >> loop.h | ||
21 | echo '#define dev_t unsigned short' >> loop.h | ||
22 | fi | ||
23 | |||
24 | # Next we have to find the loop stuff itself. | ||
25 | # First try kernel source, then a private version. | ||
26 | |||
27 | if [ -f /usr/include/linux/loop.h ]; then | ||
28 | echo '#include <linux/loop.h>' >> loop.h | ||
29 | else | ||
30 | echo '#include "real_loop.h"' >> loop.h | ||
31 | fi | ||
32 | |||
33 | echo '#undef dev_t' >> loop.h | ||
34 | |||
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 @@ | |||
1 | /* | ||
2 | * include/linux/loop.h | ||
3 | * | ||
4 | * Written by Theodore Ts'o, 3/29/93. | ||
5 | * | ||
6 | * Copyright 1993 by Theodore Ts'o. Redistribution of this file is | ||
7 | * permitted under the GNU Public License. | ||
8 | */ | ||
9 | |||
10 | #define LO_NAME_SIZE 64 | ||
11 | #define LO_KEY_SIZE 32 | ||
12 | |||
13 | struct loop_info { | ||
14 | int lo_number; /* ioctl r/o */ | ||
15 | dev_t lo_device; /* ioctl r/o */ | ||
16 | unsigned long lo_inode; /* ioctl r/o */ | ||
17 | dev_t lo_rdevice; /* ioctl r/o */ | ||
18 | int lo_offset; | ||
19 | int lo_encrypt_type; | ||
20 | int lo_encrypt_key_size; /* ioctl w/o */ | ||
21 | int lo_flags; /* ioctl r/o */ | ||
22 | char lo_name[LO_NAME_SIZE]; | ||
23 | unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ | ||
24 | unsigned long lo_init[2]; | ||
25 | char reserved[4]; | ||
26 | }; | ||
27 | |||
28 | #define LO_CRYPT_NONE 0 | ||
29 | #define LO_CRYPT_XOR 1 | ||
30 | #define LO_CRYPT_DES 2 | ||
31 | #define LO_CRYPT_IDEA 3 | ||
32 | #define MAX_LO_CRYPT 4 | ||
33 | |||
34 | #define LOOP_SET_FD 0x4C00 | ||
35 | #define LOOP_CLR_FD 0x4C01 | ||
36 | #define LOOP_SET_STATUS 0x4C02 | ||
37 | #define LOOP_GET_STATUS 0x4C03 | ||
@@ -53,11 +53,6 @@ | |||
53 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
54 | #include <sys/utsname.h> /* for uname(2) */ | 54 | #include <sys/utsname.h> /* for uname(2) */ |
55 | 55 | ||
56 | #if defined BB_FEATURE_MOUNT_LOOP | ||
57 | #include <fcntl.h> | ||
58 | #include <linux/loop.h> /* Pull in loop device support */ | ||
59 | #endif | ||
60 | |||
61 | /* Busybox mount uses either /proc/filesystems or /dev/mtab to get the | 56 | /* Busybox mount uses either /proc/filesystems or /dev/mtab to get the |
62 | * list of available filesystems used for the -t auto option */ | 57 | * list of available filesystems used for the -t auto option */ |
63 | #if defined BB_FEATURE_USE_PROCFS && defined BB_FEATURE_USE_DEVPS_PATCH | 58 | #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) | |||
1459 | } | 1454 | } |
1460 | #endif /* BB_SYSLOGD */ | 1455 | #endif /* BB_SYSLOGD */ |
1461 | 1456 | ||
1457 | |||
1462 | #if defined BB_FEATURE_MOUNT_LOOP | 1458 | #if defined BB_FEATURE_MOUNT_LOOP |
1459 | #include <fcntl.h> | ||
1460 | #include "loop.h" /* Pull in loop device support */ | ||
1461 | |||
1463 | extern int del_loop(const char *device) | 1462 | extern int del_loop(const char *device) |
1464 | { | 1463 | { |
1465 | int fd; | 1464 | int fd; |