summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/InodeIdentifier.h
blob: d6d4c4e881c0b6913a537175bced9d418a6ec55c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include <AK/AKString.h>
#include <AK/ByteBuffer.h>
#include <AK/Types.h>

class FS;
struct InodeMetadata;

class InodeIdentifier {
public:
    InodeIdentifier() {}
    InodeIdentifier(dword fsid, dword inode)
        : m_fsid(fsid)
        , m_index(inode)
    {
    }

    bool is_valid() const { return m_fsid != 0 && m_index != 0; }

    dword fsid() const { return m_fsid; }
    dword index() const { return m_index; }

    FS* fs();
    const FS* fs() const;

    bool operator==(const InodeIdentifier& other) const
    {
        return m_fsid == other.m_fsid && m_index == other.m_index;
    }

    bool operator!=(const InodeIdentifier& other) const
    {
        return m_fsid != other.m_fsid || m_index != other.m_index;
    }

    bool is_root_inode() const;

    String to_string() const { return String::format("%u:%u", m_fsid, m_index); }

private:
    dword m_fsid { 0 };
    dword m_index { 0 };
};