xref: /haiku/src/add-ons/kernel/file_systems/bfs/Attribute.h (revision b55a57da7173b9af0432bd3e148d03f06161d036)
1 /*
2  * Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de.
3  * This file may be used 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 class Attribute {
21 public:
22 							Attribute(Inode* inode);
23 							Attribute(Inode* inode, attr_cookie* cookie);
24 							~Attribute();
25 
26 			status_t		InitCheck();
27 			status_t		CheckAccess(const char* name, int openMode);
28 
29 			status_t		Get(const char* name);
30 			void			Put();
31 
32 			status_t		Create(const char* name, type_code type,
33 								int openMode, attr_cookie** _cookie);
34 			status_t		Open(const char* name, int openMode,
35 								attr_cookie** _cookie);
36 
37 			status_t		Stat(struct stat& stat);
38 
39 			status_t		Read(attr_cookie* cookie, off_t pos, uint8* buffer,
40 								size_t* _length);
41 			status_t		Write(Transaction& transaction, attr_cookie* cookie,
42 								off_t pos, const uint8* buffer, size_t* _length,
43 								bool* _created);
44 
45 private:
46 			status_t		_Truncate();
47 
48 			NodeGetter		fNodeGetter;
49 			Inode*			fInode;
50 			small_data*		fSmall;
51 			Inode*			fAttribute;
52 			const char*		fName;
53 };
54 
55 #endif	// ATTRIBUTE_H
56