Linux Assemblycollection of fast libraries

File system calls

The file is the most basic and fundamental abstraction in Linux. Linux follows the everything-is-a-file philosophy. Consequently, much interaction transpires via filesystem system calls such as reading of and writing to files, even when the object in question is not what you would consider your everyday file.

In order to be accessed, a file must first be opened. Files can be opened for reading, writing, or both. An open file is referenced via a unique descriptor, a mapping from the metadata associated with the open file back to the specific file itself. Inside the Linux kernel, this descriptor is handled by an integer (of the C type int) called the file descriptor, abbreviated fd. File descriptors are shared with user space, and are used directly by user programs to access files. A large part of Linux system programming consists of opening, manipulating, closing, and otherwise using file descriptors.

Contents

Tip: For detailed information about each system call please read: Linux man pages

File operations

SyscallNumberDescription
CLOSE3Close a file descriptor
CREAT85Open and possibly create a file
OPEN2Open and possibly create a file
OPENAT257Open and possibly create a file relative to a directory file descriptor
NAME_TO_HANDLE_AT303Obtain handle for a pathname
OPEN_BY_HANDLE_AT304Open file via a handle
MEMFD_CREATE319Сreate an anonymous file
MKNOD133Create a special or ordinary file
MKNODAT259Create a special or ordinary file relative to a directory file descriptor
RENAME82Rename a file
RENAMEAT264Rename a file relative to directory file descriptors
RENAMEAT316Rename a file relative to directory file descriptors
TRUNCATE76Truncate a file to a specified length
FTRUNCATE77Truncate a file to a specified length
FALLOCATE285Manipulate file space

Directory operations

SyscallNumberDescription
MKDIR83Create a directory
MKDIRAT258Create a directory relative to a directory file descriptor
RMDIR84Delete a directory
GETCWD79Get current working directory
CHDIR80Change working directory
FCHDIR81Change working directory
CHROOT161Change root directory
GETDENTS78Get directory entries
GETDENTS64217Get directory entries
LOOKUP_DCOOKIE212Return a directory entry's path

Link operations

SyscallNumberDescription
LINK86Create a hard link to a file
LINKAT265Create a hard link to a file relative to directory file descriptors
SYMLINK88Create a symbolic link to a file
SYMLINKAT266Create a symbolic link to a file relative to a directory file descriptor
UNLINK87Delete a name and possibly the file it refers to
UNLINKAT263Delete a name and possibly the file it refers to relative to a directory file descriptor
READLINK89Read value of a symbolic link
READLINKAT267Read value of a symbolic link relative to a directory file descriptor

Basic file attributes

SyscallNumberDescription
UMASK95Set file mode creation mask
STAT4Get file metadata
LSTAT6Get link metadata
FSTAT5Get file metadata
FSTATAT262Get file metadata relative to a directory file descriptor
CHMOD90Change permissions of a file
FCHMOD91Change permissions of a file
FCHMODAT268Change permissions of a file relative to a directory file descriptor
CHOWN92Change ownership of a file
LCHOWN94Change ownership of a link
FCHOWN93Change ownership of a file
FCHOWNAT260Change ownership of a file relative to a directory file descriptor
UTIME132Change file last access and modification times
UTIMES235Change file last access and modification times
FUTIMESAT261Change timestamps of a file relative to a directory file descriptor
UTIMENSAT280Change file timestamps with nanosecond precision
ACCESS21Check real user's permissions for a file
FACCESSAT269Check real user's permissions for a file relative to a directory file descriptor

Extended file attributes

SyscallNumberDescription
SETXATTR188Set an extended attribute value
LSETXATTR189Set an extended attribute value
FSETXATTR190Set an extended attribute value
GETXATTR191Retrieve an extended attribute value
LGETXATTR192Retrieve an extended attribute value
FGETXATTR193Retrieve an extended attribute value
LISTXATTR194List extended attribute names
LLISTXATTR195List extended attribute names
FLISTXATTR196List extended attribute names
REMOVEXATTR197Remove an extended attribute
LREMOVEXATTR198Remove an extended attribute
FREMOVEXATTR199Remove an extended attribute

File descriptor manipulations

SyscallNumberDescription
IOCTL16Control device
FCNTL72Manipulate file descriptor
DUP32Duplicate a file descriptor
DUP233Duplicate a file descriptor
DUP3292Duplicate a file descriptor
FLOCK73Apply or remove an advisory lock on an open file

Read/Write

SyscallNumberDescription
READ0Read from a file descriptor
READV19Read data into multiple buffers
PREAD17Read from a file descriptor at a given offset
PREADV295Read data into multiple buffers
WRITE1Write to a file descriptor
WRITEV20Write data into multiple buffers
PWRITE18Write to a file descriptor at a given offset
PWRITEV296Write data into multiple buffers
LSEEK8Reposition read/write file offset
SENDFILE40Transfer data between file descriptors

Synchronized I/O

SyscallNumberDescription
FDATASYNC75Synchronize a file's in-core state with storage device
FSYNC74Synchronize a file's in-core state with storage device
MSYNC26Synchronize a file with a memory map
SYNC_FILE_RANGE277Sync a file segment with disk
SYNC162Commit buffer cache to disk
SYNCFS306Commit buffer cache to disk

Asynchronous I/O

SyscallNumberDescription
IO_SETUP206Create an asynchronous I/O context
IO_DESTROY207Destroy an asynchronous I/O context
IO_SUBMIT209Submit asynchronous I/O blocks for processing
IO_CANCEL210Cancel an outstanding asynchronous I/O operation
IO_GETEVENTS208Read asynchronous I/O events from the completion queue

Multiplexed I/O

SyscallNumberDescription
SELECT23Synchronous I/O multiplexing
PSELECT6270Synchronous I/O multiplexing
POLL7Wait for some event on a file descriptor
PPOLL271Wait for some event on a file descriptor
EPOLL_CREATE213Open an epoll file descriptor
EPOLL_CREATE1291Open an epoll file descriptor
EPOLL_CTL233Control interface for an epoll descriptor
EPOLL_WAIT232Wait for an I/O event on an epoll file descriptor
EPOLL_PWAIT281Wait for an I/O event on an epoll file descriptor

Monitoring file events

SyscallNumberDescription
INOTIFY_INIT253Initialize an inotify instance
INOTIFY_INIT1294Initialize an inotify instance
INOTIFY_ADD_WATCH254Add a watch to an initialized inotify instance
INOTIFY_RM_WATCH255Remove an existing watch from an inotify instance
FANOTIFY_INIT300Create and initialize fanotify group
FANOTIFY_MARK301Add, remove, or modify an fanotify mark on a filesystem object

Miscellaneous

SyscallNumberDescription
FADVISE64221Predeclare an access pattern for file data
READAHEAD187Perform file readahead into page cache
GETRANDOM318Obtain a series of random bytes
Copyright 2012-2018 Jack Black. All rights reserved.