StRoot
1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
RTS
src
SFS
fs_index.h
1
#ifndef _FS_INDEX_H_
2
#define _FS_INDEX_H_
3
4
#include <stdlib.h>
5
//#include <sys/uio.h>
6
7
typedef
unsigned
int
UINT32;
8
typedef
unsigned
short
UINT16;
9
typedef
unsigned
char
UINT8;
10
11
struct
fs_inode
{
12
fs_inode
*parent;
13
fs_inode
*next;
14
fs_inode
*prev;
15
fs_inode
*fchild;
16
fs_inode
*lchild;
17
long
long
int
offset;
18
int
sz;
19
int
overhead;
20
char
*name;
// local name only
21
22
UINT32 swap;
23
};
24
25
struct
fs_dirent
{
26
char
full_name[256];
27
char
d_name[256];
28
int
sz;
29
long
long
int
offset;
30
int
has_child;
31
int
swap;
32
};
33
34
struct
fs_dir
{
35
fs_inode
*inode;
36
fs_inode
*currchild;
37
char
full_name[256];
38
};
39
40
struct
fs_iovec
{
41
char
*filename;
42
void
*buff;
43
int
len;
44
};
45
46
47
#define WRAP_CLOSED 0
48
#define WRAP_MEM 1
49
#define WRAP_DISK 2
50
#define WRAP_SOCKET 3
51
52
class
wrapfile
{
53
public
:
54
int
type;
// 0 closed, 1 mem, 2 disk, 3 socket
55
56
// If disk / socket
57
int
fd;
58
59
// If mem
60
char
*wbuff;
61
long
long
int
wfpos;
62
long
long
int
wsize;
63
64
65
66
wrapfile
() { type = 0; wbuff = 0; wfpos = 0; wsize = 0; };
67
int
openmem(
char
*wrapbuff,
int
wrapmsize);
68
int
opendisk(
char
*fn,
int
flags,
int
perms=0666);
69
int
openfd(
int
fd);
70
int
read(
void
*buff,
int
sz);
71
int
write(
void
*buff,
int
sz);
72
73
74
#if defined(__USE_LARGEFILE64) || defined(__LARGEFILE64_SOURCE_)
75
long
long
int
lseek(
long
long
int
offset,
int
whence);
76
int
fstat(
struct
stat64 *stat);
77
#else
78
int
lseek(
int
offset,
int
whence);
79
int
fstat(
struct
stat *stat);
80
#endif
81
82
int
close();
83
};
84
85
86
class
fs_filelist
{
87
public
:
88
char
filename[50][256];
89
int
n;
90
int
max;
91
92
fs_filelist
() {
93
n = 0;
94
max = 50;
95
}
96
};
97
98
class
fs_index
{
99
public
:
100
101
char
cwd[256];
102
103
fs_index
();
104
105
virtual
~
fs_index
();
106
107
// flags and perms are open() flags and perms...
108
//
109
// For memory mounting several points:
110
// 1. no append implemented
111
// 2. size for write only mount is max size
112
// 3. size for read only mount is file size
113
// 4. to find size of mountfile after memory writing use mountsz()
114
//
115
int
mountmem(
char
*buffer,
int
sz,
int
flags);
116
int
mount(
char
*filename,
int
flags,
int
perms=0666);
117
int
mount(
int
fd);
// mounts to a socket
118
int
mount(
int
ip,
int
port) ;
// opens and mounts a socket
119
120
void
umount();
121
122
#if defined(__USE_LARGEFILE64) || defined(__LARGEFILE64_SOURCE_)
123
long
long
int
mountsz();
124
#else
125
int
mountsz();
126
#endif
127
128
static
void
hexdump(
char
*buff,
int
sz);
129
130
int
cd(
char
*fn);
131
char
*pwd() {
return
cwd; };
132
133
// directory functions
134
fs_dir
*opendir(
const
char
*dir);
135
void
closedir(
fs_dir
*dir);
136
fs_dirent
*readdir(
fs_dir
*dir,
fs_dirent
*storage=NULL);
137
fs_dirent
*readdirent(
const
char
*name,
fs_dirent
*storage=NULL);
138
139
// meant for users that have memory mapped/memory sfs indexes
140
// and want to use the buffers in place to avoid memcpy
141
// access the data through the dirent's offset / size
142
//
143
inline
fs_dirent
*opendirent(
const
char
*name) {
return
readdirent(name); };
144
145
int
mem_ls(
fs_filelist
*filelist,
int
recurse,
fs_dir
*dir);
146
147
// File operations
148
int
read(
const
char
*fn,
char
*buff,
int
sz);
149
virtual
int
write(
char
*fn,
char
*buff,
int
sz) {
return
-1; };
150
virtual
int
getwritevsz(
fs_iovec
*fsiovec,
int
n) {
return
0; };
151
virtual
int
writev(
fs_iovec
*iovec,
int
n) {
return
-1; };
152
virtual
int
writev_sticky(
fs_iovec
*iovec,
int
n,
int
*sticky) {
return
-1; };
153
154
int
fileSize(
const
char
*fn);
155
156
int
n_inodes;
157
void
getFullPath(
char
*fullname,
const
char
*name);
158
virtual
void
dump(
int
fd)=0;
159
160
wrapfile
wfile;
161
protected
:
162
int
cdchanged;
163
int
oflags;
164
165
fs_inode
*find_child(
fs_inode
*parent,
char
*name);
166
void
free_inode(
fs_inode
*inode);
167
#if defined(__USE_LARGEFILE64) || defined(__LARGEFILE64_SOURCE_)
168
fs_inode
*alloc_inode(
const
char
*name,
long
long
int
off,
int
sz,
int
overhead);
169
#else
170
fs_inode
*alloc_inode(
const
char
*name,
int
off,
int
sz,
int
overhead);
171
#endif
172
173
virtual
int
_create()=0;
// create index for reading...
174
int
index_created;
175
176
fs_inode
*root;
177
fs_inode
*cw_inode;
178
179
virtual
int
writeFsHeader() {
return
-1; };
180
181
int
initmount();
182
183
char
*writevbuff;
184
int
writevbuffsz;
185
186
private
:
187
fs_dirent
_readdirent_static_;
188
189
protected
:
190
char
*_strtok_static_;
191
};
192
193
194
195
#endif
fs_index
Definition:
fs_index.h:98
fs_dirent
Definition:
fs_index.h:25
fs_inode
Definition:
fs_index.h:11
fs_iovec
Definition:
fs_index.h:40
wrapfile
Definition:
fs_index.h:52
fs_filelist
Definition:
fs_index.h:86
fs_dir
Definition:
fs_index.h:34
Generated by
1.8.5