io_uring/fs.c
Source file repositories/reference/linux-study-clean/io_uring/fs.c
File Facts
- System
- Linux kernel
- Corpus path
io_uring/fs.c- Extension
.c- Size
- 7506 bytes
- Lines
- 306
- Domain
- Kernel Services
- Bucket
- io_uring
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/errno.hlinux/fs.hlinux/file.hlinux/mm.hlinux/slab.hlinux/namei.hlinux/io_uring.huapi/linux/io_uring.h../fs/internal.hio_uring.hfs.h
Detected Declarations
struct io_renamestruct io_unlinkstruct io_mkdirstruct io_linkfunction io_renameat_prepfunction io_renameatfunction io_renameat_cleanupfunction io_unlinkat_prepfunction io_unlinkatfunction io_unlinkat_cleanupfunction io_mkdirat_prepfunction io_mkdiratfunction io_mkdirat_cleanupfunction io_symlinkat_prepfunction io_symlinkatfunction io_linkat_prepfunction io_linkatfunction io_link_cleanup
Annotated Snippet
struct io_rename {
struct file *file;
int old_dfd;
int new_dfd;
struct delayed_filename oldpath;
struct delayed_filename newpath;
int flags;
};
struct io_unlink {
struct file *file;
int dfd;
int flags;
struct delayed_filename filename;
};
struct io_mkdir {
struct file *file;
int dfd;
umode_t mode;
struct delayed_filename filename;
};
struct io_link {
struct file *file;
int old_dfd;
int new_dfd;
struct delayed_filename oldpath;
struct delayed_filename newpath;
int flags;
};
int io_renameat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{
struct io_rename *ren = io_kiocb_to_cmd(req, struct io_rename);
const char __user *oldf, *newf;
int err;
if (sqe->buf_index || sqe->splice_fd_in)
return -EINVAL;
if (unlikely(req->flags & REQ_F_FIXED_FILE))
return -EBADF;
ren->old_dfd = READ_ONCE(sqe->fd);
oldf = u64_to_user_ptr(READ_ONCE(sqe->addr));
newf = u64_to_user_ptr(READ_ONCE(sqe->addr2));
ren->new_dfd = READ_ONCE(sqe->len);
ren->flags = READ_ONCE(sqe->rename_flags);
err = delayed_getname(&ren->oldpath, oldf);
if (unlikely(err))
return err;
err = delayed_getname(&ren->newpath, newf);
if (unlikely(err)) {
dismiss_delayed_filename(&ren->oldpath);
return err;
}
req->flags |= REQ_F_NEED_CLEANUP;
req->flags |= REQ_F_FORCE_ASYNC;
return 0;
}
int io_renameat(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_rename *ren = io_kiocb_to_cmd(req, struct io_rename);
CLASS(filename_complete_delayed, old)(&ren->oldpath);
CLASS(filename_complete_delayed, new)(&ren->newpath);
int ret;
WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK);
ret = filename_renameat2(ren->old_dfd, old,
ren->new_dfd, new, ren->flags);
req->flags &= ~REQ_F_NEED_CLEANUP;
io_req_set_res(req, ret, 0);
return IOU_COMPLETE;
}
void io_renameat_cleanup(struct io_kiocb *req)
{
struct io_rename *ren = io_kiocb_to_cmd(req, struct io_rename);
dismiss_delayed_filename(&ren->oldpath);
dismiss_delayed_filename(&ren->newpath);
}
int io_unlinkat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/fs.h`, `linux/file.h`, `linux/mm.h`, `linux/slab.h`, `linux/namei.h`, `linux/io_uring.h`.
- Detected declarations: `struct io_rename`, `struct io_unlink`, `struct io_mkdir`, `struct io_link`, `function io_renameat_prep`, `function io_renameat`, `function io_renameat_cleanup`, `function io_unlinkat_prep`, `function io_unlinkat`, `function io_unlinkat_cleanup`.
- Atlas domain: Kernel Services / io_uring.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.