|
USBIP C library 0.7.0
Virtual USB devices & host drivers over USB/IP
|
MTP configuration: device identity + one or more storage backends. More...
#include <classes/mtp.h>
Data Fields | |
| int | read_only |
| Nonzero -> reject host writes/deletes/edits. | |
| const char * | name |
| Model / device friendly name. | |
| const char * | manufacturer |
| DeviceInfo Manufacturer (may be NULL) | |
| const char * | serial |
| 32 hex chars (NULL -> a built-in default) | |
| int | winusb |
| Nonzero -> advertise the Microsoft OS "MTP" Compatible ID. | |
| int | n_stores |
Number of storages exposed (entries used in stores) | |
| void * | stores [MTP_MAX_STORAGES] |
| Per-storage backend contexts (e.g. | |
| void(* | listdir )(void *store, const char *path, mtp_emit emit, void *ctx) |
List a directory: call emit once per entry it contains. | |
| int(* | get_info )(void *store, const char *path, int *is_dir, uint64_t *size, uint32_t *mtime) |
| Stat one object. | |
| int(* | read )(void *store, const char *path, long off, uint8_t *buf, int want) |
| Read from a file. | |
| int(* | write )(void *store, const char *path, const uint8_t *data, int len) |
| Create or overwrite a file with the given contents (whole-file write). | |
| int(* | make_dir )(void *store, const char *path) |
| Create a directory. | |
| int(* | remove )(void *store, const char *path) |
| Delete a file or empty directory. | |
| int(* | rename )(void *store, const char *path, const char *newpath) |
| Rename or move an object. | |
| int(* | pwrite )(void *store, const char *path, long off, const uint8_t *data, int len) |
Partial in-place write (Android edit extension; may be NULL). | |
| int(* | truncate )(void *store, const char *path, uint64_t size) |
Truncate a file to a new length (Android edit extension; may be NULL). | |
| void(* | disk_usage )(void *store, uint64_t *total, uint64_t *freeb) |
| Report the storage's capacity. | |
| const char *(* | description )(void *store) |
Storage label shown to the host (may be NULL). | |
| void(* | on_event )(void *user, const char *text) |
Human-readable log hook for MTP activity (may be NULL). | |
| void * | user |
Opaque pointer passed to on_event. | |
MTP configuration: device identity + one or more storage backends.
The class implements the MTP protocol and object model but performs no filesystem access - every storage operation is delegated to the callbacks below. Each callback's first argument is the per-storage context (one of stores[]). Paths are relative and "/"-separated; the empty string "" is that storage's root. Unless noted, the int callbacks return 0 on success and a negative value on failure.
| int mtp_opts::read_only |
Nonzero -> reject host writes/deletes/edits.
| const char* mtp_opts::name |
Model / device friendly name.
| const char* mtp_opts::manufacturer |
DeviceInfo Manufacturer (may be NULL)
| const char* mtp_opts::serial |
32 hex chars (NULL -> a built-in default)
| int mtp_opts::winusb |
Nonzero -> advertise the Microsoft OS "MTP" Compatible ID.
| int mtp_opts::n_stores |
Number of storages exposed (entries used in stores)
| void* mtp_opts::stores[MTP_MAX_STORAGES] |
Per-storage backend contexts (e.g.
a directory root)
| void(* mtp_opts::listdir) (void *store, const char *path, mtp_emit emit, void *ctx) |
List a directory: call emit once per entry it contains.
| store | the per-storage context. |
| path | directory path ("" = storage root). |
| emit | sink for entry names (see mtp_emit). |
| ctx | opaque pointer to pass back to emit. |
| int(* mtp_opts::get_info) (void *store, const char *path, int *is_dir, uint64_t *size, uint32_t *mtime) |
Stat one object.
| store | the per-storage context. | |
| path | object path. | |
| [out] | is_dir | set non-zero for a directory, 0 for a file. |
| [out] | size | set to the file size in bytes. |
| [out] | mtime | set to the modification time (Unix epoch seconds). |
| int(* mtp_opts::read) (void *store, const char *path, long off, uint8_t *buf, int want) |
Read from a file.
| store | the per-storage context. |
| path | file path. |
| off | byte offset to read from. |
| buf | destination buffer. |
| want | maximum number of bytes to read. |
| int(* mtp_opts::write) (void *store, const char *path, const uint8_t *data, int len) |
Create or overwrite a file with the given contents (whole-file write).
| store | the per-storage context. |
| path | file path. |
| data | the file contents. |
| len | number of bytes in data. |
| int(* mtp_opts::make_dir) (void *store, const char *path) |
Create a directory.
| store | the per-storage context. |
| path | directory path to create. |
| int(* mtp_opts::remove) (void *store, const char *path) |
Delete a file or empty directory.
| store | the per-storage context. |
| path | object path to remove. |
| int(* mtp_opts::rename) (void *store, const char *path, const char *newpath) |
Rename or move an object.
| store | the per-storage context. |
| path | existing object path. |
| newpath | new path. |
| int(* mtp_opts::pwrite) (void *store, const char *path, long off, const uint8_t *data, int len) |
Partial in-place write (Android edit extension; may be NULL).
| store | the per-storage context. |
| path | file path. |
| off | byte offset to write at. |
| data | the bytes to write. |
| len | number of bytes in data. |
| int(* mtp_opts::truncate) (void *store, const char *path, uint64_t size) |
Truncate a file to a new length (Android edit extension; may be NULL).
| store | the per-storage context. |
| path | file path. |
| size | new length in bytes. |
| void(* mtp_opts::disk_usage) (void *store, uint64_t *total, uint64_t *freeb) |
Report the storage's capacity.
| store | the per-storage context. | |
| [out] | total | set to total bytes. |
| [out] | freeb | set to free bytes. |
| const char *(* mtp_opts::description) (void *store) |
Storage label shown to the host (may be NULL).
| store | the per-storage context. |
NULL for a built-in default. | void(* mtp_opts::on_event) (void *user, const char *text) |
Human-readable log hook for MTP activity (may be NULL).
| user | the user pointer. |
| text | a NUL-terminated description. |
| void* mtp_opts::user |
Opaque pointer passed to on_event.