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

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

Add mfs_write_inode_raw() function to write V1 dirty inodes on disk.

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