|
AquilaOS documentation
How it works, and its code
|
System calls on files: opening, reading and writing them, their names and attributes, directories, links, mounts and locks. More...
#include "syscalls.h"Go to the source code of this file.
Macros | |
| #define | F_OK 0 |
| #define | X_OK 1 |
| #define | W_OK 2 |
| #define | R_OK 4 |
Functions | |
| static int | at_uio (int dirfd, const char *path, struct uio *uio) |
| Sets up the uio to look up path from the directory that dirfd refers to, or from the working directory for AT_FDCWD. | |
| static int | at_path (int dirfd, const char *upath, char **path, struct uio *uio) |
| Copies a path into the kernel (*path, which the caller frees) and sets up the uio to look it up from dirfd, for the calls that take two paths. | |
| static int | at_lookup (int dirfd, const char *upath, int flags, struct uio *uio, struct vnode **vnode) |
| Looks up a path from user memory, from dirfd; with AT_SYMLINK_NOFOLLOW in flags, a final symbolic link isn't followed. | |
| long | sys_close (int fildes) |
| Implements close(): frees a descriptor. | |
| long | sys_fstat (int fildes, struct aquila_stat *buf) |
| Implements fstat(): an open file's attributes. | |
| long | sys_isatty (int fildes) |
| Says whether a descriptor refers to a character device, the only kind of file that can be a terminal. | |
| static int | do_linkat (int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) |
| Makes a link, for link() and linkat(). | |
| long | sys_link (const char *oldpath, const char *newpath) |
| Implements link(): a new name for a file. | |
| long | sys_linkat (int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) |
| Implements linkat(): link(), with paths relative to directories. | |
| long | sys_lseek (int fildes, off_t offset, int whence) |
| Implements lseek(): moves an open file's offset. | |
| static int | creat_path (const char *path, struct uio *uio, char **ref) |
| Finds what O_CREAT should create for path: if path is a dangling symbolic link, the file it points to, through links to links. | |
| static int | do_openat (int dirfd, const char *upath, int oflags, mode_t mode) |
| Opens (or creates) a file on a new descriptor, for open() and openat(). | |
| long | sys_open (const char *path, int oflags, mode_t mode) |
| Implements open(): opens a file on a new descriptor, creating it with O_CREAT. | |
| long | sys_openat (int dirfd, const char *path, int oflags, mode_t mode) |
| Implements openat(): open(), with the path relative to a directory. | |
| long | sys_read (int fildes, void *buf, size_t nbytes) |
| Implements read(). | |
| static int | do_fstatat (int dirfd, const char *path, struct aquila_stat *buf, int flags) |
| Gets a file's attributes, for the stat() calls. | |
| long | sys_stat (const char *path, struct aquila_stat *buf) |
| Implements stat(): a file's attributes, following a symbolic link. | |
| long | sys_fstatat (int dirfd, const char *path, struct aquila_stat *buf, int flags) |
| Implements fstatat(): stat(), with the path relative to a directory. | |
| static int | do_unlinkat (int dirfd, const char *upath, int flags) |
| Removes a name, or a directory with AT_REMOVEDIR, for unlink(), unlinkat() and rmdir(). | |
| long | sys_unlink (const char *path) |
| Implements unlink(): removes a name of a file (not a directory's). | |
| long | sys_unlinkat (int dirfd, const char *path, int flags) |
| Implements unlinkat(): unlink(), or rmdir() with AT_REMOVEDIR, with the path relative to a directory. | |
| long | sys_write (int fd, void *buf, size_t nbytes) |
| Implements write(). | |
| long | sys_ioctl (int fd, int request, void *argp) |
| Implements ioctl(): a device's, a socket's, or a terminal's request. | |
| long | sys_readdir (int fd, struct dirent *dirent) |
| Reads a directory's next entry, for the C library's readdir(). | |
| long | sys_mount (struct aquila_mount_args *args) |
| Implements mount(): mounts a file system on a directory. | |
| static int | do_mknodat (int dirfd, const char *upath, mode_t mode, dev_t dev) |
| Makes a file of any type, for mknod(), mknodat() and mkdir(). | |
| long | sys_mkdir (const char *path, mode_t mode) |
| Implements mkdir(): makes a directory. | |
| long | sys_pipe (int fd[2]) |
| Implements pipe(): makes a pipe, its read end and its write end open on two new descriptors. | |
| long | sys_fcntl (int fd, int cmd, uintptr_t arg) |
| Implements fcntl(): duplicates a descriptor, or reads and sets the descriptor's flags (FD_CLOEXEC) or the open file's status flags. | |
| static int | cwd_set (struct vnode *vnode) |
| Makes vnode the working directory, if it is a directory the process may search. | |
| long | sys_chdir (const char *upath) |
| Implements chdir(): changes the working directory. | |
| long | sys_getcwd (char *buf, size_t size) |
| Implements getcwd(): the working directory's path. | |
| long | sys_mknod (const char *path, uint32_t mode, uint32_t dev) |
| Implements mknod(): makes a file, a directory, a FIFO, or (only root) a device file. | |
| long | sys_mknodat (int dirfd, const char *path, uint32_t mode, uint32_t dev) |
| Implements mknodat(): mknod(), with the path relative to a directory. | |
| long | sys_lstat (const char *path, struct aquila_stat *buf) |
| Implements lstat(): a file's attributes, a symbolic link's own. | |
| long | sys_ftruncate (int fildes, off_t len) |
| Implements ftruncate(): sets an open file's size. | |
| long | sys_umask (mode_t mask) |
| Implements umask(): sets the permissions that new files don't get. | |
| static int | do_fchmodat (int dirfd, const char *path, mode_t mode, int flags) |
| Changes a file's permissions, for chmod() and fchmodat(). | |
| long | sys_chmod (const char *path, mode_t mode) |
| Implements chmod(): changes a file's permissions. | |
| long | sys_fchmodat (int dirfd, const char *path, mode_t mode, int flags) |
| Implements fchmodat(): chmod(), with the path relative to a directory. | |
| static struct vnode * | fd_vnode (int fd, int *err) |
| Returns the vnode of an open file, or NULL with *err set (-EBADF, or -EINVAL for a socket). | |
| long | sys_fchmod (int fd, mode_t mode) |
| Implements fchmod(): changes an open file's permissions. | |
| static int | do_faccessat (int dirfd, const char *path, int mode, int flags) |
| Checks a file's permissions, for access() and faccessat(). | |
| long | sys_access (const char *path, int mode) |
| Implements access(): says whether the process may read, write or execute a file. | |
| long | sys_faccessat (int dirfd, const char *path, int mode, int flags) |
| Implements faccessat(): access(), with the path relative to a directory. | |
| static int | do_fchownat (int dirfd, const char *path, uid_t owner, gid_t group, int flags) |
| Changes a file's owner and group, for the chown() calls. | |
| long | sys_chown (const char *path, uid_t owner, gid_t group) |
| Implements chown(): changes a file's owner and group. | |
| long | sys_fchownat (int dirfd, const char *path, uid_t owner, gid_t group, int flags) |
| Implements fchownat(): chown(), with the path relative to a directory. | |
| long | sys_fchown (int fd, uid_t owner, gid_t group) |
| Implements fchown(): changes an open file's owner and group. | |
| long | sys_lchown (const char *path, uid_t owner, gid_t group) |
| Implements lchown(): chown() of a symbolic link itself. | |
| long | sys_utimensat (int dirfd, const char *path, const struct aquila_timespec times[2], int flags) |
| Implements utimensat() (and futimens()): sets a file's access and modification times. | |
| long | sys_rmdir (const char *path) |
| Implements rmdir(): removes an empty directory. | |
| long | sys_symlinkat (const char *utarget, int dirfd, const char *upath) |
| Implements symlinkat(): makes a symbolic link. | |
| long | sys_readlinkat (int dirfd, const char *upath, char *buf, size_t size) |
| Implements readlinkat(): what a symbolic link points to (not NUL-terminated). | |
| long | sys_renameat (int olddirfd, const char *oldpath, int newdirfd, const char *newpath) |
| Implements renameat() (and rename()): moves a file to another name, replacing what was there. | |
| long | sys_flock (int fd, int op) |
| Implements flock(): takes or releases an advisory lock on an open file. | |
| long | sys_sync (void) |
| Implements sync(): writes out what the devices' caches hold. | |
| long | sys_fchdir (int fd) |
| Implements fchdir(): changes the working directory to an open directory. | |
System calls on files: opening, reading and writing them, their names and attributes, directories, links, mounts and locks.
The *at() calls take paths relative to a directory descriptor, and the older calls are the same with AT_FDCWD, the working directory. Paths are copied into the kernel first (upath_get()); the work is the VFS's (fs/).
Definition in file sys_file.c.
| #define F_OK 0 |
Definition at line 1185 of file sys_file.c.
| #define R_OK 4 |
Definition at line 1188 of file sys_file.c.
Referenced by do_faccessat().
| #define W_OK 2 |
Definition at line 1187 of file sys_file.c.
Referenced by do_faccessat().
| #define X_OK 1 |
Definition at line 1186 of file sys_file.c.
Referenced by do_faccessat().
|
static |
Looks up a path from user memory, from dirfd; with AT_SYMLINK_NOFOLLOW in flags, a final symbolic link isn't followed.
Returns 0 or a negative errno.
Definition at line 60 of file sys_file.c.
References at_lookup(), at_uio(), file::flags, uio::flags, kfree(), upath_get(), and vfs_lookup().
Referenced by at_lookup(), do_faccessat(), do_fchmodat(), do_fchownat(), do_fstatat(), and sys_utimensat().
|
static |
Copies a path into the kernel (*path, which the caller frees) and sets up the uio to look it up from dirfd, for the calls that take two paths.
Returns 0 or a negative errno.
Definition at line 42 of file sys_file.c.
References at_path(), at_uio(), kfree(), NULL, and upath_get().
Referenced by at_path(), do_linkat(), and sys_renameat().
|
static |
Sets up the uio to look up path from the directory that dirfd refers to, or from the working directory for AT_FDCWD.
An absolute path ignores dirfd. Returns 0, -EBADF, or -ENOTDIR.
Definition at line 18 of file sys_file.c.
References at_uio(), curproc, uio::cwd, fd_file(), FILE_SOCKET, file::flags, and PROC_UIO.
Referenced by at_lookup(), at_path(), at_uio(), do_mknodat(), do_openat(), do_unlinkat(), sys_readlinkat(), and sys_symlinkat().
|
static |
Finds what O_CREAT should create for path: if path is a dangling symbolic link, the file it points to, through links to links.
Sets *ref to that path (which the caller frees), or to NULL for path itself. Returns 0, -EEXIST if path exists, -ELOOP, or another negative errno.
Definition at line 248 of file sys_file.c.
References creat_path(), uio::flags, kfree(), kmalloc(), memcpy(), vnode::mode, NULL, vnode::p, vnode::ref, vfs_close(), vfs_lookup(), and vfs_readlink().
Referenced by creat_path(), and do_openat().
|
static |
Makes vnode the working directory, if it is a directory the process may search.
On success, the caller's reference to it becomes the process's. Returns 0, -ENOTDIR or -EACCES.
Definition at line 933 of file sys_file.c.
References curproc, cwd_set(), vnode::mode, PROC_UIO, vfs_access(), vfs_close(), and VFS_X.
Referenced by cwd_set(), sys_chdir(), and sys_fchdir().
|
static |
Checks a file's permissions, for access() and faccessat().
Returns 0 or a negative errno.
Definition at line 1192 of file sys_file.c.
References at_lookup(), do_faccessat(), uio::flags, NULL, R_OK, vfs_access(), vfs_close(), VFS_R, VFS_W, VFS_X, W_OK, and X_OK.
Referenced by do_faccessat(), sys_access(), and sys_faccessat().
|
static |
Changes a file's permissions, for chmod() and fchmodat().
Returns 0 or a negative errno.
Definition at line 1101 of file sys_file.c.
References at_lookup(), do_fchmodat(), uio::flags, NULL, vfs_chmod(), and vfs_close().
Referenced by do_fchmodat(), sys_chmod(), and sys_fchmodat().
Changes a file's owner and group, for the chown() calls.
Returns 0 or a negative errno.
Definition at line 1244 of file sys_file.c.
References at_lookup(), do_fchownat(), uio::flags, NULL, vfs_chown(), and vfs_close().
Referenced by do_fchownat(), sys_chown(), sys_fchownat(), and sys_lchown().
|
static |
Gets a file's attributes, for the stat() calls.
Returns 0 or a negative errno.
Definition at line 477 of file sys_file.c.
References at_lookup(), do_fstatat(), uio::flags, memset(), NULL, vfs_close(), and vfs_stat().
Referenced by do_fstatat(), sys_fstatat(), sys_lstat(), and sys_stat().
|
static |
Makes a link, for link() and linkat().
Returns 0 or a negative errno.
Definition at line 157 of file sys_file.c.
References at_path(), do_linkat(), uio::flags, kfree(), NULL, and vfs_link().
Referenced by do_linkat(), sys_link(), and sys_linkat().
Makes a file of any type, for mknod(), mknodat() and mkdir().
Returns 0 or a negative errno.
Definition at line 754 of file sys_file.c.
References at_uio(), curproc, do_mknodat(), kfree(), NULL, upath_get(), and vfs_mknod().
Referenced by do_mknodat(), sys_mkdir(), sys_mknod(), and sys_mknodat().
|
static |
Opens (or creates) a file on a new descriptor, for open() and openat().
Returns the descriptor or a negative errno.
Definition at line 311 of file sys_file.c.
References at_uio(), creat_path(), curproc, do_openat(), file_new(), file::flags, uio::flags, kfree(), vnode::mode, NULL, proc_fd_get(), proc_fd_install(), proc_fd_release(), upath_get(), vfs_close(), vfs_creat(), vfs_file_open(), vfs_lookup(), and vfs_perms_check().
Referenced by do_openat(), sys_open(), and sys_openat().
|
static |
Removes a name, or a directory with AT_REMOVEDIR, for unlink(), unlinkat() and rmdir().
Returns 0 or a negative errno.
Definition at line 528 of file sys_file.c.
References at_uio(), do_unlinkat(), uio::flags, kfree(), upath_get(), vfs_rmdir(), and vfs_unlink().
Referenced by do_unlinkat(), sys_rmdir(), sys_unlink(), and sys_unlinkat().
|
static |
Returns the vnode of an open file, or NULL with *err set (-EBADF, or -EINVAL for a socket).
Definition at line 1153 of file sys_file.c.
References fd_file(), fd_vnode(), FILE_SOCKET, file::flags, and NULL.
Referenced by fd_vnode(), sys_fchmod(), sys_fchown(), and sys_utimensat().
| long sys_access | ( | const char * | path, |
| int | mode ) |
Implements access(): says whether the process may read, write or execute a file.
Definition at line 1220 of file sys_file.c.
References do_faccessat(), LOG_DEBUG, and sys_access().
Referenced by sys_access().
| long sys_chdir | ( | const char * | upath | ) |
Implements chdir(): changes the working directory.
| upath | the directory's path |
Definition at line 956 of file sys_file.c.
References curproc, cwd_set(), kfree(), LOG_DEBUG, NULL, PROC_UIO, sys_chdir(), upath_get(), vfs_close(), and vfs_lookup().
Referenced by sys_chdir().
| long sys_chmod | ( | const char * | path, |
| mode_t | mode ) |
Implements chmod(): changes a file's permissions.
| path | the file's path |
| mode | the new permissions |
Definition at line 1129 of file sys_file.c.
References do_fchmodat(), LOG_DEBUG, and sys_chmod().
Referenced by sys_chmod().
Implements chown(): changes a file's owner and group.
| path | the file's path |
| owner | the new owner, or -1 to keep it |
| group | the new group, or -1 to keep it |
Definition at line 1269 of file sys_file.c.
References do_fchownat(), LOG_DEBUG, and sys_chown().
Referenced by sys_chown().
| long sys_close | ( | int | fildes | ) |
Implements close(): frees a descriptor.
The open file is closed once nothing else refers to it (another descriptor, or a call using it).
| fildes | the descriptor |
Definition at line 86 of file sys_file.c.
References curproc, LOG_DEBUG, proc_fd_close(), and sys_close().
Referenced by sys_close().
| long sys_faccessat | ( | int | dirfd, |
| const char * | path, | ||
| int | mode, | ||
| int | flags ) |
Implements faccessat(): access(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| mode | F_OK, or R_OK, W_OK and X_OK together |
| flags | AT_EACCESS (which changes nothing), AT_SYMLINK_NOFOLLOW |
Definition at line 1236 of file sys_file.c.
References do_faccessat(), uio::flags, LOG_DEBUG, and sys_faccessat().
Referenced by sys_faccessat().
| long sys_fchdir | ( | int | fd | ) |
Implements fchdir(): changes the working directory to an open directory.
| fd | the directory's descriptor |
Definition at line 1523 of file sys_file.c.
References cwd_set(), fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, file::ref, sys_fchdir(), and vfs_close().
Referenced by sys_fchdir().
| long sys_fchmod | ( | int | fd, |
| mode_t | mode ) |
Implements fchmod(): changes an open file's permissions.
| fd | the descriptor |
| mode | the new permissions |
Definition at line 1172 of file sys_file.c.
References curproc, fd_vnode(), LOG_DEBUG, vnode::mode, PROC_UIO, sys_fchmod(), and vfs_chmod().
Referenced by sys_fchmod().
| long sys_fchmodat | ( | int | dirfd, |
| const char * | path, | ||
| mode_t | mode, | ||
| int | flags ) |
Implements fchmodat(): chmod(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| mode | the new permissions |
| flags | 0 (AT_SYMLINK_NOFOLLOW isn't supported) |
Definition at line 1145 of file sys_file.c.
References do_fchmodat(), uio::flags, LOG_DEBUG, and sys_fchmodat().
Referenced by sys_fchmodat().
Implements fchown(): changes an open file's owner and group.
| fd | the descriptor |
| owner | the new owner, or -1 |
| group | the new group, or -1 |
Definition at line 1301 of file sys_file.c.
References curproc, fd_vnode(), LOG_DEBUG, PROC_UIO, sys_fchown(), and vfs_chown().
Referenced by sys_fchown().
Implements fchownat(): chown(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| owner | the new owner, or -1 |
| group | the new group, or -1 |
| flags | AT_SYMLINK_NOFOLLOW for a symbolic link's own |
Definition at line 1286 of file sys_file.c.
References do_fchownat(), uio::flags, LOG_DEBUG, and sys_fchownat().
Referenced by sys_fchownat().
| long sys_fcntl | ( | int | fd, |
| int | cmd, | ||
| uintptr_t | arg ) |
Implements fcntl(): duplicates a descriptor, or reads and sets the descriptor's flags (FD_CLOEXEC) or the open file's status flags.
| fd | the descriptor |
| cmd | F_DUPFD, F_DUPFD_CLOEXEC, F_GETFD, F_SETFD, F_GETFL or F_SETFL |
| arg | the command's argument |
Definition at line 876 of file sys_file.c.
References curproc, fd_file(), FDS_COUNT, file_ref(), FILE_SOCKET, file::flags, LOG_DEBUG, proc_fd_install(), and sys_fcntl().
Referenced by sys_fcntl().
| long sys_flock | ( | int | fd, |
| int | op ) |
Implements flock(): takes or releases an advisory lock on an open file.
| fd | the descriptor |
| op | LOCK_SH, LOCK_EX or LOCK_UN, with LOCK_NB to not wait |
Definition at line 1490 of file sys_file.c.
References fd_file(), LOG_DEBUG, sys_flock(), and vfs_file_flock().
Referenced by sys_flock().
| long sys_fstat | ( | int | fildes, |
| struct aquila_stat * | buf ) |
Implements fstat(): an open file's attributes.
A socket only reports its type.
| fildes | the descriptor |
| buf | where to put them |
Definition at line 103 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, memset(), sys_fstat(), and vfs_stat().
Referenced by sys_fstat().
| long sys_fstatat | ( | int | dirfd, |
| const char * | path, | ||
| struct aquila_stat * | buf, | ||
| int | flags ) |
Implements fstatat(): stat(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| buf | where to put its attributes |
| flags | AT_SYMLINK_NOFOLLOW for a symbolic link's own |
Definition at line 520 of file sys_file.c.
References do_fstatat(), LOG_DEBUG, and sys_fstatat().
Referenced by sys_fstatat().
| long sys_ftruncate | ( | int | fildes, |
| off_t | len ) |
Implements ftruncate(): sets an open file's size.
| fildes | the descriptor, open for writing |
| len | the new size |
Definition at line 1065 of file sys_file.c.
References fd_file(), file::flags, LOG_DEBUG, sys_ftruncate(), and vfs_file_trunc().
Referenced by sys_ftruncate().
| long sys_getcwd | ( | char * | buf, |
| size_t | size ) |
Implements getcwd(): the working directory's path.
| buf | where to put it |
| size | the room at buf |
Definition at line 985 of file sys_file.c.
References curproc, kfree(), kmalloc(), LOG_DEBUG, MIN, NULL, vnode::size, sys_getcwd(), UPATH_MAX, and vfs_vnode_path().
Referenced by sys_getcwd().
| long sys_ioctl | ( | int | fd, |
| int | request, | ||
| void * | argp ) |
Implements ioctl(): a device's, a socket's, or a terminal's request.
FIONBIO, which sets the descriptor's O_NONBLOCK, works on any file.
| fd | the descriptor |
| request | the request |
| argp | its argument, in user memory |
Definition at line 622 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, socket_ioctl(), sys_ioctl(), and vfs_file_ioctl().
Referenced by sys_ioctl().
| long sys_isatty | ( | int | fildes | ) |
Says whether a descriptor refers to a character device, the only kind of file that can be a terminal.
(The C library's isatty() asks the device with TCGETS instead.)
| fildes | the descriptor |
Definition at line 137 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, and sys_isatty().
Referenced by sys_isatty().
Implements lchown(): chown() of a symbolic link itself.
| path | the link's path |
| owner | the new owner, or -1 |
| group | the new group, or -1 |
Definition at line 1322 of file sys_file.c.
References do_fchownat(), LOG_DEBUG, and sys_lchown().
Referenced by sys_lchown().
| long sys_link | ( | const char * | oldpath, |
| const char * | newpath ) |
Implements link(): a new name for a file.
| oldpath | the file's path |
| newpath | the new name |
Definition at line 188 of file sys_file.c.
References do_linkat(), LOG_DEBUG, and sys_link().
Referenced by sys_link().
| long sys_linkat | ( | int | olddirfd, |
| const char * | oldpath, | ||
| int | newdirfd, | ||
| const char * | newpath, | ||
| int | flags ) |
Implements linkat(): link(), with paths relative to directories.
| olddirfd | the directory oldpath is relative to, or AT_FDCWD |
| oldpath | the file's path |
| newdirfd | the directory newpath is relative to, or AT_FDCWD |
| newpath | the new name |
| flags | AT_SYMLINK_FOLLOW to link what a symbolic link points to |
Definition at line 205 of file sys_file.c.
References do_linkat(), uio::flags, LOG_DEBUG, and sys_linkat().
Referenced by sys_linkat().
| long sys_lseek | ( | int | fildes, |
| off_t | offset, | ||
| int | whence ) |
Implements lseek(): moves an open file's offset.
| fildes | the descriptor |
| offset | the offset |
| whence | SEEK_SET, SEEK_CUR or SEEK_END |
Definition at line 221 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, file::offset, sys_lseek(), and vfs_file_lseek().
Referenced by sys_lseek().
| long sys_lstat | ( | const char * | path, |
| struct aquila_stat * | buf ) |
Implements lstat(): a file's attributes, a symbolic link's own.
| path | the file's path |
| buf | where to put them |
Definition at line 1052 of file sys_file.c.
References do_fstatat(), LOG_DEBUG, and sys_lstat().
Referenced by sys_lstat().
| long sys_mkdir | ( | const char * | path, |
| mode_t | mode ) |
Implements mkdir(): makes a directory.
| path | its path |
| mode | its permissions (less the umask) |
Definition at line 797 of file sys_file.c.
References do_mknodat(), LOG_DEBUG, and sys_mkdir().
Referenced by sys_mkdir().
Implements mknod(): makes a file, a directory, a FIFO, or (only root) a device file.
| path | its path |
| mode | its type and permissions |
| dev | a device file's device number |
Definition at line 1023 of file sys_file.c.
References do_mknodat(), LOG_DEBUG, vnode::mode, and sys_mknod().
Referenced by sys_mknod().
Implements mknodat(): mknod(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the new file's path |
| mode | its type and permissions |
| dev | a device file's device number |
Definition at line 1039 of file sys_file.c.
References do_mknodat(), LOG_DEBUG, vnode::mode, and sys_mknodat().
Referenced by sys_mknodat().
| long sys_mount | ( | struct aquila_mount_args * | args | ) |
Implements mount(): mounts a file system on a directory.
Only root may.
| args | the arguments, in user memory: the file system's type, the directory, flags, and the data (the device and the options) |
Definition at line 706 of file sys_file.c.
References curproc, kfree(), LOG_DEBUG, NULL, PROC_UIO, sys_mount(), upath_get(), and vfs_mount().
Referenced by sys_mount().
| long sys_open | ( | const char * | path, |
| int | oflags, | ||
| mode_t | mode ) |
Implements open(): opens a file on a new descriptor, creating it with O_CREAT.
| path | the file's path |
| oflags | O_* flags |
| mode | the new file's permissions, with O_CREAT (less the umask) |
Definition at line 424 of file sys_file.c.
References do_openat(), LOG_DEBUG, and sys_open().
Referenced by sys_open().
| long sys_openat | ( | int | dirfd, |
| const char * | path, | ||
| int | oflags, | ||
| mode_t | mode ) |
Implements openat(): open(), with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the file's path |
| oflags | O_* flags |
| mode | the new file's permissions, with O_CREAT |
Definition at line 439 of file sys_file.c.
References do_openat(), LOG_DEBUG, and sys_openat().
Referenced by sys_openat().
| long sys_pipe | ( | int | fd[2] | ) |
Implements pipe(): makes a pipe, its read end and its write end open on two new descriptors.
| fd | where to put the two descriptors |
Definition at line 810 of file sys_file.c.
References curproc, file_new(), kfree(), LOG_DEBUG, NULL, pipefs_pipe(), proc_fd_close(), proc_fd_get(), proc_fd_install(), proc_fd_release(), sys_pipe(), and uaccess_check().
Referenced by sys_pipe().
| long sys_read | ( | int | fildes, |
| void * | buf, | ||
| size_t | nbytes ) |
Implements read().
| fildes | the descriptor |
| buf | where to put the data |
| nbytes | how much to read, at most |
Definition at line 454 of file sys_file.c.
References fd_file(), iobuf_init(), LOG_DEBUG, sys_read(), uaccess_check(), and vfs_file_read().
Referenced by sys_read().
| long sys_readdir | ( | int | fd, |
| struct dirent * | dirent ) |
Reads a directory's next entry, for the C library's readdir().
| fd | the directory's descriptor |
| dirent | where to put the entry |
Definition at line 667 of file sys_file.c.
References fd_file(), FILE_SOCKET, file::flags, LOG_DEBUG, memset(), sys_readdir(), and vfs_file_readdir().
Referenced by sys_readdir().
| long sys_readlinkat | ( | int | dirfd, |
| const char * | upath, | ||
| char * | buf, | ||
| size_t | size ) |
Implements readlinkat(): what a symbolic link points to (not NUL-terminated).
| dirfd | the directory upath is relative to, or AT_FDCWD |
| upath | the link's path |
| buf | where to put the target |
| size | the room at buf; a longer target is cut |
Definition at line 1426 of file sys_file.c.
References at_uio(), kfree(), kmalloc(), LOG_DEBUG, MIN, NULL, sys_readlinkat(), uaccess_check(), upath_get(), UPATH_MAX, and vfs_readlink().
Referenced by sys_readlinkat().
| long sys_renameat | ( | int | olddirfd, |
| const char * | oldpath, | ||
| int | newdirfd, | ||
| const char * | newpath ) |
Implements renameat() (and rename()): moves a file to another name, replacing what was there.
| olddirfd | the directory oldpath is relative to, or AT_FDCWD |
| oldpath | the file's path |
| newdirfd | the directory newpath is relative to, or AT_FDCWD |
| newpath | its new path |
Definition at line 1464 of file sys_file.c.
References at_path(), kfree(), LOG_DEBUG, NULL, sys_renameat(), and vfs_rename().
Referenced by sys_renameat().
| long sys_rmdir | ( | const char * | path | ) |
Implements rmdir(): removes an empty directory.
| path | the directory's path |
Definition at line 1383 of file sys_file.c.
References do_unlinkat(), LOG_DEBUG, and sys_rmdir().
Referenced by sys_rmdir().
| long sys_stat | ( | const char * | path, |
| struct aquila_stat * | buf ) |
Implements stat(): a file's attributes, following a symbolic link.
| path | the file's path |
| buf | where to put them |
Definition at line 504 of file sys_file.c.
References do_fstatat(), LOG_DEBUG, and sys_stat().
Referenced by sys_stat().
| long sys_symlinkat | ( | const char * | utarget, |
| int | dirfd, | ||
| const char * | upath ) |
Implements symlinkat(): makes a symbolic link.
| utarget | what it points to |
| dirfd | the directory upath is relative to, or AT_FDCWD |
| upath | the link's path |
Definition at line 1397 of file sys_file.c.
References at_uio(), kfree(), LOG_DEBUG, NULL, sys_symlinkat(), upath_get(), and vfs_symlink().
Referenced by sys_symlinkat().
| long sys_sync | ( | void | ) |
Implements sync(): writes out what the devices' caches hold.
Definition at line 1508 of file sys_file.c.
References kdev_sync(), LOG_DEBUG, and sys_sync().
Referenced by sys_sync().
| long sys_umask | ( | mode_t | mask | ) |
Implements umask(): sets the permissions that new files don't get.
| mask | the new mask |
Definition at line 1089 of file sys_file.c.
References curproc, LOG_DEBUG, and sys_umask().
Referenced by sys_umask().
| long sys_unlink | ( | const char * | path | ) |
Implements unlink(): removes a name of a file (not a directory's).
| path | the name |
Definition at line 553 of file sys_file.c.
References do_unlinkat(), LOG_DEBUG, and sys_unlink().
Referenced by sys_unlink().
| long sys_unlinkat | ( | int | dirfd, |
| const char * | path, | ||
| int | flags ) |
Implements unlinkat(): unlink(), or rmdir() with AT_REMOVEDIR, with the path relative to a directory.
| dirfd | the directory, or AT_FDCWD |
| path | the name |
| flags | AT_REMOVEDIR to remove a directory |
Definition at line 568 of file sys_file.c.
References do_unlinkat(), uio::flags, LOG_DEBUG, and sys_unlinkat().
Referenced by sys_unlinkat().
| long sys_utimensat | ( | int | dirfd, |
| const char * | path, | ||
| const struct aquila_timespec | times[2], | ||
| int | flags ) |
Implements utimensat() (and futimens()): sets a file's access and modification times.
| dirfd | the directory path is relative to, or AT_FDCWD; with a NULL path, the file itself (futimens()) |
| path | the file's path, or NULL |
| times | the two times, or NULL for now |
| flags | AT_SYMLINK_NOFOLLOW for a symbolic link's own |
Definition at line 1340 of file sys_file.c.
References at_lookup(), curproc, fd_vnode(), uio::flags, LOG_DEBUG, NULL, PROC_UIO, sys_utimensat(), vfs_close(), and vfs_utimens().
Referenced by sys_utimensat().
| long sys_write | ( | int | fd, |
| void * | buf, | ||
| size_t | nbytes ) |
Implements write().
Writing to a pipe that no one reads also raises SIGPIPE.
| fd | the descriptor |
| buf | the data |
| nbytes | how much to write |
Definition at line 584 of file sys_file.c.
References curproc, fd_file(), iobuf_init(), LOG_DEBUG, signal_proc_send(), sys_write(), uaccess_check(), and vfs_file_write().
Referenced by sys_write().