openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libfdisk/src/context.c
int fdisk_device_is_used(struct fdisk_context* cxt)
{
    int rc = 0;

    assert(cxt);
    assert(cxt->dev_fd >= 0);

    errno = 0;

#ifdef BLKRRPART
    /* it seems kernel always return EINVAL for BLKRRPART on loopdevices */
    if (S_ISBLK(cxt->dev_st.st_mode) &&
        major(cxt->dev_st.st_rdev) != LOOPDEV_MAJOR)
    {
        DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl"));
        rc = ioctl(cxt->dev_fd, BLKRRPART) != 0;
    }
#else
    errno = ENOSYS;
#endif
    DBG(CXT, ul_debugobj(cxt, "device used: %s [errno=%d]",
                         rc ? "TRUE" : "FALSE", errno));
    return rc;
}
/**
 * fdisk_device_is_used:
 * @cxt: context
 *
 * On systems where is no BLKRRPART ioctl the function returns zero and
 * sets errno to ENOSYS.
 *
 * Returns: 1 if the device assigned to the context is used by system, or 0.
 */
@cxt: context

On systems where is no BLKRRPART ioctl the function returns zero and
sets errno to ENOSYS.

1 if the device assigned to the context is used by system, or 0.
@cxt : context On systems where is no BLKRRPART ioctl the function returns zero and sets errno to ENOSYS . 1 if the device assigned to the context is used by system or 0 .
int fdisk_device_is_used(struct fdisk_context* cxt)
{
    int rc = 0;
    assert(cxt);
    assert(cxt->dev_fd >= 0);
    errno = 0;
#ifdef BLKRRPART
    if (S_ISBLK(cxt->dev_st.st_mode) &&
        major(cxt->dev_st.st_rdev) != LOOPDEV_MAJOR)
    {
        DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl"));
        rc = ioctl(cxt->dev_fd, BLKRRPART) != 0;
    }
#else
    errno = ENOSYS;
#endif
    DBG(CXT, ul_debugobj(cxt, "device used: %s [errno=%d]",
                         rc ? "TRUE" : "FALSE", errno));
    return rc;
}
int fdisk_device_is_used ( struct fdisk_context * cxt ) { int rc = 0 ; assert ( cxt ) ; assert ( cxt -> dev_fd >= 0 ) ; errno = 0 ; #ifdef BLKRRPART if ( S_ISBLK ( cxt -> dev_st . st_mode ) && major ( cxt -> dev_st . st_rdev ) != LOOPDEV_MAJOR ) { DBG ( CXT , ul_debugobj ( cxt , " " ) ) ; rc = ioctl ( cxt -> dev_fd , BLKRRPART ) != 0 ; } #else errno = ENOSYS ; #endif DBG ( CXT , ul_debugobj ( cxt , " " , rc ? " " : " " , errno ) ) ; return rc ; }
fdisk_device_is_used:
 @cxt: context
fdisk_device_is_used : @cxt : context
/* it seems kernel always return EINVAL for BLKRRPART on loopdevices */