• L
    [XFS] 971064 Various fixups for xfs_bulkstat(). · cd57e594
    Lachlan McIlroy 提交于
    - sanity check for NULL user buffer in xfs_ioc_bulkstat[_compat]()
    - remove the special case for XFS_IOC_FSBULKSTAT with count == 1. This
      special case causes bulkstat to fail because the special case uses
      xfs_bulkstat_single() instead of xfs_bulkstat() and the two functions
      have different semantics.  xfs_bulkstat() will return the next inode
      after the one supplied while skipping internal inodes (ie quota inodes).
      xfs_bulkstate_single() will only lookup the inode supplied and return
      an error if it is an internal inode.
    - in xfs_bulkstat(), need to initialise 'lastino' to the inode supplied
      so in cases were we return without examining any inodes the scan wont
      restart back at zero.
    - sanity check for valid *ubcountp values. Cannot sanity check for valid
      ubuffer here because some users of xfs_bulkstat() don't supply a buffer.
    - checks against 'ubleft' (the space left in the user's buffer) should be
      against 'statstruct_size' which is the supplied minimum object size.
      The mixture of checks against statstruct_size and 0 was one of the
      reasons we were skipping inodes.
    - if the formatter function returns BULKSTAT_RV_NOTHING and an error and
      the error is not ENOENT or EINVAL then we need to abort the scan. ENOENT
      is for inodes that are no longer valid and we just skip them. EINVAL is
      returned if we try to lookup an internal inode so we skip them too. For
      a DMF scan if the inode and DMF attribute cannot fit into the space left
      in the user's buffer it would return ERANGE. We didn't handle this error
      and skipped the inode. We would continue to skip inodes until one fitted
      into the user's buffer or we completed the scan.
    - put back the recalculation of agino (that got removed with the last fix)
      at the end of the while loop. This is because the code at the start of
      the loop expects agino to be the last inode examined if it is non-zero.
    - if we found some inodes but then encountered an error, return success
      this time and the error next time. If the formatter aborted with ENOMEM
      we will now return this error but only if we couldn't read any inodes.
      Previously if we encountered ENOMEM without reading any inodes we
      returned a zero count and no error which falsely indicated the scan was
      complete.
    
    SGI-PV: 973431
    SGI-Modid: xfs-linux-melb:xfs-kern:30089a
    Signed-off-by: NLachlan McIlroy <lachlan@sgi.com>
    Signed-off-by: NDavid Chinner <dgc@sgi.com>
    cd57e594
xfs_ioctl32.c 14.4 KB