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
13
typedef
enum
14
{
15
FILE_TYPE_REGULAR
,
16
FILE_TYPE_DIRECTORY
,
17
FILE_TYPE_SYMLINK
,
18
FILE_TYPE_CHAR_DEVICE
,
19
FILE_TYPE_BLOCK_DEVICE
,
20
FILE_TYPE_NAMED_PIPE
,
21
FILE_TYPE_SOCKET
,
22
FILE_TYPE_UNKNOWN
,
23
}
file_type_t
;
24
25
typedef
enum
26
{
27
OPEN_NONE
=
MEM_PERM_NONE
,
// 0
28
OPEN_READ
=
MEM_PERM_READ
,
// 1 << 0
29
OPEN_WRITE
=
MEM_PERM_WRITE
,
// 1 << 1
30
OPEN_EXECUTE
=
MEM_PERM_EXEC
,
// 1 << 2
31
OPEN_NO_FOLLOW
= 1 << 3,
32
OPEN_CREATE
= 1 << 4,
33
OPEN_TRUNCATE
= 1 << 5,
34
OPEN_DIR
= 1 << 6,
35
OPEN_APPEND
= 1 << 7,
36
OPEN_EXCLUSIVE
= 1 << 8,
37
}
open_flags
;
38
39
typedef
enum
40
{
41
FSTATAT_NONE
= 0,
42
FSTATAT_NOFOLLOW
= 1 << 1,
// lstat, operates on the link itself
43
FSTATAT_FILE
= 1 << 2,
// the fd is a file, not a directory
44
}
fstatat_flags
;
45
46
typedef
enum
47
{
48
FD_FLAGS_NONE
= 0,
49
FD_FLAGS_CLOEXEC
= 1 << 0,
50
}
fd_flags_t
;
51
52
typedef
u16
file_perm_t
;
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
63
typedef
struct
64
{
65
u64
ino
;
66
file_type_t
type
;
67
file_perm_t
perm
;
68
size_t
size
;
69
uid_t
uid
;
70
gid_t
gid
;
71
bool
sticky
;
72
bool
suid
;
73
bool
sgid
;
74
ssize_t
nlinks
;
75
u64
accessed
;
76
u64
created
;
77
u64
modified
;
78
}
file_stat_t
;
79
80
should_inline
void
file_format_perm
(
file_perm_t
perms,
char
buf[10])
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
}
PERM_OTHER
#define PERM_OTHER
Definition
fs_types.h:56
fstatat_flags
fstatat_flags
Definition
fs_types.h:40
FSTATAT_NONE
@ FSTATAT_NONE
Definition
fs_types.h:41
FSTATAT_FILE
@ FSTATAT_FILE
Definition
fs_types.h:43
FSTATAT_NOFOLLOW
@ FSTATAT_NOFOLLOW
Definition
fs_types.h:42
PERM_WRITE
#define PERM_WRITE
Definition
fs_types.h:58
PERM_READ
#define PERM_READ
Definition
fs_types.h:57
file_format_perm
should_inline void file_format_perm(file_perm_t perms, char buf[10])
Definition
fs_types.h:80
file_perm_t
u16 file_perm_t
Definition
fs_types.h:52
fd_flags_t
fd_flags_t
Definition
fs_types.h:47
FD_FLAGS_CLOEXEC
@ FD_FLAGS_CLOEXEC
Definition
fs_types.h:49
FD_FLAGS_NONE
@ FD_FLAGS_NONE
Definition
fs_types.h:48
PERM_OWNER
#define PERM_OWNER
Definition
fs_types.h:54
open_flags
open_flags
Definition
fs_types.h:26
OPEN_READ
@ OPEN_READ
Definition
fs_types.h:28
OPEN_NO_FOLLOW
@ OPEN_NO_FOLLOW
Definition
fs_types.h:31
OPEN_APPEND
@ OPEN_APPEND
Definition
fs_types.h:35
OPEN_NONE
@ OPEN_NONE
Definition
fs_types.h:27
OPEN_TRUNCATE
@ OPEN_TRUNCATE
Definition
fs_types.h:33
OPEN_WRITE
@ OPEN_WRITE
Definition
fs_types.h:29
OPEN_DIR
@ OPEN_DIR
Definition
fs_types.h:34
OPEN_CREATE
@ OPEN_CREATE
Definition
fs_types.h:32
OPEN_EXCLUSIVE
@ OPEN_EXCLUSIVE
Definition
fs_types.h:36
OPEN_EXECUTE
@ OPEN_EXECUTE
Definition
fs_types.h:30
PERM_GROUP
#define PERM_GROUP
Definition
fs_types.h:55
PERM_EXEC
#define PERM_EXEC
Definition
fs_types.h:59
file_type_t
file_type_t
Definition
fs_types.h:14
FILE_TYPE_UNKNOWN
@ FILE_TYPE_UNKNOWN
Definition
fs_types.h:22
FILE_TYPE_CHAR_DEVICE
@ FILE_TYPE_CHAR_DEVICE
Definition
fs_types.h:18
FILE_TYPE_NAMED_PIPE
@ FILE_TYPE_NAMED_PIPE
Definition
fs_types.h:20
FILE_TYPE_REGULAR
@ FILE_TYPE_REGULAR
Definition
fs_types.h:15
FILE_TYPE_BLOCK_DEVICE
@ FILE_TYPE_BLOCK_DEVICE
Definition
fs_types.h:19
FILE_TYPE_SYMLINK
@ FILE_TYPE_SYMLINK
Definition
fs_types.h:17
FILE_TYPE_DIRECTORY
@ FILE_TYPE_DIRECTORY
Definition
fs_types.h:16
FILE_TYPE_SOCKET
@ FILE_TYPE_SOCKET
Definition
fs_types.h:21
mm_types.h
MEM_PERM_NONE
@ MEM_PERM_NONE
Definition
mm_types.h:8
MEM_PERM_EXEC
@ MEM_PERM_EXEC
Definition
mm_types.h:11
MEM_PERM_READ
@ MEM_PERM_READ
Definition
mm_types.h:9
MEM_PERM_WRITE
@ MEM_PERM_WRITE
Definition
mm_types.h:10
mos_global.h
should_inline
#define should_inline
Definition
mos_global.h:37
file_stat_t
Definition
fs_types.h:64
file_stat_t::uid
uid_t uid
Definition
fs_types.h:69
file_stat_t::modified
u64 modified
Definition
fs_types.h:77
file_stat_t::accessed
u64 accessed
Definition
fs_types.h:75
file_stat_t::created
u64 created
Definition
fs_types.h:76
file_stat_t::perm
file_perm_t perm
Definition
fs_types.h:67
file_stat_t::sgid
bool sgid
Definition
fs_types.h:73
file_stat_t::size
size_t size
Definition
fs_types.h:68
file_stat_t::type
file_type_t type
Definition
fs_types.h:66
file_stat_t::suid
bool suid
Definition
fs_types.h:72
file_stat_t::sticky
bool sticky
Definition
fs_types.h:71
file_stat_t::gid
gid_t gid
Definition
fs_types.h:70
file_stat_t::ino
u64 ino
Definition
fs_types.h:65
file_stat_t::nlinks
ssize_t nlinks
Definition
fs_types.h:74
types.h
uid_t
u32 uid_t
Definition
types.h:75
gid_t
u32 gid_t
Definition
types.h:76
u16
unsigned short u16
Definition
types.h:20
u64
unsigned long long u64
Definition
types.h:23
ssize_t
signed long ssize_t
Definition
types.h:83
kernel
include
public
mos
filesystem
fs_types.h
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0