Serenity Operating System
1/*
2 * Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/Types.h>
10#include <Kernel/KBuffer.h>
11
12namespace Kernel {
13
14struct ISO9660FSDirectoryEntry final : public AtomicRefCounted<ISO9660FSDirectoryEntry> {
15 u32 extent { 0 };
16 u32 length { 0 };
17
18 // NOTE: This can never be empty if we read the directory successfully.
19 // We need it as an OwnPtr to default-construct this struct.
20 OwnPtr<KBuffer> blocks;
21
22 static ErrorOr<NonnullLockRefPtr<ISO9660FSDirectoryEntry>> try_create(u32 extent, u32 length, OwnPtr<KBuffer> blocks)
23 {
24 return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ISO9660FSDirectoryEntry(extent, length, move(blocks)));
25 }
26
27private:
28 ISO9660FSDirectoryEntry(u32 extent, u32 length, OwnPtr<KBuffer> blocks)
29 : extent(extent)
30 , length(length)
31 , blocks(move(blocks))
32 {
33 }
34};
35
36struct ISO9660FSDirectoryState {
37 LockRefPtr<ISO9660FSDirectoryEntry> entry;
38 u32 offset { 0 };
39};
40
41}