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

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

Add a function to free an entry in the inode or zone bitmap

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