ignore.c File Reference

groups and ignore command and functions. More...

#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <pcre.h>
#include <sys/mman.h>
#include "global.h"
#include "interface.h"
#include "waa.h"
#include "est_ops.h"
#include "helper.h"
#include "warnings.h"
#include "direnum.h"
#include "ignore.h"
#include "url.h"
Include dependency graph for ignore.c:

Go to the source code of this file.

Defines

#define RESERVE_IGNORE_ENTRIES   (4)

Functions

int ign___translate_bracketed_expr (char *end_of_buffer, char **src, char **dest)
 Processes a character class in shell ignore patterns.
int ign__compile_pattern (struct ignore_t *ignore)
 Compiles the given pattern for use with PCRE.
int ign___init_pattern_into (char *pattern, char *end, struct ignore_t *ignore)
 Does all necessary steps to use the given ignore_t structure.
int ign__load_list (char *dir)
 -.
int ign___compare_dev (struct sstat_t *st, struct ignore_t *ign)
 Compares the given sstat_t st with the device ignore pattern ign.
int ign___new_group (struct ignore_t *ign, struct grouping_t **result)
int ign___load_group (struct ignore_t *ign)
 Loads the grouping definitions, and stores them via a grouping_t.
int ign__is_ignore (struct estat *sts, int *is_ignored)
 -.
int ign__save_ignorelist (char *basedir)
 Writes the ignore list back to disk storage.
int ign__new_pattern (unsigned count, char *pattern[], char *ends, int user_pattern, int position)
 Adds a list of new ignore patterns to the internal list.
int ign___parse_position (char *arg, int *position, int *advance)
 Parses the optional position specification.
int ign___test_single_pattern (struct estat *sts)
int ign___test_all_patterns (struct estat *sts)
int ign__print_group_stats (FILE *output)
 -.
int ign__work (struct estat *root UNUSED, int argc, char *argv[])
 -.
int ign__rign (struct estat *root UNUSED, int argc, char *argv[])
 -.

Variables

apr_hash_t * ign___groups = NULL
 All groups, addressed by name.
int ign__max_group_name_len = 6
 The length of the longest group name, used for formatting the status output.
static const char ign_header_str [] = "%u"
 Header definition - currently only number of entries.
static const char ign__group_take [] = "take"
static const char ign__group_ign [] = "ignore"
const char ign___parm_delimiter = ','
int max_ignore_entries = 0
 For how many grouping patterns memory is allocated.
int used_ignore_entries = 0
 How many grouping patterns are actually used.
static struct ignore_tignore_list = NULL
 Allocated array of grouping patterns.
static char * memory
 Place where the patterns are mmap()ed.



static const char pcre_prefix [] = "PCRE:"
 The various strings that define the pattern types.
static const char dev_prefix [] = "DEVICE:"
static const char inode_prefix [] = "INODE:"
static const char norm_prefix [] = { '.', PATH_SEPARATOR, 0 }
static const char wildcard_prefix [] = { PATH_SEPARATOR, '*', '*', 0 }
static const char abs_shell_prefix [] = { PATH_SEPARATOR, 0 }

Detailed Description

groups and ignore command and functions.

Definition in file ignore.c.


Define Documentation

#define RESERVE_IGNORE_ENTRIES   (4)

Definition at line 636 of file ignore.c.

Referenced by ign__new_pattern().


Function Documentation

int ign___compare_dev ( struct sstat_t st,
struct ignore_t ign 
) [inline]

Compares the given sstat_t st with the device ignore pattern ign.

Does the less-than, greater-than and/or equal comparision.

Definition at line 1395 of file ignore.c.

References sstat_t::dev, ignore_t::has_minor, ignore_t::major, and ignore_t::minor.

Referenced by ign__is_ignore().

Here is the caller graph for this function:

int ign___init_pattern_into ( char *  pattern,
char *  end,
struct ignore_t ignore 
)
int ign___load_group ( struct ignore_t ign  ) 
int ign___new_group ( struct ignore_t ign,
struct grouping_t **  result 
)

Definition at line 1417 of file ignore.c.

References DEBUGP, global_pool, ignore_t::group_def, ignore_t::group_name, hlp__calloc(), ign___groups, and STOPIF.

Referenced by ign___load_group(), and ign__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign___parse_position ( char *  arg,
int *  position,
int *  advance 
)

Parses the optional position specification.

Definition at line 1928 of file ignore.c.

