Changeset 662bd71 in mainline for uspace/lib/ext4/libext4_bitmap.c


Ignore:
Timestamp:
2012-04-04T18:05:46Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e7ed26be
Parents:
81092ce
Message:

added support for releasing more blocks in one operation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_bitmap.c

    r81092ce r662bd71  
    5151}
    5252
     53void ext4_bitmap_free_bits(uint8_t *bitmap, uint32_t index, uint32_t count)
     54{
     55        uint8_t *target;
     56        uint32_t idx = index;
     57        uint32_t remaining = count;
     58        uint32_t byte_index;
     59
     60        while (((idx % 8) != 0) && (remaining > 0)) {
     61
     62                byte_index = idx / 8;
     63                uint32_t bit_index = idx % 8;
     64
     65                target = bitmap + byte_index;
     66
     67                *target &= ~ (1 << bit_index);
     68
     69                idx++;
     70                remaining--;
     71        }
     72
     73        assert((idx % 8) == 0);
     74
     75        byte_index = idx / 8;
     76        target = bitmap + byte_index;
     77
     78        while (remaining >= 8) {
     79                *target = 0;
     80
     81                idx += 8;
     82                remaining -= 8;
     83                target++;
     84        }
     85
     86        assert(remaining < 8);
     87
     88        while (remaining != 0) {
     89
     90                byte_index = idx / 8;
     91                uint32_t bit_index = idx % 8;
     92
     93                target = bitmap + byte_index;
     94
     95                *target &= ~ (1 << bit_index);
     96
     97                idx++;
     98                remaining--;
     99        }
     100}
     101
    53102void ext4_bitmap_set_bit(uint8_t *bitmap, uint32_t index)
    54103{
Note: See TracChangeset for help on using the changeset viewer.