aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-05-28 10:35:51 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-05-28 10:35:51 +0000
commitc21d9c72907fd9a3f75204e22fa31d3bcee13f8e (patch)
tree94bb6ac6f390fd94a849042526bf41ffec9479a1
parent1510216a55562da7c1919559bd1aa885286ffc1f (diff)
downloadbusybox-w32-c21d9c72907fd9a3f75204e22fa31d3bcee13f8e.tar.gz
busybox-w32-c21d9c72907fd9a3f75204e22fa31d3bcee13f8e.tar.bz2
busybox-w32-c21d9c72907fd9a3f75204e22fa31d3bcee13f8e.zip
- the moddir_base is supposed to be omitted frmo the .dep file
- other tweaks while at it
-rw-r--r--modutils/depmod.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/modutils/depmod.c b/modutils/depmod.c
index 9faf9c302..15b49f031 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -19,6 +19,7 @@
19 */ 19 */
20struct globals { 20struct globals {
21 llist_t *lst; 21 llist_t *lst;
22 unsigned moddir_base_len;
22}; 23};
23#define G (*(struct globals*)&bb_common_bufsiz1) 24#define G (*(struct globals*)&bb_common_bufsiz1)
24/* We have to zero it out because of NOEXEC */ 25/* We have to zero it out because of NOEXEC */
@@ -27,7 +28,8 @@ struct globals {
27static int fill_lst(const char *modulename, struct stat ATTRIBUTE_UNUSED *sb, 28static int fill_lst(const char *modulename, struct stat ATTRIBUTE_UNUSED *sb,
28 void ATTRIBUTE_UNUSED *data, int ATTRIBUTE_UNUSED depth) 29 void ATTRIBUTE_UNUSED *data, int ATTRIBUTE_UNUSED depth)
29{ 30{
30 llist_add_to(&G.lst, xstrdup(modulename)); 31 if (last_char_is(modulename, 'o') != NULL) /* it is a module, remember it */
32 llist_add_to(&G.lst, xstrdup(modulename + G.moddir_base_len));
31 return TRUE; 33 return TRUE;
32} 34}
33 35
@@ -58,16 +60,16 @@ static int fileAction(const char *fname, struct stat *sb,
58 60
59 ptr = the_module; 61 ptr = the_module;
60 62
61 fprintf((FILE*)data, "\n%s:", fname); 63 fprintf((FILE*)data, "%s:", fname + G.moddir_base_len);
62//bb_info_msg("fname='%s'", fname); 64//bb_info_msg("fname='%s'", fname + G.moddir_base_len);
63 do { 65 do {
64 /* search for a 'd' */ 66 /* search for a 'd' */
65 ptr = memchr(ptr, 'd', len); 67 ptr = memchr(ptr, 'd', len - (ptr - the_module));
66 if (ptr == NULL) /* no d left, done */ 68 if (ptr == NULL) /* no d left, done */
67 goto done; 69 goto done;
68 if (memcmp(ptr, "depends=", sizeof("depends=")-1) == 0) 70 if (memcmp(ptr, "depends=", sizeof("depends=")-1) == 0)
69 break; 71 break;
70 len -= ++ptr - the_module; 72 ++ptr;
71 } while (1); 73 } while (1);
72 deps = depends = xstrdup (ptr + sizeof("depends=")-1); 74 deps = depends = xstrdup (ptr + sizeof("depends=")-1);
73//bb_info_msg(" depends='%s'", depends); 75//bb_info_msg(" depends='%s'", depends);
@@ -80,8 +82,7 @@ static int fileAction(const char *fname, struct stat *sb,
80 *(char*)ptr = '\0'; 82 *(char*)ptr = '\0';
81 /* remember the length of the current dependency plus eventual 0 byte */ 83 /* remember the length of the current dependency plus eventual 0 byte */
82 len = strlen(deps) + (ptr != NULL); 84 len = strlen(deps) + (ptr != NULL);
83 buf1 = xmalloc(len + 3); 85 buf1 = xasprintf("/%s.", deps); /* match the correct file */
84 sprintf(buf1, "/%s.", deps); /* make sure we match the correct file */
85 while (_lst) { 86 while (_lst) {
86 ptr = strstr(_lst->data, buf1); 87 ptr = strstr(_lst->data, buf1);
87 if (ptr != NULL) 88 if (ptr != NULL)
@@ -96,6 +97,7 @@ static int fileAction(const char *fname, struct stat *sb,
96 } 97 }
97 } 98 }
98 free(depends); 99 free(depends);
100 fprintf((FILE*)data, "\n");
99done: 101done:
100 munmap(the_module, sb->st_size); 102 munmap(the_module, sb->st_size);
101skip: 103skip:
@@ -105,7 +107,7 @@ skip:
105int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 107int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
106int depmod_main(int ATTRIBUTE_UNUSED argc, char **argv) 108int depmod_main(int ATTRIBUTE_UNUSED argc, char **argv)
107{ 109{
108 int retval = EXIT_SUCCESS; 110 int ret;
109 char *moddir_base = NULL, *moddir, *system_map, *chp; 111 char *moddir_base = NULL, *moddir, *system_map, *chp;
110 FILE *filedes = stdout; 112 FILE *filedes = stdout;
111 enum { 113 enum {
@@ -119,27 +121,27 @@ int depmod_main(int ATTRIBUTE_UNUSED argc, char **argv)
119 121
120 getopt32(argv, "aAb:eF:n", &moddir_base, &system_map); 122 getopt32(argv, "aAb:eF:n", &moddir_base, &system_map);
121 argv += optind; 123 argv += optind;
122 if (*argv) {/* got a version to use? */ 124
123 chp = *argv++; 125 /* got a version to use? */
124// if (memchr(chp, '/', strlen(chp)) != NULL) /* XXX: drop this */ 126 if (*argv && (sscanf(*argv, "%u.%u.%u", &ret, &ret, &ret) == 3)) {
125// bb_show_usage(); 127 moddir = concat_path_file(CONFIG_DEFAULT_MODULES_DIR, *argv++);
126 } else { 128 } else {
127 struct utsname uts; 129 struct utsname uts;
128 if (uname(&uts) < 0) 130 if (uname(&uts) < 0)
129 bb_simple_perror_msg_and_die("uname"); 131 bb_simple_perror_msg_and_die("uname");
130 chp = xstrdup(uts.release); 132 moddir = concat_path_file(CONFIG_DEFAULT_MODULES_DIR, uts.release);
131 } 133 }
132 /* if no modules are given on the command-line, -a is on per default */ 134 /* if no modules are given on the command-line, -a is on per default */
133 option_mask32 |= *argv == NULL; 135 option_mask32 |= *argv == NULL;
134 136
135 moddir = concat_path_file(CONFIG_DEFAULT_MODULES_DIR, chp);
136// if (ENABLE_FEATURE_CLEAN_UP)
137// free(chp);
138 if (option_mask32 & ARG_b) { 137 if (option_mask32 & ARG_b) {
139 char *old_moddir = moddir; 138 G.moddir_base_len = strlen(moddir_base);
140 moddir = concat_path_file(moddir_base, moddir); 139 if (ENABLE_FEATURE_CLEAN_UP) {
141 if (ENABLE_FEATURE_CLEAN_UP) 140 chp = moddir;
142 free(old_moddir); 141 moddir = concat_path_file(moddir_base, moddir);
142 free (chp);
143 } else
144 moddir = concat_path_file(moddir_base, moddir);
143 } 145 }
144 146
145 if (!(option_mask32 & ARG_n)) { /* --dry-run */ 147 if (!(option_mask32 & ARG_n)) { /* --dry-run */
@@ -148,6 +150,7 @@ int depmod_main(int ATTRIBUTE_UNUSED argc, char **argv)
148 if (ENABLE_FEATURE_CLEAN_UP) 150 if (ENABLE_FEATURE_CLEAN_UP)
149 free(chp); 151 free(chp);
150 } 152 }
153 ret = EXIT_SUCCESS;
151 /* have to do a full walk to collect all needed data */ 154 /* have to do a full walk to collect all needed data */
152 if (!recursive_action(moddir, 155 if (!recursive_action(moddir,
153 ACTION_RECURSE, /* flags */ 156 ACTION_RECURSE, /* flags */
@@ -155,11 +158,10 @@ int depmod_main(int ATTRIBUTE_UNUSED argc, char **argv)
155 NULL, /* dir action */ 158 NULL, /* dir action */
156 NULL, /* user data */ 159 NULL, /* user data */
157 0)) { 160 0)) {
158 retval = EXIT_FAILURE; 161 ret = EXIT_FAILURE;
159 } else 162 } else
160 do { 163 do {
161 chp = concat_path_file(option_mask32 & ARG_a ? moddir : moddir_base, 164 chp = option_mask32 & ARG_a ? moddir : *argv++;
162 option_mask32 & ARG_a ? "" : *argv++);
163 165
164 if (!recursive_action(chp, 166 if (!recursive_action(chp,
165 ACTION_RECURSE, /* flags */ 167 ACTION_RECURSE, /* flags */
@@ -167,16 +169,14 @@ int depmod_main(int ATTRIBUTE_UNUSED argc, char **argv)
167 NULL, /* dir action */ 169 NULL, /* dir action */
168 (void*)filedes, /* user data */ 170 (void*)filedes, /* user data */
169 0)) { /* depth */ 171 0)) { /* depth */
170 retval = EXIT_FAILURE; 172 ret = EXIT_FAILURE;
171 } 173 }
172 if (ENABLE_FEATURE_CLEAN_UP)
173 free(chp);
174 } while (!(option_mask32 & ARG_a) && *argv); 174 } while (!(option_mask32 & ARG_a) && *argv);
175 175
176 if (ENABLE_FEATURE_CLEAN_UP) { 176 if (ENABLE_FEATURE_CLEAN_UP) {
177 fclose(filedes); 177 fclose_if_not_stdin(filedes);
178 llist_free(G.lst, free); 178 llist_free(G.lst, free);
179 free(moddir); 179 free(moddir);
180 } 180 }
181 return retval; 181 return ret;
182} 182}