MOS Source Code
Loading...
Searching...
No Matches
fs_types.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <abi-bits/fcntl.h>
6#include <mos/mm/mm_types.h>
7#include <mos/mos_global.h>
8#include <mos/types.h>
9
10#define PATH_DELIM '/'
11#define PATH_DELIM_STR "/"
12
24
25typedef enum
26{
32 OPEN_CREATE = 1 << 4,
33 OPEN_TRUNCATE = 1 << 5,
34 OPEN_DIR = 1 << 6,
35 OPEN_APPEND = 1 << 7,
38
39typedef enum
40{
42 FSTATAT_NOFOLLOW = 1 << 1, // lstat, operates on the link itself
43 FSTATAT_FILE = 1 << 2, // the fd is a file, not a directory
45
46typedef enum
47{
51
53
54#define PERM_OWNER 0x1C0 // 111 000 000
55#define PERM_GROUP 0x38 // 000 111 000
56#define PERM_OTHER 0x7 // 000 000 111
57#define PERM_READ 0x124 // 100 100 100
58#define PERM_WRITE 0x92 // 010 010 010
59#define PERM_EXEC 0x49 // 001 001 001
60
61#define PERM_MASK 0777
62
79
81{
82 buf[0] = perms & (PERM_READ & PERM_OWNER) ? 'r' : '-';
83 buf[1] = perms & (PERM_WRITE & PERM_OWNER) ? 'w' : '-';
84 buf[2] = perms & (PERM_EXEC & PERM_OWNER) ? 'x' : '-';
85
86 buf[3] = perms & (PERM_READ & PERM_GROUP) ? 'r' : '-';
87 buf[4] = perms & (PERM_WRITE & PERM_GROUP) ? 'w' : '-';
88 buf[5] = perms & (PERM_EXEC & PERM_GROUP) ? 'x' : '-';
89
90 buf[6] = perms & (PERM_READ & PERM_OTHER) ? 'r' : '-';
91 buf[7] = perms & (PERM_WRITE & PERM_OTHER) ? 'w' : '-';
92 buf[8] = perms & (PERM_EXEC & PERM_OTHER) ? 'x' : '-';
93 buf[9] = '\0';
94}
#define PERM_OTHER
Definition fs_types.h:56
fstatat_flags
Definition fs_types.h:40
@ FSTATAT_NONE
Definition fs_types.h:41
@ FSTATAT_FILE
Definition fs_types.h:43
@ FSTATAT_NOFOLLOW
Definition fs_types.h:42
#define PERM_WRITE
Definition fs_types.h:58
#define PERM_READ
Definition fs_types.h:57
should_inline void file_format_perm(file_perm_t perms, char buf[10])
Definition fs_types.h:80
u16 file_perm_t
Definition fs_types.h:52
fd_flags_t
Definition fs_types.h:47
@ FD_FLAGS_CLOEXEC
Definition fs_types.h:49
@ FD_FLAGS_NONE
Definition fs_types.h:48
#define PERM_OWNER
Definition fs_types.h:54
open_flags
Definition fs_types.h:26
@ OPEN_READ
Definition fs_types.h:28
@ OPEN_NO_FOLLOW
Definition fs_types.h:31
@ OPEN_APPEND
Definition fs_types.h:35
@ OPEN_NONE
Definition fs_types.h:27
@ OPEN_TRUNCATE
Definition fs_types.h:33
@ OPEN_WRITE
Definition fs_types.h:29
@ OPEN_DIR
Definition fs_types.h:34
@ OPEN_CREATE
Definition fs_types.h:32
@ OPEN_EXCLUSIVE
Definition fs_types.h:36
@ OPEN_EXECUTE
Definition fs_types.h:30
#define PERM_GROUP
Definition fs_types.h:55
#define PERM_EXEC
Definition fs_types.h:59
file_type_t
Definition fs_types.h:14
@ FILE_TYPE_UNKNOWN
Definition fs_types.h:22
@ FILE_TYPE_CHAR_DEVICE
Definition fs_types.h:18
@ FILE_TYPE_NAMED_PIPE
Definition fs_types.h:20
@ FILE_TYPE_REGULAR
Definition fs_types.h:15
@ FILE_TYPE_BLOCK_DEVICE
Definition fs_types.h:19
@ FILE_TYPE_SYMLINK
Definition fs_types.h:17
@ FILE_TYPE_DIRECTORY
Definition fs_types.h:16
@ FILE_TYPE_SOCKET
Definition fs_types.h:21
@ MEM_PERM_NONE
Definition mm_types.h:8
@ MEM_PERM_EXEC
Definition mm_types.h:11
@ MEM_PERM_READ
Definition mm_types.h:9
@ MEM_PERM_WRITE
Definition mm_types.h:10
#define should_inline
Definition mos_global.h:37
uid_t uid
Definition fs_types.h:69
u64 modified
Definition fs_types.h:77
u64 accessed
Definition fs_types.h:75
u64 created
Definition fs_types.h:76
file_perm_t perm
Definition fs_types.h:67
bool sgid
Definition fs_types.h:73
size_t size
Definition fs_types.h:68
file_type_t type
Definition fs_types.h:66
bool suid
Definition fs_types.h:72
bool sticky
Definition fs_types.h:71
gid_t gid
Definition fs_types.h:70
ssize_t nlinks
Definition fs_types.h:74
u32 uid_t
Definition types.h:75
u32 gid_t
Definition types.h:76
unsigned short u16
Definition types.h:20
unsigned long long u64
Definition types.h:23
signed long ssize_t
Definition types.h:83