NetBSDからMTPデバイスを使う

この記事は、NetBSD Advent Calendar 2016の6日目の記事です。

はじめに

AndroidなスマートフォンはMTP (Media Transfer Protocol) で 内蔵ストレージや挿し込まれたmicroSDカード等の中身をPCから見ることができます。 私の使っているXperia Z Ultraで言うと、どうやら内蔵ストレージは MTPでしか見ることができないようです。

と言うことで、NetBSDな常用ラップトップから、Xperia X Ultraの内蔵ストレージと microSDカードの中身を扱う方法を書いてみます。

libmtpを使う

一番簡単なのは、昔のMS-DOSのFAT領域を扱うmtoolsのような仕組みを使う方法です。 このようなツールは、一つは、pkgsrc/devel/libmtpで提供されています。 Xperia Z UltraをMTPモードに設定して、NetBSD/amd64なラップトップに接続してみます。 カーネル的にはデバイスドライバーはありませんので、ugen(4)として認識されます。


ugen0 at uhub0 port 5
ugen0: Sony C6833, rev 2.00/2.32, addr 11

libmtpをインストールして、Xperia Z Ultraが認識されるか試してみます。


$ cd /usr/pkgsrc/devel/libmtp
$ make install
$ mtp-detect
libmtp version: 1.1.12

Listing raw device(s)
Device 0 (VID=0fce and PID=019c) is a SONY Xperia Z Ultra MTP (ID3).
   Found 1 device(s):
   SONY: Xperia Z Ultra MTP (ID3) (0fce:019c) @ bus 0, dev 16
Attempting to connect device(s)
Android device detected, assigning default bug flags
Error 1: Get Storage information failed.
USB low-level info:
   Interface has a kernel driver attached.
   bcdUSB: 512
   bDeviceClass: 0
   bDeviceSubClass: 0
   bDeviceProtocol: 0
   idVendor: 0fce
   idProduct: 019c
   IN endpoint maxpacket: 512 bytes
   OUT endpoint maxpacket: 512 bytes
   Raw device info:
      Bus location: 0
      Device number: 16
      Device entry info:
         Vendor: SONY
         Vendor id: 0x0fce
         Product: Xperia Z Ultra MTP (ID3)
         Vendor id: 0x019c
         Device flags: 0x18008106
Configuration 0, interface 0, altsetting 0:
   Interface description contains the string "MTP"
   Device recognized as MTP, no further probing.
Device info:
   Manufacturer: Sony
   Model: C6833
   Device version: 1.0
   Serial number: CB5A253C8R
   Vendor extension ID: 0x00000006
   Vendor extension description: microsoft.com: 1.0; android.com: 1.0; microsoft.com/WPDNA: 1.0;sonyericsson.com/SE: 1.0; sony.net/MRLN: 1.0;microsoft.com/DeviceServices:1.0;
   Detected object size: 64 bits
   Extensions:
        microsoft.com: 1.0
        android.com: 1.0
        microsoft.com/WPDNA: 1.0
        sonyericsson.com/SE: 1.0
        sony.net/MRLN: 1.0
        microsoft.com/DeviceServices: 1.0
Supported operations:
   1001: Unknown(1001)
   1002: Unknown(1002)
   1003: Unknown(1003)
   1004: Unknown(1004)
   1005: Unknown(1005)
   1006: Unknown(1006)
   1007: Unknown(1007)
   1008: Unknown(1008)
   1009: Unknown(1009)
   100a: Unknown(100a)
   100b: Unknown(100b)
   100c: Unknown(100c)
   100d: Unknown(100d)
   1014: Unknown(1014)
   1015: Unknown(1015)
   1016: Unknown(1016)
   1017: Unknown(1017)
   101b: Unknown(101b)
   9801: Unknown(9801)
   9802: Unknown(9802)
   9803: Unknown(9803)
   9804: Unknown(9804)
   9805: Unknown(9805)
   9806: Unknown(9806)
   9808: Unknown(9808)
   9810: Unknown(9810)
   9811: Unknown(9811)
   95c1: Unknown(95c1)
   95c2: Unknown(95c2)
   95c3: Unknown(95c3)
   95c4: Unknown(95c4)
   95c5: Unknown(95c5)
   9301: Unknown(9301)
   9302: Unknown(9302)
   9303: Unknown(9303)
   9304: Unknown(9304)
   9305: Unknown(9305)
   9306: Unknown(9306)
   9307: Unknown(9307)
   9308: Unknown(9308)
   9309: Unknown(9309)
   930a: Unknown(930a)
   9185: Unknown(9185)
   9186: Unknown(9186)
   9187: Unknown(9187)
   9188: Unknown(9188)
   9189: Unknown(9189)
   9191: Unknown(9191)
   9194: Unknown(9194)
   9196: Unknown(9196)
   9197: Unknown(9197)
   940c: Unknown(940c)
   940d: Unknown(940d)
   9407: Unknown(9407)
   9408: Unknown(9408)
   9409: Unknown(9409)
