mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 18:56:49 +01:00
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 <pulkomandy@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
parent
7916bd8dda
commit
30294b6d05
@ -857,7 +857,7 @@ Inode::_EnlargeDataStream(Transaction& transaction, off_t size)
|
||||
fNode.SetSize(size);
|
||||
TRACE("Inode::_EnlargeDataStream(): Setting allocated block count to %"
|
||||
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);
|
||||
return _SetNumBlocks(_NumBlocks() - end * (fVolume->BlockSize() / 512));
|
||||
return _SetNumBlocks(NumBlocks() - end * (fVolume->BlockSize() / 512));
|
||||
}
|
||||
|
||||
|
||||
uint64
|
||||
Inode::_NumBlocks()
|
||||
Inode::NumBlocks()
|
||||
{
|
||||
if (fVolume->HugeFiles()) {
|
||||
if (fNode.Flags() & EXT2_INODE_HUGE_FILE)
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
int32 Flags() const { return fNode.Flags(); }
|
||||
|
||||
off_t Size() const { return fNode.Size(); }
|
||||
uint64 NumBlocks();
|
||||
void GetChangeTime(struct timespec *timespec) const
|
||||
{ fNode.GetChangeTime(timespec, fHasExtraAttributes); }
|
||||
void GetModificationTime(struct timespec *timespec) const
|
||||
@ -142,7 +143,6 @@ private:
|
||||
status_t _ShrinkDataStream(Transaction& transaction,
|
||||
off_t size);
|
||||
|
||||
uint64 _NumBlocks();
|
||||
status_t _SetNumBlocks(uint64 numBlocks);
|
||||
|
||||
uint32 _InodeChecksum(ext2_inode* inode);
|
||||
|
@ -490,7 +490,7 @@ struct ext2_inode {
|
||||
uint16 NumLinks() const { return B_LENDIAN_TO_HOST_INT16(num_links); }
|
||||
uint32 NumBlocks() 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,
|
||||
uint32 time_extra, bool extra)
|
||||
@ -631,7 +631,7 @@ struct ext2_inode {
|
||||
void SetNumBlocks64(uint64 numBlocks)
|
||||
{
|
||||
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)
|
||||
|
@ -587,7 +587,7 @@ ext2_read_stat(fs_volume* _volume, fs_vnode* _node, struct stat* stat)
|
||||
inode->GetCreationTime(&stat->st_crtim);
|
||||
|
||||
stat->st_size = inode->Size();
|
||||
stat->st_blocks = (inode->Size() + 511) / 512;
|
||||
stat->st_blocks = inode->NumBlocks();
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user