forked from Imagelibrary/rtems
2009-07-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/main_chmod.c, libmisc/shell/main_mdump.c, libmisc/shell/main_medit.c, libmisc/shell/main_mfill.c, libmisc/shell/main_mmove.c, libmisc/shell/main_msdosfmt.c, libmisc/shell/main_mwdump.c, libmisc/shell/main_sleep.c, libmisc/shell/main_umask.c, libmisc/shell/shell.h, libmisc/shell/shell_script.c, libmisc/stringto/stringto_template.h: Convert all shell code to use stringto.h mehods with better error checking. * libmisc/shell/str2int.c: Removed.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/shell.h>
|
||||
#include <rtems/stringto.h>
|
||||
#include "internal.h"
|
||||
|
||||
int rtems_shell_main_chmod(
|
||||
@@ -32,15 +33,30 @@ int rtems_shell_main_chmod(
|
||||
char *argv[]
|
||||
)
|
||||
{
|
||||
int n;
|
||||
mode_t mode;
|
||||
int n;
|
||||
mode_t mode;
|
||||
unsigned long tmp;
|
||||
|
||||
if (argc > 2) {
|
||||
mode = rtems_shell_str2int(argv[1]) & 0777;
|
||||
n = 2;
|
||||
while (n < argc)
|
||||
chmod(argv[n++], mode);
|
||||
if (argc < 2) {
|
||||
fprintf(stderr,"%s: too few arguments\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert arguments into numbers
|
||||
*/
|
||||
if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
|
||||
printf( "Mode argument (%s) is not a number\n", argv[1] );
|
||||
return -1;
|
||||
}
|
||||
mode = (mode_t) (tmp & 0777);
|
||||
|
||||
/*
|
||||
* Now change the files modes
|
||||
*/
|
||||
for (n=2 ; n < argc ; n++)
|
||||
chmod(argv[n++], mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user