Linux file operations written in pure x86_64 assembly with a C interface as a Shared-Library.
Designed for performance-critical applications that need direct I/O (O_DIRECT), synchronized writes (O_DSYNC).
- Pure x86_64 assembly implementation — minimal overhead, full syscall ABI control
- EINTR-safe — all operations correctly handle interrupted syscalls (except
close, which follows modern best practices) - Direct I/O ready — proper alignment handling via
fpathconf(_PC_REC_XFER_ALIGN) - Zero-copy / low-level focus —
io_pread/io_pwritewith partial-transfer retry loops
# Use the convenience script in the root folder:
sh ./io_make.sh
# Or use make in the individual folders
cd ./io/id
make clean; make # builds libio.so
cd ../demo
make clean; make # builds the demo binarycd ./demo
./go_demo.shThe demo creates ./out.txt (containing 10,000 integers (0–9999) stored in fixed 16-byte records) using O_CREAT | O_DIRECT | O_RDWR | O_DSYNC | O_TRUNC, then re-opens the file and reads the data back.
All functions are declared in io/io.h:
int io_close(int fd);
int io_creat(const char *path, int flags, mode_t mode);
int io_data_sync(int fd);
off_t io_lseek (int fd, off_t offset, int whence);
int io_open(const char *path, int flags);
ssize_t io_pread(int fd, void *buf, size_t nbyte, off_t offset);
ssize_t io_pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
ssize_t io_read(int fd, void *buf, size_t nbyte);
int io_sync(int fd);
ssize_t io_write(int fd, const void *buf, size_t nbyte);- io_creat uses the open syscall (more flexible than the legacy creat syscall)
- io_pread / io_pwrite / io_read / io_write automatically retry on partial transfers and handle EINTR
- io_pwrite and io_write treat a zero-byte return from pwrite64 or write as an error (EIO)
- io_close does not retry on EINTR (modern Linux best practice to avoid fd-reuse races)