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/lib/sysfs.c
dev_t sysfs_blkdev_partno_to_devno(struct path_cxt* pc, int partno)
{
    DIR* dir;
    struct dirent* d;
    dev_t devno = 0;

    dir = ul_path_opendir(pc, NULL);
    if (!dir)
        return 0;

    while ((d = xreaddir(dir)))
    {
        int n;

        if (!sysfs_blkdev_is_partition_dirent(dir, d, NULL))
            continue;

        if (ul_path_readf_s32(pc, &n, "%s/partition", d->d_name))
            continue;

        if (n == partno)
        {
            if (ul_path_readf_majmin(pc, &devno, "%s/dev", d->d_name) == 0)
                break;
        }
    }

    closedir(dir);
    DBG(CXT,
        ul_debugobj(pc, "partno (%d) -> devno (%d)", (int)partno, (int)devno));
    return devno;
}
/*
 * Converts @partno (partition number) to devno of the partition.
 * The @pc handles wholedisk device.
 *
 * Note that this code does not expect any special format of the
 * partitions devnames.
 */
Converts @partno (partition number) to devno of the partition.
The @pc handles wholedisk device.

Note that this code does not expect any special format of the
partitions devnames.
Converts @partno ( partition number ) to devno of the partition . The @pc handles wholedisk device . Note that this code does not expect any special format of the partitions devnames .
dev_t sysfs_blkdev_partno_to_devno(struct path_cxt* pc, int partno)
{
    DIR* dir;
    struct dirent* d;
    dev_t devno = 0;
    dir = ul_path_opendir(pc, NULL);
    if (!dir)
        return 0;
    while ((d = xreaddir(dir)))
    {
        int n;
        if (!sysfs_blkdev_is_partition_dirent(dir, d, NULL))
            continue;
        if (ul_path_readf_s32(pc, &n, "%s/partition", d->d_name))
            continue;
        if (n == partno)
        {
            if (ul_path_readf_majmin(pc, &devno, "%s/dev", d->d_name) == 0)
                break;
        }
    }
    closedir(dir);
    DBG(CXT,
        ul_debugobj(pc, "partno (%d) -> devno (%d)", (int)partno, (int)devno));
    return devno;
}
dev_t sysfs_blkdev_partno_to_devno ( struct path_cxt * pc , int partno ) { DIR * dir ; struct dirent * d ; dev_t devno = 0 ; dir = ul_path_opendir ( pc , NULL ) ; if ( ! dir ) return 0 ; while ( ( d = xreaddir ( dir ) ) ) { int n ; if ( ! sysfs_blkdev_is_partition_dirent ( dir , d , NULL ) ) continue ; if ( ul_path_readf_s32 ( pc , & n , " " , d -> d_name ) ) continue ; if ( n == partno ) { if ( ul_path_readf_majmin ( pc , & devno , " " , d -> d_name ) == 0 ) break ; } } closedir ( dir ) ; DBG ( CXT , ul_debugobj ( pc , " " , ( int ) partno , ( int ) devno ) ) ; return devno ; }
Converts @partno (partition number) to devno of the partition.
Converts @partno ( partition number ) to devno of the partition .