Lines Matching defs:mtree

99 struct mtree {
125 struct mtree *, struct mtree_entry *, int *);
128 struct mtree *, struct mtree_entry *, int *);
129 static int parse_keyword(struct archive_read *, struct mtree *,
133 static ssize_t readline(struct archive_read *, struct mtree *, char **, ssize_t);
193 struct mtree *mtree;
195 mtree = (struct mtree *)(a->format->data);
197 /* Allows to read information missing from the mtree from the file system */
199 mtree->checkfs = 0;
201 mtree->checkfs = 1;
249 struct mtree *mtree;
255 mtree = (struct mtree *)calloc(1, sizeof(*mtree));
256 if (mtree == NULL) {
258 "Can't allocate mtree data");
261 mtree->fd = -1;
263 __archive_rb_tree_init(&mtree->rbtree, &rb_ops);
265 r = __archive_read_register_format(a, mtree, "mtree",
269 free(mtree);
276 struct mtree *mtree;
279 mtree = (struct mtree *)(a->format->data);
281 p = mtree->entries;
289 archive_string_free(&mtree->line);
290 archive_string_free(&mtree->current_dir);
291 archive_string_free(&mtree->contents_name);
292 archive_entry_linkresolver_free(mtree->resolver);
294 free(mtree->buff);
295 free(mtree);
366 * mtree is almost free-form input and without line length limits,
397 * Compare characters with a mtree keyword.
398 * Returns the length of a mtree keyword if matched.
428 * Test whether the characters 'p' has is mtree keyword.
495 * Test whether there is a set of mtree keywords.
605 * a mtree format(a.k.a form D) ``NetBSD's mtree -D'' creates,
648 const char *signature = "#mtree";
662 * There is not a mtree signature. Let's try to detect mtree format.
674 int form_D = 0;/* The archive is generated by `NetBSD mtree -D'
744 * to assume that this file is a mtree
782 * The extended mtree format permits multiple lines specifying
785 * to read the entire mtree file into memory up front.
899 process_add_entry(struct archive_read *a, struct mtree *mtree,
921 mtree->entries = entry;
973 if (!__archive_rb_tree_insert_node(&mtree->rbtree, &entry->rbnode)) {
976 &mtree->rbtree, entry->name);
1013 read_mtree(struct archive_read *a, struct mtree *mtree)
1022 mtree->archive_format = ARCHIVE_FORMAT_MTREE;
1023 mtree->archive_format_name = "mtree";
1032 len = readline(a, mtree, &p, 65536);
1034 mtree->this_entry = mtree->entries;
1062 r = process_add_entry(a, mtree, &global, p, len,
1088 * Read in the entire mtree file into memory on the first request.
1094 struct mtree *mtree;
1098 mtree = (struct mtree *)(a->format->data);
1100 if (mtree->fd >= 0) {
1101 close(mtree->fd);
1102 mtree->fd = -1;
1105 if (mtree->entries == NULL) {
1106 mtree->resolver = archive_entry_linkresolver_new();
1107 if (mtree->resolver == NULL)
1109 archive_entry_linkresolver_set_strategy(mtree->resolver,
1111 r = read_mtree(a, mtree);
1116 a->archive.archive_format = mtree->archive_format;
1117 a->archive.archive_format_name = mtree->archive_format_name;
1120 if (mtree->this_entry == NULL)
1122 if (strcmp(mtree->this_entry->name, "..") == 0) {
1123 mtree->this_entry->used = 1;
1124 if (archive_strlen(&mtree->current_dir) > 0) {
1126 p = mtree->current_dir.s
1127 + mtree->current_dir.length - 1;
1128 while (p >= mtree->current_dir.s && *p != '/')
1130 if (p >= mtree->current_dir.s)
1132 mtree->current_dir.length
1133 = p - mtree->current_dir.s + 1;
1136 if (!mtree->this_entry->used) {
1138 r = parse_file(a, entry, mtree, mtree->this_entry,
1143 mtree->this_entry = mtree->this_entry->next;
1154 struct mtree *mtree, struct mtree_entry *mentry, int *use_next)
1167 archive_string_empty(&mtree->contents_name);
1171 r = parse_line(a, entry, mtree, mentry, &parsed_kws);
1186 &mtree->rbtree, mentry->name);
1191 r1 = parse_line(a, entry, mtree, mp, &parsed_kws);
1202 size_t n = archive_strlen(&mtree->current_dir);
1204 archive_strcat(&mtree->current_dir, "/");
1205 archive_strcat(&mtree->current_dir, mentry->name);
1206 archive_entry_copy_pathname(entry, mtree->current_dir.s);
1208 mtree->current_dir.length = n;
1211 if (mtree->checkfs) {
1215 * this here so that getting a listing of an mtree
1223 mtree->fd = -1;
1224 if (archive_strlen(&mtree->contents_name) > 0)
1225 path = mtree->contents_name.s;
1231 mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
1232 __archive_ensure_cloexec_flag(mtree->fd);
1233 if (mtree->fd == -1 &&
1235 archive_strlen(&mtree->contents_name) > 0)) {
1243 if (mtree->fd >= 0) {
1244 if (fstat(mtree->fd, st) == -1) {
1249 close(mtree->fd);
1250 mtree->fd = -1;
1290 if (mtree->fd >= 0)
1291 close(mtree->fd);
1292 mtree->fd = -1;
1300 "mtree specification has different"
1362 archive_entry_linkify(mtree->resolver, &entry,
1375 mtree->cur_size = archive_entry_size(entry);
1376 mtree->offset = 0;
1386 struct mtree *mtree, struct mtree_entry *mp, int *parsed_kws)
1392 r1 = parse_keyword(a, mtree, entry, iter, parsed_kws);
1398 "Missing type keyword in mtree specification");
1488 parse_keyword(struct archive_read *a, struct mtree *mtree,
1508 * The mtree processing is not recursive, so
1530 archive_strcpy(&mtree->contents_name, val);
1656 /* Replicate an old mtree bug:
1753 struct mtree *mtree;
1755 mtree = (struct mtree *)(a->format->data);
1756 if (mtree->fd < 0) {
1762 if (mtree->buff == NULL) {
1763 mtree->buffsize = 64 * 1024;
1764 mtree->buff = malloc(mtree->buffsize);
1765 if (mtree->buff == NULL) {
1772 *buff = mtree->buff;
1773 *offset = mtree->offset;
1774 if ((int64_t)mtree->buffsize > mtree->cur_size - mtree->offset)
1775 bytes_to_read = (size_t)(mtree->cur_size - mtree->offset);
1777 bytes_to_read = mtree->buffsize;
1778 bytes_read = read(mtree->fd, mtree->buff, bytes_to_read);
1787 mtree->offset += bytes_read;
1796 struct mtree *mtree;
1798 mtree = (struct mtree *)(a->format->data);
1799 if (mtree->fd >= 0) {
1800 close(mtree->fd);
1801 mtree->fd = -1;
1958 readline(struct archive_read *a, struct mtree *mtree, char **start,
1987 if (archive_string_ensure(&mtree->line,
1994 memcpy(mtree->line.s + total_size, t, bytes_read);
1997 mtree->line.s[total_size] = '\0';
1999 for (u = mtree->line.s + find_off; *u; ++u) {
2002 *start = mtree->line.s;
2014 mtree->line.s[total_size] = '\0';
2022 find_off = u - mtree->line.s;