Lines Matching refs:d
830 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_device_info() local
834 usb_mtp_add_u16(d, 100); in usb_mtp_get_device_info()
835 usb_mtp_add_u32(d, 0x00000006); in usb_mtp_get_device_info()
836 usb_mtp_add_u16(d, 0x0064); in usb_mtp_get_device_info()
837 usb_mtp_add_wstr(d, L""); in usb_mtp_get_device_info()
838 usb_mtp_add_u16(d, 0x0000); in usb_mtp_get_device_info()
840 usb_mtp_add_u16_array(d, ARRAY_SIZE(ops), ops); in usb_mtp_get_device_info()
841 usb_mtp_add_u16_array(d, 0, NULL); in usb_mtp_get_device_info()
842 usb_mtp_add_u16_array(d, 0, NULL); in usb_mtp_get_device_info()
843 usb_mtp_add_u16_array(d, 0, NULL); in usb_mtp_get_device_info()
844 usb_mtp_add_u16_array(d, ARRAY_SIZE(fmt), fmt); in usb_mtp_get_device_info()
846 usb_mtp_add_wstr(d, L"" MTP_MANUFACTURER); in usb_mtp_get_device_info()
847 usb_mtp_add_wstr(d, L"" MTP_PRODUCT); in usb_mtp_get_device_info()
848 usb_mtp_add_wstr(d, L"0.1"); in usb_mtp_get_device_info()
849 usb_mtp_add_wstr(d, L"0123456789abcdef0123456789abcdef"); in usb_mtp_get_device_info()
851 return d; in usb_mtp_get_device_info()
859 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_storage_ids() local
863 usb_mtp_add_u32_array(d, ARRAY_SIZE(ids), ids); in usb_mtp_get_storage_ids()
865 return d; in usb_mtp_get_storage_ids()
870 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_storage_info() local
877 usb_mtp_add_u16(d, 0x0003); in usb_mtp_get_storage_info()
878 usb_mtp_add_u16(d, 0x0002); in usb_mtp_get_storage_info()
879 usb_mtp_add_u16(d, 0x0000); in usb_mtp_get_storage_info()
881 usb_mtp_add_u16(d, 0x0001); in usb_mtp_get_storage_info()
882 usb_mtp_add_u16(d, 0x0002); in usb_mtp_get_storage_info()
883 usb_mtp_add_u16(d, 0x0001); in usb_mtp_get_storage_info()
888 usb_mtp_add_u64(d, (uint64_t)buf.f_frsize * buf.f_blocks); in usb_mtp_get_storage_info()
889 usb_mtp_add_u64(d, (uint64_t)buf.f_frsize * buf.f_bavail); in usb_mtp_get_storage_info()
890 usb_mtp_add_u32(d, buf.f_ffree); in usb_mtp_get_storage_info()
892 usb_mtp_add_u64(d, 0xffffffff); in usb_mtp_get_storage_info()
893 usb_mtp_add_u64(d, 0xffffffff); in usb_mtp_get_storage_info()
894 usb_mtp_add_u32(d, 0xffffffff); in usb_mtp_get_storage_info()
897 usb_mtp_add_str(d, s->desc); in usb_mtp_get_storage_info()
898 usb_mtp_add_wstr(d, L"123456789abcdef"); in usb_mtp_get_storage_info()
899 return d; in usb_mtp_get_storage_info()
905 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_object_handles() local
916 usb_mtp_add_u32_array(d, o->nchildren, handles); in usb_mtp_get_object_handles()
918 return d; in usb_mtp_get_object_handles()
924 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_object_info() local
928 usb_mtp_add_u32(d, QEMU_STORAGE_ID); in usb_mtp_get_object_info()
929 usb_mtp_add_u16(d, o->format); in usb_mtp_get_object_info()
930 usb_mtp_add_u16(d, 0); in usb_mtp_get_object_info()
933 usb_mtp_add_u32(d, 0xFFFFFFFF); in usb_mtp_get_object_info()
935 usb_mtp_add_u32(d, o->stat.st_size); in usb_mtp_get_object_info()
938 usb_mtp_add_u16(d, 0); in usb_mtp_get_object_info()
939 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
940 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
941 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
942 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
943 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
944 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
947 usb_mtp_add_u32(d, o->parent->handle); in usb_mtp_get_object_info()
949 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
952 usb_mtp_add_u16(d, 0x0001); in usb_mtp_get_object_info()
953 usb_mtp_add_u32(d, 0x00000001); in usb_mtp_get_object_info()
954 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
956 usb_mtp_add_u16(d, 0); in usb_mtp_get_object_info()
957 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
958 usb_mtp_add_u32(d, 0); in usb_mtp_get_object_info()
961 usb_mtp_add_str(d, o->name); in usb_mtp_get_object_info()
962 usb_mtp_add_time(d, o->stat.st_ctime); in usb_mtp_get_object_info()
963 usb_mtp_add_time(d, o->stat.st_mtime); in usb_mtp_get_object_info()
964 usb_mtp_add_wstr(d, L""); in usb_mtp_get_object_info()
966 return d; in usb_mtp_get_object_info()
972 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_object() local
976 d->fd = open(o->path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); in usb_mtp_get_object()
977 if (d->fd == -1) { in usb_mtp_get_object()
978 usb_mtp_data_free(d); in usb_mtp_get_object()
981 d->length = o->stat.st_size; in usb_mtp_get_object()
982 d->alloc = 512; in usb_mtp_get_object()
983 d->data = g_malloc(d->alloc); in usb_mtp_get_object()
984 return d; in usb_mtp_get_object()
990 MTPData *d; in usb_mtp_get_partial_object() local
999 d = usb_mtp_data_alloc(c); in usb_mtp_get_partial_object()
1000 d->fd = open(o->path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); in usb_mtp_get_partial_object()
1001 if (d->fd == -1) { in usb_mtp_get_partial_object()
1002 usb_mtp_data_free(d); in usb_mtp_get_partial_object()
1010 if (lseek(d->fd, offset, SEEK_SET) < 0) { in usb_mtp_get_partial_object()
1011 usb_mtp_data_free(d); in usb_mtp_get_partial_object()
1015 d->length = c->argv[2]; in usb_mtp_get_partial_object()
1016 if (d->length > o->stat.st_size - offset) { in usb_mtp_get_partial_object()
1017 d->length = o->stat.st_size - offset; in usb_mtp_get_partial_object()
1020 return d; in usb_mtp_get_partial_object()
1033 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_object_props_supported() local
1034 usb_mtp_add_u16_array(d, ARRAY_SIZE(props), props); in usb_mtp_get_object_props_supported()
1036 return d; in usb_mtp_get_object_props_supported()
1041 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_object_prop_desc() local
1044 usb_mtp_add_u16(d, PROP_STORAGE_ID); in usb_mtp_get_object_prop_desc()
1045 usb_mtp_add_u16(d, DATA_TYPE_UINT32); in usb_mtp_get_object_prop_desc()
1046 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1047 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_desc()
1048 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_desc()
1049 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1052 usb_mtp_add_u16(d, PROP_OBJECT_FORMAT); in usb_mtp_get_object_prop_desc()
1053 usb_mtp_add_u16(d, DATA_TYPE_UINT16); in usb_mtp_get_object_prop_desc()
1054 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1055 usb_mtp_add_u16(d, 0x0000); in usb_mtp_get_object_prop_desc()
1056 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_desc()
1057 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1060 usb_mtp_add_u16(d, PROP_OBJECT_COMPRESSED_SIZE); in usb_mtp_get_object_prop_desc()
1061 usb_mtp_add_u16(d, DATA_TYPE_UINT64); in usb_mtp_get_object_prop_desc()
1062 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1063 usb_mtp_add_u64(d, 0x0000000000000000); in usb_mtp_get_object_prop_desc()
1064 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_desc()
1065 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1068 usb_mtp_add_u16(d, PROP_PARENT_OBJECT); in usb_mtp_get_object_prop_desc()
1069 usb_mtp_add_u16(d, DATA_TYPE_UINT32); in usb_mtp_get_object_prop_desc()
1070 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1071 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_desc()
1072 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_desc()
1073 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1076 usb_mtp_add_u16(d, PROP_PERSISTENT_UNIQUE_OBJECT_IDENTIFIER); in usb_mtp_get_object_prop_desc()
1077 usb_mtp_add_u16(d, DATA_TYPE_UINT128); in usb_mtp_get_object_prop_desc()
1078 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1079 usb_mtp_add_u64(d, 0x0000000000000000); in usb_mtp_get_object_prop_desc()
1080 usb_mtp_add_u64(d, 0x0000000000000000); in usb_mtp_get_object_prop_desc()
1081 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_desc()
1082 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1085 usb_mtp_add_u16(d, PROP_NAME); in usb_mtp_get_object_prop_desc()
1086 usb_mtp_add_u16(d, DATA_TYPE_STRING); in usb_mtp_get_object_prop_desc()
1087 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1088 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1089 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_desc()
1090 usb_mtp_add_u8(d, 0x00); in usb_mtp_get_object_prop_desc()
1093 usb_mtp_data_free(d); in usb_mtp_get_object_prop_desc()
1097 return d; in usb_mtp_get_object_prop_desc()
1103 MTPData *d = usb_mtp_data_alloc(c); in usb_mtp_get_object_prop_value() local
1106 usb_mtp_add_u32(d, QEMU_STORAGE_ID); in usb_mtp_get_object_prop_value()
1109 usb_mtp_add_u16(d, o->format); in usb_mtp_get_object_prop_value()
1112 usb_mtp_add_u64(d, o->stat.st_size); in usb_mtp_get_object_prop_value()
1116 usb_mtp_add_u32(d, 0x00000000); in usb_mtp_get_object_prop_value()
1118 usb_mtp_add_u32(d, o->parent->handle); in usb_mtp_get_object_prop_value()
1125 usb_mtp_add_u64(d, 0x0000000000000000); in usb_mtp_get_object_prop_value()
1126 usb_mtp_add_u64(d, o->handle); in usb_mtp_get_object_prop_value()
1129 usb_mtp_add_str(d, o->name); in usb_mtp_get_object_prop_value()
1132 usb_mtp_data_free(d); in usb_mtp_get_object_prop_value()
1136 return d; in usb_mtp_get_object_prop_value()
1604 MTPData *d = s->data_out; in usb_mtp_write_data() local
1612 assert(d != NULL); in usb_mtp_write_data()
1614 switch (d->write_status) { in usb_mtp_write_data()
1617 usb_mtp_queue_result(s, RES_INVALID_OBJECTINFO, d->trans, in usb_mtp_write_data()
1627 usb_mtp_queue_result(s, RES_OK, d->trans, 3, in usb_mtp_write_data()
1636 d->fd = open(path, O_CREAT | O_WRONLY | in usb_mtp_write_data()
1638 if (d->fd == -1) { in usb_mtp_write_data()
1647 if (d->length != MTP_WRITE_BUF_SZ && !d->pending) { in usb_mtp_write_data()
1648 d->write_status = WRITE_END; in usb_mtp_write_data()
1654 rc = write_retry(d->fd, d->data, d->data_offset, in usb_mtp_write_data()
1655 d->offset - d->data_offset); in usb_mtp_write_data()
1656 if (rc != d->data_offset) { in usb_mtp_write_data()
1660 if (d->write_status != WRITE_END) { in usb_mtp_write_data()
1670 d->offset != s->dataset.size) || in usb_mtp_write_data()
1672 usb_mtp_queue_result(s, RES_INCOMPLETE_TRANSFER, d->trans, in usb_mtp_write_data()
1681 usb_mtp_queue_result(s, RES_STORE_FULL, d->trans, in usb_mtp_write_data()
1684 usb_mtp_queue_result(s, RES_OK, d->trans, in usb_mtp_write_data()
1692 if (d->fd != -1) { in usb_mtp_write_data()
1693 close(d->fd); in usb_mtp_write_data()
1694 d->fd = -1; in usb_mtp_write_data()
1704 MTPData *d = s->data_out; in usb_mtp_write_metadata() local
1705 ObjectInfo *dataset = (ObjectInfo *)d->data; in usb_mtp_write_metadata()
1726 usb_mtp_queue_result(s, RES_PARAMETER_NOT_SUPPORTED, d->trans, in usb_mtp_write_metadata()
1745 usb_mtp_queue_result(s, RES_OK, d->trans, 3, QEMU_STORAGE_ID, in usb_mtp_write_metadata()
1753 MTPData *d = s->data_out; in usb_mtp_get_data() local
1758 if (!d) { in usb_mtp_get_data()
1763 if (d->first) { in usb_mtp_get_data()
1769 usb_mtp_realloc(d, total_len); in usb_mtp_get_data()
1770 d->length += total_len; in usb_mtp_get_data()
1772 usb_mtp_realloc(d, MTP_WRITE_BUF_SZ - sizeof(mtp_container)); in usb_mtp_get_data()
1773 d->length += MTP_WRITE_BUF_SZ - sizeof(mtp_container); in usb_mtp_get_data()
1775 d->offset = 0; in usb_mtp_get_data()
1776 d->first = false; in usb_mtp_get_data()
1777 d->pending = false; in usb_mtp_get_data()
1778 d->data_offset = 0; in usb_mtp_get_data()
1779 d->write_status = WRITE_START; in usb_mtp_get_data()
1782 if (d->pending) { in usb_mtp_get_data()
1783 memset(d->data, 0, d->length); in usb_mtp_get_data()
1784 if (d->length != MTP_WRITE_BUF_SZ) { in usb_mtp_get_data()
1785 usb_mtp_realloc(d, MTP_WRITE_BUF_SZ - d->length); in usb_mtp_get_data()
1786 d->length += (MTP_WRITE_BUF_SZ - d->length); in usb_mtp_get_data()
1788 d->pending = false; in usb_mtp_get_data()
1789 d->write_status = WRITE_CONTINUE; in usb_mtp_get_data()
1790 d->data_offset = 0; in usb_mtp_get_data()
1793 if (d->length - d->data_offset > data_len) { in usb_mtp_get_data()
1796 dlen = d->length - d->data_offset; in usb_mtp_get_data()
1799 switch (d->code) { in usb_mtp_get_data()
1801 usb_packet_copy(p, d->data + d->data_offset, dlen); in usb_mtp_get_data()
1802 d->offset += dlen; in usb_mtp_get_data()
1803 d->data_offset += dlen; in usb_mtp_get_data()
1804 if (d->data_offset == d->length) { in usb_mtp_get_data()
1815 usb_packet_copy(p, d->data + d->data_offset, dlen); in usb_mtp_get_data()
1816 d->offset += dlen; in usb_mtp_get_data()
1817 d->data_offset += dlen; in usb_mtp_get_data()
1820 (s->dataset.size == d->offset)); in usb_mtp_get_data()
1822 if (d->length == MTP_WRITE_BUF_SZ) { in usb_mtp_get_data()
1823 d->write_status = WRITE_END; in usb_mtp_get_data()
1825 d->write_status = WRITE_START; in usb_mtp_get_data()
1832 if (d->data_offset == d->length) { in usb_mtp_get_data()
1833 d->pending = true; in usb_mtp_get_data()
1866 MTPData *d = s->data_in; in usb_mtp_handle_data() local
1867 uint64_t dlen = d->length - d->offset; in usb_mtp_handle_data()
1868 if (d->first) { in usb_mtp_handle_data()
1869 trace_usb_mtp_data_in(s->dev.addr, d->trans, d->length); in usb_mtp_handle_data()
1870 if (d->length + sizeof(container) > 0xFFFFFFFF) { in usb_mtp_handle_data()
1874 cpu_to_le32(d->length + sizeof(container)); in usb_mtp_handle_data()
1877 container.code = cpu_to_le16(d->code); in usb_mtp_handle_data()
1878 container.trans = cpu_to_le32(d->trans); in usb_mtp_handle_data()
1880 d->first = false; in usb_mtp_handle_data()
1889 if (d->fd == -1) { in usb_mtp_handle_data()
1890 usb_packet_copy(p, d->data + d->offset, dlen); in usb_mtp_handle_data()
1892 if (d->alloc < p->iov.size) { in usb_mtp_handle_data()
1893 d->alloc = p->iov.size; in usb_mtp_handle_data()
1894 d->data = g_realloc(d->data, d->alloc); in usb_mtp_handle_data()
1896 rc = read(d->fd, d->data, dlen); in usb_mtp_handle_data()
1898 memset(d->data, 0, dlen); in usb_mtp_handle_data()
1901 usb_packet_copy(p, d->data, dlen); in usb_mtp_handle_data()
1903 d->offset += dlen; in usb_mtp_handle_data()
1904 if (d->offset == d->length) { in usb_mtp_handle_data()