2020-01-18 11:38:21 +03:00
|
|
|
/*
|
2020-01-24 16:45:29 +03:00
|
|
|
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
2020-01-18 11:38:21 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-08-15 18:16:45 +03:00
|
|
|
#include <Kernel/FileSystem/TmpFS.h>
|
|
|
|
#include <Kernel/Process.h>
|
2020-10-22 19:59:00 +03:00
|
|
|
#include <LibC/limits.h>
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2020-02-16 03:27:42 +03:00
|
|
|
namespace Kernel {
|
|
|
|
|
2021-05-28 15:41:05 +03:00
|
|
|
RefPtr<TmpFS> TmpFS::create()
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-06-20 11:21:16 +03:00
|
|
|
return adopt_ref_if_nonnull(new (nothrow) TmpFS);
|
2019-08-15 18:16:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TmpFS::TmpFS()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TmpFS::~TmpFS()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-08-14 15:02:47 +03:00
|
|
|
KResult TmpFS::initialize()
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
|
|
|
m_root_inode = TmpFSInode::create_root(*this);
|
2021-08-14 15:02:47 +03:00
|
|
|
if (!m_root_inode)
|
|
|
|
return ENOMEM;
|
|
|
|
return KSuccess;
|
2019-08-15 18:16:45 +03:00
|
|
|
}
|
|
|
|
|
2021-07-18 02:50:47 +03:00
|
|
|
Inode& TmpFS::root_inode()
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(!m_root_inode.is_null());
|
2020-06-24 23:35:56 +03:00
|
|
|
return *m_root_inode;
|
2019-08-15 18:16:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void TmpFS::register_inode(TmpFSInode& inode)
|
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_lock);
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(inode.identifier().fsid() == fsid());
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2021-02-12 11:18:47 +03:00
|
|
|
auto index = inode.identifier().index();
|
2019-08-15 18:16:45 +03:00
|
|
|
m_inodes.set(index, inode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TmpFS::unregister_inode(InodeIdentifier identifier)
|
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_lock);
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(identifier.fsid() == fsid());
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
m_inodes.remove(identifier.index());
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TmpFS::next_inode_index()
|
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_lock);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
return m_next_inode_index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Inode> TmpFS::get_inode(InodeIdentifier identifier) const
|
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_lock, Mutex::Mode::Shared);
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(identifier.fsid() == fsid());
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
auto it = m_inodes.find(identifier.index());
|
|
|
|
if (it == m_inodes.end())
|
|
|
|
return nullptr;
|
|
|
|
return it->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
TmpFSInode::TmpFSInode(TmpFS& fs, InodeMetadata metadata, InodeIdentifier parent)
|
|
|
|
: Inode(fs, fs.next_inode_index())
|
|
|
|
, m_metadata(metadata)
|
|
|
|
, m_parent(parent)
|
|
|
|
{
|
|
|
|
m_metadata.inode = identifier();
|
|
|
|
}
|
|
|
|
|
|
|
|
TmpFSInode::~TmpFSInode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-28 15:41:05 +03:00
|
|
|
RefPtr<TmpFSInode> TmpFSInode::create(TmpFS& fs, InodeMetadata metadata, InodeIdentifier parent)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-06-20 11:21:16 +03:00
|
|
|
auto inode = adopt_ref_if_nonnull(new (nothrow) TmpFSInode(fs, metadata, parent));
|
2021-05-28 15:41:05 +03:00
|
|
|
if (inode)
|
|
|
|
fs.register_inode(*inode);
|
2019-08-15 18:16:45 +03:00
|
|
|
return inode;
|
|
|
|
}
|
|
|
|
|
2021-05-28 15:41:05 +03:00
|
|
|
RefPtr<TmpFSInode> TmpFSInode::create_root(TmpFS& fs)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
|
|
|
InodeMetadata metadata;
|
2021-02-28 04:18:48 +03:00
|
|
|
auto now = kgettimeofday().to_truncated_seconds();
|
|
|
|
metadata.atime = now;
|
|
|
|
metadata.ctime = now;
|
|
|
|
metadata.mtime = now;
|
2020-06-16 22:03:51 +03:00
|
|
|
metadata.mode = S_IFDIR | S_ISVTX | 0777;
|
2020-01-10 14:35:18 +03:00
|
|
|
return create(fs, metadata, { fs.fsid(), 1 });
|
2019-08-15 18:16:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
InodeMetadata TmpFSInode::metadata() const
|
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock, Mutex::Mode::Shared);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
return m_metadata;
|
|
|
|
}
|
|
|
|
|
2021-07-11 01:20:38 +03:00
|
|
|
KResult TmpFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock, Mutex::Mode::Shared);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
if (!is_directory())
|
2021-01-21 01:11:17 +03:00
|
|
|
return ENOTDIR;
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2020-01-10 14:35:18 +03:00
|
|
|
callback({ ".", identifier(), 0 });
|
|
|
|
callback({ "..", m_parent, 0 });
|
|
|
|
|
2021-07-18 14:47:18 +03:00
|
|
|
for (auto& child : m_children) {
|
|
|
|
callback({ child.name->view(), child.inode->identifier(), 0 });
|
2020-08-18 13:41:27 +03:00
|
|
|
}
|
2020-05-26 10:36:11 +03:00
|
|
|
return KSuccess;
|
2019-08-15 18:16:45 +03:00
|
|
|
}
|
|
|
|
|
2021-06-16 17:44:15 +03:00
|
|
|
KResultOr<size_t> TmpFSInode::read_bytes(off_t offset, size_t size, UserOrKernelBuffer& buffer, FileDescription*) const
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock, Mutex::Mode::Shared);
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(!is_directory());
|
|
|
|
VERIFY(offset >= 0);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2020-12-18 15:34:57 +03:00
|
|
|
if (!m_content)
|
2019-08-15 18:16:45 +03:00
|
|
|
return 0;
|
|
|
|
|
2020-01-08 14:45:39 +03:00
|
|
|
if (offset >= m_metadata.size)
|
|
|
|
return 0;
|
|
|
|
|
2019-08-24 20:52:18 +03:00
|
|
|
if (static_cast<off_t>(size) > m_metadata.size - offset)
|
|
|
|
size = m_metadata.size - offset;
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2020-12-18 15:34:57 +03:00
|
|
|
if (!buffer.write(m_content->data() + offset, size))
|
2021-05-02 00:29:39 +03:00
|
|
|
return EFAULT;
|
2019-08-15 18:16:45 +03:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2021-06-16 17:44:15 +03:00
|
|
|
KResultOr<size_t> TmpFSInode::write_bytes(off_t offset, size_t size, const UserOrKernelBuffer& buffer, FileDescription*)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(!is_directory());
|
|
|
|
VERIFY(offset >= 0);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2020-04-04 20:46:55 +03:00
|
|
|
auto result = prepare_to_write_data();
|
|
|
|
if (result.is_error())
|
|
|
|
return result;
|
|
|
|
|
2019-08-24 20:52:18 +03:00
|
|
|
off_t old_size = m_metadata.size;
|
|
|
|
off_t new_size = m_metadata.size;
|
2021-07-07 09:17:22 +03:00
|
|
|
if (static_cast<off_t>(offset + size) > new_size)
|
2019-08-24 20:52:18 +03:00
|
|
|
new_size = offset + size;
|
|
|
|
|
2021-07-07 09:17:22 +03:00
|
|
|
if (static_cast<u64>(new_size) > (NumericLimits<size_t>::max() / 2)) // on 32-bit, size_t might be 32 bits while off_t is 64 bits
|
|
|
|
return ENOMEM; // we won't be able to resize to this capacity
|
|
|
|
|
2019-08-24 20:52:18 +03:00
|
|
|
if (new_size > old_size) {
|
2021-07-07 09:17:22 +03:00
|
|
|
if (m_content && static_cast<off_t>(m_content->capacity()) >= new_size) {
|
2020-12-18 15:34:57 +03:00
|
|
|
m_content->set_size(new_size);
|
2019-08-24 20:52:18 +03:00
|
|
|
} else {
|
2020-10-03 00:14:37 +03:00
|
|
|
// Grow the content buffer 2x the new sizeto accommodate repeating write() calls.
|
2020-01-19 15:58:16 +03:00
|
|
|
// Note that we're not actually committing physical memory to the buffer
|
|
|
|
// until it's needed. We only grow VM here.
|
|
|
|
|
|
|
|
// FIXME: Fix this so that no memcpy() is necessary, and we can just grow the
|
|
|
|
// KBuffer and it will add physical pages as needed while keeping the
|
|
|
|
// existing ones.
|
2020-12-18 15:34:57 +03:00
|
|
|
auto tmp = KBuffer::try_create_with_size(new_size * 2);
|
|
|
|
if (!tmp)
|
2021-05-02 00:29:39 +03:00
|
|
|
return ENOMEM;
|
2020-12-18 15:34:57 +03:00
|
|
|
tmp->set_size(new_size);
|
|
|
|
if (m_content)
|
|
|
|
memcpy(tmp->data(), m_content->data(), old_size);
|
2019-08-24 20:52:18 +03:00
|
|
|
m_content = move(tmp);
|
|
|
|
}
|
|
|
|
m_metadata.size = new_size;
|
2021-08-19 09:41:08 +03:00
|
|
|
notify_watchers();
|
2019-08-15 18:16:45 +03:00
|
|
|
}
|
|
|
|
|
2020-12-18 15:34:57 +03:00
|
|
|
if (!buffer.read(m_content->data() + offset, size)) // TODO: partial reads?
|
2021-05-02 00:29:39 +03:00
|
|
|
return EFAULT;
|
2021-05-12 22:17:51 +03:00
|
|
|
|
|
|
|
did_modify_contents();
|
2019-08-15 18:16:45 +03:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2021-08-14 14:32:35 +03:00
|
|
|
KResultOr<NonnullRefPtr<Inode>> TmpFSInode::lookup(StringView name)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock, Mutex::Mode::Shared);
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(is_directory());
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
if (name == ".")
|
2021-08-14 14:32:35 +03:00
|
|
|
return *this;
|
|
|
|
if (name == "..") {
|
|
|
|
auto inode = fs().get_inode(m_parent);
|
|
|
|
// FIXME: If this cannot fail, we should probably VERIFY here instead.
|
|
|
|
if (!inode)
|
|
|
|
return ENOENT;
|
|
|
|
return inode.release_nonnull();
|
|
|
|
}
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2021-07-18 14:47:18 +03:00
|
|
|
auto* child = find_child_by_name(name);
|
|
|
|
if (!child)
|
2021-08-14 14:32:35 +03:00
|
|
|
return ENOENT;
|
2021-07-18 14:47:18 +03:00
|
|
|
return child->inode;
|
|
|
|
}
|
|
|
|
|
|
|
|
TmpFSInode::Child* TmpFSInode::find_child_by_name(StringView name)
|
|
|
|
{
|
|
|
|
for (auto& child : m_children) {
|
|
|
|
if (child.name->view() == name)
|
|
|
|
return &child;
|
|
|
|
}
|
|
|
|
return nullptr;
|
2019-08-15 18:16:45 +03:00
|
|
|
}
|
|
|
|
|
2020-06-24 23:35:56 +03:00
|
|
|
void TmpFSInode::notify_watchers()
|
|
|
|
{
|
|
|
|
set_metadata_dirty(true);
|
|
|
|
set_metadata_dirty(false);
|
|
|
|
}
|
|
|
|
|
2019-08-15 18:16:45 +03:00
|
|
|
void TmpFSInode::flush_metadata()
|
|
|
|
{
|
|
|
|
// We don't really have any metadata that could become dirty.
|
|
|
|
// The only reason we even call set_metadata_dirty() is
|
|
|
|
// to let the watchers know we have updates. Once that is
|
|
|
|
// switched to a different mechanism, we can stop ever marking
|
|
|
|
// our metadata as dirty at all.
|
|
|
|
set_metadata_dirty(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
KResult TmpFSInode::chmod(mode_t mode)
|
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
m_metadata.mode = mode;
|
2020-06-24 23:35:56 +03:00
|
|
|
notify_watchers();
|
2019-08-15 18:16:45 +03:00
|
|
|
return KSuccess;
|
|
|
|
}
|
|
|
|
|
2021-08-28 23:11:16 +03:00
|
|
|
KResult TmpFSInode::chown(UserID uid, GroupID gid)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
m_metadata.uid = uid;
|
|
|
|
m_metadata.gid = gid;
|
2020-06-24 23:35:56 +03:00
|
|
|
notify_watchers();
|
2019-08-15 18:16:45 +03:00
|
|
|
return KSuccess;
|
|
|
|
}
|
|
|
|
|
2021-08-28 23:11:16 +03:00
|
|
|
KResultOr<NonnullRefPtr<Inode>> TmpFSInode::create_child(StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
2020-06-24 23:35:56 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2020-06-24 23:35:56 +03:00
|
|
|
|
|
|
|
// TODO: Support creating devices on TmpFS.
|
|
|
|
if (dev != 0)
|
2021-01-21 01:11:17 +03:00
|
|
|
return ENOTSUP;
|
2020-06-24 23:35:56 +03:00
|
|
|
|
2021-02-28 04:18:48 +03:00
|
|
|
time_t now = kgettimeofday().to_truncated_seconds();
|
2020-06-24 23:35:56 +03:00
|
|
|
|
|
|
|
InodeMetadata metadata;
|
|
|
|
metadata.mode = mode;
|
|
|
|
metadata.uid = uid;
|
|
|
|
metadata.gid = gid;
|
2021-02-28 04:18:48 +03:00
|
|
|
metadata.atime = now;
|
|
|
|
metadata.ctime = now;
|
|
|
|
metadata.mtime = now;
|
2020-06-24 23:35:56 +03:00
|
|
|
|
|
|
|
auto child = TmpFSInode::create(fs(), metadata, identifier());
|
2021-05-28 15:41:05 +03:00
|
|
|
if (!child)
|
|
|
|
return ENOMEM;
|
|
|
|
auto result = add_child(*child, name, mode);
|
2020-06-24 23:35:56 +03:00
|
|
|
if (result.is_error())
|
|
|
|
return result;
|
2021-05-28 15:41:05 +03:00
|
|
|
return child.release_nonnull();
|
2020-06-24 23:35:56 +03:00
|
|
|
}
|
|
|
|
|
2021-07-18 14:47:18 +03:00
|
|
|
KResult TmpFSInode::add_child(Inode& child, StringView const& name, mode_t)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(is_directory());
|
|
|
|
VERIFY(child.fsid() == fsid());
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2020-10-22 19:59:00 +03:00
|
|
|
if (name.length() > NAME_MAX)
|
2021-01-21 01:11:17 +03:00
|
|
|
return ENAMETOOLONG;
|
2020-10-22 19:59:00 +03:00
|
|
|
|
2021-07-18 14:47:18 +03:00
|
|
|
auto name_kstring = KString::try_create(name);
|
|
|
|
if (!name_kstring)
|
|
|
|
return ENOMEM;
|
|
|
|
|
|
|
|
auto* child_entry = new (nothrow) Child { name_kstring.release_nonnull(), static_cast<TmpFSInode&>(child) };
|
|
|
|
if (!child_entry)
|
|
|
|
return ENOMEM;
|
|
|
|
|
|
|
|
MutexLocker locker(m_inode_lock);
|
|
|
|
m_children.append(*child_entry);
|
2021-05-12 22:17:51 +03:00
|
|
|
did_add_child(child.identifier(), name);
|
2019-08-15 18:16:45 +03:00
|
|
|
return KSuccess;
|
|
|
|
}
|
|
|
|
|
2021-07-18 14:47:18 +03:00
|
|
|
KResult TmpFSInode::remove_child(StringView const& name)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(is_directory());
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2020-01-10 14:35:18 +03:00
|
|
|
if (name == "." || name == "..")
|
|
|
|
return KSuccess;
|
|
|
|
|
2021-07-18 14:47:18 +03:00
|
|
|
auto* child = find_child_by_name(name);
|
|
|
|
if (!child)
|
2021-01-21 01:11:17 +03:00
|
|
|
return ENOENT;
|
2021-07-18 14:47:18 +03:00
|
|
|
|
|
|
|
auto child_id = child->inode->identifier();
|
|
|
|
child->inode->did_delete_self();
|
|
|
|
m_children.remove(*child);
|
2021-05-12 22:17:51 +03:00
|
|
|
did_remove_child(child_id, name);
|
2019-08-15 18:16:45 +03:00
|
|
|
return KSuccess;
|
|
|
|
}
|
|
|
|
|
2020-02-08 14:07:04 +03:00
|
|
|
KResult TmpFSInode::truncate(u64 size)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(!is_directory());
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
m_content.clear();
|
2020-12-18 15:34:57 +03:00
|
|
|
else if (!m_content) {
|
|
|
|
m_content = KBuffer::try_create_with_size(size);
|
|
|
|
if (!m_content)
|
2021-01-21 01:11:17 +03:00
|
|
|
return ENOMEM;
|
2020-12-18 15:34:57 +03:00
|
|
|
} else if (static_cast<size_t>(size) < m_content->capacity()) {
|
2019-08-24 20:52:18 +03:00
|
|
|
size_t prev_size = m_metadata.size;
|
2020-12-18 15:34:57 +03:00
|
|
|
m_content->set_size(size);
|
2019-08-15 18:16:45 +03:00
|
|
|
if (prev_size < static_cast<size_t>(size))
|
2020-12-18 15:34:57 +03:00
|
|
|
memset(m_content->data() + prev_size, 0, size - prev_size);
|
2019-08-15 18:16:45 +03:00
|
|
|
} else {
|
2019-08-24 20:52:18 +03:00
|
|
|
size_t prev_size = m_metadata.size;
|
2020-12-18 15:34:57 +03:00
|
|
|
auto tmp = KBuffer::try_create_with_size(size);
|
|
|
|
if (!tmp)
|
2021-01-21 01:11:17 +03:00
|
|
|
return ENOMEM;
|
2020-12-18 15:34:57 +03:00
|
|
|
memcpy(tmp->data(), m_content->data(), prev_size);
|
2019-08-15 18:16:45 +03:00
|
|
|
m_content = move(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_metadata.size = size;
|
2020-06-24 23:35:56 +03:00
|
|
|
notify_watchers();
|
2019-08-15 18:16:45 +03:00
|
|
|
return KSuccess;
|
|
|
|
}
|
|
|
|
|
2021-04-30 16:51:06 +03:00
|
|
|
KResult TmpFSInode::set_atime(time_t time)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
m_metadata.atime = time;
|
2021-08-19 09:41:08 +03:00
|
|
|
notify_watchers();
|
2019-08-15 18:16:45 +03:00
|
|
|
return KSuccess;
|
|
|
|
}
|
|
|
|
|
2021-04-30 16:51:06 +03:00
|
|
|
KResult TmpFSInode::set_ctime(time_t time)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
|
|
|
m_metadata.ctime = time;
|
2020-06-24 23:35:56 +03:00
|
|
|
notify_watchers();
|
2019-08-15 18:16:45 +03:00
|
|
|
return KSuccess;
|
|
|
|
}
|
|
|
|
|
2021-04-30 16:51:06 +03:00
|
|
|
KResult TmpFSInode::set_mtime(time_t t)
|
2019-08-15 18:16:45 +03:00
|
|
|
{
|
2021-07-18 02:13:34 +03:00
|
|
|
MutexLocker locker(m_inode_lock);
|
2019-08-15 18:16:45 +03:00
|
|
|
|
2021-04-30 16:51:06 +03:00
|
|
|
m_metadata.mtime = t;
|
2020-06-24 23:35:56 +03:00
|
|
|
notify_watchers();
|
2019-08-15 18:16:45 +03:00
|
|
|
return KSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TmpFSInode::one_ref_left()
|
|
|
|
{
|
|
|
|
// Destroy ourselves.
|
|
|
|
fs().unregister_inode(identifier());
|
|
|
|
}
|
2020-02-16 03:27:42 +03:00
|
|
|
|
|
|
|
}
|