Support for <device file> option when doing --device-list
- simple-mtpfs can be used as lightweight crossplatform mtp-probe - at current state simple-mtpfs does not respect libmtp device quirks when connecting via device file. That leads to errors on some devices This issue can be workarounded now with following command: simple-mtpfs --device `simple-mtpfs <device file> -l | cut -f1 -d:` <mount point>
This commit is contained in:
parent
8a971b0ba7
commit
a924098f97
|
@ -30,7 +30,7 @@ print version
|
||||||
.SS "SIMPLE-MTPFS options:"
|
.SS "SIMPLE-MTPFS options:"
|
||||||
.TP
|
.TP
|
||||||
\fB\-l\fR \fB\-\-list\-devices\fR
|
\fB\-l\fR \fB\-\-list\-devices\fR
|
||||||
list available MTP devices
|
list available MTP devices. Supports \fB<device>\fR option
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-device\fR
|
\fB\-\-device\fR
|
||||||
select device no. to mount
|
select device no. to mount
|
||||||
|
|
|
@ -180,15 +180,16 @@ int SMTPFileSystem::SMTPFileSystemOptions::opt_proc(void *data, const char *arg,
|
||||||
SMTPFileSystemOptions *options = static_cast<SMTPFileSystemOptions*>(data);
|
SMTPFileSystemOptions *options = static_cast<SMTPFileSystemOptions*>(data);
|
||||||
|
|
||||||
if (key == FUSE_OPT_KEY_NONOPT) {
|
if (key == FUSE_OPT_KEY_NONOPT) {
|
||||||
if (options->m_mount_point && !options->m_device_file) {
|
if (options->m_mount_point && options->m_device_file) {
|
||||||
options->m_device_file = options->m_mount_point;
|
|
||||||
options->m_mount_point = nullptr;
|
|
||||||
} else if (options->m_mount_point && options->m_device_file) {
|
|
||||||
// Unknown positional argument supplied
|
// Unknown positional argument supplied
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (options->m_device_file) {
|
||||||
|
fuse_opt_add_opt(&options->m_mount_point, arg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
fuse_opt_add_opt(&options->m_mount_point, arg);
|
fuse_opt_add_opt(&options->m_device_file, arg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -287,6 +288,11 @@ bool SMTPFileSystem::parseOptions(int argc, char **argv)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_options.m_device_file && !m_options.m_mount_point) {
|
||||||
|
m_options.m_mount_point = m_options.m_device_file;
|
||||||
|
m_options.m_device_file = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_options.m_mount_point) {
|
if (!m_options.m_mount_point) {
|
||||||
logerr("Mount point missing.\n");
|
logerr("Mount point missing.\n");
|
||||||
m_options.m_good = false;
|
m_options.m_good = false;
|
||||||
|
@ -326,7 +332,7 @@ void SMTPFileSystem::printHelp() const
|
||||||
<< " -V --version print version\n\n"
|
<< " -V --version print version\n\n"
|
||||||
<< "simple-mtpfs options:\n"
|
<< "simple-mtpfs options:\n"
|
||||||
<< " -v --verbose verbose output, implies -f\n"
|
<< " -v --verbose verbose output, implies -f\n"
|
||||||
<< " -l --list-devices print available devices\n"
|
<< " -l --list-devices print available devices. Supports <source> option\n"
|
||||||
<< " --device select a device number to mount\n"
|
<< " --device select a device number to mount\n"
|
||||||
<< " -o enable-move enable the move operations\n\n";
|
<< " -o enable-move enable the move operations\n\n";
|
||||||
fuse_opt_add_arg(&args, m_args.argv[0]);
|
fuse_opt_add_arg(&args, m_args.argv[0]);
|
||||||
|
@ -350,7 +356,9 @@ void SMTPFileSystem::printVersion() const
|
||||||
|
|
||||||
bool SMTPFileSystem::listDevices() const
|
bool SMTPFileSystem::listDevices() const
|
||||||
{
|
{
|
||||||
return MTPDevice::listDevices(m_options.m_verbose);
|
const std::string dev_file = m_options.m_device_file ? m_options.m_device_file : "";
|
||||||
|
|
||||||
|
return MTPDevice::listDevices(m_options.m_verbose, dev_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMTPFileSystem::exec()
|
bool SMTPFileSystem::exec()
|
||||||
|
|
|
@ -646,10 +646,11 @@ MTPDevice::Capabilities MTPDevice::getCapabilities(const MTPDevice &device)
|
||||||
return capabilities;
|
return capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MTPDevice::listDevices(bool verbose)
|
bool MTPDevice::listDevices(bool verbose, const std::string &dev_file)
|
||||||
{
|
{
|
||||||
int raw_devices_cnt;
|
int raw_devices_cnt;
|
||||||
LIBMTP_raw_device_t *raw_devices;
|
LIBMTP_raw_device_t *raw_devices;
|
||||||
|
std::string dev_path;
|
||||||
|
|
||||||
// Do not output LIBMTP debug stuff
|
// Do not output LIBMTP debug stuff
|
||||||
StreamHelper::off();
|
StreamHelper::off();
|
||||||
|
@ -663,7 +664,18 @@ bool MTPDevice::listDevices(bool verbose)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dev_file.empty()) {
|
||||||
|
dev_path = smtpfs_realpath(dev_file);
|
||||||
|
if (dev_path.empty()) {
|
||||||
|
std::cerr << "Can not open such device '" << dev_file << "'.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < raw_devices_cnt; ++i) {
|
for (int i = 0; i < raw_devices_cnt; ++i) {
|
||||||
|
if (!dev_file.empty() &&
|
||||||
|
dev_path != smtpfs_usb_devpath(raw_devices[i].bus_location, raw_devices[i].devnum))
|
||||||
|
continue;
|
||||||
std::cout << i + 1 << ": "
|
std::cout << i + 1 << ": "
|
||||||
<< (raw_devices[i].device_entry.vendor ? raw_devices[i].device_entry.vendor : "Unknown vendor ")
|
<< (raw_devices[i].device_entry.vendor ? raw_devices[i].device_entry.vendor : "Unknown vendor ")
|
||||||
<< (raw_devices[i].device_entry.product ? raw_devices[i].device_entry.product : "Unknown product")
|
<< (raw_devices[i].device_entry.product ? raw_devices[i].device_entry.product : "Unknown product")
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
Capabilities getCapabilities() const;
|
Capabilities getCapabilities() const;
|
||||||
|
|
||||||
static bool listDevices(bool verbose = false);
|
static bool listDevices(bool verbose, const std::string &dev_file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void criticalEnter() { m_device_mutex.lock(); }
|
void criticalEnter() { m_device_mutex.lock(); }
|
||||||
|
|
Loading…
Reference in New Issue