Events supported:
   0x4002
   0x4003
   0x4004
   0x4005
   0x4006
   0xc350
   0xc35a
Device Properties Supported:
   0xd401: Synchronization Partner
   0xd402: Friendly Device Name
   0xd405: Device Icon
   0x5003: Image Size
   0x5001: Battery Level
   0xd120: Unknown property
   0xd302: Unknown property
   0xd303: Unknown property
Playable File (Object) Types and Object Properties Supported:
   3000: Undefined Type
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   300a: MS AVI
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc46: Artist STRING data type READ ONLY
      dc9a: Album Name STRING data type READ ONLY
      dc8b: Track UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc89: Duration UINT32 data type range: MIN 0, MAX -1, STEP 1 READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      de97: Scan Depth UINT16 data type enumeration: 0, 1, 2, 3, 6, 7,  GET/SET
      de9b: Video Four CC Codec UINT32 data type enumeration: 875967048, 1395937357, 842289229, 844313677, 859189832,  GET/SET
      de9c: Video Bit Rate UINT32 data type range: MIN 1, MAX 34816000, STEP 1 GET/SET
      de9d: Frames Per Thousand Seconds UINT32 data type range: MIN 1, MAX 30000, STEP 1 GET/SET
      dea1: Encoding Profile STRING data type GET/SET
      dc87: Width UINT32 data type range: MIN 1, MAX 4096, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 2160, STEP 1 READ ONLY
      de93: Sample Rate UINT32 data type range: MIN 1, MAX 96000, STEP 1 GET/SET
      de94: Number Of Channels UINT16 data type enumeration: 0, 1, 2,  GET/SET
      de99: Audio WAVE Codec UINT32 data type enumeration: 41222,  GET/SET
      de9a: Audio Bit Rate UINT32 data type range: MIN 5000, MAX 384000, STEP 1 READ ONLY
   3001: Association/Directory
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   3004: Text
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   3005: HTML
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   3008: MS Wave
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc46: Artist STRING data type READ ONLY
      dc9a: Album Name STRING data type READ ONLY
      dc9b: Album Artist STRING data type READ ONLY
      dc8b: Track UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc99: Original Release Date STRING data type DATETIME FORM READ ONLY
      dc89: Duration UINT32 data type range: MIN 0, MAX -1, STEP 1 READ ONLY
      dc8c: Genre STRING data type READ ONLY
      dc96: Composer STRING data type READ ONLY
      de99: Audio WAVE Codec UINT32 data type enumeration: 1, 2, 3,  GET/SET
      de92: Bit Rate Type UINT16 data type enumeration: 1, 2,  READ ONLY
      de9a: Audio Bit Rate UINT32 data type range: MIN 5000, MAX 1536000, STEP 1 READ ONLY
      de94: Number Of Channels UINT16 data type enumeration: 0, 1, 2,  GET/SET
      de93: Sample Rate UINT32 data type range: MIN 8000, MAX 48000, STEP 1 GET/SET
   3009: MP3
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc46: Artist STRING data type READ ONLY
      dc9a: Album Name STRING data type READ ONLY
      dc9b: Album Artist STRING data type READ ONLY
      dc8b: Track UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc99: Original Release Date STRING data type DATETIME FORM READ ONLY
      dc89: Duration UINT32 data type range: MIN 0, MAX -1, STEP 1 READ ONLY
      dc8c: Genre STRING data type READ ONLY
      dc96: Composer STRING data type READ ONLY
      de99: Audio WAVE Codec UINT32 data type enumeration: 80, 85,  GET/SET
      de92: Bit Rate Type UINT16 data type enumeration: 1, 2,  READ ONLY
      de9a: Audio Bit Rate UINT32 data type range: MIN 5000, MAX 320000, STEP 1 READ ONLY
      de94: Number Of Channels UINT16 data type enumeration: 0, 1, 2,  GET/SET
      de93: Sample Rate UINT32 data type range: MIN 8000, MAX 48000, STEP 1 GET/SET
   3801: JPEG
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc87: Width UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
   3802: TIFF EP
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc87: Width UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
   3804: BMP
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc87: Width UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
   3807: GIF
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc87: Width UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
   3808: JFIF
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc87: Width UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
   380b: PNG
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc87: Width UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
   380d: TIFF
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc87: Width UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 32767, STEP 1 READ ONLY
   b902: OGG
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc46: Artist STRING data type READ ONLY
      dc9a: Album Name STRING data type READ ONLY
      dc8b: Track UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc89: Duration UINT32 data type range: MIN 0, MAX -1, STEP 1 READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      de97: Scan Depth UINT16 data type enumeration: 0, 1, 2, 3, 6, 7,  GET/SET
      de9b: Video Four CC Codec UINT32 data type enumeration: 875967048, 1395937357, 842289229, 844313677, 859189832,  GET/SET
      de9c: Video Bit Rate UINT32 data type range: MIN 1, MAX 96000, STEP 1 GET/SET
      de9d: Frames Per Thousand Seconds UINT32 data type range: MIN 1, MAX 30000, STEP 1 GET/SET
      dea1: Encoding Profile STRING data type GET/SET
      dc87: Width UINT32 data type range: MIN 1, MAX 4096, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 2160, STEP 1 READ ONLY
      de93: Sample Rate UINT32 data type range: MIN 1, MAX 96000, STEP 1 GET/SET
      de94: Number Of Channels UINT16 data type enumeration: 0, 1, 2,  GET/SET
      de99: Audio WAVE Codec UINT32 data type enumeration: 80, 85,  GET/SET
      de9a: Audio Bit Rate UINT32 data type range: MIN 5000, MAX 1500000, STEP 1 READ ONLY
   b903: AAC
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc46: Artist STRING data type READ ONLY
      dc9a: Album Name STRING data type READ ONLY
      dc9b: Album Artist STRING data type READ ONLY
      dc8b: Track UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc99: Original Release Date STRING data type DATETIME FORM READ ONLY
      dc89: Duration UINT32 data type range: MIN 0, MAX -1, STEP 1 READ ONLY
      dc8c: Genre STRING data type READ ONLY
      dc96: Composer STRING data type READ ONLY
      de99: Audio WAVE Codec UINT32 data type enumeration: 41222,  GET/SET
      de92: Bit Rate Type UINT16 data type enumeration: 1, 2,  READ ONLY
      de9a: Audio Bit Rate UINT32 data type range: MIN 5000, MAX 384000, STEP 1 READ ONLY
      de94: Number Of Channels UINT16 data type enumeration: 0, 1, 2,  GET/SET
      de93: Sample Rate UINT32 data type range: MIN 1, MAX 48000, STEP 1 GET/SET
   b982: MP4
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc46: Artist STRING data type READ ONLY
      dc9a: Album Name STRING data type READ ONLY
      dc8b: Track UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc89: Duration UINT32 data type range: MIN 0, MAX -1, STEP 1 READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      de97: Scan Depth UINT16 data type enumeration: 0, 1, 2, 3, 6, 7,  GET/SET
      de9b: Video Four CC Codec UINT32 data type enumeration: 875967048, 1395937357, 842289229, 844313677, 859189832,  GET/SET
      de9c: Video Bit Rate UINT32 data type range: MIN 1, MAX 139264000, STEP 1 GET/SET
      de9d: Frames Per Thousand Seconds UINT32 data type range: MIN 1, MAX 30000, STEP 1 GET/SET
      dea1: Encoding Profile STRING data type GET/SET
      dc87: Width UINT32 data type range: MIN 1, MAX 4096, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 2160, STEP 1 READ ONLY
      de93: Sample Rate UINT32 data type range: MIN 1, MAX 96000, STEP 1 GET/SET
      de94: Number Of Channels UINT16 data type enumeration: 0, 1, 2,  GET/SET
      de99: Audio WAVE Codec UINT32 data type enumeration: 41222,  GET/SET
      de9a: Audio Bit Rate UINT32 data type range: MIN 5000, MAX 393216, STEP 1 READ ONLY
   b984: 3GP
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc46: Artist STRING data type READ ONLY
      dc9a: Album Name STRING data type READ ONLY
      dc8b: Track UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc89: Duration UINT32 data type range: MIN 0, MAX -1, STEP 1 READ ONLY
      dc48: Description array of UINT16 data type ANY 16BIT VALUE form READ ONLY
      de97: Scan Depth UINT16 data type enumeration: 0, 1, 2, 3, 6, 7,  GET/SET
      de9b: Video Four CC Codec UINT32 data type enumeration: 875967048, 1395937357, 842289229, 844313677, 859189832,  GET/SET
      de9c: Video Bit Rate UINT32 data type range: MIN 1, MAX 20480000, STEP 1 GET/SET
      de9d: Frames Per Thousand Seconds UINT32 data type range: MIN 1, MAX 30000, STEP 1 GET/SET
      dea1: Encoding Profile STRING data type GET/SET
      dc87: Width UINT32 data type range: MIN 1, MAX 4096, STEP 1 READ ONLY
      dc88: Height UINT32 data type range: MIN 1, MAX 2160, STEP 1 READ ONLY
      de93: Sample Rate UINT32 data type range: MIN 1, MAX 96000, STEP 1 GET/SET
      de94: Number Of Channels UINT16 data type enumeration: 0, 1, 2,  GET/SET
      de99: Audio WAVE Codec UINT32 data type enumeration: 41222, 1935764850,  GET/SET
      de9a: Audio Bit Rate UINT32 data type range: MIN 5000, MAX 384000, STEP 1 READ ONLY
   ba03: Abstract Audio Album
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc9b: Album Artist STRING data type READ ONLY
   ba05: Abstract Audio Video Playlist
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   ba10: WPL Playlist
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   ba11: M3U Playlist
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   ba14: PLS Playlist
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   ba82: XMLDocument
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
   b906: FLAC
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      dc46: Artist STRING data type READ ONLY
      dc9a: Album Name STRING data type READ ONLY
      dc9b: Album Artist STRING data type READ ONLY
      dc8b: Track UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc99: Original Release Date STRING data type DATETIME FORM READ ONLY
      dc89: Duration UINT32 data type range: MIN 0, MAX -1, STEP 1 READ ONLY
      dc8c: Genre STRING data type READ ONLY
      dc96: Composer STRING data type READ ONLY
      de99: Audio WAVE Codec UINT32 data type enumeration: 1, 2, 3,  GET/SET
      de92: Bit Rate Type UINT16 data type enumeration: 1, 2,  READ ONLY
      de9a: Audio Bit Rate UINT32 data type range: MIN 5000, MAX 1500000, STEP 1 READ ONLY
      de94: Number Of Channels UINT16 data type enumeration: 0, 1, 2,  GET/SET
      de93: Sample Rate UINT32 data type range: MIN 1, MAX 48000, STEP 1 GET/SET
   b102: Unknown(b102)
      dc01: Storage ID UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc02: Object Format UINT16 data type ANY 16BIT VALUE form READ ONLY
      dc03: Protection Status UINT16 data type enumeration: 0, 1, 32770, 32771,  READ ONLY
      dc04: Object Size UINT64 data type READ ONLY
      dc07: Object File Name STRING data type GET/SET
      dc09: Date Modified STRING data type DATETIME FORM READ ONLY
      dc0b: Parent Object UINT32 data type ANY 32BIT VALUE form READ ONLY
      dc41: Persistant Unique Object Identifier UINT128 data type READ ONLY
      dc44: Name STRING data type GET/SET
      dce0: Display Name STRING data type READ ONLY
      dc4e: Date Added STRING data type DATETIME FORM READ ONLY
      dc4f: Non Consumable UINT8 data type enumeration: 0, 1,  READ ONLY
      d920: Unknown property array of UINT64 data type GET/SET
