xref: /haiku/headers/os/storage/NodeMonitor.h (revision 83b1a68c52ba3e0e8796282759f694b7fdddf06d)
1 /*
2  * Copyright 2003-2010 Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _NODE_MONITOR_H
6 #define _NODE_MONITOR_H
7 
8 
9 #include <StorageDefs.h>
10 
11 
12 // Flags for the watch_node() call.
13 
14 // Note that B_WATCH_MOUNT is NOT included in B_WATCH_ALL.
15 // You may prefer to use BVolumeRoster for volume watching.
16 
17 enum {
18 	B_STOP_WATCHING			= 0x0000,
19 	B_WATCH_NAME			= 0x0001,
20 	B_WATCH_STAT			= 0x0002,
21 	B_WATCH_ATTR			= 0x0004,
22 	B_WATCH_DIRECTORY		= 0x0008,
23 	B_WATCH_ALL				= 0x000f,
24 
25 	B_WATCH_MOUNT			= 0x0010,
26 	B_WATCH_INTERIM_STAT	= 0x0020
27 };
28 
29 
30 // The "opcode" field of the B_NODE_MONITOR notification message you get.
31 
32 // The presence and meaning of the other fields in that message specifying what
33 // exactly caused the notification depend on this value.
34 
35 #define B_ENTRY_CREATED	 	1
36 #define B_ENTRY_REMOVED	 	2
37 #define B_ENTRY_MOVED	 	3
38 #define B_STAT_CHANGED	 	4
39 #define B_ATTR_CHANGED	 	5
40 #define B_DEVICE_MOUNTED	6
41 #define B_DEVICE_UNMOUNTED	7
42 
43 
44 // More specific info in the "cause" field of B_ATTR_CHANGED notification
45 // messages. (Haiku only)
46 
47 #define B_ATTR_CREATED		1
48 #define B_ATTR_REMOVED		2
49 //		B_ATTR_CHANGED is reused
50 
51 
52 // More specific info in the "fields" field of B_STAT_CHANGED notification
53 // messages, specifying what parts of the stat data have actually been
54 // changed. (Haiku only)
55 
56 enum {
57 	B_STAT_MODE					= 0x0001,
58 	B_STAT_UID					= 0x0002,
59 	B_STAT_GID					= 0x0004,
60 	B_STAT_SIZE					= 0x0008,
61 	B_STAT_ACCESS_TIME			= 0x0010,
62 	B_STAT_MODIFICATION_TIME	= 0x0020,
63 	B_STAT_CREATION_TIME		= 0x0040,
64 	B_STAT_CHANGE_TIME			= 0x0080,
65 
66 	B_STAT_INTERIM_UPDATE		= 0x1000
67 };
68 
69 
70 // C++ callable Prototypes
71 
72 // Since you are not able to parse BMessages from plain C, there is no
73 // API exported.
74 
75 #if defined(__cplusplus) && !defined(_KERNEL_MODE)
76 
77 // these are only needed for the function exports
78 #include <Node.h>
79 #include <Messenger.h>
80 
81 class BLooper;
82 class BHandler;
83 
84 
85 extern status_t watch_volume(dev_t volume, uint32 flags, BMessenger target);
86 extern status_t watch_volume(dev_t volume, uint32 flags,
87 	const BHandler* handler, const BLooper* looper = NULL);
88 
89 extern status_t watch_node(const node_ref* node, uint32 flags,
90 	BMessenger target);
91 extern status_t watch_node(const node_ref* node, uint32 flags,
92 	const BHandler* handler, const BLooper* looper = NULL);
93 
94 extern status_t stop_watching(BMessenger target);
95 extern status_t stop_watching(const BHandler* handler, const BLooper* looper = NULL);
96 
97 #endif	// __cplusplus && !_KERNEL_MODE
98 
99 
100 #endif	// _NODE_MONITOR_H
101