Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1551747

Summary: Can't read gvfs/gphoto2 filesystem: Error: Failed to get folder list: -1: Unspecified error
Product: Red Hat Enterprise Linux 7 Reporter: Michael Mráka <mmraka>
Component: libgphoto2Assignee: Josef Ridky <jridky>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.5CC: dmardones, gerrit.slomma, jkoten, jkucera, mattias.ohlsson, mmraka, ovasik, riehecky, toracat, tpelka
Target Milestone: rcKeywords: Patch, Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libgphoto2-2.5.15-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-06 13:03:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
debug logfile
none
gphoto2 debug log file
none
debug from working version none

Description Michael Mráka 2018-03-05 21:33:16 UTC
Description of problem:
Digital camera connected via gvfs-gphoto2 no more works.

Version-Release number of selected component (if applicable):
gvfs-gphoto2.x86_64 0:1.30.4-5.el7
libgphoto2.x86_64 0:2.5.15-1.el7

How reproducible:
Always.

Steps to Reproduce:
1. connect a camera providing MTP interface via usb
2. gvfs-ls /run/user/1000/gvfs/gphoto2:host=%5Busb%3A001%2C008%5D/store_deadbeef/DCIM/
3. (same error message pops up in nautilus)

Actual results:
$ gvfs-ls /run/user/1000/gvfs/gphoto2:host=%5Busb%3A001%2C008%5D/store_deadbeef/DCIM/
Error: Failed to get folder list: -1: Unspecified error

Expected results:
$ gvfs-ls /run/user/1000/gvfs/gphoto2:host=%5Busb%3A001%2C008%5D/store_deadbeef/DCIM/
126__02/
127__03/

i.e. content of directory shown.

Additional info:
dmesg show connected camera:
[  925.607955] usb 1-4.1: new high-speed USB device number 8 using xhci_hcd
[  925.696356] usb 1-4.1: New USB device found, idVendor=04a9, idProduct=329a
[  925.696365] usb 1-4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  925.696369] usb 1-4.1: Product: Canon Digital Camera
[  925.696373] usb 1-4.1: Manufacturer: Canon Inc.

Works after downgrade to RHEL 7.4 versions:
gvfs-gphoto2.x86_64 0:1.30.4-3.el7
libgphoto2.x86_64 0:2.5.2-5.el7

Comment 1 Tomas Pelka 2018-03-06 06:47:50 UTC
We updated libgphoto2 to libgphoto2-2.5.15-1.el7 in rhel7.5, would you mind checking this new version?

Note that couple of other components were updated too, see https://errata.devel.redhat.com/advisory/30790

