move ROUND_{UP,DOWN} to support.h, make second parameter to be order in which
we should power 2 (to prevent incorrect use)edge.strict_endians
parent
5369c19613
commit
035df31eae
|
@ -26,9 +26,7 @@
|
|||
#include "attrib.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
#define ROUND_UP(num,bound) (((num)+((bound)-1)) & ~((bound)-1))
|
||||
#define ROUND_DOWN(num,bound) ((num) & ~((bound)-1))
|
||||
#define ATTR_SIZE(s) ROUND_UP(s,8)
|
||||
#define ATTR_SIZE(s) ROUND_UP(s, 3)
|
||||
|
||||
ATTR_RECORD * find_attribute(const ATTR_TYPES type, ntfs_attr_search_ctx *ctx);
|
||||
ATTR_RECORD * find_first_attribute(const ATTR_TYPES type, MFT_RECORD *mft);
|
||||
|
|
|
@ -60,6 +60,13 @@
|
|||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Round up and down @num to 2 in power of @order.
|
||||
*/
|
||||
#define ROUND_UP(num,order) (((num) + ((1 << order) - 1)) & \
|
||||
~((1 << order) - 1))
|
||||
#define ROUND_DOWN(num,order) ((num) & ~((1 << order) - 1))
|
||||
|
||||
/*
|
||||
* Simple bit operation macros. NOTE: These are NOT atomic.
|
||||
*/
|
||||
|
|
|
@ -401,9 +401,9 @@ int ntfs_bmp_add_data(struct ntfs_bmp *bmp, VCN vcn, u8 *data)
|
|||
return -1;
|
||||
|
||||
ntfs_log_trace ("\n");
|
||||
old = ROUND_UP(bmp->count, 16);
|
||||
old = ROUND_UP(bmp->count, 4);
|
||||
bmp->count++;
|
||||
new = ROUND_UP(bmp->count, 16);
|
||||
new = ROUND_UP(bmp->count, 4);
|
||||
|
||||
if (old != new) {
|
||||
bmp->data = realloc(bmp->data, new * sizeof(*bmp->data));
|
||||
|
@ -513,8 +513,8 @@ int ntfs_bmp_set_range(struct ntfs_bmp *bmp, VCN vcn, s64 length, int value)
|
|||
vcn_finish = vcn + length - 1;
|
||||
|
||||
//ntfs_log_debug("vcn_start = %d, vcn_finish = %d\n", vcn_start, vcn_finish);
|
||||
a = ROUND_DOWN(vcn_start, csib);
|
||||
b = ROUND_DOWN(vcn_finish, csib) + 1;
|
||||
a = ROUND_DOWN(vcn_start, bmp->vol->cluster_size_bits + 3);
|
||||
b = ROUND_DOWN(vcn_finish, bmp->vol->cluster_size_bits + 3) + 1;
|
||||
|
||||
//ntfs_log_debug("a = %lld, b = %lld\n", a, b);
|
||||
|
||||
|
@ -598,7 +598,7 @@ s64 ntfs_bmp_find_last_set(struct ntfs_bmp *bmp)
|
|||
// find cluster size of bmp
|
||||
|
||||
byte_count = bmp->attr->data_size;
|
||||
clust_count = ROUND_UP(byte_count, bmp->vol->cluster_size) >> bmp->vol->cluster_size_bits;
|
||||
clust_count = ROUND_UP(byte_count, bmp->vol->cluster_size_bits) >> bmp->vol->cluster_size_bits;
|
||||
|
||||
//ntfs_log_debug("bitmap = %lld bytes\n", byte_count);
|
||||
//ntfs_log_debug("bitmap = %lld buffers\n", clust_count);
|
||||
|
|
|
@ -1750,7 +1750,7 @@ int ntfs_dir_truncate(ntfs_volume *vol, struct ntfs_dir *dir)
|
|||
return 0;
|
||||
|
||||
#if 0
|
||||
buf_count = ROUND_UP(dir->bitmap->attr->allocated_size, vol->cluster_size) >> vol->cluster_size_bits;
|
||||
buf_count = ROUND_UP(dir->bitmap->attr->allocated_size, vol->cluster_size_bits) >> vol->cluster_size_bits;
|
||||
ntfs_log_debug("alloc = %lld bytes\n", dir->ialloc->allocated_size);
|
||||
ntfs_log_debug("alloc = %lld clusters\n", dir->ialloc->allocated_size >> vol->cluster_size_bits);
|
||||
ntfs_log_debug("bitmap bytes 0 to %lld\n", ((dir->ialloc->allocated_size >> vol->cluster_size_bits)-1)>>3);
|
||||
|
|
Loading…
Reference in New Issue