Exemple #1
0
//for file descriptor debugging
void debug_print_descriptor(struct fuse_file_info* info)
{
  char file_path[MAX_PATH_SIZE];
  get_file_path_from_fd(info->fh, file_path, sizeof(file_path));
  debugf(DBG_LEVEL_EXT, KCYN "descriptor localfile=[%s] fd=%d", file_path,
         info->fh);
  debug_print_flags(info->flags);
}
Exemple #2
0
/**
 * Processes events
 * @param main_struct is the maion structure
 * @param event is the fanotify's structure event
 * @param dir_list MUST be a list of gchar * g_utf8_casefold()
 *        transformed.
 */
static void event_process(main_struct_t *main_struct, struct fanotify_event_metadata *event, GSList *dir_list)
{
    gchar *path = NULL;
    gboolean to_save = FALSE;
    GSList *head = NULL;

    path = get_file_path_from_fd(event->fd);

    if (path != NULL)
        {
            /* Does the event concern a monitored directory ? */
            head = does_event_concerns_monitored_directory(path, dir_list);

            /* Do we need to save this file ? Is it excluded somehow ? */
            to_save = filter_out_if_necessary(head, event);

            if (to_save == TRUE)
                {
                    print_debug(_("Received event file/directory: %s\n"), path);
                    print_debug(_(" matching directory is: %s\n"), head->data);

                    /* we are only watching this event so it is not necessary to print it !
                     * if (event->mask & FAN_CLOSE_WRITE)
                     *   {
                     *       print_debug(_("\tFAN_CLOSE_WRITE\n"));
                     *   }
                     */

                    /* Saving the file effectively */
                    prepare_before_saving(main_struct, path);

                    fflush(stdout);
                }

            close(event->fd);
            free_variable(path);
        }
}