1/*
2 * Copyright 2003-2016 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
17enum {
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	B_WATCH_CHILDREN		= 0x0040
28};
29
30
31// The "opcode" field of the B_NODE_MONITOR notification message you get.
32
33// The presence and meaning of the other fields in that message specifying what
34// exactly caused the notification depend on this value.
35
36#define B_ENTRY_CREATED	 	1
37#define B_ENTRY_REMOVED	 	2
38#define B_ENTRY_MOVED	 	3
39#define B_STAT_CHANGED	 	4
40#define B_ATTR_CHANGED	 	5
41#define B_DEVICE_MOUNTED	6
42#define B_DEVICE_UNMOUNTED	7
43
44
45// More specific info in the "cause" field of B_ATTR_CHANGED notification
46// messages. (Haiku only)
47
48#define B_ATTR_CREATED		1
49#define B_ATTR_REMOVED		2
50//		B_ATTR_CHANGED is reused
51
52
53// More specific info in the "fields" field of B_STAT_CHANGED notification
54// messages, specifying what parts of the stat data have actually been
55// changed. (Haiku only)
56
57enum {
58	B_STAT_MODE					= 0x0001,
59	B_STAT_UID					= 0x0002,
60	B_STAT_GID					= 0x0004,
61	B_STAT_SIZE					= 0x0008,
62	B_STAT_ACCESS_TIME			= 0x0010,
63	B_STAT_MODIFICATION_TIME	= 0x0020,
64	B_STAT_CREATION_TIME		= 0x0040,
65	B_STAT_CHANGE_TIME			= 0x0080,
66
67	B_STAT_INTERIM_UPDATE		= 0x1000
68};
69
70
71// C++ callable Prototypes
72
73// Since you are not able to parse BMessages from plain C, there is no
74// API exported.
75
76#if defined(__cplusplus) && !defined(_KERNEL_MODE)
77
78// these are only needed for the function exports
79#include <Node.h>
80#include <Messenger.h>
81
82class BLooper;
83class BHandler;
84
85
86extern status_t watch_volume(dev_t volume, uint32 flags, BMessenger target);
87extern status_t watch_volume(dev_t volume, uint32 flags,
88	const BHandler* handler, const BLooper* looper = NULL);
89
90extern status_t watch_node(const node_ref* node, uint32 flags,
91	BMessenger target);
92extern status_t watch_node(const node_ref* node, uint32 flags,
93	const BHandler* handler, const BLooper* looper = NULL);
94
95extern status_t stop_watching(BMessenger target);
96extern status_t stop_watching(const BHandler* handler, const BLooper* looper = NULL);
97
98#endif	// __cplusplus && !_KERNEL_MODE
99
100
101#endif	// _NODE_MONITOR_H
102