entangler 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,212 @@
1
+ /******************************************************************************
2
+ *******************************************************************************
3
+ *******************************************************************************
4
+
5
+
6
+ kernel-filesystem-monitor-daemon
7
+ Copyright (C) 2005 Ben Martin
8
+
9
+ This program is free software; you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation; either version 2 of the License, or
12
+ (at your option) any later version.
13
+
14
+ This program is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with this program; if not, write to the Free Software
21
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
+
23
+ For more details see the COPYING file in the root directory of this
24
+ distribution.
25
+
26
+ $Id: kernel-filesystem-monitor-daemon.hh,v 1.3 2008/01/03 21:31:06 ben Exp $
27
+
28
+ *******************************************************************************
29
+ *******************************************************************************
30
+ ******************************************************************************/
31
+
32
+ #ifndef _ALREADY_INCLUDED_KERNEL_FILESYSTEM_MONITOR_DAEMON_HH_
33
+ #define _ALREADY_INCLUDED_KERNEL_FILESYSTEM_MONITOR_DAEMON_HH_
34
+
35
+ #include <sys/stat.h>
36
+
37
+ #include <sys/inotify.h>
38
+ #include <popt.h>
39
+
40
+ #include <string>
41
+ #include <map>
42
+ #include <set>
43
+ #include <list>
44
+
45
+ using namespace std;
46
+
47
+ extern unsigned long Verbose;
48
+
49
+ string getHomeDir( const char* homedir_CSTR );
50
+
51
+ /********************************************************************************/
52
+ /********************************************************************************/
53
+ /********************************************************************************/
54
+
55
+ template< class STREAM >
56
+ void print_mask(STREAM& ss,int mask)
57
+ {
58
+ if (mask & IN_ACCESS)
59
+ {
60
+ ss << "ACCESS ";
61
+ }
62
+ if (mask & IN_MODIFY)
63
+ {
64
+ ss << "MODIFY ";
65
+ }
66
+ if (mask & IN_ATTRIB)
67
+ {
68
+ ss << "ATTRIB ";
69
+ }
70
+ if (mask & IN_CLOSE)
71
+ {
72
+ ss << "CLOSE ";
73
+ }
74
+ if (mask & IN_OPEN)
75
+ {
76
+ ss << "OPEN ";
77
+ }
78
+ if (mask & IN_MOVED_FROM)
79
+ {
80
+ ss << "MOVE_FROM ";
81
+ }
82
+ if (mask & IN_MOVED_TO)
83
+ {
84
+ ss << "MOVE_TO ";
85
+ }
86
+ #ifdef IN_DELETE_SUBDIR
87
+ if (mask & IN_DELETE_SUBDIR)
88
+ {
89
+ ss << "DELETE_SUBDIR ";
90
+ }
91
+ #endif
92
+ #ifdef IN_DELETE
93
+ if (mask & IN_DELETE)
94
+ {
95
+ ss << "DELETE ";
96
+ }
97
+ #endif
98
+ #ifdef IN_DELETE_FILE
99
+ if (mask & IN_DELETE_FILE)
100
+ {
101
+ ss << "DELETE_FILE ";
102
+ }
103
+ #endif
104
+ #ifdef IN_DELETE_SELF
105
+ if (mask & IN_DELETE_SELF)
106
+ {
107
+ ss << "DELETE_SELF ";
108
+ }
109
+ #endif
110
+ #ifdef IN_CREATE_SUBDIR
111
+ if (mask & IN_CREATE_SUBDIR)
112
+ {
113
+ ss << "CREATE_SUBDIR ";
114
+ }
115
+ #endif
116
+ #ifdef IN_CREATE_FILE
117
+ if (mask & IN_CREATE_FILE)
118
+ {
119
+ ss << "CREATE_FILE ";
120
+ }
121
+ #endif
122
+ #ifdef IN_CREATE
123
+ if (mask & IN_CREATE)
124
+ {
125
+ ss << "CREATE ";
126
+ }
127
+ #endif
128
+ if (mask & IN_DELETE_SELF)
129
+ {
130
+ ss << "DELETE_SELF ";
131
+ }
132
+ if (mask & IN_UNMOUNT)
133
+ {
134
+ ss << "UNMOUNT ";
135
+ }
136
+ if (mask & IN_Q_OVERFLOW)
137
+ {
138
+ ss << "Q_OVERFLOW ";
139
+ }
140
+ if (mask & IN_IGNORED)
141
+ {
142
+ ss << "IGNORED" ;
143
+ }
144
+ }
145
+
146
+ /********************************************************************************/
147
+ /********************************************************************************/
148
+ /********************************************************************************/
149
+
150
+ class KernelFileSystemMonitorDaemon
151
+ {
152
+ bool m_runInForground;
153
+
154
+ #define ALL_MASK 0xffffffff
155
+ int watch_mask;
156
+ int dev_fd;
157
+
158
+ unsigned long m_inotify_queue_threshold_bytes;
159
+ unsigned long long m_inotify_queue_sleep_threshold_ns;
160
+ unsigned long m_nanosleep_ns;
161
+
162
+ void background_into_daemon();
163
+
164
+ void priv_handle_event( struct inotify_event *pevent, time_t tt );
165
+ void priv_Closedown();
166
+
167
+ bool handle_create_subdir_event_by_maybe_watching( struct inotify_event *pevent, time_t tt );
168
+
169
+ void HandleSleepForQueueSize();
170
+
171
+ protected:
172
+ typedef map< int, string > m_workingDirToURL_t;
173
+ m_workingDirToURL_t m_workingDirToURL;
174
+
175
+ typedef list< string > m_ignorePrefixes_t;
176
+ m_ignorePrefixes_t m_ignorePrefixes;
177
+
178
+ typedef list< string > stringlist_t;
179
+ stringlist_t m_watchRoots;
180
+
181
+ void print_event (struct inotify_event *event);
182
+
183
+ bool shouldAddSubObject( int wd, const std::string& fn );
184
+ virtual void candidateObject( int wd, const std::string& fn, struct stat& statbuf );
185
+ virtual void setupWorkingDirToPersistentDirIDMapping( long wd, const string& earl ) = 0;
186
+ virtual void event_batch_start( time_t tt );
187
+ virtual void event_batch_end( time_t tt );
188
+ virtual void handle_event( struct inotify_event *pevent, time_t tt ) = 0;
189
+ virtual void Closedown();
190
+
191
+ public:
192
+ KernelFileSystemMonitorDaemon();
193
+ ~KernelFileSystemMonitorDaemon();
194
+
195
+ void setRunInForground( bool v );
196
+
197
+ void setupWatches();
198
+ void setupSignalHandlers();
199
+ bool shouldWatch( const string& earl );
200
+ void add_watches_recursive( const string& earl );
201
+
202
+ void addIgnorePrefix( const string& s );
203
+ void ParseWatchOptions( poptContext& optCon );
204
+
205
+ int run();
206
+
207
+
208
+ struct ::poptOption* getPopTable();
209
+
210
+ };
211
+
212
+ #endif
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: entangler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dave Allie
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: lib_ruby_diff
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ description: Two way file syncer using platform native notify and rdiff syncing.
70
+ email:
71
+ - dave@daveallie.com
72
+ executables:
73
+ - entangler
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - entangler.gemspec
88
+ - exe/entangler
89
+ - lib/entangler.rb
90
+ - lib/entangler/entangled_file.rb
91
+ - lib/entangler/executor/base.rb
92
+ - lib/entangler/executor/master.rb
93
+ - lib/entangler/executor/slave.rb
94
+ - lib/entangler/version.rb
95
+ - lib/notifier/bin/darwin/notify
96
+ - lib/notifier/bin/linux/notify
97
+ - lib/notifier/src/darwin/BUILD
98
+ - lib/notifier/src/darwin/README
99
+ - lib/notifier/src/darwin/notify.c
100
+ - lib/notifier/src/linux/BUILD
101
+ - lib/notifier/src/linux/README
102
+ - lib/notifier/src/linux/notify.c
103
+ - lib/notifier/src/linux/old/BUILD
104
+ - lib/notifier/src/linux/old/README
105
+ - lib/notifier/src/linux/old/kernel-filesystem-monitor-daemon-cat.cpp
106
+ - lib/notifier/src/linux/old/kernel-filesystem-monitor-daemon.cpp
107
+ - lib/notifier/src/linux/old/kernel-filesystem-monitor-daemon.hh
108
+ homepage: https://github.com/daveallie/entangler
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.5.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Two way file syncer using platform native notify and rdiff syncing.
132
+ test_files: []