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

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

d_name should be declared as const char* within the insert_dentry() function

  • Property mode set to 100644
File size: 5.0 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 "../../vfs/vfs.h"
42
43#define NAME "mfs"
44
45#define DEBUG_MODE
46
47#define min(a, b) ((a) < (b) ? (a) : (b))
48
49#ifdef DEBUG_MODE
50#define mfsdebug(...) printf(__VA_ARGS__)
51#else
52#define mfsdebug(...)
53#endif
54
55#ifdef _MAIN
56#define GLOBAL
57#else
58#define GLOBAL extern
59#endif
60
61GLOBAL fs_reg_t mfs_reg;
62
63typedef uint32_t bitchunk_t;
64
65typedef enum {
66 BMAP_ZONE,
67 BMAP_INODE
68} bmap_id_t;
69
70typedef enum {
71 MFS_VERSION_V1 = 1,
72 MFS_VERSION_V2,
73 MFS_VERSION_V3
74} mfs_version_t;
75
76/*Generic MinixFS superblock*/
77struct mfs_sb_info {
78 uint32_t ninodes;
79 uint32_t nzones;
80 unsigned long ibmap_blocks;
81 unsigned long zbmap_blocks;
82 unsigned long firstdatazone;
83 int log2_zone_size;
84 int block_size;
85 uint32_t max_file_size;
86 uint16_t magic;
87 uint16_t state;
88
89 /*The following fields do not exist on disk but only in memory*/
90 unsigned long itable_size;
91 mfs_version_t fs_version;
92 int ino_per_block;
93 size_t dirsize;
94 int itable_off;
95 unsigned max_name_len;
96 bool long_names;
97 bool native;
98 unsigned isearch;
99 unsigned zsearch;
100};
101
102/*Generic MinixFS inode*/
103struct mfs_ino_info {
104 uint16_t i_mode;
105 uint16_t i_nlinks;
106 int16_t i_uid;
107 uint16_t i_gid;
108 size_t i_size;
109 int32_t i_atime;
110 int32_t i_mtime;
111 int32_t i_ctime;
112 /*Block numbers for direct zones*/
113 uint32_t i_dzone[V2_NR_DIRECT_ZONES];
114 /*Block numbers for indirect zones*/
115 uint32_t i_izone[V2_NR_INDIRECT_ZONES];
116
117 /*The following fields do not exist on disk but only in memory*/
118 bool dirty;
119 fs_index_t index;
120};
121
122/*Generic MFS directory entry*/
123struct mfs_dentry_info {
124 uint32_t d_inum;
125 char d_name[MFS3_MAX_NAME_LEN + 1];
126
127 /*The following fields do not exist on disk but only in memory*/
128
129 /*Index of the dentry in the list*/
130 unsigned index;
131 /*Pointer to the node at witch the dentry belongs*/
132 struct mfs_node *node;
133};
134
135struct mfs_instance {
136 link_t link;
137 devmap_handle_t handle;
138 struct mfs_sb_info *sbi;
139};
140
141/*MinixFS node in core*/
142struct mfs_node {
143 struct mfs_ino_info *ino_i;
144 struct mfs_instance *instance;
145};
146
147/*mfs_ops.c*/
148extern void mfs_mounted(ipc_callid_t rid, ipc_call_t *request);
149extern void mfs_mount(ipc_callid_t rid, ipc_call_t *request);
150extern void mfs_lookup(ipc_callid_t rid, ipc_call_t *request);
151extern int mfs_instance_get(devmap_handle_t handle,
152 struct mfs_instance **instance);
153
154extern void mfs_stat(ipc_callid_t rid, ipc_call_t *request);
155
156extern void
157mfs_read(ipc_callid_t rid, ipc_call_t *request);
158
159
160/*mfs_inode.c*/
161int
162get_inode(struct mfs_instance *inst, struct mfs_ino_info **ino_i,
163 fs_index_t index);
164
165extern int
166put_inode(struct mfs_node *mnode);
167
168int
169inode_grow(struct mfs_node *mnode, size_t size_grow);
170
171/*mfs_rw.c*/
172extern int
173read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos);
174
175extern int
176write_map(struct mfs_node *mnode, uint32_t pos, uint32_t new_zone,
177 uint32_t *old_zone);
178
179extern int
180free_zone(struct mfs_node *mnode, const uint32_t zone);
181
182/*mfs_dentry.c*/
183extern struct mfs_dentry_info *
184read_directory_entry(struct mfs_node *mnode, unsigned index);
185
186extern int
187write_dentry(struct mfs_dentry_info *d_info);
188
189int
190insert_dentry(struct mfs_node *mnode, const char *d_name, fs_index_t d_inum);
191
192/*mfs_balloc.c*/
193extern int
194mfs_alloc_bit(struct mfs_instance *inst, uint32_t *idx, bmap_id_t bid);
195
196extern int
197mfs_free_bit(struct mfs_instance *inst, uint32_t idx, bmap_id_t bid);
198
199#endif
200
201/**
202 * @}
203 */
204
Note: See TracBrowser for help on using the repository browser.