diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-12 12:17:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-12 12:17:46 +0100 |
commit | 13d7c09125f8eec703d0a43a9a87fc8aa08f7319 (patch) | |
tree | 70fd643c429cea5c1f9362c2674511d17a53f3b5 /Userland/Libraries/LibC/fcntl.h | |
parent | dc28c07fa526841e05e16161c74a6c23984f1dd5 (diff) | |
download | serenity-13d7c09125f8eec703d0a43a9a87fc8aa08f7319.zip |
Libraries: Move to Userland/Libraries/
Diffstat (limited to 'Userland/Libraries/LibC/fcntl.h')
-rw-r--r-- | Userland/Libraries/LibC/fcntl.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/fcntl.h b/Userland/Libraries/LibC/fcntl.h new file mode 100644 index 0000000000..1aa6e6cd09 --- /dev/null +++ b/Userland/Libraries/LibC/fcntl.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include <sys/cdefs.h> +#include <sys/types.h> + +__BEGIN_DECLS + +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 +#define F_ISTTY 5 + +#define FD_CLOEXEC 1 + +#define O_RDONLY (1 << 0) +#define O_WRONLY (1 << 1) +#define O_RDWR (O_RDONLY | O_WRONLY) +#define O_ACCMODE (O_RDONLY | O_WRONLY) +#define O_EXEC (1 << 2) +#define O_CREAT (1 << 3) +#define O_EXCL (1 << 4) +#define O_NOCTTY (1 << 5) +#define O_TRUNC (1 << 6) +#define O_APPEND (1 << 7) +#define O_NONBLOCK (1 << 8) +#define O_DIRECTORY (1 << 9) +#define O_NOFOLLOW (1 << 10) +#define O_CLOEXEC (1 << 11) +#define O_DIRECT (1 << 12) + +#define S_IFMT 0170000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFBLK 0060000 +#define S_IFREG 0100000 +#define S_IFIFO 0010000 +#define S_IFLNK 0120000 +#define S_IFSOCK 0140000 + +#define S_ISUID 04000 +#define S_ISGID 02000 +#define S_ISVTX 01000 +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IXUSR 0100 +#define S_IRGRP 0040 +#define S_IWGRP 0020 +#define S_IXGRP 0010 +#define S_IROTH 0004 +#define S_IWOTH 0002 +#define S_IXOTH 0001 + +#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) + +#define S_IRWXG (S_IRWXU >> 3) +#define S_IRWXO (S_IRWXG >> 3) + +int creat(const char* path, mode_t); +int open(const char* path, int options, ...); +int creat_with_path_length(const char* path, size_t path_length, mode_t); +int open_with_path_length(const char* path, size_t path_length, int options, mode_t); +#define AT_FDCWD -100 +int openat(int dirfd, const char* path, int options, ...); +int openat_with_path_length(int dirfd, const char* path, size_t path_length, int options, mode_t); + +int fcntl(int fd, int cmd, ...); +int watch_file(const char* path, size_t path_length); + +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 +#define F_SETLK 6 +#define F_SETLKW 7 + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +__END_DECLS |