source: mainline/uspace/srv/fs/minixfs/mfs.h@ 936ece7

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 936ece7 was 6468072e, checked in by Maurizio Lombardi <m.lombardi85@…>, 14 years ago

Remove unused function

  • Property mode set to 100644
File size: 5.8 KB
Line 
1/*
2 * Copyright (c) 2011 Maurizio Lombardi
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup fs
30 * @{
31 */
32
33#ifndef _MFS_H_
34#define _MFS_H_
35
36#include <minix.h>
37#include <macros.h>
38#include <libblock.h>
39#include <libfs.h>
40#include <adt/list.h>
41#include <malloc.h>
42#include <mem.h>
43#include <stdio.h>
44#include <errno.h>
45#include <assert.h>
46#include "../../vfs/vfs.h"
47
48#define NAME "mfs"
49
50//#define DEBUG_MODE
51
52#define min(a, b) ((a) < (b) ? (a) : (b))
53
54#ifdef DEBUG_MODE
55#define mfsdebug(...) printf(__VA_ARGS__)
56#else
57#define mfsdebug(...)
58#endif
59
60#ifdef _MAIN
61#define GLOBAL
62#else
63#define GLOBAL extern
64#endif
65
66#define on_error(r, inst) do { \
67 if (r != EOK) inst; \
68 }while(0)
69
70GLOBAL fs_reg_t mfs_reg;
71
72typedef uint32_t bitchunk_t;
73
74typedef enum {
75 BMAP_ZONE,
76 BMAP_INODE
77} bmap_id_t;
78
79typedef enum {
80 MFS_VERSION_V1 = 1,
81 MFS_VERSION_V2,
82 MFS_VERSION_V3
83} mfs_version_t;
84
85/*Generic MinixFS superblock*/
86struct mfs_sb_info {
87 uint32_t ninodes;
88 uint32_t nzones;
89 unsigned long ibmap_blocks;
90 unsigned long zbmap_blocks;
91 unsigned long firstdatazone;
92 int log2_zone_size;
93 int block_size;
94 uint32_t max_file_size;
95 uint16_t magic;
96 uint16_t state;
97
98 /*The following fields do not exist on disk but only in memory*/
99 unsigned long itable_size;
100 mfs_version_t fs_version;
101 int ino_per_block;
102 size_t dirsize;
103 int itable_off;
104 unsigned max_name_len;
105 bool long_names;
106 bool native;
107 unsigned isearch;
108 unsigned zsearch;
109};
110
111/*Generic MinixFS inode*/
112struct mfs_ino_info {
113 uint16_t i_mode;
114 uint16_t i_nlinks;
115 int16_t i_uid;
116 uint16_t i_gid;
117 size_t i_size;
118 int32_t i_atime;
119 int32_t i_mtime;
120 int32_t i_ctime;
121 /*Block numbers for direct zones*/
122 uint32_t i_dzone[V2_NR_DIRECT_ZONES];
123 /*Block numbers for indirect zones*/
124 uint32_t i_izone[V2_NR_INDIRECT_ZONES];
125
126 /*The following fields do not exist on disk but only in memory*/
127 bool dirty;
128 fs_index_t index;
129};
130
131/*Generic MFS directory entry*/
132struct mfs_dentry_info {
133 uint32_t d_inum;
134 char d_name[MFS3_MAX_NAME_LEN + 1];
135
136 /*The following fields do not exist on disk but only in memory*/
137
138 /*Index of the dentry in the list*/
139 unsigned index;
140 /*Pointer to the node at witch the dentry belongs*/
141 struct mfs_node *node;
142};
143
144struct mfs_instance {
145 link_t link;
146 devmap_handle_t handle;
147 struct mfs_sb_info *sbi;
148};
149
150/*MinixFS node in core*/
151struct mfs_node {
152 struct mfs_ino_info *ino_i;
153 struct mfs_instance *instance;
154};
155
156/*mfs_ops.c*/
157extern void mfs_mounted(ipc_callid_t rid, ipc_call_t *request);
158extern void mfs_mount(ipc_callid_t rid, ipc_call_t *request);
159extern void mfs_lookup(ipc_callid_t rid, ipc_call_t *request);
160extern int mfs_instance_get(devmap_handle_t handle,
161 struct mfs_instance **instance);
162
163extern void mfs_stat(ipc_callid_t rid, ipc_call_t *request);
164extern void mfs_close(ipc_callid_t rid, ipc_call_t *request);
165extern void mfs_open_node(ipc_callid_t rid, ipc_call_t *request);
166
167extern void
168mfs_read(ipc_callid_t rid, ipc_call_t *request);
169
170extern void
171mfs_write(ipc_callid_t rid, ipc_call_t *request);
172
173extern void
174mfs_truncate(ipc_callid_t rid, ipc_call_t *request);
175
176extern void
177mfs_destroy(ipc_callid_t rid, ipc_call_t *request);
178
179extern void
180mfs_unmounted(ipc_callid_t rid, ipc_call_t *request);
181
182extern void
183mfs_unmount(ipc_callid_t rid, ipc_call_t *request);
184
185extern void
186mfs_sync(ipc_callid_t rid, ipc_call_t *request);
187
188/*mfs_inode.c*/
189extern int
190get_inode(struct mfs_instance *inst, struct mfs_ino_info **ino_i,
191 fs_index_t index);
192
193extern int
194put_inode(struct mfs_node *mnode);
195
196extern int
197inode_grow(struct mfs_node *mnode, size_t size_grow);
198
199extern int
200inode_shrink(struct mfs_node *mnode, size_t size_shrink);
201
202/*mfs_rw.c*/
203extern int
204read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos);
205
206extern int
207write_map(struct mfs_node *mnode, uint32_t pos, uint32_t new_zone,
208 uint32_t *old_zone);
209
210extern int
211prune_ind_zones(struct mfs_node *mnode, size_t new_size);
212
213/*mfs_dentry.c*/
214extern int
215read_directory_entry(struct mfs_node *mnode,
216 struct mfs_dentry_info *d_info, unsigned index);
217
218extern int
219write_dentry(struct mfs_dentry_info *d_info);
220
221extern int
222remove_dentry(struct mfs_node *mnode, const char *d_name);
223
224extern int
225insert_dentry(struct mfs_node *mnode, const char *d_name, fs_index_t d_inum);
226
227/*mfs_balloc.c*/
228extern int
229mfs_alloc_inode(struct mfs_instance *inst, uint32_t *inum);
230
231extern int
232mfs_free_inode(struct mfs_instance *inst, uint32_t inum);
233
234extern int
235mfs_alloc_zone(struct mfs_instance *inst, uint32_t *zone);
236
237extern int
238mfs_free_zone(struct mfs_instance *inst, uint32_t zone);
239
240#endif
241
242/**
243 * @}
244 */
245
Note: See TracBrowser for help on using the repository browser.