X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Flib%2Ftree.h;h=7a2467cc1f07301f657eb9ee088befcb18b4ded4;hb=c6064c3a1bf0db4047fce7c4a291eb108c5386a2;hp=fbe89b02fdf0e63753631dbff19fbdd6bdd15789;hpb=7cefbfdacb1d394f034d4bee6e7a96af1f06df95;p=bacula%2Fbacula diff --git a/bacula/src/lib/tree.h b/bacula/src/lib/tree.h index fbe89b02fd..7a2467cc1f 100644 --- a/bacula/src/lib/tree.h +++ b/bacula/src/lib/tree.h @@ -1,36 +1,29 @@ +/* + Bacula(R) - The Network Backup Solution + + Copyright (C) 2000-2017 Kern Sibbald + + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. + + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. + + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. +*/ /* * Directory tree build/traverse routines * * Kern Sibbald, June MMII * */ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2002-2006 Free Software Foundation Europe e.V. - - The main author of Bacula is Kern Sibbald, with contributions from - many others, a complete list can be found in the file AUTHORS. - This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation plus additions - that are listed in the file LICENSE. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Bacula® is a registered trademark ofJohn Walker. - The licensor of Bacula is the Free Software Foundation Europe - (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, - Switzerland, email:ftf@fsfeurope.org. -*/ + +#include "htable.h" struct s_mem { struct s_mem *next; /* next buffer */ @@ -50,6 +43,11 @@ struct s_mem { #define first_child(node) \ ((TREE_NODE *)(node->child.first()) +struct delta_list { + struct delta_list *next; + JobId_t JobId; + int32_t FileIndex; +}; /* * Keep this node as small as possible because @@ -58,11 +56,12 @@ struct s_mem { struct s_tree_node { /* KEEP sibling as the first member to avoid having to * do initialization of child */ - dlink sibling; - dlist child; + rblink sibling; + rblist child; char *fname; /* file name */ int32_t FileIndex; /* file index */ uint32_t JobId; /* JobId */ + int32_t delta_seq; /* current delta sequence */ uint16_t fname_len; /* filename length */ int type: 8; /* node type */ unsigned int extract: 1; /* extract item */ @@ -71,28 +70,34 @@ struct s_tree_node { unsigned int soft_link: 1; /* set if is soft link */ unsigned int inserted: 1; /* set when node newly inserted */ unsigned int loaded: 1; /* set when the dir is in the tree */ + unsigned int can_access: 1; /* Can access to this node */ struct s_tree_node *parent; struct s_tree_node *next; /* next hash of FileIndex */ + struct delta_list *delta_list; /* delta parts for this node */ }; typedef struct s_tree_node TREE_NODE; struct s_tree_root { /* KEEP sibling as the first member to avoid having to * do initialization of child */ - dlink sibling; - dlist child; + rblink sibling; + rblist child; const char *fname; /* file name */ int32_t FileIndex; /* file index */ uint32_t JobId; /* JobId */ + int32_t delta_seq; /* current delta sequence */ uint16_t fname_len; /* filename length */ unsigned int type: 8; /* node type */ unsigned int extract: 1; /* extract item */ unsigned int extract_dir: 1; /* extract dir entry only */ - unsigned int have_link: 1; /* set if have hard link */ + unsigned int hard_link: 1; /* set if have hard link */ + unsigned int soft_link: 1; /* set if is soft link */ unsigned int inserted: 1; /* set when newly inserted */ unsigned int loaded: 1; /* set when the dir is in the tree */ + unsigned int can_access: 1; /* Can access to this node */ struct s_tree_node *parent; struct s_tree_node *next; /* next hash of FileIndex */ + struct delta_list *delta_list; /* delta parts for this node */ /* The above ^^^ must be identical to a TREE_NODE structure */ struct s_tree_node *first; /* first entry in the tree */ @@ -103,9 +108,17 @@ struct s_tree_root { int cached_path_len; /* length of cached path */ char *cached_path; /* cached current path */ TREE_NODE *cached_parent; /* cached parent for above path */ + htable hardlinks; /* references to first occurrence of hardlinks */ }; typedef struct s_tree_root TREE_ROOT; +/* hardlink hashtable entry */ +struct s_hl_entry { + uint64_t key; + hlink link; + TREE_NODE *node; +}; +typedef struct s_hl_entry HL_ENTRY; /* type values */ #define TN_ROOT 1 /* root node */ @@ -121,8 +134,11 @@ TREE_NODE *insert_tree_node(char *path, char *fname, int type, TREE_NODE *make_tree_path(char *path, TREE_ROOT *root); TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node); TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node); +void tree_add_delta_part(TREE_ROOT *root, TREE_NODE *node, + JobId_t JobId, int32_t FileIndex); void free_tree(TREE_ROOT *root); int tree_getpath(TREE_NODE *node, char *buf, int buf_size); +void tree_remove_node(TREE_ROOT *root, TREE_NODE *node); /* * Use the following for traversing the whole tree. It will be