Skip to content

ENT-14692: Added file event types - #6409

Draft
victormlg wants to merge 3 commits into
cfengine:masterfrom
victormlg:cf-reactor.AllFileEventTypes_2
Draft

victormlg wants to merge 3 commits into
cfengine:masterfrom
victormlg:cf-reactor.AllFileEventTypes_2

Conversation

@victormlg

Copy link
Copy Markdown
Contributor

No description provided.

Moved from a hardcoded and single `file_deleted` event type, to
a table with all the event types and their necessary code, so
that cf-reactor can easiky be extended with new event types.

Ticket: ENT-14692
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Signed-off-by: Victor Moene <victor.moene@northern.tech>
1. file_created: the file appears at the path.
2. file_modified: the modification time of the file changes.
3. file_content_modified: the SHA-256 hash of a regular file's content changes.
4. file_permissions_changed: the permission bits (07777) change.
5. file_owner_changed: the owning user or group changes.
6. file_replaced: the path now points to a different file (another inode or device), for example after an atomic rename over it.
7. file_type_changed: the file's type changes, for example a regular file replaced by a directory or a symlink.
8. symlink_target_changed: the target of a symlink changes.
9. file_size_exceeds: the size grows above size_threshold bytes. This requires the extra size_threshold constraint.

Ticket: ENT-14692
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Comment thread cf-reactor/file_watcher.c
{
assert(args != NULL && args->next != NULL);
const char *path = RlistScalarValue(args);
const long size_threshold = IntFromString(RlistScalarValue(args->next));
Comment thread cf-reactor/watcher.c
ThreadUnlock(&watchers_mutex);
opt.destroy_state(opt.state);
return;
opt->destroy_state(opt->state);
Comment thread cf-reactor/watcher.c
ThreadUnlock(&watchers_mutex);
opt.destroy_state(opt.state);
return;
opt->destroy_state(opt->state);
Comment thread cf-reactor/watcher.c
w->promise = pp->org_pp;
w->promiser = xstrdup(pp->promiser);
w->poll_interval_secs = interval;
w->poll_interval_secs = opt->interval;
Comment thread cf-reactor/watcher.c
w->last_check = WATCHER_CHECK_NO_EVENT;
w->check_callback = opt.check_callback;
w->destroy_state = opt.destroy_state;
w->check_callback = opt->check_callback;
Comment thread cf-reactor/watcher.c
w->check_callback = opt.check_callback;
w->destroy_state = opt.destroy_state;
w->check_callback = opt->check_callback;
w->destroy_state = opt->destroy_state;
Comment thread cf-reactor/watcher.c
if (prev == NULL)
{
w->state = opt.state;
w->state = opt->state;
Comment thread cf-reactor/watcher.c
w->state = prev->state;
prev->state = NULL; /* so not destroyed with prev */
opt.destroy_state(opt.state);
opt->destroy_state(opt->state);
Comment thread cf-reactor/watcher.c
w->state = prev->state;
prev->state = NULL; /* so not destroyed with prev */
opt.destroy_state(opt.state);
opt->destroy_state(opt->state);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants