2 * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef FS_DESCRIPTORS_H
6 #define FS_DESCRIPTORS_H
12 #include <StorageDefs.h>
13 #include <SupportDefs.h>
27 virtual ~Descriptor();
29 virtual status_t
Close() = 0;
30 virtual status_t
Dup(Descriptor
*&clone
) = 0;
31 virtual status_t
GetStat(bool traverseLink
, struct stat
*st
) = 0;
33 virtual bool IsSystemFD() const;
34 virtual status_t
GetPath(string
& path
) const;
36 virtual status_t
GetNodeRef(NodeRef
&ref
);
40 struct FileDescriptor
: Descriptor
{
41 FileDescriptor(int fd
);
42 virtual ~FileDescriptor();
44 virtual status_t
Close();
45 virtual status_t
Dup(Descriptor
*&clone
);
46 virtual status_t
GetStat(bool traverseLink
, struct stat
*st
);
48 virtual bool IsSystemFD() const;
51 // DirectoryDescriptor
52 struct DirectoryDescriptor
: Descriptor
{
56 DirectoryDescriptor(DIR *dir
, const NodeRef
&ref
);
57 virtual ~DirectoryDescriptor();
59 virtual status_t
Close();
60 virtual status_t
Dup(Descriptor
*&clone
);
61 virtual status_t
GetStat(bool traverseLink
, struct stat
*st
);
63 virtual status_t
GetNodeRef(NodeRef
&ref
);
67 struct SymlinkDescriptor
: Descriptor
{
70 SymlinkDescriptor(const char *path
);
72 virtual status_t
Close();
73 virtual status_t
Dup(Descriptor
*&clone
);
74 virtual status_t
GetStat(bool traverseLink
, struct stat
*st
);
76 virtual status_t
GetPath(string
& path
) const;
79 // AttributeDescriptor
80 struct AttributeDescriptor
: Descriptor
{
81 AttributeDescriptor(int fileFD
,
82 const char* attribute
, uint32 type
,
84 virtual ~AttributeDescriptor();
87 status_t
Write(off_t offset
, const void* buffer
,
90 int FileFD() const { return fFileFD
; }
91 const char* Attribute() const { return fAttribute
; }
92 uint32
Type() const { return fType
; }
93 int OpenMode() const { return fOpenMode
; }
95 virtual status_t
Close();
96 virtual status_t
Dup(Descriptor
*& clone
);
97 virtual status_t
GetStat(bool traverseLink
, struct stat
* st
);
101 char fAttribute
[B_ATTR_NAME_LENGTH
];
109 struct AttrDirDescriptor
: DirectoryDescriptor
{
111 AttrDirDescriptor(DIR *dir
, const NodeRef
&ref
);
112 virtual ~AttrDirDescriptor();
114 virtual status_t
Close();
115 virtual status_t
Dup(Descriptor
*&clone
);
116 virtual status_t
GetStat(bool traverseLink
, struct stat
*st
);
118 virtual status_t
GetNodeRef(NodeRef
&ref
);
122 Descriptor
* get_descriptor(int fd
);
123 int add_descriptor(Descriptor
*descriptor
);
124 status_t
delete_descriptor(int fd
);
125 bool is_unknown_or_system_descriptor(int fd
);
127 } // namespace BPrivate
129 #endif // FS_DESCRIPTORS_H