diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-14 02:23:43 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-14 02:23:43 +0000 |
commit | ea62077b850076c4d7dc3cf78ebd1888928c6ddf (patch) | |
tree | 37b7584ae40b99edb5583fbc4392b62ffdadf278 /modutils | |
parent | 88ca06769028e442bf873b270c176ca0e9f021f8 (diff) | |
download | busybox-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.tar.gz |
add open_read_close() and similar stuff
Diffstat (limited to 'modutils')
-rw-r--r-- | modutils/insmod.c | 4 | ||||
-rw-r--r-- | modutils/lsmod.c | 8 | ||||
-rw-r--r-- | modutils/modprobe.c | 31 |
3 files changed, 7 insertions, 36 deletions
diff --git a/modutils/insmod.c b/modutils/insmod.c index 3d9add19a..882fcf80f 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -4186,10 +4186,10 @@ int insmod_main( int argc, char **argv) m_addr = create_module(m_name, m_size); if (m_addr == -1) switch (errno) { case EEXIST: - bb_error_msg("A module named %s already exists", m_name); + bb_error_msg("a module named %s already exists", m_name); goto out; case ENOMEM: - bb_error_msg("Can't allocate kernel memory for module; needed %lu bytes", + bb_error_msg("can't allocate kernel memory for module; needed %lu bytes", m_size); goto out; default: diff --git a/modutils/lsmod.c b/modutils/lsmod.c index ac1cded2b..2bf4afbe9 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -147,9 +147,8 @@ int lsmod_main(int argc, char **argv) check_tainted(); #if defined(CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT) { - char line[4096]; - - while (fgets(line, sizeof(line), file)) { + char *line; + while ((line = xmalloc_fgets(file)) != NULL) { char *tok; tok = strtok(line, " \t"); @@ -175,7 +174,8 @@ int lsmod_main(int argc, char **argv) tok = ""; printf(" %s", tok); } - printf("\n"); + puts(""); + free(line); } fclose(file); } diff --git a/modutils/modprobe.c b/modutils/modprobe.c index b629390e4..ab595c847 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -93,35 +93,6 @@ static int parse_tag_value ( char *buffer, char **ptag, char **pvalue ) return 1; } -/* Jump through hoops to simulate how fgets() grabs just one line at a - * time... Don't use any stdio since modprobe gets called from a kernel - * thread and stdio junk can overflow the limited stack... - */ -static char *reads ( int fd, char *buffer, size_t len ) -{ - int n = read ( fd, buffer, len ); - - if ( n > 0 ) { - char *p; - - buffer [len-1] = 0; - p = strchr ( buffer, '\n' ); - - if ( p ) { - off_t offset; - - offset = lseek ( fd, 0L, SEEK_CUR ); // Get the current file descriptor offset - lseek ( fd, offset-n + (p-buffer) + 1, SEEK_SET ); // Set the file descriptor offset to right after the \n - - p[1] = 0; - } - return buffer; - } - - else - return 0; -} - /* * This function appends an option to a list */ @@ -913,7 +884,7 @@ int modprobe_main(int argc, char** argv) depend = build_dep ( ); if ( !depend ) - bb_error_msg_and_die ( "could not parse modules.dep" ); + bb_error_msg_and_die ( "cannot parse modules.dep" ); if (remove_opt) { do { |