Changeset fe27eb4 in mainline for uspace/lib/ext4/libext4_superblock.c
- Timestamp:
- 2011-11-20T12:07:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 343ccfd
- Parents:
- ae3d4f8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_superblock.c
rae3d4f8 rfe27eb4 47 47 } 48 48 49 void ext4_superblock_set_inodes_count(ext4_superblock_t *sb, uint32_t count) 50 { 51 sb->inodes_count = host2uint32_t_le(count); 52 } 53 49 54 uint64_t ext4_superblock_get_blocks_count(ext4_superblock_t *sb) 50 55 { … … 53 58 } 54 59 60 void ext4_superblock_set_blocks_count(ext4_superblock_t *sb, uint64_t count) 61 { 62 sb->blocks_count_lo = host2uint32_t_le((count << 32) >> 32); 63 sb->blocks_count_hi = host2uint32_t_le(count >> 32); 64 } 65 55 66 uint64_t ext4_superblock_get_reserved_blocks_count(ext4_superblock_t *sb) 56 67 { … … 59 70 } 60 71 72 void ext4_superblock_set_reserved_blocks_count(ext4_superblock_t *sb, uint64_t count) 73 { 74 sb->reserved_blocks_count_lo = host2uint32_t_le((count << 32) >> 32); 75 sb->reserved_blocks_count_hi = host2uint32_t_le(count >> 32); 76 } 77 61 78 uint64_t ext4_superblock_get_free_blocks_count(ext4_superblock_t *sb) 62 79 { … … 76 93 } 77 94 95 void ext4_superblock_set_free_inodes_count(ext4_superblock_t *sb, uint32_t count) 96 { 97 sb->free_inodes_count = host2uint32_t_le(count); 98 } 99 78 100 uint32_t ext4_superblock_get_first_data_block(ext4_superblock_t *sb) 79 101 { … … 81 103 } 82 104 105 void ext4_superblock_set_first_data_block(ext4_superblock_t *sb, uint32_t first) 106 { 107 sb->first_data_block = host2uint32_t_le(first); 108 } 109 83 110 uint32_t ext4_superblock_get_log_block_size(ext4_superblock_t *sb) 84 111 { … … 86 113 } 87 114 115 void ext4_superblock_set_log_block_size(ext4_superblock_t *sb, uint32_t log_size) 116 { 117 sb->log_block_size = host2uint32_t_le(log_size); 118 } 119 88 120 uint32_t ext4_superblock_get_block_size(ext4_superblock_t *sb) 89 121 { … … 91 123 } 92 124 125 void ext4_superblock_set_block_size(ext4_superblock_t *sb, uint32_t size) 126 { 127 uint32_t log = 0; 128 uint32_t tmp = size / EXT4_MIN_BLOCK_SIZE; 129 130 tmp >>= 1; 131 while (tmp) { 132 log++; 133 tmp >>= 1; 134 } 135 136 ext4_superblock_set_log_block_size(sb, log); 137 } 93 138 94 139 uint32_t ext4_superblock_get_blocks_per_group(ext4_superblock_t *sb) … … 97 142 } 98 143 144 void ext4_superblock_set_blocks_per_group(ext4_superblock_t *sb, uint32_t blocks) 145 { 146 sb->blocks_per_group = host2uint32_t_le(blocks); 147 } 148 99 149 uint32_t ext4_superblock_get_inodes_per_group(ext4_superblock_t *sb) 100 150 { … … 102 152 } 103 153 154 void ext4_superblock_set_inodes_per_group(ext4_superblock_t *sb, uint32_t inodes) 155 { 156 sb->inodes_per_group = host2uint32_t_le(inodes); 157 } 158 104 159 uint32_t ext4_superblock_get_mount_time(ext4_superblock_t *sb) 105 160 { … … 107 162 } 108 163 164 void ext4_superblock_set_mount_time(ext4_superblock_t *sb, uint32_t time) 165 { 166 sb->mount_time = host2uint32_t_le(time); 167 } 168 109 169 uint32_t ext4_superblock_get_write_time(ext4_superblock_t *sb) 110 170 { … … 112 172 } 113 173 174 void ext4_superblock_set_write_time(ext4_superblock_t *sb, uint32_t time) 175 { 176 sb->write_time = host2uint32_t_le(time); 177 } 178 114 179 uint16_t ext4_superblock_get_mount_count(ext4_superblock_t *sb) 115 180 { … … 117 182 } 118 183 184 void ext4_superblock_set_mount_count(ext4_superblock_t *sb, uint16_t count) 185 { 186 sb->mount_count = host2uint16_t_le(count); 187 } 188 119 189 uint16_t ext4_superblock_get_max_mount_count(ext4_superblock_t *sb) 120 190 { … … 122 192 } 123 193 194 void ext4_superblock_set_max_mount_count(ext4_superblock_t *sb, uint16_t count) 195 { 196 sb->max_mount_count = host2uint16_t_le(count); 197 } 198 124 199 uint16_t ext4_superblock_get_magic(ext4_superblock_t *sb) 125 200 { … … 132 207 } 133 208 209 void ext4_superblock_set_state(ext4_superblock_t *sb, uint16_t state) 210 { 211 sb->state = host2uint16_t_le(state); 212 } 213 134 214 uint16_t ext4_superblock_get_errors(ext4_superblock_t *sb) 135 215 { … … 137 217 } 138 218 219 void ext4_superblock_set_errors(ext4_superblock_t *sb, uint16_t errors) 220 { 221 sb->errors = host2uint16_t_le(errors); 222 } 139 223 140 224 uint16_t ext4_superblock_get_minor_rev_level(ext4_superblock_t *sb) … … 143 227 } 144 228 229 void ext4_superblock_set_minor_rev_level(ext4_superblock_t *sb, uint16_t level) 230 { 231 sb->minor_rev_level = host2uint16_t_le(level); 232 } 233 145 234 uint32_t ext4_superblock_get_last_check_time(ext4_superblock_t *sb) 146 235 { 147 236 return uint32_t_le2host(sb->last_check_time); 237 } 238 239 void ext4_superblock_set_last_check_time(ext4_superblock_t *sb, uint32_t time) 240 { 241 sb->state = host2uint32_t_le(time); 148 242 } 149 243 … … 152 246 } 153 247 248 void ext4_superblock_set_check_interval(ext4_superblock_t *sb, uint32_t interval) 249 { 250 sb->check_interval = host2uint32_t_le(interval); 251 } 252 154 253 uint32_t ext4_superblock_get_creator_os(ext4_superblock_t *sb) 155 254 { … … 157 256 } 158 257 258 void ext4_superblock_set_creator_os(ext4_superblock_t *sb, uint32_t os) 259 { 260 sb->creator_os = host2uint32_t_le(os); 261 } 262 159 263 uint32_t ext4_superblock_get_rev_level(ext4_superblock_t *sb) 160 264 { 161 265 return uint32_t_le2host(sb->rev_level); 266 } 267 268 void ext4_superblock_set_rev_level(ext4_superblock_t *sb, uint32_t level) 269 { 270 sb->rev_level = host2uint32_t_le(level); 271 } 272 273 uint16_t ext4_superblock_get_def_resuid(ext4_superblock_t *sb) 274 { 275 return uint16_t_le2host(sb->def_resuid); 276 } 277 278 void ext4_superblock_set_def_resuid(ext4_superblock_t *sb, uint16_t uid) 279 { 280 sb->def_resuid = host2uint16_t_le(uid); 281 } 282 283 uint16_t ext4_superblock_get_def_resgid(ext4_superblock_t *sb) 284 { 285 return uint16_t_le2host(sb->def_resgid); 286 } 287 288 void ext4_superblock_set_def_resgid(ext4_superblock_t *sb, uint16_t gid) 289 { 290 sb->def_resgid = host2uint16_t_le(gid); 291 } 292 293 uint32_t ext4_superblock_get_first_inode(ext4_superblock_t *sb) 294 { 295 return uint32_t_le2host(sb->first_inode); 296 } 297 298 void ext4_superblock_set_first_inode(ext4_superblock_t *sb, uint32_t first_inode) 299 { 300 sb->first_inode = host2uint32_t_le(first_inode); 162 301 } 163 302 … … 170 309 } 171 310 311 void ext4_superblock_set_inode_size(ext4_superblock_t *sb, uint16_t size) 312 { 313 sb->inode_size = host2uint16_t_le(size); 314 } 315 172 316 uint16_t ext4_superblock_get_block_group_number(ext4_superblock_t *sb) 173 317 { … … 175 319 } 176 320 321 void ext4_superblock_set_block_group_number(ext4_superblock_t *sb, uint16_t bg) 322 { 323 sb->block_group_number = host2uint16_t_le(bg); 324 } 325 177 326 uint32_t ext4_superblock_get_features_compatible(ext4_superblock_t *sb) 178 327 { … … 180 329 } 181 330 331 void ext4_superblock_set_features_compatible(ext4_superblock_t *sb, uint32_t features) 332 { 333 sb->features_compatible = host2uint32_t_le(features); 334 } 335 182 336 uint32_t ext4_superblock_get_features_incompatible(ext4_superblock_t *sb) 183 337 { … … 185 339 } 186 340 341 void ext4_superblock_set_features_incompatible(ext4_superblock_t *sb, uint32_t features) 342 { 343 sb->features_incompatible = host2uint32_t_le(features); 344 } 345 187 346 uint32_t ext4_superblock_get_features_read_only(ext4_superblock_t *sb) 188 347 { … … 190 349 } 191 350 351 void ext4_superblock_set_features_read_only(ext4_superblock_t *sb, uint32_t features) 352 { 353 sb->features_read_only = host2uint32_t_le(features); 354 } 192 355 193 356 uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *sb) … … 207 370 } 208 371 372 void ext4_superblock_set_desc_size(ext4_superblock_t *sb, uint16_t size) 373 { 374 sb->desc_size = host2uint16_t_le(size); 375 } 376 209 377 uint32_t ext4_superblock_get_flags(ext4_superblock_t *sb) 210 378 { 211 379 return uint32_t_le2host(sb->flags); 380 } 381 382 void ext4_superblock_set_flags(ext4_superblock_t *sb, uint32_t flags) 383 { 384 sb->flags = host2uint32_t_le(flags); 212 385 } 213 386 … … 307 480 } 308 481 482 // block size 483 // desc size 484 485 309 486 // TODO more checks !!! 310 487
Note:
See TracChangeset
for help on using the changeset viewer.