InodeIdentifier.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include <AK/String.h>
  3. #include <AK/ByteBuffer.h>
  4. #include <AK/Types.h>
  5. class FS;
  6. struct InodeMetadata;
  7. class InodeIdentifier {
  8. public:
  9. InodeIdentifier() {}
  10. InodeIdentifier(u32 fsid, u32 inode)
  11. : m_fsid(fsid)
  12. , m_index(inode)
  13. {
  14. }
  15. bool is_valid() const { return m_fsid != 0 && m_index != 0; }
  16. u32 fsid() const { return m_fsid; }
  17. u32 index() const { return m_index; }
  18. FS* fs();
  19. const FS* fs() const;
  20. bool operator==(const InodeIdentifier& other) const
  21. {
  22. return m_fsid == other.m_fsid && m_index == other.m_index;
  23. }
  24. bool operator!=(const InodeIdentifier& other) const
  25. {
  26. return m_fsid != other.m_fsid || m_index != other.m_index;
  27. }
  28. bool is_root_inode() const;
  29. String to_string() const { return String::format("%u:%u", m_fsid, m_index); }
  30. private:
  31. u32 m_fsid { 0 };
  32. u32 m_index { 0 };
  33. };
  34. inline const LogStream& operator<<(const LogStream& stream, const InodeIdentifier& value)
  35. {
  36. stream << value.fsid() << ':' << value.index();
  37. return stream;
  38. }