Notice: We have migrated to GitLab launching 2024-05-01 see here:

#4558 closed defect (fixed)

chmod problem in shell of RTEMS4.13/RTEMS5.1

Reported by: chenjin_zhong Owned by: Chris Johns <chrisj@…>
Priority: normal Milestone: 5.3
Component: shell Version: 5
Severity: normal Keywords:
Cc: Blocked By:

Description (last modified by Chris Johns)

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;

Change History (2)

comment:1 Changed on 11/10/22 at 00:49:01 by Chris Johns

Description: modified (diff)
Milestone: 5.15.3

This is also valid on main.

comment:2 Changed on 01/31/23 at 05:20:39 by Chris Johns <chrisj@…>

Owner: set to Chris Johns <chrisj@…>
Resolution: fixed
Status: newclosed

In [changeset:"2243fd6d6b2faa7f7f734c8bcc6c320b34a160cb/rtems" 2243fd6/rtems]:

libmisc/shell/chmod: Fix multiple file arguments to the command

Closes #4558

Note: See TracTickets for help on using tickets.