- DiskStructures.{h,cpp} -> UdfStructures.{h,cpp}
- Added Udf::get_block_shift() git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5529 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -103,4 +103,29 @@ make_time(timestamp ×tamp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! \brief Calculates the block shift amount for the given
|
||||||
|
block size, which must be a positive power of 2.
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
Udf::get_block_shift(uint32 blockSize, uint32 &blockShift)
|
||||||
|
{
|
||||||
|
if (blockSize == 0)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
uint32 bitCount = 0;
|
||||||
|
uint32 result = 0;
|
||||||
|
for (int i = 0; i < 32; i++) {
|
||||||
|
// Zero out all bits except bit i
|
||||||
|
uint32 block = blockSize & (uint32(1) << i);
|
||||||
|
if (block) {
|
||||||
|
if (++bitCount > 1) {
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
} else {
|
||||||
|
result = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blockShift = result;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Udf
|
} // namespace Udf
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ extern "C" {
|
|||||||
#include <fsproto.h>
|
#include <fsproto.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "DiskStructures.h"
|
#include "UdfStructures.h"
|
||||||
|
|
||||||
namespace Udf {
|
namespace Udf {
|
||||||
|
|
||||||
@@ -30,6 +30,8 @@ vnode_id to_vnode_id(long_address address);
|
|||||||
|
|
||||||
time_t make_time(timestamp ×tamp);
|
time_t make_time(timestamp ×tamp);
|
||||||
|
|
||||||
|
status_t get_block_shift(uint32 blockSize, uint32 &blockShift);
|
||||||
|
|
||||||
} // namespace Udf
|
} // namespace Udf
|
||||||
|
|
||||||
#endif // _UDF_UTILS_H
|
#endif // _UDF_UTILS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user