[RTEMS Project] #4222: Add a per mount flag to not create a node on O_CREAT in open

RTEMS trac trac at rtems.org
Sat Jan 23 23:41:29 UTC 2021


#4222: Add a per mount flag to not create a node on O_CREAT in open
--------------------------+--------------------
  Reporter:  Chris Johns  |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  normal       |  Milestone:  6.1
 Component:  fs           |    Version:  6
  Severity:  normal       |   Keywords:
Blocked By:               |   Blocking:
--------------------------+--------------------
 The libio `rtems_filesystem_eval_path_context_t` context uses a token left
 after a path evaluation to indicate the path to the leaf node is valid and
 the path leaf does not exist. System calls such as `mknod`, `mkdir` and
 `open` uses this to return `EEXIST` or in the case of `open` to create a
 `S_IFREG` node for a file. Some file systems do not support creating an
 `S_IFREG` node and the `open` handler is required to do this.

 [ An aside, libio should leave the `EEXIST` detection to the file system
 and its evaluation handlers. The `EEXIST` error is one of many that could
 be returned yet it is specifically singled out using a fragile interface
 of a path token remaining. Anyway back to the change ... ]

 The `open` call has:
 {{{
   if ( rtems_filesystem_eval_path_has_token( &ctx ) ) {
     create_regular_file( &ctx, mode );
   }
 }}}
 and `create_regular_file` makes a node:
 {{{
   rv = rtems_filesystem_mknod(
     currentloc,
     token,
     tokenlen,
     S_IFREG | mode,
     0
   );
 }}}
 then wipes the evaluation context of any real and valid flags and
 settings:
 {{{
     rtems_filesystem_eval_path_set_flags( ctx, 0 );
     rtems_filesystem_eval_path_set_path( ctx, token, tokenlen );
     rtems_filesystem_eval_path_continue( ctx );
 }}}
 then continues the path evaluation. The continues path evaluation is
 suppose to find the new node. If a file system does not support making a
 regular file node and the `mknod` call is stubbed out to lie about making
 the node continuing the path evaluation fails with a not found error. I
 cannot see a way to code around this with the current libio code.

 I propose adding a `bool` flag called `no_reg_make_node` to the
 `rtems_filesystem_mount_table_entry_t` struct that defaults to `false`. If
 `true` open does not call `create_regular_file`.

--
Ticket URL: <http://devel.rtems.org/ticket/4222>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list