1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*
* wnix, a Unix-like operating system for WebAssembly applications.
* Copyright (C) 2025 Xavier Del Campo Romero
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef FS_INODE_H
#define FS_INODE_H
#include <state.h>
#include <sys/types.h>
#include <time.h>
struct fs;
struct fs_mp;
struct fs_ret;
struct inode_prv;
enum
{
INODE_DIR = 1,
INODE_REGFILE = 1 << 1,
INODE_BLOCKDEV = 1 << 2,
INODE_MOUNTPOINT = 1 << 3,
};
struct inode
{
char *name;
int flags;
ino_t ino;
mode_t mode;
uid_t uid;
gid_t gid;
off_t size;
struct timespec atim, mtim, ctim;
struct inode *parent, *child, *left, *right;
struct inode_prv *prv;
void (*free)(void *);
};
union inode_result
{
struct inode cachei, *memi;
};
typedef int (*inode_search_done)(enum state state, const char *relpath,
const struct fs_mp *mp, const union inode_result *inode, void *args);
struct inode_search
{
const char *path;
inode_search_done done;
void *args;
};
struct inode_ops
{
int (*search)(const char *path, const struct fs_mp *mp,
union inode_result *inode, struct fs_ret *r);
int (*reserve)(const struct inode *i, void *args, struct fs_ret *r);
int (*flags)(const union inode_result *i);
};
int inode_search(const struct inode_search *s, struct fs_ret *r);
void inode_search_free(struct inode_search *s);
void inode_free(struct inode *i);
#endif
|