diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-08 12:07:04 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-08 12:07:04 +0100 |
commit | 7291370478c8ccb2ad94e1aa31f47e1f9cc7e300 (patch) | |
tree | 64610c534bd4ad04a1ca5a79fd76552f55c70ac6 /Kernel | |
parent | 42d41fdf947956af0dcbab46dbd316a38e7f6199 (diff) | |
download | serenity-7291370478c8ccb2ad94e1aa31f47e1f9cc7e300.zip |
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.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 4 | ||||
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/File.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/FileDescription.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/FileDescription.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/Inode.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/InodeFile.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/InodeFile.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/TmpFS.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/TmpFS.h | 2 | ||||
-rw-r--r-- | Kernel/Process.cpp | 2 |
11 files changed, 12 insertions, 12 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 3c9a83c2eb..06a5413c39 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -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()) diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index 4446dd64cf..7736008d49 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -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; diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h index 5804fa478d..46e8d802e1 100644 --- a/Kernel/FileSystem/File.h +++ b/Kernel/FileSystem/File.h @@ -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); } diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index 106946f831..73017d2f6c 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -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); diff --git a/Kernel/FileSystem/FileDescription.h b/Kernel/FileSystem/FileDescription.h index 4638f00028..be1e3d2120 100644 --- a/Kernel/FileSystem/FileDescription.h +++ b/Kernel/FileSystem/FileDescription.h @@ -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; } diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index 23ec6616f2..0747eb4c5d 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -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(); } diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp index 5915b5faab..ecbb41c49b 100644 --- a/Kernel/FileSystem/InodeFile.cpp +++ b/Kernel/FileSystem/InodeFile.cpp @@ -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()) diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h index 3d21853bec..0e3b8ef511 100644 --- a/Kernel/FileSystem/InodeFile.h +++ b/Kernel/FileSystem/InodeFile.h @@ -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; diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp index 64a84c0820..6e1575ad6a 100644 --- a/Kernel/FileSystem/TmpFS.cpp +++ b/Kernel/FileSystem/TmpFS.cpp @@ -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()); diff --git a/Kernel/FileSystem/TmpFS.h b/Kernel/FileSystem/TmpFS.h index d2067504c9..2f98ec0853 100644 --- a/Kernel/FileSystem/TmpFS.h +++ b/Kernel/FileSystem/TmpFS.h @@ -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; diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 47683a4135..240cc83947 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -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) |