Skip to content

Commit

Permalink
Report the proper open status for the uring driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Mar 16, 2023
1 parent 304cf51 commit d7650d7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion source/eventcore/drivers/posix/io_uring/files.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import eventcore.internal.utils;

import eventcore.driver;
import eventcore.drivers.posix.io_uring.io_uring;
import core.stdc.errno;
import core.sys.posix.sys.types;
import core.sys.posix.sys.stat;
import core.sys.linux.fcntl;
Expand Down Expand Up @@ -77,7 +78,18 @@ final class UringDriverFiles : EventDriverFiles
FileOpenCallback cb = cast(FileOpenCallback) userCb;
if (e.res == -1)
{
cb(FileFD.init, OpenStatus.failed);
OpenStatus status;
switch (errno) {
default: status = OpenStatus.failed; break;
case ENOENT: status = OpenStatus.notFound; break;
case EACCES: status = OpenStatus.notAccessible; break;
case EBUSY: status = OpenStatus.sharingViolation; break;
static if (is(typeof(ETXTBSY))) {
case ETXTBSY: status = OpenStatus.sharingViolation; break;
}
case EEXIST: status = OpenStatus.alreadyExists; break;
}
cb(FileFD.init, status);
return;
}
FileFD fileFD = adopt(e.res);
Expand Down

0 comments on commit d7650d7

Please sign in to comment.