static int hdev_open(BlockDriverState *bs, const char *filename, int flags)

{

    BDRVRawState *s = bs->opaque;



#if defined(__APPLE__) && defined(__MACH__)

    if (strstart(filename, "/dev/cdrom", NULL)) {

        kern_return_t kernResult;

        io_iterator_t mediaIterator;

        char bsdPath[ MAXPATHLEN ];

        int fd;



        kernResult = FindEjectableCDMedia( &mediaIterator );

        kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) );



        if ( bsdPath[ 0 ] != '\0' ) {

            strcat(bsdPath,"s0");

            /* some CDs don't have a partition 0 */

            fd = qemu_open(bsdPath, O_RDONLY | O_BINARY | O_LARGEFILE);

            if (fd < 0) {

                bsdPath[strlen(bsdPath)-1] = '1';

            } else {

                qemu_close(fd);

            }

            filename = bsdPath;

        }



        if ( mediaIterator )

            IOObjectRelease( mediaIterator );

    }

#endif



    s->type = FTYPE_FILE;

#if defined(__linux__)

    {

        char resolved_path[ MAXPATHLEN ], *temp;



        temp = realpath(filename, resolved_path);

        if (temp && strstart(temp, "/dev/sg", NULL)) {

            bs->sg = 1;

        }

    }

#endif



    return raw_open_common(bs, filename, flags, 0);

}

static int hdev_open(BlockDriverState *bs, const char *filename, int flags)

{

    BDRVRawState *s = bs->opaque;



#if defined(__APPLE__) && defined(__MACH__)

    if (strstart(filename, "/dev/cdrom", NULL)) {

        kern_return_t kernResult;

        io_iterator_t mediaIterator;

        char bsdPath[ MAXPATHLEN ];

        int fd;



        kernResult = FindEjectableCDMedia( &mediaIterator );

        kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) );



        if ( bsdPath[ 0 ] != '\0' ) {

            strcat(bsdPath,"s0");

            

            fd = qemu_open(bsdPath, O_RDONLY | O_BINARY | O_LARGEFILE);

            if (fd < 0) {

                bsdPath[strlen(bsdPath)-1] = '1';

            } else {

                qemu_close(fd);

            }

            filename = bsdPath;

        }



        if ( mediaIterator )

            IOObjectRelease( mediaIterator );

    }

#endif



    s->type = FTYPE_FILE;

#if defined(__linux__)

    {

        char resolved_path[ MAXPATHLEN ], *temp;



        temp = realpath(filename, resolved_path);

        if (temp && strstart(temp, "/dev/sg", NULL)) {

            bs->sg = 1;

        }

    }

#endif



    return raw_open_common(bs, filename, flags, 0);

}

    return raw_open_common(bs, filename, flags, 0);
static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2)

{

    BDRVRawState *s = VAR_0->opaque;



#if defined(__APPLE__) && defined(__MACH__)

    if (strstart(VAR_1, "/dev/cdrom", NULL)) {

        kern_return_t kernResult;

        io_iterator_t mediaIterator;

        char VAR_3[ MAXPATHLEN ];

        int VAR_4;



        kernResult = FindEjectableCDMedia( &mediaIterator );

        kernResult = GetBSDPath( mediaIterator, VAR_3, sizeof( VAR_3 ) );



        if ( VAR_3[ 0 ] != '\0' ) {

            strcat(VAR_3,"s0");

            

            VAR_4 = qemu_open(VAR_3, O_RDONLY | O_BINARY | O_LARGEFILE);

            if (VAR_4 < 0) {

                VAR_3[strlen(VAR_3)-1] = '1';

            } else {

                qemu_close(VAR_4);

            }

            VAR_1 = VAR_3;

        }



        if ( mediaIterator )

            IOObjectRelease( mediaIterator );

    }

#endif



    s->type = FTYPE_FILE;

#if defined(__linux__)

    {

        char resolved_path[ MAXPATHLEN ], *temp;



        temp = realpath(VAR_1, resolved_path);

        if (temp && strstart(temp, "/dev/sg", NULL)) {

            VAR_0->sg = 1;

        }

    }

#endif



    return raw_open_common(VAR_0, VAR_1, VAR_2, 0);

}

static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2)
{ BDRVRawState *s = VAR_0->opaque; #if defined(__APPLE__) && defined(__MACH__)
if (strstart(VAR_1, "/dev/cdrom", NULL)) { kern_return_t kernResult; io_iterator_t mediaIterator; char VAR_3[ MAXPATHLEN ]; int VAR_4; kernResult = FindEjectableCDMedia( &mediaIterator ); kernResult = GetBSDPath( mediaIterator, VAR_3, sizeof( VAR_3 ) ); if ( VAR_3[ 0 ] != '\0' ) { strcat(VAR_3,"s0"); VAR_4 = qemu_open(VAR_3, O_RDONLY | O_BINARY | O_LARGEFILE); if (VAR_4 < 0) { VAR_3[strlen(VAR_3)-1] = '1'; } else { qemu_close(VAR_4); } VAR_1 = VAR_3; } if ( mediaIterator )
IOObjectRelease( mediaIterator ); } #endif
s->type = FTYPE_FILE; #if defined(__linux__)
{ char resolved_path[ MAXPATHLEN ], *temp; temp = realpath(VAR_1, resolved_path); if (temp && strstart(temp, "/dev/sg", NULL)) { VAR_0->sg = 1; } } #endif
return raw_open_common(VAR_0, VAR_1, VAR_2, 0); }