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
char* sysfs_blkdev_get_slave(struct path_cxt* pc)
{
    DIR* dir;
    struct dirent* d;
    char* name = NULL;

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

    while ((d = xreaddir(dir)))
    {
        if (name)
            goto err; /* more slaves */
        name = strdup(d->d_name);
    }

    closedir(dir);
    return name;
err:
    free(name);
    closedir(dir);
    return NULL;
}
/*
 * Returns slave name if there is only one slave, otherwise returns NULL.
 * The result should be deallocated by free().
 */
Returns slave name if there is only one slave, otherwise returns NULL.
The result should be deallocated by free().
Returns slave name if there is only one slave otherwise returns NULL . The result should be deallocated by free () .
char* sysfs_blkdev_get_slave(struct path_cxt* pc)
{
    DIR* dir;
    struct dirent* d;
    char* name = NULL;
    dir = ul_path_opendir(pc, "slaves");
    if (!dir)
        return NULL;
    while ((d = xreaddir(dir)))
    {
        if (name)
            goto err; 
        name = strdup(d->d_name);
    }
    closedir(dir);
    return name;
err:
    free(name);
    closedir(dir);
    return NULL;
}
char * sysfs_blkdev_get_slave ( struct path_cxt * pc ) { DIR * dir ; struct dirent * d ; char * name = NULL ; dir = ul_path_opendir ( pc , " " ) ; if ( ! dir ) return NULL ; while ( ( d = xreaddir ( dir ) ) ) { if ( name ) goto err ; name = strdup ( d -> d_name ) ; } closedir ( dir ) ; return name ; err : free ( name ) ; closedir ( dir ) ; return NULL ; }
Returns slave name if there is only one slave, otherwise returns NULL.
Returns slave name if there is only one slave otherwise returns NULL .
/* more slaves */