Changeset 06d85e5 in mainline for uspace/lib/ext4/libext4_bitmap.c
- Timestamp:
- 2012-06-18T11:09:34Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2616a75b
- Parents:
- 9a487cc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_bitmap.c
r9a487cc r06d85e5 73 73 uint32_t byte_index; 74 74 75 / / Align index to multiple of 875 /* Align index to multiple of 8 */ 76 76 while (((idx % 8) != 0) && (remaining > 0)) { 77 77 … … 87 87 } 88 88 89 / / For < 8 bits this check necessary89 /* For < 8 bits this check necessary */ 90 90 if (remaining == 0) { 91 91 return; … … 97 97 target = bitmap + byte_index; 98 98 99 / / Zero the whole bytes99 /* Zero the whole bytes */ 100 100 while (remaining >= 8) { 101 101 *target = 0; … … 108 108 assert(remaining < 8); 109 109 110 / / Zero remaining bytes110 /* Zero remaining bytes */ 111 111 while (remaining != 0) { 112 112 … … 174 174 uint32_t idx; 175 175 176 / / Align idx176 /* Align idx */ 177 177 if (start % 8) { 178 178 idx = start + (8 - (start % 8)); … … 183 183 uint8_t *pos = bitmap + (idx / 8); 184 184 185 / / Try to find free byte185 /* Try to find free byte */ 186 186 while (idx < max) { 187 187 … … 197 197 } 198 198 199 / / Free byte not found199 /* Free byte not found */ 200 200 return ENOSPC; 201 201 } … … 218 218 bool byte_part = false; 219 219 220 / / Check the rest of first byte220 /* Check the rest of first byte */ 221 221 while ((idx % 8) != 0) { 222 222 byte_part = true; … … 235 235 } 236 236 237 / / Check the whole bytes (255 = 11111111 binary)237 /* Check the whole bytes (255 = 11111111 binary) */ 238 238 while (idx < max) { 239 239 240 240 if ((*pos & 255) != 255) { 241 / / free bit found241 /* free bit found */ 242 242 break; 243 243 } … … 247 247 } 248 248 249 / / If idx < max, some free bit found249 /* If idx < max, some free bit found */ 250 250 if (idx < max) { 251 251 252 / / Check which bit from byte is free252 /* Check which bit from byte is free */ 253 253 for (uint8_t i = 0; i < 8; ++i) { 254 254 if ((*pos & (1 << i)) == 0) { 255 / / free bit found255 /* free bit found */ 256 256 *pos |= (1 << i); 257 257 *index = idx; … … 262 262 } 263 263 264 / / Free bit not found264 /* Free bit not found */ 265 265 return ENOSPC; 266 266 }
Note:
See TracChangeset
for help on using the changeset viewer.