mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:12:08 +00:00
Ext2FS: Assert that inline symlink read/write always uses offset=0
This commit is contained in:
parent
5a13a5416e
commit
e91f03cb39
1 changed files with 2 additions and 0 deletions
|
@ -611,6 +611,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes
|
||||||
// Symbolic links shorter than 60 characters are store inline inside the i_block array.
|
// Symbolic links shorter than 60 characters are store inline inside the i_block array.
|
||||||
// This avoids wasting an entire block on short links. (Most links are short.)
|
// This avoids wasting an entire block on short links. (Most links are short.)
|
||||||
if (is_symlink() && size() < max_inline_symlink_length) {
|
if (is_symlink() && size() < max_inline_symlink_length) {
|
||||||
|
ASSERT(offset == 0);
|
||||||
ssize_t nread = min((off_t)size() - offset, static_cast<off_t>(count));
|
ssize_t nread = min((off_t)size() - offset, static_cast<off_t>(count));
|
||||||
memcpy(buffer, ((const u8*)m_raw_inode.i_block) + offset, (size_t)nread);
|
memcpy(buffer, ((const u8*)m_raw_inode.i_block) + offset, (size_t)nread);
|
||||||
return nread;
|
return nread;
|
||||||
|
@ -722,6 +723,7 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi
|
||||||
Locker fs_locker(fs().m_lock);
|
Locker fs_locker(fs().m_lock);
|
||||||
|
|
||||||
if (is_symlink()) {
|
if (is_symlink()) {
|
||||||
|
ASSERT(offset == 0);
|
||||||
if (max((size_t)(offset + count), (size_t)m_raw_inode.i_size) < max_inline_symlink_length) {
|
if (max((size_t)(offset + count), (size_t)m_raw_inode.i_size) < max_inline_symlink_length) {
|
||||||
#ifdef EXT2_DEBUG
|
#ifdef EXT2_DEBUG
|
||||||
dbgprintf("Ext2FSInode: write_bytes poking into i_block array for inline symlink '%s' (%u bytes)\n", String((const char*)data, count).characters(), count);
|
dbgprintf("Ext2FSInode: write_bytes poking into i_block array for inline symlink '%s' (%u bytes)\n", String((const char*)data, count).characters(), count);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue