MTP
MTP copied to clipboard
Fix integer truncation in OpenFileByIndex due to change in sdfat library
This pull request doesn't seem to make a lot of sense: oflag_t
is a typedef to int
/uint8_t
within FatApiConstants.h
Am I missing something @wolfmanjm ? Can you provide an example of the truncation behavior? If somehow this is the case it would require also including <fcntl.h>
as far as I can tell.
o_flag_t is not a uint_t in certain cases (https://github.com/greiman/SdFat/blob/master/src/FatLib/FatApiConstants.h#L29) if USE_FCNTL_H is not defined it is 32bits. In the case of a newlib system it is 32 bits not 8 bits, and if coded to 8 bits will truncate the flag from the 32 bit definition to 8 bits causing it to not work as expected. Using this typedef fixes the issue in all cases. The issue was noted here and I ran into the same issue. https://forum.pjrc.com/threads/43050-MTP-Responder-Contribution?p=199532&viewfull=1#post199532
Hi guys, I wasn't able to copy a new file in the mounted SD (the file seems copied but size was 0)... after applying this fix it works fine. Hope it will be merged on master.
Thanks!
This patch is necessary for MTP to work in Ubuntu 18.04.
Thank you Wolfmanjm.