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

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

the read_map() function returns the data block address on disk given the position into the file

  • Property mode set to 100644
File size: 3.5 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 DEBUG_MODE
43
44#ifdef DEBUG_MODE
45#define mfsdebug(...) printf(__VA_ARGS__)
46#else
47#define mfsdebug(...)
48#endif
49
50#ifdef _MAIN
51#define GLOBAL
52#else
53#define GLOBAL extern
54#endif
55
56GLOBAL fs_reg_t mfs_reg;
57
58typedef enum {
59 MFS_VERSION_V1 = 1,
60 MFS_VERSION_V2,
61 MFS_VERSION_V3
62} mfs_version_t;
63
64/*Generic MinixFS superblock*/
65struct mfs_sb_info {
66 uint32_t ninodes;
67 uint32_t nzones;
68 unsigned long ibmap_blocks;
69 unsigned long zbmap_blocks;
70 unsigned long firstdatazone;
71 unsigned long itable_size;
72 int log2_zone_size;
73 int ino_per_block;
74 int dirsize;
75 int block_size;
76 mfs_version_t fs_version;
77 uint32_t max_file_size;
78 uint16_t magic;
79 uint16_t state;
80 bool long_names;
81 bool native;
82};
83
84struct mfs_instance {
85 link_t link;
86 devmap_handle_t handle;
87 struct mfs_sb_info *sbi;
88};
89
90/*MinixFS node in core*/
91struct mfs_node {
92 union {
93 struct mfs_inode *ino;
94 struct mfs2_inode *ino2;
95 };
96
97 struct mfs_instance *instance;
98};
99
100/*mfs_ops.c*/
101extern void mfs_mounted(ipc_callid_t rid, ipc_call_t *request);
102extern void mfs_mount(ipc_callid_t rid, ipc_call_t *request);
103extern aoff64_t mfs_size_get(fs_node_t *node);
104extern bool mfs_is_directory(fs_node_t *fsnode);
105extern bool mfs_is_file(fs_node_t *fsnode);
106extern int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle);
107extern devmap_handle_t mfs_device_get(fs_node_t *fsnode);
108extern int mfs_instance_get(devmap_handle_t handle,
109 struct mfs_instance **instance);
110int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
111 fs_index_t index);
112
113extern void mfs_stat(ipc_callid_t rid, ipc_call_t *request);
114
115/*mfs_inode.c*/
116extern
117struct mfs_inode *mfs_read_inode_raw(const struct mfs_instance *instance,
118 uint16_t inum);
119extern
120struct mfs2_inode *mfs2_read_inode_raw(const struct mfs_instance *instance,
121 uint32_t inum);
122
123/*mfs_read.c*/
124int read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos);
125
126#endif
127
128/**
129 * @}
130 */
131
Note: See TracBrowser for help on using the repository browser.