Comment 2 Michael Mráka 2018-03-06 07:24:52 UTC
(In reply to Tomas Pelka from comment #1)
> We updated libgphoto2 to libgphoto2-2.5.15-1.el7 in rhel7.5, would you mind
> checking this new version?

This is the broken version reported in comment #0.

Comment 3 Ondrej Holy 2018-03-06 09:38:42 UTC
Nothing changed in gphoto2 backend between gvfs-gphoto2.x86_64 0:1.30.4-5.el7 and gvfs-gphoto2.x86_64 0:1.30.4-3.el7. This error comes from gp_camera_folder_list_folders, so something had to change in libgphoto2. I can't reproduce with my camera, but it is probably because it does not use folders... 

It would be good to try with gphoto2 cmd utils (see --list-folders and --debug options).

Changing component to libgphoto2.

Comment 5 Michael Mráka 2018-03-06 22:45:16 UTC
old version (libgphoto2-2.5.2-5.el7.x86_64)

$ gphoto2 --list-folders
There is 1 folder in folder '/'.                                               
 - store_00010001
There is 1 folder in folder '/store_00010001'.
 - DCIM
There are 2 folders in folder '/store_00010001/DCIM'.
 - 126___02
 - 127___03
There are 0 folders in folder '/store_00010001/DCIM/126___02'.
There are 0 folders in folder '/store_00010001/DCIM/127___03'.


new version (libgphoto2-2.5.15-1.el7.x86_64)

$ gphoto2 --list-folders
There is 1 folder in folder '/'.                                               
 - store_deadbeef
There is 1 folder in folder '/store_deadbeef'.
 - DCIM

*** Error ***              
PTP Invalid Storage ID
*** Error (-1: 'Unspecified error') ***       

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list <gphoto-devel.net>, please run
gphoto2 as follows:

    env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --list-folders

Please make sure there is sufficient quoting around the arguments.

Comment 6 Michael Mráka 2018-03-06 22:47:27 UTC
Created attachment 1405049 [details]
debug logfile

Debug info obtained using

$ env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --list-folders
There is 1 folder in folder '/'.                                               
 - store_deadbeef
There is 1 folder in folder '/store_deadbeef'.
 - DCIM

*** Error ***              
PTP Invalid Storage ID
*** Error (-1: 'Unspecified error') ***

Comment 7 Akemi Yagi 2018-06-03 22:38:12 UTC
Created attachment 1447268 [details]
gphoto2 debug log file

Comment 8 Akemi Yagi 2018-06-03 22:39:20 UTC
I'm seeing the same problem with my two Canon cameras. I have uploaded a debug file.

Comment 9 Akemi Yagi 2018-06-04 15:44:02 UTC
I have rebuilt libgphoto2 using the 2.5.17 tar file. The issue seems to be fixed in this version.

$ gphoto2 --list-folders
There is 1 folder in folder '/'.                                               
 - store_00010001
There is 1 folder in folder '/store_00010001'.
 - DCIM
There are 20 folders in folder '/store_00010001/DCIM'.
 - 124___02
 - 126___04
 - 127___05
 - 128___06
 - 129___07
etc.

Comment 10 Josef Ridky 2018-06-05 06:05:51 UTC
Thanks for it. I'll check changes between 2.5.15 and 2.5.17 and prepare patch with solution.

Comment 12 Akemi Yagi 2018-12-06 15:30:33 UTC
(In reply to Josef Ridky from comment #10)
> Thanks for it. I'll check changes between 2.5.15 and 2.5.17 and prepare
> patch with solution.

Any update on this?

I see that RHEL 8 beta has 2.5.16. I don't (yet) know if this works or not.

Comment 13 Jiri Kucera 2019-02-14 10:54:49 UTC
Hello Michael,

could you please provide also a log for successful cases? I'm curious for whats going on in
- libgphoto2-2.5.2-5.el7.x86_64
- libgphoto2 using the 2.5.17 tar file

From the inspection of the log previously attached, I am deducing that there is something wrong with the device info obtained from camera ("Supported operations:" list should not be empty).

Comment 14 Michael Mráka 2019-02-14 19:57:11 UTC
Created attachment 1534950 [details]
debug from working version

Hello Jiri,

here is the log using libgphoto2-2.5.2-5.el7.x86_64 obtained by

$ env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --list-folders
There is 1 folder in folder '/'.                                               
 - store_00010001
There is 1 folder in folder '/store_00010001'.
 - DCIM
There is 1 folder in folder '/store_00010001/DCIM'.
 - 137___01
There are 0 folders in folder '/store_00010001/DCIM/137___01'.



I don't have access to libgphoto2 2.5.17 version.

Comment 15 Jiri Kucera 2019-02-14 22:39:20 UTC
Thank you Michael!

Finally, I found it. In libgphoto2-2.5.15, the problem was that ptp_unpack_string from camlibs/ptp2/ptp-pack.c returns prematurely if the length of string is 0 and leave data to which 'len' points untouched:

https://github.com/gphoto/libgphoto2/blob/230b2433ee567676c779a7a1ac021f061288cfff/camlibs/ptp2/ptp-pack.c#L143

Since len points to an uninitialized local variable, it contains random data and hence the nonsensical device output in logs, concretely:
- in your previous log, it contains 0x1 and hence it treats the Supported operations array's size (0x42) as Functional Mode
- in Akemi Yagi's log, it contains 0x1f (if I computed it rightly), and hence the 'Functional Mode: 0x901c' (offset 0x53 from the beginning of received USB packet)

As we can see, libgphoto2-2.5.2 has no such a problem:

https://github.com/gphoto/libgphoto2/blob/21984d946125e411d72d002907c8038ba7984b74/camlibs/ptp2/ptp-pack.c#L134

Simply said, this bug has been caused by a regression introduced by refactoring of ptp_unpack_string somewhere between libgphoto2-2.5.2 and libgphoto2-2.5.15.

This patch from libgphoto2-2.5.16 should fix the problem:

https://github.com/gphoto/libgphoto2/commit/d8f6ec8c1a03572f638cfca44a2ee48cccb8c465.patch

Comment 16 Akemi Yagi 2019-02-15 01:30:40 UTC
Hi Jiri,

Thanks for identifying the patch. I applied it to libgphoto2-2.5.15 and confirm that it does fix the problem.

Comment 17 Josef Ridky 2019-02-21 10:28:14 UTC
*** Bug 1676681 has been marked as a duplicate of this bug. ***

Comment 22 errata-xmlrpc 2019-08-06 13:03:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2194