aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
Diffstat (limited to 'modutils')
-rw-r--r--modutils/Config.in2
-rw-r--r--modutils/modprobe-small.c48
2 files changed, 1 insertions, 49 deletions
diff --git a/modutils/Config.in b/modutils/Config.in
index 25841b8ff..2e7f9b6e5 100644
--- a/modutils/Config.in
+++ b/modutils/Config.in
@@ -31,7 +31,7 @@ config MODPROBE_SMALL
31 than "non-small" modutils. 31 than "non-small" modutils.
32 32
33config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE 33config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE
34 bool "module options on cmdline" 34 bool "Accept module options on modprobe command line"
35 default n 35 default n
36 depends on MODPROBE_SMALL 36 depends on MODPROBE_SMALL
37 help 37 help
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index 4f073536a..1096ba7ae 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -14,54 +14,6 @@
14#include <sys/utsname.h> /* uname() */ 14#include <sys/utsname.h> /* uname() */
15#include <fnmatch.h> 15#include <fnmatch.h>
16 16
17/* libbb candidate */
18static void *xmalloc_read(int fd, size_t *sizep)
19{
20 char *buf;
21 size_t size, rd_size, total;
22 off_t to_read;
23 struct stat st;
24
25 to_read = sizep ? *sizep : INT_MAX; /* max to read */
26
27 /* Estimate file size */
28 st.st_size = 0; /* in case fstat fails, assume 0 */
29 fstat(fd, &st);
30 /* /proc/N/stat files report st_size 0 */
31 /* In order to make such files readable, we add small const */
32 size = (st.st_size | 0x3ff) + 1;
33
34 total = 0;
35 buf = NULL;
36 while (1) {
37 if (to_read < size)
38 size = to_read;
39 buf = xrealloc(buf, total + size + 1);
40 rd_size = full_read(fd, buf + total, size);
41 if ((ssize_t)rd_size < 0) { /* error */
42 free(buf);
43 return NULL;
44 }
45 total += rd_size;
46 if (rd_size < size) /* EOF */
47 break;
48 to_read -= rd_size;
49 if (to_read <= 0)
50 break;
51 /* grow by 1/8, but in [1k..64k] bounds */
52 size = ((total / 8) | 0x3ff) + 1;
53 if (size > 64*1024)
54 size = 64*1024;
55 }
56 xrealloc(buf, total + 1);
57 buf[total] = '\0';
58
59 if (sizep)
60 *sizep = total;
61 return buf;
62}
63
64
65#define dbg1_error_msg(...) ((void)0) 17#define dbg1_error_msg(...) ((void)0)
66#define dbg2_error_msg(...) ((void)0) 18#define dbg2_error_msg(...) ((void)0)
67//#define dbg1_error_msg(...) bb_error_msg(__VA_ARGS__) 19//#define dbg1_error_msg(...) bb_error_msg(__VA_ARGS__)