UbixOS  2.0
vfs.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 #ifndef _VFS_VFS_H
29 #define _VFS_VFS_H
30 
31 #include <sys/types.h>
32 #include <vfs/file.h>
33 #include <vfs/mount.h>
34 #include <sys/sysproto_posix.h>
35 #include <sys/thread.h>
36 #include <net/net.h>
37 #include <ubixos/wait.h>
38 
39 #define MAY_EXEC 1
40 #define MAY_WRITE 2
41 #define MAY_READ 4
42 
43 #define maxFd 32
44 #define fdAvail 1
45 #define fdOpen 2
46 #define fdRead 3
47 #define fdEof 4
48 
49 #define fileRead 0x0001
50 #define fileWrite 0x0002
51 #define fileBinary 0x0004
52 #define fileAppend 0x0008
53 
59 struct fileSystem {
60  struct fileSystem *prev;
61  struct fileSystem *next;
62  int (*vfsInitFS)(void*);
63  int (*vfsRead)(void*, char*, off_t, long);
64  int (*vfsWrite)(void*, char*, off_t, long);
65  int (*vfsOpenFile)(void*, void*);
66  int (*vfsUnlink)(char*, void*);
67  int (*vfsMakeDir)(char*, void*);
68  int (*vfsRemDir)(char*);
69  int (*vfsSync)(void);
70  int vfsType;
71 };
72 
74  struct file_operations *default_file_ops;
75  int (*create)(struct inode*, const char*, int, int, struct inode**);
76  int (*lookup)(struct inode*, const char*, int, struct inode**);
77  int (*link)(struct inode*, struct inode*, const char*, int);
78  int (*unlink)(struct inode*, const char*, int);
79  int (*symlink)(struct inode*, const char*, int, const char*);
80  int (*mkdir)(struct inode*, const char*, int, int);
81  int (*rmdir)(struct inode*, const char*, int);
82  int (*mknod)(struct inode*, const char*, int, int, int);
83  int (*rename)(struct inode*, const char*, int, struct inode*, const char*, int);
84  int (*readlink)(struct inode*, char*, int);
85  int (*follow_link)(struct inode*, struct inode*, int, int, struct inode**);
86  int (*bmap)(struct inode*, int);
87  void (*truncate)(struct inode*);
88  int (*permission)(struct inode*, int);
89 };
90 
91 /* VFS Functions */
92 int vfs_init();
93 int vfsRegisterFS(struct fileSystem);
94 struct fileSystem* vfs_findFS(int);
95 
97  void (*read_inode)(struct inode*);
98  int (*notify_change)(int flags, struct inode*);
99  void (*write_inode)(struct inode*);
100  void (*put_inode)(struct inode*);
101  void (*put_super)(struct super_block*);
102  void (*write_super)(struct super_block*);
103  void (*statfs)(struct super_block*, struct statfs*);
104  int (*remount_fs)(struct super_block*, int*, char*);
105 };
106 
107 struct super_block {
109  unsigned long s_blocksize;
110  unsigned char s_blocksize_bits;
111  unsigned char s_lock;
112  unsigned char s_rd_only;
113  unsigned char s_dirt;
115  unsigned long s_flags;
116  unsigned long s_magic;
117  unsigned long s_time;
118  struct inode *s_covered;
119  struct inode *s_mounted;
121  union {
123  /*
124  struct fs ufs1_sb;
125  struct fs ufs2_sb;
126  */
127  } u;
128 };
129 
130 #endif
super_operations
Definition: vfs.h:96
fileSystem::vfsWrite
int(* vfsWrite)(void *, char *, off_t, long)
Definition: vfs.h:64
super_block::s_flags
unsigned long s_flags
Definition: vfs.h:115
fileSystem::next
struct fileSystem * next
Definition: vfs.h:61
__dev_t
__uint32_t __dev_t
Definition: _types.h:48
vfs_findFS
struct fileSystem * vfs_findFS(int)
file.h
inode_operations::readlink
int(* readlink)(struct inode *, char *, int)
Definition: vfs.h:84
vfsRegisterFS
int vfsRegisterFS(struct fileSystem)
register a file system
Definition: vfs.c:79
super_block::s_rd_only
unsigned char s_rd_only
Definition: vfs.h:112
super_operations::remount_fs
int(* remount_fs)(struct super_block *, int *, char *)
Definition: vfs.h:104
inode_operations::mkdir
int(* mkdir)(struct inode *, const char *, int, int)
Definition: vfs.h:80
sysproto_posix.h
inode_operations::truncate
void(* truncate)(struct inode *)
Definition: vfs.h:87
super_block::s_dev
__dev_t s_dev
Definition: vfs.h:108
inode_operations::link
int(* link)(struct inode *, struct inode *, const char *, int)
Definition: vfs.h:77
super_block
Definition: vfs.h:107
super_operations::put_super
void(* put_super)(struct super_block *)
Definition: vfs.h:101
super_block::s_blocksize_bits
unsigned char s_blocksize_bits
Definition: vfs.h:110
fileSystem
filesSystem Structure
Definition: vfs.h:59
types.h
fileSystem::vfsRead
int(* vfsRead)(void *, char *, off_t, long)
Definition: vfs.h:63
super_block::s_blocksize
unsigned long s_blocksize
Definition: vfs.h:109
inode_operations::mknod
int(* mknod)(struct inode *, const char *, int, int, int)
Definition: vfs.h:82
wait.h
vfs_init
int vfs_init()
Definition: vfs.c:46
super_operations::write_super
void(* write_super)(struct super_block *)
Definition: vfs.h:102
super_block::s_magic
unsigned long s_magic
Definition: vfs.h:116
super_operations::notify_change
int(* notify_change)(int flags, struct inode *)
Definition: vfs.h:98
fileSystem::vfsMakeDir
int(* vfsMakeDir)(char *, void *)
Definition: vfs.h:67
inode_operations::rmdir
int(* rmdir)(struct inode *, const char *, int)
Definition: vfs.h:81
inode_operations::default_file_ops
struct file_operations * default_file_ops
Definition: vfs.h:74
inode
Definition: inode.h:39
super_block::s_lock
unsigned char s_lock
Definition: vfs.h:111
fileSystem::vfsSync
int(* vfsSync)(void)
Definition: vfs.h:69
inode_operations::symlink
int(* symlink)(struct inode *, const char *, int, const char *)
Definition: vfs.h:79
inode_operations::follow_link
int(* follow_link)(struct inode *, struct inode *, int, int, struct inode **)
Definition: vfs.h:85
inode_operations::create
int(* create)(struct inode *, const char *, int, int, struct inode **)
Definition: vfs.h:75
inode_operations::bmap
int(* bmap)(struct inode *, int)
Definition: vfs.h:86
super_block::u
union super_block::@23 u
fileSystem::prev
struct fileSystem * prev
Definition: vfs.h:60
super_block::s_covered
struct inode * s_covered
Definition: vfs.h:118
fileSystem::vfsRemDir
int(* vfsRemDir)(char *)
Definition: vfs.h:68
fileSystem::vfsInitFS
int(* vfsInitFS)(void *)
Definition: vfs.h:62
super_block::msdos_sb
struct msdos_sb_info msdos_sb
Definition: vfs.h:122
msdos_sb_info
Definition: msdos_fs.h:35
inode_operations::unlink
int(* unlink)(struct inode *, const char *, int)
Definition: vfs.h:78
inode_operations
Definition: vfs.h:73
fileSystem::vfsType
int vfsType
Definition: vfs.h:70
super_block::s_time
unsigned long s_time
Definition: vfs.h:117
super_operations::read_inode
void(* read_inode)(struct inode *)
Definition: vfs.h:97
inode_operations::permission
int(* permission)(struct inode *, int)
Definition: vfs.h:88
super_block::s_wait
struct wait_queue * s_wait
Definition: vfs.h:120
statfs
Definition: mount.h:41
inode_operations::lookup
int(* lookup)(struct inode *, const char *, int, struct inode **)
Definition: vfs.h:76
mount.h
off_t
__int64_t off_t
Definition: types.h:119
wait_queue
Definition: wait.h:34
super_operations::put_inode
void(* put_inode)(struct inode *)
Definition: vfs.h:100
net.h
super_block::s_op
struct super_operations * s_op
Definition: vfs.h:114
super_block::s_dirt
unsigned char s_dirt
Definition: vfs.h:113
thread.h
fileSystem::vfsUnlink
int(* vfsUnlink)(char *, void *)
Definition: vfs.h:66
super_block::s_mounted
struct inode * s_mounted
Definition: vfs.h:119
fileSystem::vfsOpenFile
int(* vfsOpenFile)(void *, void *)
Definition: vfs.h:65
super_operations::write_inode
void(* write_inode)(struct inode *)
Definition: vfs.h:99
inode_operations::rename
int(* rename)(struct inode *, const char *, int, struct inode *, const char *, int)
Definition: vfs.h:83