libhd 5.0
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 ScsiCommandscsi_command_new (void)
static ScsiCommandscsi_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]);
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()

◆ scsi_command_free()

void scsi_command_free ( ScsiCommand * cmd)
static

◆ scsi_command_init()

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

◆ scsi_command_new()

ScsiCommand * scsi_command_new ( void )
static

◆ scsi_command_new_from_fd()

ScsiCommand * scsi_command_new_from_fd ( int f)
static

◆ scsi_command_transport()

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

Variable Documentation

◆ Dir_xlate

const int Dir_xlate[4]
Initial value:
= {
0,
SG_DXFER_TO_DEV,
SG_DXFER_FROM_DEV,
SG_DXFER_NONE
}