File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifdef HAVE_CONFIG_H
0016 #include "config.h"
0017 #endif
0018
0019 #include <stdio.h>
0020 #include <unistd.h>
0021 #include <string.h>
0022 #include <errno.h>
0023 #include <sys/types.h>
0024 #include <sys/stat.h>
0025
0026 #include <rtems.h>
0027 #include <rtems/shell.h>
0028 #include <rtems/stringto.h>
0029 #include "internal.h"
0030
0031 static int rtems_shell_main_chmod(
0032 int argc,
0033 char *argv[]
0034 )
0035 {
0036 int n;
0037 mode_t mode;
0038 unsigned long tmp;
0039 int sc;
0040
0041 if (argc < 2) {
0042 fprintf(stderr,"%s: too few arguments\n", argv[0]);
0043 return -1;
0044 }
0045
0046
0047
0048
0049 if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
0050 printf( "Mode argument (%s) is not a number\n", argv[1] );
0051 return -1;
0052 }
0053 mode = (mode_t) (tmp & 0777);
0054
0055
0056
0057
0058 for (n=2 ; n < argc ; n++) {
0059 sc = chmod(argv[n], mode);
0060 _Assert_Unused_variable_unequal(sc, -1);
0061 }
0062
0063 return 0;
0064 }
0065
0066 rtems_shell_cmd_t rtems_shell_CHMOD_Command = {
0067 "chmod",
0068 "chmod 0777 n1 n2... # change filemode",
0069 "files",
0070 rtems_shell_main_chmod,
0071 NULL,
0072 NULL
0073 };