[RTEMS Project] #2139: rtems_rfs_format() can return 0 (indicating success) erroneously

RTEMS trac trac at rtems.org
Wed Dec 24 03:54:01 UTC 2014


#2139: rtems_rfs_format() can return 0 (indicating success) erroneously
--------------------------+---------------------------
 Reporter:  nick.withers  |       Owner:  nick.withers
     Type:  defect        |      Status:  closed
 Priority:  highest       |   Milestone:  4.11
Component:  filesystem    |     Version:  4.11
 Severity:  normal        |  Resolution:  fixed
 Keywords:                |
--------------------------+---------------------------

Old description:

> rtems_rfs_format() calls rtems_rfs_write_root_dir(), which in turn calls
> rtems_rfs_fs_open().
>
> When this rtems_rfs_fs_open() call fails, rtems_rfs_write_root_dir()
> returns -1.
>
> rtems_rts_format(), however, considers only a return > 0 from
> rtems_rfs_write_root_dir() to mean an error and seems to be expecting it
> to return a POSIX error code:
> ____
>
>   rc = rtems_rfs_write_root_dir (name);
>   if (rc > 0)
>   {
>     printf ("rtems-rfs: format: writing root dir failed: %d: %s\n",
>             rc, strerror (rc));
>     return -1;
>   }
> ____
>
> Changing this code to the following has sorted out *this particular*
> failure issue for me, but there're quite a few function calls in
> rtems_rfs_write_root_dir() and I haven't gone through them to make sure
> the success of each is correctly tested (and hence I haven't provided a
> patch)...
> ____
>
>   rc = rtems_rfs_write_root_dir (name);
>   if (rc != 0)
>   {
>     printf ("rtems-rfs: format: writing root dir failed: %d: %s\n",
>             errno, strerror (errno));
>     return -1;
>   }
> ____

New description:

 rtems_rfs_format() calls rtems_rfs_write_root_dir(), which in turn calls
 rtems_rfs_fs_open().

 When this rtems_rfs_fs_open() call fails, rtems_rfs_write_root_dir()
 returns -1.

 rtems_rts_format(), however, considers only a return > 0 from
 rtems_rfs_write_root_dir() to mean an error and seems to be expecting it
 to return a POSIX error code:
 ____

   rc = rtems_rfs_write_root_dir (name);
   if (rc > 0)
   {
     printf ("rtems-rfs: format: writing root dir failed: %d: %s\n",
             rc, strerror (rc));
     return -1;
   }
 ____

 Changing this code to the following has sorted out *this particular*
 failure issue for me, but there're quite a few function calls in
 rtems_rfs_write_root_dir() and I haven't gone through them to make sure
 the success of each is correctly tested (and hence I haven't provided a
 patch)...
 ____

   rc = rtems_rfs_write_root_dir (name);
   if (rc != 0)
   {
     printf ("rtems-rfs: format: writing root dir failed: %d: %s\n",
             errno, strerror (errno));
     return -1;
   }
 ____

--

Comment (by gedare):

 I removed the change to rtems-rfs-rtems.c, which was partially implemented
 already.

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


More information about the bugs mailing list