cccl icon indicating copy to clipboard operation
cccl copied to clipboard

[BUG]: cuFile open_mode() loses read-only access on Linux

Open ylwang0701 opened this issue 6 days ago • 1 comments

Describe the bug

On Linux, cuda::experimental::cufile::open_mode() loses the input bit on a file opened read-only. This came up while checking native-handle interoperability for rapidsai/kvikio#1093. It affects the CUDA Experimental component at c5342055.

How to reproduce

On a cuFile-capable filesystem, start with an existing file:

namespace cx = cuda::experimental;
int fd = ::open(path, O_RDONLY);
auto file = cx::cufile::from_native_handle(fd);
assert(file.open_mode() == cx::cufile_open_mode::in);

The current implementation tests flags & O_RDONLY. Linux defines O_RDONLY as zero, so the call reports an empty mode. Opening with O_RDONLY | O_DIRECT reports only direct. The expected results are in and in | direct, respectively. The write-only and read-write controls return their expected modes.

Environment

Ubuntu 24.04, CUDA 13.0.88, RTX 5090, driver 580.105.08. The local regression check used real Linux file descriptors and the public CCCL API. We wrapped only cuFile handle registration and deregistration at link time because the installed GDS stack rejects registration on these mounts. The mode query itself uses the real fcntl(F_GETFL) call.

ylwang0701 avatar Nov 28 '26 00:11 ylwang0701

Hi @ylwang0701!

Thanks for submitting this issue - the CCCL team has been notified and we'll get back to you as soon as we can! In the mean time, feel free to add any relevant information to this issue.

github-actions[bot] avatar Nov 28 '26 00:11 github-actions[bot]