File and Directory Operations
open and openat
Supported functionality of open in SCML:
access_mode =
O_RDONLY |
O_WRONLY |
O_RDWR;
creation_flags =
O_CLOEXEC |
O_DIRECTORY |
O_EXCL |
O_NOCTTY |
O_NOFOLLOW |
O_TRUNC;
status_flags =
O_APPEND |
O_ASYNC |
O_DIRECT |
O_LARGEFILE |
O_NOATIME |
O_NONBLOCK |
O_SYNC;
// Open an existing file
open(
path,
flags = <access_mode> | <creation_flags> | <status_flags>,
);
openat(
dirfd,
path,
flags = <access_mode> | <creation_flags> | <status_flags>,
);
// Create a new file
open(
path,
flags = O_CREAT | <access_mode> | <creation_flags> | <status_flags>,
mode
);
openat(
dirfd,
path,
flags = O_CREAT | <access_mode> | <creation_flags> | <status_flags>,
mode
);
// Status flags that are meaningful with O_PATH
opath_valid_flags = O_CLOEXEC | O_DIRECTORY | O_NOFOLLOW;
// All other flags are ignored with O_PATH
opath_ignored_flags = O_CREAT | <creation_flags> | <status_flags>;
// Obtain a file descriptor to indicate a location in FS
open(
path,
flags = O_PATH | <opath_valid_flags> | <opath_ignored_flags>
);
openat(
dirfd,
path,
flags = O_PATH | <opath_valid_flags> | <opath_ignored_flags>
);
// Create an unnamed file
// open(path, flags = O_TMPFILE | <creation_flags> | <status_flags>)
Silently-ignored flags:
O_NOCTTYO_DSYNCO_SYNCO_LARGEFILEO_NOATIMEO_NOCTTY
Partially-supported flags:
O_PATH
Unsupported flags:
O_TMPFILE
Supported and unsupported functionality of openat are the same as open.
The SCML rules are omitted for brevity.
For more information, see the man page.
renameat2
Supported functionality in SCML:
// Rename a file, moving it between directories if required.
renameat2(olddirfd, oldpath, newdirfd, newpath, 0);
Unsupported flags:
RENAME_EXCHANGERENAME_NOREPLACERENAME_WHITEOUT
For more information, see the man page.
lseek
Supported functionality in SCML:
// Set file offset
lseek(
fd, offset,
whence = SEEK_SET | SEEK_CUR | SEEK_END
);
Unsupported flags:
SEEK_DATASEEK_HOLE
For more information, see the man page.
newfstatat
Supported functionality in SCML:
// Retrieve file status by file descriptor
newfstatat(
dirfd, path, statbuf,
flags = AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW
);
Silently-ignored flags:
AT_NO_AUTOMOUNT
For more information, see the man page.