1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Various functions to work with meta entries.
5 * Copyright (C) 2007-2008 David Härdeman <david@hardeman.nu>
6 * Copyright (C) 2012-2016 Przemyslaw Pawelczyk <przemoc@gmail.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; only version 2 of the License is applicable.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 /* Data structure to hold all metadata for a file/dir */
30 struct metaentry
*next
; /* For the metahash chains */
31 struct metaentry
*list
; /* For creating additional lists of entries */
44 ssize_t
*xattr_lvalues
;
48 #define HASH_INDEXES 1024
50 /* Data structure to hold a number of metadata entries */
52 struct metaentry
*bucket
[HASH_INDEXES
];
56 /* Create a metaentry for the file/dir/etc at path */
57 struct metaentry
*mentry_create(const char *path
);
59 /* Recurses opath and adds metadata entries to the metaentry list */
60 void mentries_recurse_path(const char *opath
, struct metahash
**mhash
,
63 /* Stores a metaentry list to a file */
64 void mentries_tofile(const struct metahash
*mhash
, const char *path
);
66 /* Creates a metaentry list from a file */
67 void mentries_fromfile(struct metahash
**mhash
, const char *path
);
69 /* Searches haystack for an xattr matching xattr number n in needle */
70 int mentry_find_xattr(struct metaentry
*haystack
,
71 struct metaentry
*needle
,
74 #define DIFF_NONE 0x00
75 #define DIFF_OWNER 0x01
76 #define DIFF_GROUP 0x02
77 #define DIFF_MODE 0x04
78 #define DIFF_TYPE 0x08
79 #define DIFF_MTIME 0x10
80 #define DIFF_XATTR 0x20
81 #define DIFF_ADDED 0x40
82 #define DIFF_DELE 0x80
84 /* Compares two metaentries and returns an int with a bitmask of differences */
85 int mentry_compare(struct metaentry
*left
,
86 struct metaentry
*right
,
89 /* Compares lists of real and stored metadata and calls pfunc for each */
90 void mentries_compare(struct metahash
*mhashreal
,
91 struct metahash
*mhashstored
,
92 void (*pfunc
)(struct metaentry
*real
,
93 struct metaentry
*stored
,
97 void mentries_dump(struct metahash
*mhash
);
99 #endif /* METAENTRY_H */