mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
Advisory locks don't actually prevent other processes from writing to the file, but they do prevent other processes looking to acquire and advisory lock on the file. This implementation currently only adds non-blocking locks, which are all I need for now.
57 lines
998 B
C++
57 lines
998 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/StringView.h>
|
|
#include <Kernel/FileSystem/File.h>
|
|
#include <Kernel/FileSystem/FileDescription.h>
|
|
#include <Kernel/Process.h>
|
|
|
|
namespace Kernel {
|
|
|
|
File::File()
|
|
{
|
|
}
|
|
|
|
File::~File()
|
|
{
|
|
}
|
|
|
|
KResultOr<NonnullRefPtr<FileDescription>> File::open(int options)
|
|
{
|
|
auto description = FileDescription::create(*this);
|
|
if (!description.is_error()) {
|
|
description.value()->set_rw_mode(options);
|
|
description.value()->set_file_flags(options);
|
|
}
|
|
return description;
|
|
}
|
|
|
|
KResult File::close()
|
|
{
|
|
return KSuccess;
|
|
}
|
|
|
|
int File::ioctl(FileDescription&, unsigned, FlatPtr)
|
|
{
|
|
return -ENOTTY;
|
|
}
|
|
|
|
KResultOr<Region*> File::mmap(Process&, FileDescription&, const Range&, u64, int, bool)
|
|
{
|
|
return ENODEV;
|
|
}
|
|
|
|
KResult File::attach(FileDescription&)
|
|
{
|
|
m_attach_count++;
|
|
return KSuccess;
|
|
}
|
|
|
|
void File::detach(FileDescription&)
|
|
{
|
|
m_attach_count--;
|
|
}
|
|
}
|