arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.21k stars 995 forks source link

[Android] NTFS/exFAT is unsupported: (1) Operation not permitted [write : file_open] #6687

Closed proninyaroslav closed 2 years ago

proninyaroslav commented 2 years ago

Please provide the following information

libtorrent version (or branch): master

platform/architecture: Android arm64

Initially, this problem is seen in libtorrent4j, but I think this is the upstream problem: https://github.com/aldenml/libtorrent4j/issues/201

One of the users is using NTFS as file system for SD card on Android 11, another user is using exFAT on Android 12 for SD card. Both get the same error, about halfway through download progress. It seems that exFAT has become a standard solution for SD cards in recent versions of Android (in the form of the sdfat driver), because SdCardFs is deprecated since Android 11, so this problem is quite critical.

disk error: (1) Operation not permitted [write : file_open] in file: /storage/B8CCF31FCCF2D69A/Download/***

Full log: LibreTorrent_log_11-29-2021_12-36-35.txt

arvidn commented 2 years ago

I can't tell exactly what libtorrent alert that corresponds to. Presumably file_error_alert with EPERM as the error. But is that a write or a file_open operation? Is it perhaps opening the file for writing?

Either case, it's not clear what libtorrent can do about this. If the operating system says you don't have permission to open this file, what fallback behavior would you suggest, other than stopping the torrent?

proninyaroslav commented 2 years ago

Do you mean that the system doesn't give permission to write? Write permission is checked for the selected directory before uploading. Probably, the app had the write permission to this folder.

arvidn commented 2 years ago

right, that's the mystery. Sometimes with new/unstable drivers and filesystems they may be missing features or return failures at unexpected times. You could strace the process to really get the full details.

proninyaroslav commented 2 years ago

Yes, this seems to be a bug on the Android Framework side. The system gives incorrect information about the write permission.