Skip to content

Commit

Permalink
io/uring/CoOperation: add unlink support
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Nov 28, 2024
1 parent 124137c commit ac6117e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/io/uring/CoOperation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,18 @@ CoWriteOperation::GetValue(int value) const
return value;
}

CoUnlinkOperation::CoUnlinkOperation(struct io_uring_sqe &sqe,
const char *path,
int flags) noexcept
{
io_uring_prep_unlink(&sqe, path, flags);
}

CoUnlinkOperation::CoUnlinkOperation(struct io_uring_sqe &sqe,
FileDescriptor directory_fd, const char *path,
int flags) noexcept
{
io_uring_prep_unlinkat(&sqe, directory_fd.Get(), path, flags);
}

} // namespace Uring
23 changes: 23 additions & 0 deletions src/io/uring/CoOperation.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,27 @@ public:

using CoWrite = CoOperation<CoWriteOperation>;

/**
* Performs the unlink() or unlinkat() system call.
*
* @return 0 on success or a negative errno value on error (no
* exceptions thrown on error)
*/
class CoUnlinkOperation final {
public:
CoUnlinkOperation(struct io_uring_sqe &sqe,
const char *path,
int flags=0) noexcept;

CoUnlinkOperation(struct io_uring_sqe &sqe,
FileDescriptor directory_fd, const char *path,
int flags=0) noexcept;

int GetValue(int value) const noexcept {
return value;
}
};

using CoUnlink = CoOperation<CoUnlinkOperation>;

} // namespace Uring

0 comments on commit ac6117e

Please sign in to comment.