File seek from end #967
Replies: 2 comments 1 reply
-
For now just running an async statx on file open, but would love to see some seeking APIs in io_uring :) |
Beta Was this translation helpful? Give feedback.
-
Generally using the file position for anything doesn't make a lot of sense for an async API, where you can have multiple IOs inflight. There are obviously cases where it can make sense, depending on the use case, I'm just speaking generically here. This is why I'd be hesitant to add an lseek variant. Are you just looking for end-of-file? This is obviously also potentially racy depending on the use case, but I can see that making sense to expose. We'd just need to add an opcode for it. Ideally I'd like the stat variants to be sync-issue capable, in which case we could just use those. |
Beta Was this translation helpful? Give feedback.
-
I'm implementing a seek function that allows the user to seek in the same way as
lseek
, and came up with two possible implementations.lseek
synchronously and then proceed to use that as the offset. Though I'm a little worried as it seems like it might blockEdit: hmm seems like statx only takes file paths, which may be a little inconvenient
My program is entirely single threaded so there is no worry for synchronization.
What would you say is the best approach? Thanks.
Maybe a feature can be added to io_uring as SEEK_END -> -1 - (bytes_from_end + 1) ? It seems like the kernel uses signed long internally anyway, even though the read/write functions use u64
Beta Was this translation helpful? Give feedback.
All reactions