mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
Kernel: Make File::truncate() take a u64
No point in taking a signed type here. We validate at the syscall layer and then pass around a u64 from then on.
This commit is contained in:
parent
42d41fdf94
commit
7291370478
Notes:
sideshowbarker
2024-07-19 09:31:58 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7291370478c
@ -1598,10 +1598,10 @@ KResult Ext2FSInode::chown(uid_t uid, gid_t gid)
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult Ext2FSInode::truncate(off_t size)
|
||||
KResult Ext2FSInode::truncate(u64 size)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if ((off_t)m_raw_inode.i_size == size)
|
||||
if (static_cast<u64>(m_raw_inode.i_size) == size)
|
||||
return KSuccess;
|
||||
auto result = resize(size);
|
||||
if (result.is_error())
|
||||
|
@ -70,7 +70,7 @@ private:
|
||||
virtual size_t directory_entry_count() const override;
|
||||
virtual KResult chmod(mode_t) override;
|
||||
virtual KResult chown(uid_t, gid_t) override;
|
||||
virtual KResult truncate(off_t) override;
|
||||
virtual KResult truncate(u64) override;
|
||||
|
||||
bool write_directory(const Vector<FS::DirectoryEntry>&);
|
||||
void populate_lookup_cache() const;
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
|
||||
virtual String absolute_path(const FileDescription&) const = 0;
|
||||
|
||||
virtual KResult truncate(off_t) { return KResult(-EINVAL); }
|
||||
virtual KResult truncate(u64) { return KResult(-EINVAL); }
|
||||
virtual KResult chown(uid_t, gid_t) { return KResult(-EBADF); }
|
||||
virtual KResult chmod(mode_t) { return KResult(-EBADF); }
|
||||
|
||||
|
@ -283,7 +283,7 @@ KResultOr<Region*> FileDescription::mmap(Process& process, VirtualAddress vaddr,
|
||||
return m_file->mmap(process, *this, vaddr, offset, size, prot);
|
||||
}
|
||||
|
||||
KResult FileDescription::truncate(off_t length)
|
||||
KResult FileDescription::truncate(u64 length)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
return m_file->truncate(length);
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
|
||||
void set_original_inode(Badge<VFS>, NonnullRefPtr<Inode>&& inode) { m_inode = move(inode); }
|
||||
|
||||
KResult truncate(off_t);
|
||||
KResult truncate(u64);
|
||||
|
||||
off_t offset() const { return m_current_offset; }
|
||||
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
virtual size_t directory_entry_count() const = 0;
|
||||
virtual KResult chmod(mode_t) = 0;
|
||||
virtual KResult chown(uid_t, gid_t) = 0;
|
||||
virtual KResult truncate(off_t) { return KSuccess; }
|
||||
virtual KResult truncate(u64) { return KSuccess; }
|
||||
virtual KResultOr<NonnullRefPtr<Custody>> resolve_as_link(Custody& base, RefPtr<Custody>* out_parent = nullptr, int options = 0, int symlink_recursion_level = 0) const;
|
||||
|
||||
LocalSocket* socket() { return m_socket.ptr(); }
|
||||
|
@ -74,7 +74,7 @@ String InodeFile::absolute_path(const FileDescription& description) const
|
||||
return description.absolute_path();
|
||||
}
|
||||
|
||||
KResult InodeFile::truncate(off_t size)
|
||||
KResult InodeFile::truncate(u64 size)
|
||||
{
|
||||
auto truncate_result = m_inode->truncate(size);
|
||||
if (truncate_result.is_error())
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
|
||||
virtual String absolute_path(const FileDescription&) const override;
|
||||
|
||||
virtual KResult truncate(off_t) override;
|
||||
virtual KResult truncate(u64) override;
|
||||
virtual KResult chown(uid_t, gid_t) override;
|
||||
virtual KResult chmod(mode_t) override;
|
||||
|
||||
|
@ -327,7 +327,7 @@ KResult TmpFSInode::remove_child(const StringView& name)
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult TmpFSInode::truncate(off_t size)
|
||||
KResult TmpFSInode::truncate(u64 size)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(!is_directory());
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
virtual size_t directory_entry_count() const override;
|
||||
virtual KResult chmod(mode_t) override;
|
||||
virtual KResult chown(uid_t, gid_t) override;
|
||||
virtual KResult truncate(off_t) override;
|
||||
virtual KResult truncate(u64) override;
|
||||
virtual int set_atime(time_t) override;
|
||||
virtual int set_ctime(time_t) override;
|
||||
virtual int set_mtime(time_t) override;
|
||||
|
@ -3868,7 +3868,7 @@ int Process::sys$ftruncate(int fd, off_t length)
|
||||
return -EBADF;
|
||||
if (!description->is_writable())
|
||||
return -EBADF;
|
||||
return description->truncate(length);
|
||||
return description->truncate(static_cast<u64>(length));
|
||||
}
|
||||
|
||||
int Process::sys$watch_file(const char* user_path, size_t path_length)
|
||||
|
Loading…
Reference in New Issue
Block a user