References PATTERN_POSITION_END, PATTERN_POSITION_START, STOPIF_CODE_ERR, and used_ignore_entries.

Referenced by ign__rign(), and ign__work().

Here is the caller graph for this function:

int ign___test_all_patterns ( struct estat sts  ) 

Definition at line 1982 of file ignore.c.

References BUG_ON, estat::entry_status, FS_NEW, ignore_t::group_name, estat::match_pattern, ops__build_path(), opt__is_verbose(), ignore_t::pattern, STOPIF, and STOPIF_CODE_EPIPE.

Referenced by ign__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign___test_single_pattern ( struct estat sts  ) 

Definition at line 1962 of file ignore.c.

References BUG_ON, estat::entry_status, FS_NEW, estat::match_pattern, ops__build_path(), opt__is_verbose(), STOPIF, and STOPIF_CODE_EPIPE.

Referenced by ign__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign___translate_bracketed_expr ( char *  end_of_buffer,
char **  src,
char **  dest 
)

Processes a character class in shell ignore patterns.

Definition at line 673 of file ignore.c.

References STOPIF, and STOPIF_CODE_ERR.

Referenced by ign__compile_pattern().

Here is the caller graph for this function:

int ign__compile_pattern ( struct ignore_t ignore  ) 

Compiles the given pattern for use with PCRE.

Definition at line 740 of file ignore.c.

References BUG, ignore_t::compare_string, ignore_t::compiled, DEBUGP, ignore_t::extra, hlp__alloc(), hlp__realloc(), ign___translate_bracketed_expr(), ignore_t::is_icase, norm_prefix, PATH_SEPARATOR, ignore_t::pattern, PT_PCRE, PT_SHELL, PT_SHELL_ABS, STOPIF, STOPIF_CODE_ERR, ignore_t::type, wa__warn(), wc_path, wc_path_len, wildcard_prefix, and WRN__IGNPAT_WCBASE.

Referenced by ign___init_pattern_into().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign__is_ignore ( struct estat sts,
int *  is_ignored 
)

-.

Tells whether the given entry is to be ignored.

Searches this entry for a take/ignore pattern.

If a parent directory has an ignore entry which might be valid for this directory (like **/*~), it is mentioned in this directory, too - in case of something like dir/a*/b*/* a path level value is given.

As we need to preserve the _order_ of the ignore/take statements, we cannot easily optimize. is_ignored is set to +1 if ignored, 0 if unknown, and -1 if on a take-list (overriding later ignore list).

sts must already have the correct estat::st.mode bits set.

Definition at line 1639 of file ignore.c.

References BUG, ignore_t::compare, ignore_t::compiled, DEBUGP, ignore_t::dev, sstat_t::dev, dir___f_sort_by_inodePP(), ignore_t::dir_only, ignore_t::extra, ignore_t::group_def, ign___compare_dev(), ign___load_group(), sstat_t::ino, ignore_t::inode, grouping_t::is_ignore, estat::match_pattern, sstat_t::mode, ignore_t::mode_match_and, ignore_t::mode_match_cmp, ops__build_path(), estat::parent, PAT_DEV__EQUAL, PAT_DEV__GREATER, PAT_DEV__LESS, estat::path_len, ignore_t::pattern, PT_DEVICE, PT_INODE, PT_PCRE, PT_SHELL, PT_SHELL_ABS, estat::st, ignore_t::stats_matches, ignore_t::stats_tested, STOPIF, STOPIF_CODE_ERR, estat::to_be_ignored, ignore_t::type, UNUSED, and used_ignore_entries.

Referenced by au__action(), prp__s_work(), st__status(), waa__build_tree(), and waa__update_dir().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign__load_list ( char *  dir  ) 

-.

Loads the ignore list from the WAA.

Definition at line 1309 of file ignore.c.

References DEBUGP, ign__new_pattern(), ign_header_str, memory, PATTERN_POSITION_END, STOPIF, STOPIF_CODE_ERR, used_ignore_entries, WAA__IGNORE_EXT, waa__open_byext(), and WAA__READ.

Referenced by au__prepare_for_added(), ci__work(), df__work(), ign__rign(), ign__work(), and st__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign__new_pattern ( unsigned  count,
char *  pattern[],
char *  ends,
int  user_pattern,
int  position 
)

Adds a list of new ignore patterns to the internal list.

Definition at line 1834 of file ignore.c.

References BUG_ON, DEBUGP, hlp__realloc(), ign___init_pattern_into(), ignore_t::is_user_pat, max_ignore_entries, PATTERN_POSITION_END, RESERVE_IGNORE_ENTRIES, STOPIF, and used_ignore_entries.

Referenced by ign__load_list(), ign__rign(), and ign__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign__print_group_stats ( FILE *  output  ) 

-.

Print the grouping statistics.

Definition at line 2010 of file ignore.c.

References ignore_t::group_name, ignore_t::is_user_pat, opt__is_verbose(), ignore_t::pattern, ignore_t::stats_matches, ignore_t::stats_tested, STOPIF_CODE_EPIPE, and used_ignore_entries.

Referenced by ign__work(), and st__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign__rign ( struct estat *root  UNUSED,
int  argc,
char *  argv[] 
)

-.

Relativizes the given paths, and stores them.

Definition at line 2182 of file ignore.c.

References ac__Usage_this, FCB__NO_REALPATH, FCB__PUT_DOTSLASH, ign___parse_position(), ign__load_list(), ign__new_pattern(), ign__save_ignorelist(), STOPIF, and waa__find_common_base2().

Here is the call graph for this function:

int ign__save_ignorelist ( char *  basedir  ) 

Writes the ignore list back to disk storage.

Definition at line 1766 of file ignore.c.

References DEBUGP, HEADER_LEN, ign_header_str, ignore_t::is_user_pat, ignore_t::pattern, STOPIF, STOPIF_CODE_ERR, used_ignore_entries, waa__close(), waa__delete_byext(), WAA__IGNORE_EXT, waa__open_byext(), WAA__WRITE, and wc_path.

Referenced by ign__rign(), and ign__work().

Here is the call graph for this function:

Here is the caller graph for this function:

int ign__work ( struct estat *root  UNUSED,
int  argc,
char *  argv[] 
)

Variable Documentation

const char abs_shell_prefix[] = { PATH_SEPARATOR, 0 } [static]

Definition at line 667 of file ignore.c.

Referenced by ign___init_pattern_into().

const char dev_prefix[] = "DEVICE:" [static]

Definition at line 661 of file ignore.c.

Referenced by ign___init_pattern_into().

const char ign___parm_delimiter = ','

Definition at line 643 of file ignore.c.

Referenced by ign___init_pattern_into().

const char ign__group_ign[] = "ignore" [static]

Definition at line 641 of file ignore.c.

Referenced by ign___init_pattern_into(), and ign___load_group().

const char ign__group_take[] = "take" [static]

Definition at line 640 of file ignore.c.

Referenced by ign___init_pattern_into(), and ign___load_group().

The length of the longest group name, used for formatting the status output.

This is initialized to 6, because "ignore" at least takes that much space - and "(none)" too.

Definition at line 633 of file ignore.c.

Referenced by ign___init_pattern_into(), and st__print_status().

const char ign_header_str[] = "%u" [static]

Header definition - currently only number of entries.

Definition at line 639 of file ignore.c.

Referenced by ign__load_list(), and ign__save_ignorelist().

struct ignore_t* ignore_list = NULL [static]

Allocated array of grouping patterns.

Definition at line 651 of file ignore.c.

const char inode_prefix[] = "INODE:" [static]

Definition at line 662 of file ignore.c.

Referenced by ign___init_pattern_into().

For how many grouping patterns memory is allocated.

Definition at line 646 of file ignore.c.

Referenced by ign__new_pattern().

char* memory [static]

Place where the patterns are mmap()ed.

Definition at line 654 of file ignore.c.

Referenced by ign__load_list().

const char norm_prefix[] = { '.', PATH_SEPARATOR, 0 } [static]

Definition at line 663 of file ignore.c.

Referenced by ign___init_pattern_into(), and ign__compile_pattern().

const char pcre_prefix[] = "PCRE:" [static]

The various strings that define the pattern types.

Definition at line 660 of file ignore.c.

Referenced by ign___init_pattern_into().

How many grouping patterns are actually used.

Definition at line 648 of file ignore.c.

Referenced by ign___parse_position(), ign__is_ignore(), ign__load_list(), ign__new_pattern(), ign__print_group_stats(), ign__save_ignorelist(), and ign__work().

const char wildcard_prefix[] = { PATH_SEPARATOR, '*', '*', 0 } [static]

Definition at line 665 of file ignore.c.

Referenced by ign__compile_pattern().


Generated for fsvs by  doxygen 1.6.1