[rtems commit] libcsupport: Add no_regular_file_mknod as a mount option to the mount table

Chris Johns chrisj at rtems.org
Mon Feb 8 02:12:45 UTC 2021


Module:    rtems
Branch:    master
Commit:    822cad8967e130b3769f719502cbd6db81e3efea
Changeset: http://git.rtems.org/rtems/commit/?id=822cad8967e130b3769f719502cbd6db81e3efea

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Jan 25 12:03:06 2021 +1100

libcsupport: Add no_regular_file_mknod as a mount option to the mount table

- Add the bool flag no_regular_file_mknod to the mount table so a file
  system can indicate creating regular files is not done by
  use the mknod handler. The file system will handle creating a
  file node in the open handler.

- Note, the mount option is an enum which means there is only one
  exclusive option supported. As a result no encapsulation is
  provided and file systems need to set no_regular_file_mknod directly.

Closes #4222

---

 cpukit/include/rtems/libio.h  |  1 +
 cpukit/libcsupport/src/open.c | 13 ++++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h
index 18141c3..519e797 100644
--- a/cpukit/include/rtems/libio.h
+++ b/cpukit/include/rtems/libio.h
@@ -1613,6 +1613,7 @@ struct rtems_filesystem_mount_table_entry_tt {
   rtems_filesystem_global_location_t    *mt_fs_root;
   bool                                   mounted;
   bool                                   writeable;
+  bool                                   no_regular_file_mknod;
   const rtems_filesystem_limits_and_options_t *pathconf_limits_and_options;
 
   /*
diff --git a/cpukit/libcsupport/src/open.c b/cpukit/libcsupport/src/open.c
index bdb5024..15cc7d5 100644
--- a/cpukit/libcsupport/src/open.c
+++ b/cpukit/libcsupport/src/open.c
@@ -34,7 +34,7 @@ static void create_regular_file(
 )
 {
   int rv = 0;
-  const rtems_filesystem_location_info_t *currentloc = 
+  const rtems_filesystem_location_info_t *currentloc =
     rtems_filesystem_eval_path_get_currentloc( ctx );
   const char *token = rtems_filesystem_eval_path_get_token( ctx );
   size_t tokenlen = rtems_filesystem_eval_path_get_tokenlen( ctx );
@@ -85,10 +85,15 @@ static int do_open(
     | (make ? RTEMS_FS_MAKE : 0)
     | (exclusive ?  RTEMS_FS_EXCLUSIVE : 0);
   rtems_filesystem_eval_path_context_t ctx;
+  const rtems_filesystem_location_info_t *currentloc;
+  bool create_reg_file;
 
   rtems_filesystem_eval_path_start( &ctx, path, eval_flags );
 
-  if ( rtems_filesystem_eval_path_has_token( &ctx ) ) {
+  currentloc = rtems_filesystem_eval_path_get_currentloc( &ctx );
+  create_reg_file = !currentloc->mt_entry->no_regular_file_mknod;
+
+  if ( create_reg_file && rtems_filesystem_eval_path_has_token( &ctx ) ) {
     create_regular_file( &ctx, mode );
   }
 
@@ -99,11 +104,9 @@ static int do_open(
 #endif
 
   if ( write_access || open_dir ) {
-    const rtems_filesystem_location_info_t *currentloc =
-      rtems_filesystem_eval_path_get_currentloc( &ctx );
     mode_t type = rtems_filesystem_location_type( currentloc );
 
-    if ( write_access && S_ISDIR( type ) ) {
+    if ( create_reg_file && write_access && S_ISDIR( type ) ) {
       rtems_filesystem_eval_path_error( &ctx, EISDIR );
     }
 



More information about the vc mailing list