openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/systemd/1_242+AUTOINC+db2e367bfc-r0/git/src/udev/cdrom_id/cdrom_id.c
static int cd_profiles_old_mmc(int fd)
{
    struct scsi_cmd sc;
    int err;

    unsigned char header[32];

    scsi_cmd_init(&sc);
    scsi_cmd_set(&sc, 0, 0x51);
    scsi_cmd_set(&sc, 8, sizeof(header));
    scsi_cmd_set(&sc, 9, 0);
    err = scsi_cmd_run(&sc, fd, header, sizeof(header));
    if ((err != 0))
    {
        info_scsi_cmd_err("READ DISC INFORMATION", err);
        if (cd_media == 1)
        {
            log_debug(
                "no current profile, but disc is present; assuming CD-ROM");
            cd_media_cd_rom = 1;
            cd_media_track_count = 1;
            cd_media_track_count_data = 1;
            return 0;
        }
        else
        {
            log_debug("no current profile, assuming no media");
            return -1;
        }
    };

    cd_media = 1;

    if (header[2] & 16)
    {
        cd_media_cd_rw = 1;
        log_debug("profile 0x0a media_cd_rw");
    }
    else if ((header[2] & 3) < 2 && cd_cd_r)
    {
        cd_media_cd_r = 1;
        log_debug("profile 0x09 media_cd_r");
    }
    else
    {
        cd_media_cd_rom = 1;
        log_debug("profile 0x08 media_cd_rom");
    }
    return 0;
}
/* returns 0 if media was detected */
returns 0 if media was detected
returns 0 if media was detected
static int cd_profiles_old_mmc(int fd)
{
    struct scsi_cmd sc;
    int err;
    unsigned char header[32];
    scsi_cmd_init(&sc);
    scsi_cmd_set(&sc, 0, 0x51);
    scsi_cmd_set(&sc, 8, sizeof(header));
    scsi_cmd_set(&sc, 9, 0);
    err = scsi_cmd_run(&sc, fd, header, sizeof(header));
    if ((err != 0))
    {
        info_scsi_cmd_err("READ DISC INFORMATION", err);
        if (cd_media == 1)
        {
            log_debug(
                "no current profile, but disc is present; assuming CD-ROM");
            cd_media_cd_rom = 1;
            cd_media_track_count = 1;
            cd_media_track_count_data = 1;
            return 0;
        }
        else
        {
            log_debug("no current profile, assuming no media");
            return -1;
        }
    };
    cd_media = 1;
    if (header[2] & 16)
    {
        cd_media_cd_rw = 1;
        log_debug("profile 0x0a media_cd_rw");
    }
    else if ((header[2] & 3) < 2 && cd_cd_r)
    {
        cd_media_cd_r = 1;
        log_debug("profile 0x09 media_cd_r");
    }
    else
    {
        cd_media_cd_rom = 1;
        log_debug("profile 0x08 media_cd_rom");
    }
    return 0;
}
static int cd_profiles_old_mmc ( int fd ) { struct scsi_cmd sc ; int err ; unsigned char header [ 32 ] ; scsi_cmd_init ( & sc ) ; scsi_cmd_set ( & sc , 0 , 0x51 ) ; scsi_cmd_set ( & sc , 8 , sizeof ( header ) ) ; scsi_cmd_set ( & sc , 9 , 0 ) ; err = scsi_cmd_run ( & sc , fd , header , sizeof ( header ) ) ; if ( ( err != 0 ) ) { info_scsi_cmd_err ( " " , err ) ; if ( cd_media == 1 ) { log_debug ( " " ) ; cd_media_cd_rom = 1 ; cd_media_track_count = 1 ; cd_media_track_count_data = 1 ; return 0 ; } else { log_debug ( " " ) ; return -1 ; } } ; cd_media = 1 ; if ( header [ 2 ] & 16 ) { cd_media_cd_rw = 1 ; log_debug ( " " ) ; } else if ( ( header [ 2 ] & 3 ) < 2 && cd_cd_r ) { cd_media_cd_r = 1 ; log_debug ( " " ) ; } else { cd_media_cd_rom = 1 ; log_debug ( " " ) ; } return 0 ; }
returns 0 if media was detected
returns 0 if media was detected