Special directories:
   Default music folder: 0xffffffff
   Default playlist folder: 0xffffffff
   Default picture folder: 0xffffffff
   Default video folder: 0xffffffff
   Default organizer folder: 0xffffffff
   Default zencast folder: 0xffffffff
   Default album folder: 0xffffffff
   Default text folder: 0xffffffff
MTP-specific device properties:
   Friendly name: Xperia Z Ultra
   Synchronization partner: (NULL)
   Battery level 86 of 100 (86%)
libmtp supported (playable) filetypes:
   Audio Video Interleave
   Folder
   Text file
   HTML file
   RIFF WAVE file
   ISO MPEG-1 Audio Layer 3
   JPEG file
   BMP bitmap file
   GIF bitmap file
   JFIF file
   Portable Network Graphics
   TIFF bitmap file
   Ogg container format
   Advanced Audio Coding (AAC)/MPEG-2 Part 7/MPEG-4 Part 3
   MPEG-4 Part 14 Container Format (Audio+Video Emphasis)
   Abstract Album file
   Abstract Playlist file
   XML file
   Free Lossless Audio Codec (FLAC)
OK.
inep: usb_get_endpoint_status(): Bad file descriptor
outep: usb_get_endpoint_status(): Bad file descriptor

この次には、以下のように実行すると、ls相当のことができるはずです。


$ mtp-files
libmtp version: 1.1.12

Device 0 (VID=0fce and PID=019c) is a SONY Xperia Z Ultra MTP (ID3).
mtp-files: Successfully connected
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
LIBMTP PANIC: failed to open session on second attempt
Unable to open raw device 0
OK.

最後にOKと出力されましたが、全くOKではありません。 何度か試しましたが、どうやらこのままでは動かないようです。

gPhoto2を使う

私の知っているもう一つのMTP実装は、gPhoto2 (pkgsrc/graphics/gphoto2とpkgsrc/deve/libgphoto2)です。 これもmtools的なツールです。


$ cd /usr/pkgsrc/graphics/gphoto2
# make install
$ gphoto2 -a
Abilities for camera             : SONY Xperia Z Ultra MTP (ID3)
Serial port support              : no
USB support                      : yes
Capture choices                  :
                                 : Capture not supported by the driver
Configuration support            : no
Delete selected files on camera  : yes
Delete all files on camera       : no
File preview (thumbnail) support : no
File upload support              : yes

どうやらエラーはなさそうですので、期待が持てそうです。 lsに相当することをしてみます。


$ gphoto2 -L
There is no file in folder '/'.
There are 2 files in folder '/store_00010001'.
#1     customized-capability.xml  rd     1 KB application/x-unknown
#2     default-capability.xml     rd     2 KB application/x-unknown
There is 1 file in folder '/store_00010001/.HhTjqSRo6dybqDAV2ImUSREmnZU='.
#3     .nomedia                   rd     1 KB application/x-unknown
There is no file in folder '/store_00010001/.android'.
There is 1 file in folder '/store_00010001/.android/.secure'.
#4     925bee4023f985f3c92c620ced45ca4700aa188drd     1 KB application/x-unknown
(snip)
#918   track77.cdda.wav.mp3       rd   590 KB audio/mpeg
#919   track78.cdda.wav.mp3       rd   634 KB audio/mpeg
#920   track79.cdda.wav.mp3       rd   704 KB audio/mpeg
#921   track80.cdda.wav.mp3       rd   603 KB audio/mpeg
#922   track81.cdda.wav.mp3       rd   835 KB audio/mpeg

複数回繰り返しても、2回目以降エラーになることもないようです。 次にファイルを取り出してみます。最後のファイル#922を取り出してみます。


$ gphoto2 -p 922
Saving file as track81.cdda.wav.mp3

なぜかXperia Z Ultraを操作中には、成功するようです。 そのまま置いておくと、失敗しました。 mtools的な操作で、機動性には欠けますが、MTPでしか接続できないデバイスからも無事にファイルを取得できそうです。

今後の課題

FUSEを使ってmountできるようになれば便利そうですが、MTPはそもそもPOSIXがファイルシステムへ要求する仕様を満足していないそうですので、あまり使いやすくないかもしれません。

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。

plgarc/wip/llama.cppでpkgsrcのBLASサポートを探る

この記事は、 NetBSD Advent Calendar 2024 の13日目の記事です。 llama.cppを使ってみる 以前に、 NetBSD/amd64でllama.cppを使ってみる という記事で llama.cpp を使ってみていました。 あれか...