xref: /haiku/src/tests/system/kernel/file_corruption/fs/Notifications.cpp (revision e828231248036363167313f7cad872c2bb5676e4)
1 /*
2  * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "Notifications.h"
8 
9 #include "Directory.h"
10 #include "Volume.h"
11 
12 
13 // #pragma mark - EntryCreatedNotification
14 
15 
EntryCreatedNotification(Directory * directory,const char * name,Node * node)16 EntryCreatedNotification::EntryCreatedNotification(Directory* directory,
17 	const char* name, Node* node)
18 	:
19 	fDirectory(directory),
20 	fName(name),
21 	fNode(node)
22 {
23 }
24 
25 
26 void
NotifyPostCommit() const27 EntryCreatedNotification::NotifyPostCommit() const
28 {
29 	notify_entry_created(fDirectory->GetVolume()->ID(),
30 		fDirectory->BlockIndex(), fName, fNode->BlockIndex());
31 }
32 
33 
34 // #pragma mark - EntryRemovedNotification
35 
36 
EntryRemovedNotification(Directory * directory,const char * name,Node * node)37 EntryRemovedNotification::EntryRemovedNotification(Directory* directory,
38 	const char* name, Node* node)
39 	:
40 	fDirectory(directory),
41 	fName(name),
42 	fNode(node)
43 {
44 }
45 
46 
47 void
NotifyPostCommit() const48 EntryRemovedNotification::NotifyPostCommit() const
49 {
50 	notify_entry_removed(fDirectory->GetVolume()->ID(),
51 		fDirectory->BlockIndex(), fName, fNode->BlockIndex());
52 }
53 
54 
55 // #pragma mark - EntryMovedNotification
56 
57 
EntryMovedNotification(Directory * fromDirectory,const char * fromName,Directory * toDirectory,const char * toName,Node * node)58 EntryMovedNotification::EntryMovedNotification(Directory* fromDirectory,
59 	const char* fromName, Directory* toDirectory, const char* toName,
60 	Node* node)
61 	:
62 	fFromDirectory(fromDirectory),
63 	fFromName(fromName),
64 	fToDirectory(toDirectory),
65 	fToName(toName),
66 	fNode(node)
67 {
68 }
69 
70 
71 void
NotifyPostCommit() const72 EntryMovedNotification::NotifyPostCommit() const
73 {
74 	notify_entry_moved(fFromDirectory->GetVolume()->ID(),
75 		fFromDirectory->BlockIndex(), fFromName, fToDirectory->BlockIndex(),
76 		fToName, fNode->BlockIndex());
77 }
78 
79 
80 // #pragma mark - StatChangedNotification
81 
82 
StatChangedNotification(Node * node,uint32 statFields)83 StatChangedNotification::StatChangedNotification(Node* node, uint32 statFields)
84 	:
85 	fNode(node),
86 	fStatFields(statFields)
87 {
88 }
89 
90 
91 void
NotifyPostCommit() const92 StatChangedNotification::NotifyPostCommit() const
93 {
94 	notify_stat_changed(fNode->GetVolume()->ID(), fNode->BlockIndex(),
95 		fStatFields);
96 }
97 
98 
99 // #pragma mark - AttributeChangedNotification
100 
101 
AttributeChangedNotification(Node * node,const char * attribute,int32 cause)102 AttributeChangedNotification::AttributeChangedNotification(Node* node,
103 	const char* attribute, int32 cause)
104 	:
105 	fNode(node),
106 	fAttribute(attribute),
107 	fCause(cause)
108 {
109 }
110 
111 
112 void
NotifyPostCommit() const113 AttributeChangedNotification::NotifyPostCommit() const
114 {
115 	notify_attribute_changed(fNode->GetVolume()->ID(), fNode->BlockIndex(),
116 		fAttribute, fCause);
117 }
118