USBIP C library 0.7.0
Virtual USB devices & host drivers over USB/IP
Loading...
Searching...
No Matches
msc_opts Struct Reference

Mass-storage configuration: a block-storage backend + presentation options. More...

#include <classes/msc.h>

+ Collaboration diagram for msc_opts:

Data Fields

uint32_t(* num_blocks )(void *user)
 Report the medium's capacity, in blocks.
 
uint32_t(* block_size )(void *user)
 Report the block size in bytes (commonly 512).
 
int(* read )(void *user, uint32_t lba, uint32_t count, uint8_t *buf)
 Read count blocks starting at logical block lba.
 
int(* write )(void *user, uint32_t lba, uint32_t count, const uint8_t *buf)
 Write count blocks starting at logical block lba.
 
int n_luns
 Logical units this interface carries: entries used in luns.
 
msc_lun luns [MSC_MAX_LUNS]
 The units, when n_luns says there are several.
 
int read_only
 Present a write-protected medium (every unit)
 
int medium
 What the medium is: one of MSC_MEDIUM_DISK (the default), MSC_MEDIUM_CDROM or MSC_MEDIUM_FLOPPY.
 
int ufi
 Declare the UFI command set (bInterfaceSubClass 0x04, SFF-8070i) instead of SCSI transparent (0x06) - the subclass a real USB floppy drive reports, and what makes Windows show the drive as a floppy rather than a removable disk.
 
const char * vendor
 INQUIRY strings (may be NULL).
 
const char * product
 
const char * revision
 
const char * serial
 Serial number returned by INQUIRY EVPD page 0x80, which Windows asks every removable device for (may be NULL for a default).
 
void(* on_command )(void *user, const char *text)
 Human-readable log hook, called with a description of each SCSI command handled (may be NULL).
 
const char * name
 Optional iInterface name for this disk, e.g.
 
void * user
 Opaque pointer passed to on_command - and, on a single-unit disk, to the block callbacks above.
 

Detailed Description

Mass-storage configuration: a block-storage backend + presentation options.

The backend addresses the medium in fixed-size blocks. With one logical unit - the default - every callback receives the opaque user pointer below; with several (see luns) they receive that unit's msc_lun::user instead, and user is left to on_command.

Field Documentation

◆ num_blocks

uint32_t(* msc_opts::num_blocks) (void *user)

Report the medium's capacity, in blocks.

Parameters
userthe unit's backend context.
Returns
the number of addressable blocks (capacity = this × block_size()).

◆ block_size

uint32_t(* msc_opts::block_size) (void *user)

Report the block size in bytes (commonly 512).

Parameters
userthe unit's backend context.
Returns
bytes per block.

◆ read

int(* msc_opts::read) (void *user, uint32_t lba, uint32_t count, uint8_t *buf)

Read count blocks starting at logical block lba.

Parameters
userthe unit's backend context.
lbafirst logical block address.
countnumber of blocks to read.
bufdestination, count × block_size() bytes.
Returns
0 on success, non-zero to fail the SCSI command.

◆ write

int(* msc_opts::write) (void *user, uint32_t lba, uint32_t count, const uint8_t *buf)

Write count blocks starting at logical block lba.

Parameters
userthe unit's backend context.
lbafirst logical block address.
countnumber of blocks to write.
bufsource, count × block_size() bytes.
Returns
0 on success, non-zero to fail the SCSI command.

◆ n_luns

int msc_opts::n_luns

Logical units this interface carries: entries used in luns.

Zero - the usual case - means one unit, backed by user, described by the fields below; anything above MSC_MAX_LUNS is refused by msc_add().

◆ luns

msc_lun msc_opts::luns[MSC_MAX_LUNS]

The units, when n_luns says there are several.

◆ read_only

int msc_opts::read_only

Present a write-protected medium (every unit)

◆ medium

int msc_opts::medium

What the medium is: one of MSC_MEDIUM_DISK (the default), MSC_MEDIUM_CDROM or MSC_MEDIUM_FLOPPY.

A CD-ROM is always read-only; a floppy answers MODE SENSE page 0x05 with the geometry of the standard format its capacity matches. Overridden per unit by msc_lun::medium

◆ ufi

int msc_opts::ufi

Declare the UFI command set (bInterfaceSubClass 0x04, SFF-8070i) instead of SCSI transparent (0x06) - the subclass a real USB floppy drive reports, and what makes Windows show the drive as a floppy rather than a removable disk.

The transport stays Bulk-Only (bInterfaceProtocol 0x50); UFI-over-CBI is not offered. Intended for MSC_MEDIUM_FLOPPY, but not restricted to it. The UFI commands themselves (FORMAT UNIT, READ(12)/WRITE(12), VERIFY, SEEK, REZERO UNIT) are answered whatever the subclass, as they are legal SCSI too.

◆ vendor

const char* msc_opts::vendor

INQUIRY strings (may be NULL).

The vendor and revision are the device's; the product id is overridden per unit by msc_lun::product.

◆ product

const char * msc_opts::product

◆ revision

const char * msc_opts::revision

◆ serial

const char* msc_opts::serial

Serial number returned by INQUIRY EVPD page 0x80, which Windows asks every removable device for (may be NULL for a default).

Truncated past 20 chars. Overridden per unit by msc_lun::serial.

◆ on_command

void(* msc_opts::on_command) (void *user, const char *text)

Human-readable log hook, called with a description of each SCSI command handled (may be NULL).

On a multi-unit disk each line names its unit.

Parameters
userthe user pointer.
texta NUL-terminated description.

◆ name

const char* msc_opts::name

Optional iInterface name for this disk, e.g.

"Storage" - shown by the host (Linux: /sys/bus/usb/devices/.../interface; Windows: the device name).

◆ user

void* msc_opts::user

Opaque pointer passed to on_command - and, on a single-unit disk, to the block callbacks above.

With n_luns set, each unit brings its own msc_lun::user for those instead.


The documentation for this struct was generated from the following file: