[1ffbbc1] | 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 |
|
---|
[86d0b4b3] | 36 | #include <minix.h>
|
---|
[953a823] | 37 | #include <libblock.h>
|
---|
[3b08178] | 38 | #include <libfs.h>
|
---|
[953a823] | 39 | #include <adt/list.h>
|
---|
[1ffbbc1] | 40 | #include "../../vfs/vfs.h"
|
---|
| 41 |
|
---|
[92dd5c8] | 42 | #define DEBUG_MODE
|
---|
| 43 |
|
---|
| 44 | #ifdef DEBUG_MODE
|
---|
| 45 | #define mfsdebug(...) printf(__VA_ARGS__)
|
---|
| 46 | #else
|
---|
| 47 | #define mfsdebug(...)
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
[3b08178] | 50 | #ifdef _MAIN
|
---|
| 51 | #define GLOBAL
|
---|
| 52 | #else
|
---|
| 53 | #define GLOBAL extern
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
| 56 | GLOBAL fs_reg_t mfs_reg;
|
---|
| 57 |
|
---|
[82650385] | 58 | typedef enum {
|
---|
| 59 | MFS_VERSION_V1 = 1,
|
---|
| 60 | MFS_VERSION_V2,
|
---|
| 61 | MFS_VERSION_V3
|
---|
| 62 | } mfs_version_t;
|
---|
| 63 |
|
---|
[953a823] | 64 | /*Generic MinixFS superblock*/
|
---|
| 65 | struct 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 | int 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 | struct mfs_instance {
|
---|
| 85 | link_t link;
|
---|
| 86 | devmap_handle_t handle;
|
---|
| 87 | struct mfs_sb_info *sbi;
|
---|
| 88 | };
|
---|
| 89 |
|
---|
[e54ba607] | 90 | /*MinixFS node in core*/
|
---|
| 91 | struct mfs_node {
|
---|
| 92 | union {
|
---|
| 93 | struct mfs_inode *ino;
|
---|
| 94 | struct mfs2_inode *ino2;
|
---|
| 95 | };
|
---|
| 96 |
|
---|
| 97 | struct mfs_instance *instance;
|
---|
| 98 | };
|
---|
| 99 |
|
---|
[1ffbbc1] | 100 | extern void mfs_mounted(ipc_callid_t rid, ipc_call_t *request);
|
---|
[3b08178] | 101 | extern void mfs_mount(ipc_callid_t rid, ipc_call_t *request);
|
---|
[5a58ae2] | 102 | extern bool mfs_is_directory(fs_node_t *fsnode);
|
---|
[7d04324] | 103 | extern bool mfs_is_file(fs_node_t *fsnode);
|
---|
[e54ba607] | 104 | extern devmap_handle_t mfs_device_get(fs_node_t *fsnode);
|
---|
[3b08178] | 105 | extern int mfs_get_instance(devmap_handle_t handle,
|
---|
| 106 | struct mfs_instance **instance);
|
---|
[1ffbbc1] | 107 |
|
---|
| 108 | #endif
|
---|
| 109 |
|
---|
| 110 | /**
|
---|
| 111 | * @}
|
---|
| 112 | */
|
---|
| 113 |
|
---|