xref: /haiku/src/add-ons/kernel/file_systems/xfs/Attribute.h (revision da8162be21b36442f34a731873d2358a0d63c25a)
1 /*
2  * Copyright 2022, Raghav Sharma, raghavself28@gmail.com
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef ATTRIBUTE_H
6 #define ATTRIBUTE_H
7 
8 
9 #include "Inode.h"
10 
11 
12 struct attr_cookie {
13 	char	name[B_ATTR_NAME_LENGTH];
14 	uint32	type;
15 	int		open_mode;
16 	bool	create;
17 };
18 
19 
20 // This class will act as an interface between all types of attributes for xfs
21 class Attribute {
22 public:
23 
24 			virtual				~Attribute()									=	0;
25 
26 			virtual status_t	Open(const char* name, int openMode,
27 									attr_cookie** _cookie)						=	0;
28 
29 			virtual status_t	Stat(attr_cookie* cookie, struct stat& stat)	=	0;
30 
31 			virtual status_t	Read(attr_cookie* cookie, off_t pos,
32 									uint8* buffer, size_t* length)				=	0;
33 
34 			virtual status_t	GetNext(char* name, size_t* nameLength)			=	0;
35 
36 			virtual status_t	Lookup(const char* name, size_t* nameLength)	=	0;
37 
38 			static Attribute*	Init(Inode* inode);
39 };
40 
41 #endif