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

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

Fix bug when reading inodes that causes on-disk structures corruption if the
endianness is not native.

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