ext2: use st_blocks from the disk inode structure
* this lets cp from coreutils use lseek to find the data chunks in a sparse file. * fix endian conversion macro used for num_blocks_high Change-Id: I221d6316002b1c491ae987aeef3f25e8721b5ab9 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5218 Reviewed-by: Adrien Destugues <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -857,7 +857,7 @@ Inode::_EnlargeDataStream(Transaction& transaction, off_t size)
|
|||||||
fNode.SetSize(size);
|
fNode.SetSize(size);
|
||||||
TRACE("Inode::_EnlargeDataStream(): Setting allocated block count to %"
|
TRACE("Inode::_EnlargeDataStream(): Setting allocated block count to %"
|
||||||
B_PRIdOFF "\n", end);
|
B_PRIdOFF "\n", end);
|
||||||
return _SetNumBlocks(_NumBlocks() + end * (fVolume->BlockSize() / 512));
|
return _SetNumBlocks(NumBlocks() + end * (fVolume->BlockSize() / 512));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -895,12 +895,12 @@ Inode::_ShrinkDataStream(Transaction& transaction, off_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fNode.SetSize(size);
|
fNode.SetSize(size);
|
||||||
return _SetNumBlocks(_NumBlocks() - end * (fVolume->BlockSize() / 512));
|
return _SetNumBlocks(NumBlocks() - end * (fVolume->BlockSize() / 512));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64
|
uint64
|
||||||
Inode::_NumBlocks()
|
Inode::NumBlocks()
|
||||||
{
|
{
|
||||||
if (fVolume->HugeFiles()) {
|
if (fVolume->HugeFiles()) {
|
||||||
if (fNode.Flags() & EXT2_INODE_HUGE_FILE)
|
if (fNode.Flags() & EXT2_INODE_HUGE_FILE)
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public:
|
|||||||
int32 Flags() const { return fNode.Flags(); }
|
int32 Flags() const { return fNode.Flags(); }
|
||||||
|
|
||||||
off_t Size() const { return fNode.Size(); }
|
off_t Size() const { return fNode.Size(); }
|
||||||
|
uint64 NumBlocks();
|
||||||
void GetChangeTime(struct timespec *timespec) const
|
void GetChangeTime(struct timespec *timespec) const
|
||||||
{ fNode.GetChangeTime(timespec, fHasExtraAttributes); }
|
{ fNode.GetChangeTime(timespec, fHasExtraAttributes); }
|
||||||
void GetModificationTime(struct timespec *timespec) const
|
void GetModificationTime(struct timespec *timespec) const
|
||||||
@@ -142,7 +143,6 @@ private:
|
|||||||
status_t _ShrinkDataStream(Transaction& transaction,
|
status_t _ShrinkDataStream(Transaction& transaction,
|
||||||
off_t size);
|
off_t size);
|
||||||
|
|
||||||
uint64 _NumBlocks();
|
|
||||||
status_t _SetNumBlocks(uint64 numBlocks);
|
status_t _SetNumBlocks(uint64 numBlocks);
|
||||||
|
|
||||||
uint32 _InodeChecksum(ext2_inode* inode);
|
uint32 _InodeChecksum(ext2_inode* inode);
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ struct ext2_inode {
|
|||||||
uint16 NumLinks() const { return B_LENDIAN_TO_HOST_INT16(num_links); }
|
uint16 NumLinks() const { return B_LENDIAN_TO_HOST_INT16(num_links); }
|
||||||
uint32 NumBlocks() const { return B_LENDIAN_TO_HOST_INT32(num_blocks); }
|
uint32 NumBlocks() const { return B_LENDIAN_TO_HOST_INT32(num_blocks); }
|
||||||
uint64 NumBlocks64() const { return B_LENDIAN_TO_HOST_INT32(num_blocks)
|
uint64 NumBlocks64() const { return B_LENDIAN_TO_HOST_INT32(num_blocks)
|
||||||
| ((uint64)B_LENDIAN_TO_HOST_INT32(num_blocks_high) << 32); }
|
| ((uint64)B_LENDIAN_TO_HOST_INT16(num_blocks_high) << 32); }
|
||||||
|
|
||||||
static void _DecodeTime(struct timespec *timespec, uint32 time,
|
static void _DecodeTime(struct timespec *timespec, uint32 time,
|
||||||
uint32 time_extra, bool extra)
|
uint32 time_extra, bool extra)
|
||||||
@@ -631,7 +631,7 @@ struct ext2_inode {
|
|||||||
void SetNumBlocks64(uint64 numBlocks)
|
void SetNumBlocks64(uint64 numBlocks)
|
||||||
{
|
{
|
||||||
num_blocks = B_HOST_TO_LENDIAN_INT32(numBlocks & 0xffffffff);
|
num_blocks = B_HOST_TO_LENDIAN_INT32(numBlocks & 0xffffffff);
|
||||||
num_blocks_high = B_HOST_TO_LENDIAN_INT32(numBlocks >> 32);
|
num_blocks_high = B_HOST_TO_LENDIAN_INT16(numBlocks >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetNextOrphan(ino_t id)
|
void SetNextOrphan(ino_t id)
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ ext2_read_stat(fs_volume* _volume, fs_vnode* _node, struct stat* stat)
|
|||||||
inode->GetCreationTime(&stat->st_crtim);
|
inode->GetCreationTime(&stat->st_crtim);
|
||||||
|
|
||||||
stat->st_size = inode->Size();
|
stat->st_size = inode->Size();
|
||||||
stat->st_blocks = (inode->Size() + 511) / 512;
|
stat->st_blocks = inode->NumBlocks();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user