2 * Copyright 2011, Jérôme Duval, korli@users.berlios.de.
3 * Copyright 2008, Axel Dörfler, axeld@pinc-software.de.
4 * This file may be used under the terms of the MIT License.
18 # define TRACEI(x...) dprintf("\33[34mbtrfs:\33[0m " x)
20 # define TRACEI(x...) ;
26 Inode(Volume
* volume
, ino_t id
);
27 Inode(Volume
* volume
, ino_t id
,
28 const btrfs_inode
& item
);
33 ino_t
ID() const { return fID
; }
35 rw_lock
* Lock() { return& fLock
; }
37 status_t
UpdateNodeFromDisk();
39 bool IsDirectory() const
40 { return S_ISDIR(Mode()); }
42 { return S_ISREG(Mode()); }
43 bool IsSymLink() const
44 { return S_ISLNK(Mode()); }
45 status_t
CheckPermissions(int accessMode
) const;
47 mode_t
Mode() const { return fNode
.Mode(); }
48 off_t
Size() const { return fNode
.Size(); }
49 uid_t
UserID() const { return fNode
.UserID(); }
50 gid_t
GroupID() const { return fNode
.GroupID(); }
51 void GetChangeTime(struct timespec
& timespec
) const
52 { fNode
.GetChangeTime(timespec
); }
53 void GetModificationTime(struct timespec
& timespec
) const
54 { fNode
.GetModificationTime(timespec
); }
55 void GetCreationTime(struct timespec
& timespec
) const
56 { fNode
.GetCreationTime(timespec
); }
57 void GetAccessTime(struct timespec
& timespec
) const
58 { fNode
.GetCreationTime(timespec
); }
60 Volume
* GetVolume() const { return fVolume
; }
62 status_t
FindBlock(off_t logical
, off_t
& physical
,
63 off_t
* _length
= NULL
);
64 status_t
ReadAt(off_t pos
, uint8
* buffer
, size_t* length
);
65 status_t
FillGapWithZeros(off_t start
, off_t end
);
67 void* FileCache() const { return fCache
; }
68 void* Map() const { return fMap
; }
70 status_t
FindParent(ino_t
* id
);
71 uint64
FindNextIndex(BTree::Path
* path
) const;
72 static Inode
* Create(Transaction
& transaction
, ino_t id
,
73 Inode
* parent
, int32 mode
, uint64 size
= 0,
75 status_t
Insert(Transaction
& transaction
, BTree::Path
* path
);
76 status_t
Remove(Transaction
& transaction
, BTree::Path
* path
);
77 status_t
MakeReference(Transaction
& transaction
, BTree::Path
* path
,
78 Inode
* parent
, const char* name
, int32 mode
);
79 status_t
Dereference(Transaction
& transaction
, BTree::Path
* path
,
80 ino_t parentID
, const char* name
);
82 Inode(Volume
* volume
);
84 Inode
& operator=(const Inode
&);
100 // The Vnode class provides a convenience layer upon get_vnode(), so that
101 // you don't have to call put_vnode() anymore, which may make code more
102 // readable in some cases
106 Vnode(Volume
* volume
, ino_t id
)
132 if (fInode
!= NULL
) {
133 put_vnode(fInode
->GetVolume()->FSVolume(), fInode
->ID());
139 status_t
SetTo(Volume
* volume
, ino_t id
)
143 return fStatus
= get_vnode(volume
->FSVolume(), id
, (void**)&fInode
);
146 status_t
Get(Inode
** _inode
)
154 TRACEI("Vnode::Keep()\n");