Is `File::lock` really unsupported on Android?

I was gathering information for an error in uv on Termux, Android (as in astral-sh/uv#16707):

error: failed to lock `/data/data/com.termux/file/home/.local/share/uv/tools/.lock`: lock() not supported

I think it may rise from this function call in uv:

However, it is surprising to me that Android has no support for File::lock.

There are reports that some Android 14 or above doesn't support flock syscall (however all my devices support it), but a fcntl with param F_SETLKW seems work. As in etcd-io/bbolt#558 and etcd-io/bbolt#571, although this is a Golang library using syscall package.

Just a question, why is Android considered unsupported in File::lock implementation? Is it possible to support it in the future?

It's a relatively new function, so the implementation is probably just unfinished.

You could help by submitting a PR to the standard library.

5 Likes

In short it's unsupported because nobody has added support for it yet. If you'd like to help then there's an issue open: `File::lock` does not work on Android · Issue #148325 · rust-lang/rust · GitHub

1 Like