xref: /haiku/src/add-ons/kernel/file_systems/btrfs/Attribute.h (revision 5e96d7d537fbec23bad4ae9b4c8e7b02e769f0c6)
1 /*
2  * Copyright 2010-2011, Jérôme Duval, korli@users.berlios.de.
3  * Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de.
4  * This file may be used under the terms of the MIT License.
5  */
6 #ifndef ATTRIBUTE_H
7 #define ATTRIBUTE_H
8 
9 
10 #include "CachedBlock.h"
11 #include "Inode.h"
12 
13 
14 struct attr_cookie {
15 	char	name[B_ATTR_NAME_LENGTH];
16 	uint32	type;
17 	int		open_mode;
18 	bool	create;
19 };
20 
21 
22 class Attribute {
23 public:
24 								Attribute(Inode* inode);
25 								Attribute(Inode* inode, attr_cookie* cookie);
26 								~Attribute();
27 
28 			status_t			CheckAccess(const char* name, int openMode);
29 
30 			status_t			Create(const char* name, type_code type,
31 									int openMode, attr_cookie** _cookie);
32 			status_t			Open(const char* name, int openMode,
33 									attr_cookie** _cookie);
34 
35 			status_t			Stat(struct stat& stat);
36 
37 			status_t			Read(attr_cookie* cookie, off_t pos,
38 									uint8* buffer, size_t* _length);
39 private:
40 			status_t			_Lookup(const char* name, size_t nameLength,
41 									btrfs_dir_entry **entries = NULL,
42 									size_t *length = NULL);
43 			status_t			_FindEntry(btrfs_dir_entry *entries,
44 									size_t length, const char* name,
45 									size_t nameLength,
46 									btrfs_dir_entry **_entry);
47 
48 			::Volume*			fVolume;
49 			Inode*				fInode;
50 			const char*			fName;
51 };
52 
53 #endif	// ATTRIBUTE_H
54 
55