Changeset d2c8533 in mainline for uspace/srv/fs/mfs/mfs_ops.c
- Timestamp:
- 2017-05-08T20:38:47Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f066a87
- Parents:
- 582a0b8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_ops.c
r582a0b8 rd2c8533 140 140 } 141 141 142 static int 143 mfs_mounted(service_id_t service_id, const char *opts, fs_index_t *index, 144 aoff64_t *size, unsigned *linkcnt) 145 { 146 enum cache_mode cmode; 142 /** Read the superblock. 143 */ 144 static int mfs_read_sb(service_id_t service_id, struct mfs_sb_info **rsbi) 145 { 147 146 struct mfs_superblock *sb = NULL; 148 147 struct mfs3_superblock *sb3 = NULL; 149 struct mfs_sb_info *sbi = NULL;150 s truct mfs_instance *instance = NULL;148 struct mfs_sb_info *sbi; 149 size_t bsize; 151 150 bool native, longnames; 152 151 mfs_version_t version; 153 152 uint16_t magic; 154 153 int rc; 155 156 /* Check for option enabling write through. */157 if (str_cmp(opts, "wtcache") == 0)158 cmode = CACHE_MODE_WT;159 else160 cmode = CACHE_MODE_WB;161 162 /* initialize libblock */163 rc = block_init(service_id, 4096);164 if (rc != EOK)165 return rc;166 154 167 155 /* Allocate space for generic MFS superblock */ … … 172 160 } 173 161 174 /* Allocate space for filesystem instance */175 instance = malloc(sizeof(*instance));176 if (!instance) {177 rc = ENOMEM;178 goto out_error;179 }180 181 162 sb = malloc(MFS_SUPERBLOCK_SIZE); 182 163 if (!sb) { 183 164 rc = ENOMEM; 165 goto out_error; 166 } 167 168 rc = block_get_bsize(service_id, &bsize); 169 if (rc != EOK) { 170 rc = EIO; 171 goto out_error; 172 } 173 174 /* We don't support other block size than 512 */ 175 if (bsize != 512) { 176 rc = ENOTSUP; 184 177 goto out_error; 185 178 } … … 269 262 } 270 263 264 mfsdebug("read superblock successful\n"); 265 266 free(sb); 267 *rsbi = sbi; 268 return EOK; 269 270 out_error: 271 if (sb) 272 free(sb); 273 if (sbi) 274 free(sbi); 275 return rc; 276 } 277 278 279 static int mfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info) 280 { 281 struct mfs_sb_info *sbi = NULL; 282 int rc; 283 284 /* Initialize libblock */ 285 rc = block_init(service_id, 4096); 286 if (rc != EOK) 287 return rc; 288 289 /* Read the superblock */ 290 rc = mfs_read_sb(service_id, &sbi); 291 block_fini(service_id); 292 293 return rc; 294 } 295 296 static int 297 mfs_mounted(service_id_t service_id, const char *opts, fs_index_t *index, 298 aoff64_t *size, unsigned *linkcnt) 299 { 300 enum cache_mode cmode; 301 struct mfs_sb_info *sbi = NULL; 302 struct mfs_instance *instance = NULL; 303 int rc; 304 305 /* Check for option enabling write through. */ 306 if (str_cmp(opts, "wtcache") == 0) 307 cmode = CACHE_MODE_WT; 308 else 309 cmode = CACHE_MODE_WB; 310 311 /* Initialize libblock */ 312 rc = block_init(service_id, 4096); 313 if (rc != EOK) 314 return rc; 315 316 /* Allocate space for filesystem instance */ 317 instance = malloc(sizeof(*instance)); 318 if (!instance) { 319 rc = ENOMEM; 320 goto out_error; 321 } 322 323 /* Read the superblock */ 324 rc = mfs_read_sb(service_id, &sbi); 325 if (rc != EOK) 326 goto out_error; 327 271 328 rc = block_cache_init(service_id, sbi->block_size, 0, cmode); 272 329 if (rc != EOK) { … … 298 355 *linkcnt = 1; 299 356 300 free(sb);301 302 357 return mfs_node_put(fn); 303 358 304 359 out_error: 305 360 block_fini(service_id); 306 if (sb)307 free(sb);308 361 if (sbi) 309 362 free(sbi); … … 1205 1258 1206 1259 vfs_out_ops_t mfs_ops = { 1260 .fsprobe = mfs_fsprobe, 1207 1261 .mounted = mfs_mounted, 1208 1262 .unmounted = mfs_unmounted,
Note:
See TracChangeset
for help on using the changeset viewer.