File change event API for netatalk. More...
#include <arpa/inet.h>#include <errno.h>#include <netdb.h>#include <netinet/in.h>#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/param.h>#include <sys/socket.h>#include <time.h>#include <unistd.h>#include <atalk/adouble.h>#include <atalk/afp.h>#include <atalk/cnid.h>#include <atalk/fce_api.h>#include <atalk/globals.h>#include <atalk/logger.h>#include <atalk/unix.h>#include <atalk/util.h>#include <atalk/vfs.h>#include "desktop.h"#include "directory.h"#include "file.h"#include "fork.h"#include "volume.h"#include "fce_api_internal.h"Macros | |
| #define | MAXIOBUF 4096 |
Functions | |
| int | afprun_bg (char *cmd) |
| Run a command in the background without waiting. | |
| void | fce_init_udp (void) |
| Initialize network structs for any listeners. | |
| void | fce_cleanup (void) |
| static ssize_t | build_fce_packet (const AFPObj *obj, unsigned char *iobuf, fce_ev_t event, const char *path, const char *oldpath, pid_t pid, const char *user, uint32_t event_id) |
| static void | send_fce_event (const AFPObj *obj, int event, const char *path, const char *oldpath) |
| Send the fce information to all (connected) listeners. | |
| static int | add_udp_socket (const char *target_ip, const char *target_port) |
| static void | save_close_event (const AFPObj *obj, const char *path) |
| static void | fce_init_ign_paths (const char *ignores, const char ***dest_array, bool is_directory) |
| int | fce_register (const AFPObj *obj, fce_ev_t event, const char *path, const char *oldpath) |
| static void | check_saved_close_events (const AFPObj *obj) |
| void | fce_pending_events (const AFPObj *obj) |
| int | fce_add_udp_socket (const char *target) |
| Extern connect to afpd parameter. | |
| int | fce_set_events (const char *events) |
Variables | |
| static struct udp_entry | udp_socket_list [FCE_MAX_UDP_SOCKS] |
| static int | udp_sockets = 0 |
| static bool | udp_initialized = false |
| static unsigned long | fce_ev_enabled |
| static uint8_t | fce_ev_info |
| static unsigned char | iobuf [MAXIOBUF] |
| static const char ** | skip_files |
| static const char ** | skip_directories |
| static struct fce_close_event | last_close_event |
| static char * | fce_event_names [] |
File change event API for netatalk.
for every detected filesystem change a UDP packet is sent to an arbitrary list of listeners. Each packet contains unix path of modified filesystem element, event reason, and a consecutive event id (32 bit). Technically we are UDP client and are sending out packets synchronuosly as they are created by the afp functions. This should not affect performance measurably. The only delaying calls occur during initialization, if we have to resolve non-IP hostnames to IP. All numeric data inside the packet is network byte order, so use ntohs / ntohl to resolve length and event id. Ideally a listener receives every packet with no gaps in event ids, starting with event id 1 and mode FCE_CONN_START followed by data events from id 2 up to 0xFFFFFFFF, followed by 0 to 0xFFFFFFFF and so on.
A gap or not starting with 1 mode FCE_CONN_START or receiving mode FCE_CONN_BROKEN means that the listener has lost at least one filesystem event
| #define MAXIOBUF 4096 |
|
static |
|
extern |
Run a command in the background without waiting.
|
static |
Construct a UDP packet for our listeners and return packet size
|
static |
| int fce_add_udp_socket | ( | const char * | target | ) |
Extern connect to afpd parameter.
| void fce_cleanup | ( | void | ) |
|
static |
| void fce_init_udp | ( | void | ) |
Initialize network structs for any listeners.
| void fce_pending_events | ( | const AFPObj * | obj | ) |
API-Calls for file change api, called from outside (file.c directory.c ofork.c filedir.c)
Dispatcher for all incoming file change events
| int fce_set_events | ( | const char * | events | ) |
fmod,fdel,ddel,fcre,dcre
|
static |
|
static |
Send the fce information to all (connected) listeners.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |