dvd.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <unistd.h>`
`#include <stdint.h>`
`#include <sys/stat.h>`
`#include <fcntl.h>`
`#include <sys/ioctl.h>`
`#include <linux/cdrom.h>`
`#include <errno.h>`
`#include <string.h>`
`#include <mntent.h>`
`#include <sys/wait.h>`
`#include <sys/utsname.h>`
`#include <scsi/scsi.h>`
`#include <scsi/sg.h>`
`#include <poll.h>`
`#include <sys/time.h>`
`#include "dvd.h"`

## Data Structures

struct | ScsiCommand

## Macros

#define | CREAM_ON_ERRNO(s)
#define | ERRCODE(s)
#define | SK(errcode)
#define | ASC(errcode)
#define | ASCQ(errcode)
#define | _LARGEFILE_SOURCE
#define | _LARGEFILE64_SOURCE
#define | _FILE_OFFSET_BITS 64
#define | _GNU_SOURCE
#define | SG_FLAG_LUN_INHIBIT 0
#define | DIRECTION(i)

## Typedefs

typedef struct ScsiCommand | ScsiCommand

## Enumerations

enum | Direction { NONE = CGC_DATA_NONE , READ = CGC_DATA_READ , WRITE = CGC_DATA_WRITE }

## Functions

static ScsiCommand * | scsi_command_new (void)
static ScsiCommand * | scsi_command_new_from_fd (int f)
static void | scsi_command_free (ScsiCommand *cmd)
static int | scsi_command_transport (ScsiCommand *cmd, Direction dir, void *buf, size_t sz)
static void | scsi_command_init (ScsiCommand *cmd, size_t i, int arg)
int | get_dvd_profile (int fd)

## Variables

const int | Dir_xlate [4]

## Macro Definition Documentation

## _FILE_OFFSET_BITS

#define _FILE_OFFSET_BITS 64

## _GNU_SOURCE

#define _GNU_SOURCE

## _LARGEFILE64_SOURCE

#define _LARGEFILE64_SOURCE

## _LARGEFILE_SOURCE

#define _LARGEFILE_SOURCE

## ASC

#define ASC | ( |  | errcode | ) |

Value:
(((errcode)>>8)&0xFF)

## ASCQ

#define ASCQ | ( |  | errcode | ) |

Value:
((errcode)&0xFF)

## CREAM_ON_ERRNO

#define CREAM_ON_ERRNO | ( |  | s | ) |

Value:
do { \
switch ((s)[2]&0x0F) \
{ case 2: if ((s)[12]==4) errno=EAGAIN; break; \
case 5: errno=EINVAL; \
if ((s)[13]==0) \
{ if ((s)[12]==0x21) errno=ENOSPC; \
else if ((s)[12]==0x20) errno=ENODEV; \
} \
break; \
} \
} while(0)

Referenced by scsi_command_transport().

## DIRECTION

#define DIRECTION | ( |  | i | ) |

Value:
(Dir_xlate[i]);
Dir_xlate
const int Dir_xlate[4]
Definition dvd.c:92

Referenced by scsi_command_transport().

## ERRCODE

#define ERRCODE | ( |  | s | ) |

Value:
((((s)[2]&0x0F)<<16)|((s)[12]<<8)|((s)[13]))

Referenced by scsi_command_transport().

## SG_FLAG_LUN_INHIBIT

#define SG_FLAG_LUN_INHIBIT 0

Referenced by scsi_command_init().

## SK

#define SK | ( |  | errcode | ) |

Value:
(((errcode)>>16)&0xF)

## Typedef Documentation

## ScsiCommand

typedef struct ScsiCommand ScsiCommand

## Enumeration Type Documentation

## Direction

enum Direction

Enumerator
NONE |
READ |
WRITE |

## Function Documentation

## get_dvd_profile()

int get_dvd_profile | ( | int | fd | ) |

References DRIVE_CDROM_CAPS_BDR, DRIVE_CDROM_CAPS_BDRE, DRIVE_CDROM_CAPS_BDROM, DRIVE_CDROM_CAPS_DVDPLUSR, DRIVE_CDROM_CAPS_DVDPLUSRDL, DRIVE_CDROM_CAPS_DVDPLUSRW, DRIVE_CDROM_CAPS_DVDPLUSRWDL, DRIVE_CDROM_CAPS_DVDRDL, DRIVE_CDROM_CAPS_DVDRW, DRIVE_CDROM_CAPS_HDDVDR, DRIVE_CDROM_CAPS_HDDVDROM, DRIVE_CDROM_CAPS_HDDVDRW, READ, scsi_command_free(), scsi_command_init(), scsi_command_new_from_fd(), and scsi_command_transport().

Referenced by add_cdrom_info().

## scsi_command_free()

void scsi_command_free | ( | ScsiCommand * | cmd | ) |

static

References ScsiCommand::autoclose, ScsiCommand::fd, and ScsiCommand::filename.

Referenced by get_dvd_profile().

## scsi_command_init()

void scsi_command_init | ( | ScsiCommand * | cmd,
|  | size_t | i,
|  | int | arg )

static

References ScsiCommand::_sense, ScsiCommand::cgc, ScsiCommand::s, SG_FLAG_LUN_INHIBIT, ScsiCommand::sg_io, and ScsiCommand::u.

Referenced by get_dvd_profile().

## scsi_command_new()

ScsiCommand * scsi_command_new | ( | void |  | ) |

static

References ScsiCommand::autoclose, ScsiCommand::fd, and ScsiCommand::filename.

Referenced by scsi_command_new_from_fd().

## scsi_command_new_from_fd()

ScsiCommand * scsi_command_new_from_fd | ( | int | f | ) |

static

References ScsiCommand::autoclose, ScsiCommand::fd, and scsi_command_new().

Referenced by get_dvd_profile().

## scsi_command_transport()

int scsi_command_transport | ( | ScsiCommand * | cmd,
|  | Direction | dir,
|  | void * | buf,
|  | size_t | sz )

static

References CREAM_ON_ERRNO, DIRECTION, ERRCODE, ScsiCommand::fd, and ScsiCommand::sg_io.

Referenced by get_dvd_profile().

## Variable Documentation

## Dir_xlate

const int Dir_xlate[4]

Initial value:
= {
0,
SG_DXFER_TO_DEV,
SG_DXFER_FROM_DEV,
SG_DXFER_NONE
}