master
h 66 lines 2.65 KB
Raw
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2 #pragma once
3
4 #include "p9defs.h"
5 #include "p9await.h"
6 #include "p9errors.h"
7 #include "p9protohelpers.h"
8 #include "p9handler.h"
9
10 namespace p9fs {
11
12 class XAttrBase;
13
14 class Fid
15 {
16 public:
17 virtual ~Fid() = default;
18
19 virtual Expected<Qid> Walk(std::string_view Name);
20 virtual Expected<std::tuple<UINT64, Qid, StatResult>> GetAttr(UINT64 Mask);
21 virtual LX_INT SetAttr(UINT32 Valid, const StatResult& Stat);
22 virtual Expected<Qid> Open(OpenFlags Flags);
23 virtual Expected<Qid> Create(std::string_view Name, OpenFlags Flags, UINT32 Mode, UINT32 Gid);
24 virtual Expected<Qid> MkDir(std::string_view Name, UINT32 Mode, UINT32 Gid);
25 virtual LX_INT ReadDir(UINT64 Offset, SpanWriter& Writer, bool IncludeAttributes);
26 virtual Task<Expected<UINT32>> Read(UINT64 Offset, gsl::span<gsl::byte> Buffer);
27 virtual Task<Expected<UINT32>> Write(UINT64 Offset, gsl::span<const gsl::byte> Buffer);
28 virtual LX_INT UnlinkAt(std::string_view Name, UINT32 Flags);
29 virtual LX_INT Remove();
30 virtual LX_INT RenameAt(std::string_view OldName, Fid& NewParent, std::string_view NewName);
31 virtual LX_INT Rename(Fid& NewParent, std::string_view NewName);
32 virtual Expected<Qid> SymLink(std::string_view Name, std::string_view Target, UINT32 Gid);
33 virtual Expected<Qid> MkNod(std::string_view Name, UINT32 Mode, UINT32 Major, UINT32 Minor, UINT32 Gid);
34 virtual LX_INT Link(std::string_view Name, Fid& Target);
35 virtual Expected<UINT32> ReadLink(gsl::span<char> Name);
36 virtual LX_INT Fsync();
37 virtual Expected<StatFsResult> StatFs();
38 virtual Expected<LockStatus> Lock(LockType Type, UINT32 Flags, UINT64 Start, UINT64 Length, UINT32 ProcId, std::string_view ClientId);
39 virtual Expected<std::tuple<LockType, UINT64, UINT64, UINT32, std::string_view>> GetLock(
40 LockType Type, UINT64 Start, UINT64 Length, UINT32 ProcId, std::string_view ClientId);
41 virtual Expected<std::shared_ptr<XAttrBase>> XattrWalk(const std::string& Name);
42 virtual Expected<std::shared_ptr<XAttrBase>> XattrCreate(const std::string& Name, UINT64 Size, UINT32 Flags);
43 virtual LX_INT Clunk();
44
45 // 9P2000.W operations
46 virtual LX_INT Access(AccessFlags Flags);
47
48 virtual std::shared_ptr<Fid> Clone() const;
49 virtual bool IsOnRoot(const std::shared_ptr<const IRoot>& root);
50 virtual bool IsFile() const;
51 virtual Qid GetQid() const;
52
53 protected:
54 Fid() = default;
55 };
56
57 class XAttrBase : public Fid
58 {
59 public:
60 virtual Expected<UINT64> GetSize() = 0;
61 };
62
63 #undef CreateFile
64 Expected<std::tuple<std::shared_ptr<Fid>, Qid>> CreateFile(std::shared_ptr<const IRoot> root, LX_UID_T uid);
65
66 } // namespace p9fs