Changeset 953a823 in mainline for uspace/srv/fs/minixfs/mfs_ops.c
- Timestamp:
- 2011-03-17T13:41:58Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3b08178
- Parents:
- f66d903
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs_ops.c
rf66d903 r953a823 35 35 #include <stdlib.h> 36 36 #include <libblock.h> 37 #include <fibril_synch.h> 37 38 #include <errno.h> 38 #include < str.h>39 #include <adt/list.h> 39 40 #include "mfs.h" 40 41 #include "mfs_utils.h" … … 43 44 static bool check_magic_number(uint16_t magic, bool *native, 44 45 mfs_version_t *version, bool *longfilenames); 46 47 static LIST_INITIALIZE(inst_list); 48 static FIBRIL_MUTEX_INITIALIZE(inst_list_mutex); 45 49 46 50 void mfs_mounted(ipc_callid_t rid, ipc_call_t *request) … … 48 52 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 49 53 enum cache_mode cmode; 50 struct mfs_superblock *sp; 51 struct mfs3_superblock *sp3; 54 struct mfs_superblock *sb; 55 struct mfs3_superblock *sb3; 56 struct mfs_sb_info *sbi; 57 struct mfs_instance *instance; 52 58 bool native, longnames; 53 59 mfs_version_t version; … … 80 86 } 81 87 82 sp = (struct mfs_superblock *) malloc(MFS_SUPERBLOCK_SIZE); 88 /*Allocate space for generic MFS superblock*/ 89 sbi = (struct mfs_sb_info *) malloc(sizeof(struct mfs_sb_info)); 90 91 if (!sbi) { 92 async_answer_0(rid, ENOMEM); 93 return; 94 } 95 96 /*Allocate space for filesystem instance*/ 97 instance = (struct mfs_instance *) malloc(sizeof(struct mfs_instance)); 98 99 if (!instance) { 100 async_answer_0(rid, ENOMEM); 101 return; 102 } 103 104 sb = (struct mfs_superblock *) malloc(MFS_SUPERBLOCK_SIZE); 105 106 if (!sb) { 107 async_answer_0(rid, ENOMEM); 108 return; 109 } 83 110 84 111 /* Read the superblock */ 85 rc = block_read_direct(devmap_handle, MFS_SUPERBLOCK << 1, 1, s p);112 rc = block_read_direct(devmap_handle, MFS_SUPERBLOCK << 1, 1, sb); 86 113 if (rc != EOK) { 87 114 block_fini(devmap_handle); … … 90 117 } 91 118 92 if (check_magic_number(sp->s_magic, &native, &version, &longnames)) { 93 magic = sp->s_magic; 119 sb3 = (struct mfs3_superblock *) sb; 120 121 if (check_magic_number(sb->s_magic, &native, &version, &longnames)) { 122 magic = sb->s_magic; 94 123 goto recognized; 95 124 } 96 125 97 sp3 = (struct mfs3_superblock *) sp; 98 99 if (!check_magic_number(sp3->s_magic, &native, &version, &longnames)) { 126 if (!check_magic_number(sb3->s_magic, &native, &version, &longnames)) { 100 127 mfsdebug("magic number not recognized\n"); 101 128 block_fini(devmap_handle); … … 104 131 } 105 132 106 magic = s p3->s_magic;133 magic = sb3->s_magic; 107 134 108 135 recognized: 109 136 110 137 mfsdebug("magic number recognized = %04x\n", magic); 111 free(sp); 138 139 /*Fill superblock info structure*/ 140 141 sbi->fs_version = version; 142 sbi->long_names = longnames; 143 sbi->native = native; 144 sbi->magic = magic; 145 146 if (version == MFS_VERSION_V3) { 147 sbi->ninodes = conv32(native, sb3->s_ninodes); 148 sbi->ibmap_blocks = conv16(native, sb3->s_ibmap_blocks); 149 sbi->zbmap_blocks = conv16(native, sb3->s_zbmap_blocks); 150 sbi->firstdatazone = conv16(native, sb3->s_first_data_zone); 151 sbi->log2_zone_size = conv16(native, sb3->s_log2_zone_size); 152 sbi->max_file_size = conv32(native, sb3->s_max_file_size); 153 sbi->nzones = conv32(native, sb3->s_nzones); 154 sbi->block_size = conv16(native, sb3->s_block_size); 155 } else { 156 sbi->ninodes = conv16(native, sb->s_ninodes); 157 sbi->ibmap_blocks = conv16(native, sb->s_ibmap_blocks); 158 sbi->zbmap_blocks = conv16(native, sb->s_zbmap_blocks); 159 sbi->firstdatazone = conv16(native, sb->s_first_data_zone); 160 sbi->log2_zone_size = conv16(native, sb->s_log2_zone_size); 161 sbi->max_file_size = conv32(native, sb->s_max_file_size); 162 sbi->nzones = conv16(native, sb->s_nzones); 163 if (version == MFS_VERSION_V2) 164 sbi->nzones = conv32(native, sb->s_nzones2); 165 } 166 167 free(sb); 168 169 /*Initialize the instance structure and add it to the list*/ 170 link_initialize(&instance->link); 171 instance->handle = devmap_handle; 172 instance->sbi = sbi; 173 174 fibril_mutex_lock(&inst_list_mutex); 175 list_append(&instance->link, &inst_list); 176 fibril_mutex_unlock(&inst_list_mutex); 177 178 mfsdebug("mount successful\n"); 179 180 async_answer_0(rid, EOK); 112 181 } 113 182
Note:
See TracChangeset
for help on using the changeset viewer.