mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
Kernel+LibC: Implement fcntl(2) advisory locks
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.
This commit is contained in:
parent
fbc56461da
commit
3fa2816642
8 changed files with 186 additions and 7 deletions
|
@ -97,6 +97,11 @@ public:
|
|||
|
||||
NonnullRefPtr<FIFO> fifo();
|
||||
|
||||
KResult can_apply_flock(FileDescription const&, flock const&) const;
|
||||
KResult apply_flock(Process const&, FileDescription const&, Userspace<flock const*>);
|
||||
KResult get_flock(FileDescription const&, Userspace<flock*>) const;
|
||||
void remove_flocks_for_description(FileDescription const&);
|
||||
|
||||
protected:
|
||||
Inode(FileSystem&, InodeIndex);
|
||||
void set_metadata_dirty(bool);
|
||||
|
@ -119,6 +124,16 @@ private:
|
|||
RefPtr<FIFO> m_fifo;
|
||||
IntrusiveListNode<Inode> m_inode_list_node;
|
||||
|
||||
struct Flock {
|
||||
short type;
|
||||
off_t start;
|
||||
off_t len;
|
||||
FileDescription const* owner;
|
||||
pid_t pid;
|
||||
};
|
||||
|
||||
Vector<Flock> m_flocks;
|
||||
|
||||
public:
|
||||
using List = IntrusiveList<Inode, RawPtr<Inode>, &Inode::m_inode_list_node>;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue