[RTEMS Project] #4558: chmod problem in shell of RTEMS4.13/RTEMS5.1

RTEMS trac trac at rtems.org
Thu Nov 10 00:49:01 UTC 2022


#4558: chmod problem in shell of RTEMS4.13/RTEMS5.1
---------------------------+---------------------
 Reporter:  chenjin_zhong  |       Owner:  (none)
     Type:  defect         |      Status:  new
 Priority:  normal         |   Milestone:  5.3
Component:  shell          |     Version:  5
 Severity:  normal         |  Resolution:
 Keywords:                 |  Blocked By:
 Blocking:                 |
---------------------------+---------------------
Changes (by Chris Johns):

 * milestone:  5.1 => 5.3


Old description:

> Hi, I find one problem in rtems_shell_main_chmod function. the usage of
> this instruction is descripted as  "chmod 0777 n1 n2... #change
> filemode", .the src code is listed as follows. the bold part should be
> replaced with **chmod(argv[n], mode)**?
>

> static int rtems_shell_main_chmod(
>   int argc,
>   char *argv[]
> )
> {
>   int           n;
>   mode_t        mode;
>   unsigned long tmp;
>
>   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;
> }

New description:

 Hi, I find one problem in rtems_shell_main_chmod function. the usage of
 this instruction is descripted as  "chmod 0777 n1 n2... #change filemode",
 .the src code is listed as follows. the bold part should be replaced with
 **chmod(argv[n], mode)**?

 {{{
 static int rtems_shell_main_chmod(
   int argc,
   char *argv[]
 )
 {
   int           n;
   mode_t        mode;
   unsigned long tmp;

   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); /* <<<< here */

   return 0;
 }
 }}}

--

Comment:

 This is also valid on `main`.

--
Ticket URL: <http://devel.rtems.org/ticket/4558#comment:1>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list