add open_read_close() and similar stuff

This commit is contained in:
Denis Vlasenko
2006-10-14 02:23:43 +00:00
parent 88ca067690
commit ea62077b85
38 changed files with 228 additions and 234 deletions

View File

@@ -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:

View File

@@ -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);
}

View File

@@ -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 {