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

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

Lot of improvements to the MinixFS driver:

  • Add mfs_node_put()
  • Add mfs_node_open()
  • Add mfs_index_get()
  • Add mfs_lnkcnt_get()

Add the mfs_dentry.c file which I forgot to add before.

  • 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 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
84/*Generic MinixFS inode*/
85struct mfs_ino_info {
86 uint16_t i_mode;
87 uint16_t i_nlinks;
88 int16_t i_uid;
89 uint16_t i_gid;
90 int32_t i_size;
91 int32_t i_atime;
92 int32_t i_mtime;
93 int32_t i_ctime;
94 /*Block numbers for direct zones*/
95 uint32_t i_dzone[V2_NR_DIRECT_ZONES];
96 /*Block numbers for indirect zones*/
97 uint32_t i_izone[V2_NR_INDIRECT_ZONES];
98
99 bool dirty;
100 fs_index_t index;
101};
102
103/*Generic MFS directory entry*/
104struct mfs_dentry_info {
105 uint32_t d_inum;
106 char d_name[MFS3_MAX_NAME_LEN];
107
108 bool dirty;
109};
110
111struct mfs_instance {
112 link_t link;
113 devmap_handle_t handle;
114 struct mfs_sb_info *sbi;
115};
116
117/*MinixFS node in core*/
118struct mfs_node {
119 struct mfs_ino_info *ino_i;
120 struct mfs_instance *instance;
121};
122
123/*mfs_ops.c*/
124extern void mfs_mounted(ipc_callid_t rid, ipc_call_t *request);
125extern void mfs_mount(ipc_callid_t rid, ipc_call_t *request);
126extern void mfs_lookup(ipc_callid_t rid, ipc_call_t *request);
127extern aoff64_t mfs_size_get(fs_node_t *node);
128extern bool mfs_is_directory(fs_node_t *fsnode);
129extern bool mfs_is_file(fs_node_t *fsnode);
130extern char mfs_plb_get_char(unsigned pos);
131extern int mfs_has_children(bool *has_children, fs_node_t *fsnode);
132extern int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle);
133extern devmap_handle_t mfs_device_get(fs_node_t *fsnode);
134extern int mfs_instance_get(devmap_handle_t handle,
135 struct mfs_instance **instance);
136extern
137int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
138 fs_index_t index);
139
140extern void mfs_stat(ipc_callid_t rid, ipc_call_t *request);
141
142/*mfs_inode.c*/
143extern
144struct mfs_ino_info *mfs_read_inode_raw(const struct mfs_instance *instance,
145 uint16_t inum);
146extern
147struct mfs_ino_info *mfs2_read_inode_raw(const struct mfs_instance *instance,
148 uint32_t inum);
149
150/*mfs_read.c*/
151int read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos);
152
153/*mfs_dentry.c*/
154extern struct mfs_dentry_info *
155read_directory_entry(struct mfs_node *mnode, unsigned index);
156
157#endif
158
159/**
160 * @}
161 */
162
Note: See TracBrowser for help on using the repository browser.