Changeset df3caec5 in mainline
- Timestamp:
- 2011-10-14T20:01:24Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3958e315, 4c3ad56
- Parents:
- 2ac7af3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_ops.c
r2ac7af3 rdf3caec5 69 69 static int mfs_instance_get(service_id_t service_id, 70 70 struct mfs_instance **instance); 71 71 static int mfs_check_sanity(struct mfs_sb_info *sbi); 72 static bool is_power_of_two(uint32_t n); 72 73 73 74 static hash_table_t open_nodes; … … 261 262 262 263 sbi->itable_off = 2 + sbi->ibmap_blocks + sbi->zbmap_blocks; 264 if ((rc = mfs_check_sanity(sbi)) != EOK) { 265 fprintf(stderr, "Filesystem corrupted, invalid superblock"); 266 goto out_error; 267 } 263 268 264 269 rc = block_cache_init(service_id, sbi->block_size, 0, cmode); … … 1071 1076 } 1072 1077 1078 /** Filesystem sanity check 1079 * 1080 * @param Pointer to the MFS superblock. 1081 * 1082 * @return EOK on success, ENOTSUP otherwise. 1083 */ 1084 static int 1085 mfs_check_sanity(struct mfs_sb_info *sbi) 1086 { 1087 if (!is_power_of_two(sbi->block_size) || 1088 sbi->block_size < MFS_MIN_BLOCKSIZE || 1089 sbi->block_size > MFS_MAX_BLOCKSIZE) 1090 return ENOTSUP; 1091 else if (sbi->ibmap_blocks == 0 || sbi->zbmap_blocks == 0) 1092 return ENOTSUP; 1093 else if (sbi->ninodes == 0 || sbi->nzones == 0) 1094 return ENOTSUP; 1095 else if (sbi->firstdatazone == 0) 1096 return ENOTSUP; 1097 1098 return EOK; 1099 } 1100 1073 1101 static int 1074 1102 mfs_close(service_id_t service_id, fs_index_t index) … … 1091 1119 1092 1120 return mfs_node_put(fn); 1121 } 1122 1123 /** Check if a given number is a power of two. 1124 * 1125 * @param n The number to check. 1126 * 1127 * @return true if it is a power of two, false otherwise. 1128 */ 1129 static bool 1130 is_power_of_two(uint32_t n) 1131 { 1132 if (n == 0) 1133 return false; 1134 1135 return (n & (n - 1)) == 0; 1093 1136 } 1094 1137
Note:
See TracChangeset
for help on using the changeset viewer.