Lines Matching defs:mtree

100 struct mtree {
126 struct mtree *, struct mtree_entry *, int *);
129 struct mtree *, struct mtree_entry *, int *);
130 static int parse_keyword(struct archive_read *, struct mtree *,
134 static ssize_t readline(struct archive_read *, struct mtree *, char **, ssize_t);
194 struct mtree *mtree;
196 mtree = (struct mtree *)(a->format->data);
198 /* Allows to read information missing from the mtree from the file system */
200 mtree->checkfs = 0;
202 mtree->checkfs = 1;
250 struct mtree *mtree;
256 mtree = (struct mtree *)calloc(1, sizeof(*mtree));
257 if (mtree == NULL) {
259 "Can't allocate mtree data");
262 mtree->checkfs = 0;
263 mtree->fd = -1;
265 __archive_rb_tree_init(&mtree->rbtree, &rb_ops);
267 r = __archive_read_register_format(a, mtree, "mtree",
271 free(mtree);
278 struct mtree *mtree;
281 mtree = (struct mtree *)(a->format->data);
283 p = mtree->entries;
291 archive_string_free(&mtree->line);
292 archive_string_free(&mtree->current_dir);
293 archive_string_free(&mtree->contents_name);
294 archive_entry_linkresolver_free(mtree->resolver);
296 free(mtree->buff);
297 free(mtree);
368 * mtree is almost free-form input and without line length limits,
399 * Compare characters with a mtree keyword.
400 * Returns the length of a mtree keyword if matched.
430 * Test whether the characters 'p' has is mtree keyword.
497 * Test whether there is a set of mtree keywords.
607 * a mtree format(a.k.a form D) ``NetBSD's mtree -D'' creates,
650 const char *signature = "#mtree";
664 * There is not a mtree signature. Let's try to detect mtree format.
676 int form_D = 0;/* The archive is generated by `NetBSD mtree -D'
746 * to assume that this file is a mtree
784 * The extended mtree format permits multiple lines specifying
787 * to read the entire mtree file into memory up front.
901 process_add_entry(struct archive_read *a, struct mtree *mtree,
923 mtree->entries = entry;
975 if (!__archive_rb_tree_insert_node(&mtree->rbtree, &entry->rbnode)) {
978 &mtree->rbtree, entry->name);
1015 read_mtree(struct archive_read *a, struct mtree *mtree)
1024 mtree->archive_format = ARCHIVE_FORMAT_MTREE;
1025 mtree->archive_format_name = "mtree";
1034 len = readline(a, mtree, &p, 65536);
1036 mtree->this_entry = mtree->entries;
1064 r = process_add_entry(a, mtree, &global, p, len,
1090 * Read in the entire mtree file into memory on the first request.
1096 struct mtree *mtree;
1100 mtree = (struct mtree *)(a->format->data);
1102 if (mtree->fd >= 0) {
1103 close(mtree->fd);
1104 mtree->fd = -1;
1107 if (mtree->entries == NULL) {
1108 mtree->resolver = archive_entry_linkresolver_new();
1109 if (mtree->resolver == NULL)
1111 archive_entry_linkresolver_set_strategy(mtree->resolver,
1113 r = read_mtree(a, mtree);
1118 a->archive.archive_format = mtree->archive_format;
1119 a->archive.archive_format_name = mtree->archive_format_name;
1122 if (mtree->this_entry == NULL)
1124 if (strcmp(mtree->this_entry->name, "..") == 0) {
1125 mtree->this_entry->used = 1;
1126 if (archive_strlen(&mtree->current_dir) > 0) {
1128 p = mtree->current_dir.s
1129 + mtree->current_dir.length - 1;
1130 while (p >= mtree->current_dir.s && *p != '/')
1132 if (p >= mtree->current_dir.s)
1134 mtree->current_dir.length
1135 = p - mtree->current_dir.s + 1;
1138 if (!mtree->this_entry->used) {
1140 r = parse_file(a, entry, mtree, mtree->this_entry,
1145 mtree->this_entry = mtree->this_entry->next;
1156 struct mtree *mtree, struct mtree_entry *mentry, int *use_next)
1169 archive_string_empty(&mtree->contents_name);
1173 r = parse_line(a, entry, mtree, mentry, &parsed_kws);
1188 &mtree->rbtree, mentry->name);
1193 r1 = parse_line(a, entry, mtree, mp, &parsed_kws);
1204 size_t n = archive_strlen(&mtree->current_dir);
1206 archive_strcat(&mtree->current_dir, "/");
1207 archive_strcat(&mtree->current_dir, mentry->name);
1208 archive_entry_copy_pathname(entry, mtree->current_dir.s);
1210 mtree->current_dir.length = n;
1213 if (mtree->checkfs) {
1217 * this here so that getting a listing of an mtree
1225 mtree->fd = -1;
1226 if (archive_strlen(&mtree->contents_name) > 0)
1227 path = mtree->contents_name.s;
1233 mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
1234 __archive_ensure_cloexec_flag(mtree->fd);
1235 if (mtree->fd == -1 &&
1237 archive_strlen(&mtree->contents_name) > 0)) {
1245 if (mtree->fd >= 0) {
1246 if (fstat(mtree->fd, st) == -1) {
1251 close(mtree->fd);
1252 mtree->fd = -1;
1292 if (mtree->fd >= 0)
1293 close(mtree->fd);
1294 mtree->fd = -1;
1302 "mtree specification has different"
1364 archive_entry_linkify(mtree->resolver, &entry,
1377 mtree->cur_size = archive_entry_size(entry);
1378 mtree->offset = 0;
1388 struct mtree *mtree, struct mtree_entry *mp, int *parsed_kws)
1394 r1 = parse_keyword(a, mtree, entry, iter, parsed_kws);
1400 "Missing type keyword in mtree specification");
1568 parse_keyword(struct archive_read *a, struct mtree *mtree,
1588 * The mtree processing is not recursive, so
1610 archive_strcpy(&mtree->contents_name, val);
1749 /* Replicate an old mtree bug:
1846 struct mtree *mtree;
1848 mtree = (struct mtree *)(a->format->data);
1849 if (mtree->fd < 0) {
1855 if (mtree->buff == NULL) {
1856 mtree->buffsize = 64 * 1024;
1857 mtree->buff = malloc(mtree->buffsize);
1858 if (mtree->buff == NULL) {
1865 *buff = mtree->buff;
1866 *offset = mtree->offset;
1867 if ((int64_t)mtree->buffsize > mtree->cur_size - mtree->offset)
1868 bytes_to_read = (size_t)(mtree->cur_size - mtree->offset);
1870 bytes_to_read = mtree->buffsize;
1871 bytes_read = read(mtree->fd, mtree->buff, bytes_to_read);
1880 mtree->offset += bytes_read;
1889 struct mtree *mtree;
1891 mtree = (struct mtree *)(a->format->data);
1892 if (mtree->fd >= 0) {
1893 close(mtree->fd);
1894 mtree->fd = -1;
2051 readline(struct archive_read *a, struct mtree *mtree, char **start,
2080 if (archive_string_ensure(&mtree->line,
2087 memcpy(mtree->line.s + total_size, t, bytes_read);
2090 mtree->line.s[total_size] = '\0';
2092 for (u = mtree->line.s + find_off; *u; ++u) {
2095 *start = mtree->line.s;
2107 mtree->line.s[total_size] = '\0';
2115 find_off = u - mtree->line.s;