[Bug 2139] rtems_rfs_format() can return 0 (indicating success) erroneously

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Wed Dec 4 03:47:35 UTC 2013


https://www.rtems.org/bugzilla/show_bug.cgi?id=2139

Nick Withers <nick.withers at anu.edu.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #2 from Nick Withers <nick.withers at anu.edu.au> 2013-12-03 21:47:35 CST ---
First part of analysis, as at commit bb81e04ae3a88ce37de8718ef112ace59b3975af

Working through error return cases in rtems_rfs_format() (per its documentation
at
http://www.rtems.org/onlinedocs/doxygen/cpukit/html/rtems-rfs-format_8h.html,
it should return 0 for success or -1 with errno set):
  - Line 556 - 562: rtems_rfs_buffer_open() > 0:
    - rtems_rfs_buffer_open() returns 0 on success or a (positive integer)
POSIX error code (always ENXIO at present); does not necessarily set errno on
failure. This is consistent with its doco at
http://www.rtems.org/onlinedocs/doxygen/cpukit/html/rtems-rfs-buffer_8h.html#af8b9acf77d20824a7121b89ab7b29bf9
    X Not handled correctly by rtems_rfs_format(): errno is not necessarily set
in the error case but -1 is returned
  - 567 - 572: rtems_rfs_fs_media_block_size() == 0:
    - rtems_rfs_fs_media_block_size() returns a value, possibly equal to 0
    X Not handled correctly by rtems_rfs_format(): errno is not necessarily set
in the error case but -1 is returned
  - 577 - 578: !rtems_rfs_check_config():
    - rtems_rfs_check_config() returns (bool) true on success or false; does
not necessarily set errno on failure
    X Not handled correctly by rtems_rfs_format(): errno is not necessarily set
in the error case but -1 is returned
  - 606 - 612: rtems_rfs_buffer_setblksize() > 0:
    - rtems_rfs_buffer_setblksize() returns the return value of a
fs->disk->ioctl() call (where fs is a rtems_rfs_buffer_setblksize() parameter)
when preprocessor macro RTEMS_RFS_USE_LIBBLOCK is enabled, the return value of
a rtems_rfs_buffer_sync() call when RTEMS_RFS_USE_LIBBLOCK is not enabled
      - RTEMS_RFS_USE_LIBBLOCK enabled:
        ! Not sure, did not trace possible fs->disk->ioctl() calls
      - RTEMS_RFS_USE_LIBBLOCK not enabled:
        - rtems_rfs_buffer_sync() returns 0 on success or a POSIX error code
      ! Should a failure in rtems_rfs_buffer_setblksize()'s
rtems_rfs_buffers_release() call cause it to return immediately?
    - Assuming fs->disk->ioctl() calls always return 0 on success or -1 on
failure with errno set, rtems_rfs_buffer_setblksize() returns 0 on success or a
POSIX error code; does not necessarily set errno on failure. Consistent with
doco at
http://www.rtems.org/onlinedocs/doxygen/cpukit/html/rtems-rfs-buffer_8h.html#af00baa0cdea85aa9ff81f8edd8d13883
    X Not handled correctly by rtems_rfs_format(): errno is not necessarily set
in the error case but -1 is returned
  - 614 - 618: !rtems_rfs_write_superblock():
    - rtems_rfs_write_superblock() returns (bool) true on success or false;
does not necessarily set errno on failure
    X Not handled correctly by rtems_rfs_format(): errno is not necessarily set
in the error case but -1 is returned
    ! I didn't check that each call made by rtems_rfs_write_superblock() checks
and returns errors correctly
  - 621 - 623: !rtems_rfs_write_group():
    - rtems_rfs_write_group() returns (bool) true on success or false; does not
necessarily set errno on failure
    X Not handled correctly by rtems_rfs_format(): errno is not necessarily set
in the error case but -1 is returned
  - 628 - 634: rtems_rfs_buffer_close() > 0:
    - rtems_rfs_buffer_close() returns the return value of a
rtems_rfs_buffer_setblksize() call (see above) or a POSIX error code
    - Assuming rtems_rfs_buffer_setblksize() calls return 0 on success or a
POSIX error code, rtems_rfs_buffer_close() also returns 0 on success or a POSIX
error code; does not necessarily set errno on failure. Consistent with doco at
http://www.rtems.org/onlinedocs/doxygen/cpukit/html/rtems-rfs-buffer_8h.html#ae5b347848c87353252dde82820821b05
    X Not handled correctly by rtems_rfs_format(): errno is not necessarily set
in the error case but -1 is returned
    ! Should a failure in rtems_rfs_buffer_close()'s
rtems_rfs_buffer_setblksize() call cause it to return immediately?
  - 636 - 642: rtems_rfs_write_root_dir() > 0:
    X rtems_rfs_write_root_dir() can return -1, a POSIX error code or 0 (when
ino != RTEMS_RFS_ROOT_INO) on error
    X If rtems_rfs_write_root_dir() returns -1 on error it is not detected by
rtems_rfs_format()
    X rtems_rfs_write_root_dir() can return a POSIX error code on error with
errno not set but -1 is returned by rtems_rfs_format()
    X Detection of errors in the general case is impossible
    ! I'll look at rtems_rfs_write_root_dir() separately

Summary:
  - errno is not guaranteed set when -1 is returned from rtems_rfs_format(),
contravening it's specification as documented at
http://www.rtems.org/onlinedocs/doxygen/cpukit/html/rtems-rfs-format_8h.html#a56f021e1569663ecb2f46921a35e1a17
  - Errors in rtems_rfs_write_root_dir() may not be detected by
rtems_rfs_format() and it may return 0, indicating success, erroneously

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list