1/*
2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Pawe�� Dziepak, pdziepak@quarnos.org
7 */
8#ifndef ROOTINODE_H
9#define ROOTINODE_H
10
11
12#include <fs_info.h>
13
14#include "Inode.h"
15
16
17class RootInode : public Inode {
18public:
19								RootInode();
20								~RootInode();
21
22	virtual	const char*			Name() const;
23	inline	void				SetName(const char* name);
24
25			status_t			ReadInfo(struct fs_info* info);
26	inline	void				MakeInfoInvalid();
27
28	inline	uint32				IOSize();
29
30			bool				ProbeMigration();
31			status_t			GetLocations(AttrValue** attr);
32
33private:
34			struct fs_info		fInfoCache;
35			mutex				fInfoCacheLock;
36			time_t				fInfoCacheExpire;
37
38			const char*			fName;
39
40			uint32				fIOSize;
41
42			status_t			_UpdateInfo(bool force = false);
43
44};
45
46
47inline void
48RootInode::MakeInfoInvalid()
49{
50	fInfoCacheExpire = 0;
51}
52
53
54inline uint32
55RootInode::IOSize()
56{
57	if (fIOSize == 0)
58		_UpdateInfo(true);
59	return fIOSize;
60}
61
62
63inline void
64RootInode::SetName(const char* name)
65{
66	ASSERT(name != NULL);
67
68	free(const_cast<char*>(fName));
69	fName = strdup(name);
70}
71
72
73#endif	// ROOTINODE_H
74
75