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);
215 struct mtree *mtree;
217 mtree = (struct mtree *)(a->format->data);
219 /* Allows to read information missing from the mtree from the file system */
221 mtree->checkfs = 0;
223 mtree->checkfs = 1;
271 struct mtree *mtree;
277 mtree = (struct mtree *)calloc(1, sizeof(*mtree));
278 if (mtree == NULL) {
280 "Can't allocate mtree data");
283 mtree->checkfs = 0;
284 mtree->fd = -1;
286 __archive_rb_tree_init(&mtree->rbtree, &rb_ops);
288 r = __archive_read_register_format(a, mtree, "mtree",
292 free(mtree);
299 struct mtree *mtree;
302 mtree = (struct mtree *)(a->format->data);
304 p = mtree->entries;
312 archive_string_free(&mtree->line);
313 archive_string_free(&mtree->current_dir);
314 archive_string_free(&mtree->contents_name);
315 archive_entry_linkresolver_free(mtree->resolver);
317 free(mtree->buff);
318 free(mtree);
389 * mtree is almost free-form input and without line length limits,
420 * Compare characters with a mtree keyword.
421 * Returns the length of a mtree keyword if matched.
451 * Test whether the characters 'p' has is mtree keyword.
518 * Test whether there is a set of mtree keywords.
628 * a mtree format(a.k.a form D) ``NetBSD's mtree -D'' creates,
671 const char *signature = "#mtree";
685 * There is not a mtree signature. Let's try to detect mtree format.
697 int form_D = 0;/* The archive is generated by `NetBSD mtree -D'
767 * to assume that this file is a mtree
805 * The extended mtree format permits multiple lines specifying
808 * to read the entire mtree file into memory up front.
922 process_add_entry(struct archive_read *a, struct mtree *mtree,
944 mtree->entries = entry;
996 if (!__archive_rb_tree_insert_node(&mtree->rbtree, &entry->rbnode)) {
999 &mtree->rbtree, entry->name);
1036 read_mtree(struct archive_read *a, struct mtree *mtree)
1045 mtree->archive_format = ARCHIVE_FORMAT_MTREE;
1046 mtree->archive_format_name = "mtree";
1055 len = readline(a, mtree, &p, 65536);
1057 mtree->this_entry = mtree->entries;
1085 r = process_add_entry(a, mtree, &global, p, len,
1111 * Read in the entire mtree file into memory on the first request.
1117 struct mtree *mtree;
1121 mtree = (struct mtree *)(a->format->data);
1123 if (mtree->fd >= 0) {
1124 close(mtree->fd);
1125 mtree->fd = -1;
1128 if (mtree->entries == NULL) {
1129 mtree->resolver = archive_entry_linkresolver_new();
1130 if (mtree->resolver == NULL)
1132 archive_entry_linkresolver_set_strategy(mtree->resolver,
1134 r = read_mtree(a, mtree);
1139 a->archive.archive_format = mtree->archive_format;
1140 a->archive.archive_format_name = mtree->archive_format_name;
1143 if (mtree->this_entry == NULL)
1145 if (strcmp(mtree->this_entry->name, "..") == 0) {
1146 mtree->this_entry->used = 1;
1147 if (archive_strlen(&mtree->current_dir) > 0) {
1149 p = mtree->current_dir.s
1150 + mtree->current_dir.length - 1;
1151 while (p >= mtree->current_dir.s && *p != '/')
1153 if (p >= mtree->current_dir.s)
1155 mtree->current_dir.length
1156 = p - mtree->current_dir.s + 1;
1159 if (!mtree->this_entry->used) {
1161 r = parse_file(a, entry, mtree, mtree->this_entry,
1166 mtree->this_entry = mtree->this_entry->next;
1177 struct mtree *mtree, struct mtree_entry *mentry, int *use_next)
1190 archive_string_empty(&mtree->contents_name);
1194 r = parse_line(a, entry, mtree, mentry, &parsed_kws);
1209 &mtree->rbtree, mentry->name);
1214 r1 = parse_line(a, entry, mtree, mp, &parsed_kws);
1225 size_t n = archive_strlen(&mtree->current_dir);
1227 archive_strcat(&mtree->current_dir, "/");
1228 archive_strcat(&mtree->current_dir, mentry->name);
1229 archive_entry_copy_pathname(entry, mtree->current_dir.s);
1231 mtree->current_dir.length = n;
1234 if (mtree->checkfs) {
1238 * this here so that getting a listing of an mtree
1246 mtree->fd = -1;
1247 if (archive_strlen(&mtree->contents_name) > 0)
1248 path = mtree->contents_name.s;
1254 mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
1255 __archive_ensure_cloexec_flag(mtree->fd);
1256 if (mtree->fd == -1 &&
1258 archive_strlen(&mtree->contents_name) > 0)) {
1266 if (mtree->fd >= 0) {
1267 if (fstat(mtree->fd, st) == -1) {
1272 close(mtree->fd);
1273 mtree->fd = -1;
1313 if (mtree->fd >= 0)
1314 close(mtree->fd);
1315 mtree->fd = -1;
1323 "mtree specification has different"
1385 archive_entry_linkify(mtree->resolver, &entry,
1398 mtree->cur_size = archive_entry_size(entry);
1399 mtree->offset = 0;
1409 struct mtree *mtree, struct mtree_entry *mp, int *parsed_kws)
1415 r1 = parse_keyword(a, mtree, entry, iter, parsed_kws);
1421 "Missing type keyword in mtree specification");
1589 parse_keyword(struct archive_read *a, struct mtree *mtree,
1609 * The mtree processing is not recursive, so
1631 archive_strcpy(&mtree->contents_name, val);
1770 /* Replicate an old mtree bug:
1867 struct mtree *mtree;
1869 mtree = (struct mtree *)(a->format->data);
1870 if (mtree->fd < 0) {
1876 if (mtree->buff == NULL) {
1877 mtree->buffsize = 64 * 1024;
1878 mtree->buff = malloc(mtree->buffsize);
1879 if (mtree->buff == NULL) {
1886 *buff = mtree->buff;
1887 *offset = mtree->offset;
1888 if ((int64_t)mtree->buffsize > mtree->cur_size - mtree->offset)
1889 bytes_to_read = (size_t)(mtree->cur_size - mtree->offset);
1891 bytes_to_read = mtree->buffsize;
1892 bytes_read = read(mtree->fd, mtree->buff, bytes_to_read);
1901 mtree->offset += bytes_read;
1910 struct mtree *mtree;
1912 mtree = (struct mtree *)(a->format->data);
1913 if (mtree->fd >= 0) {
1914 close(mtree->fd);
1915 mtree->fd = -1;
2072 readline(struct archive_read *a, struct mtree *mtree, char **start,
2101 if (archive_string_ensure(&mtree->line,
2108 memcpy(mtree->line.s + total_size, t, bytes_read);
2111 mtree->line.s[total_size] = '\0';
2113 for (u = mtree->line.s + find_off; *u; ++u) {
2116 *start = mtree->line.s;
2128 mtree->line.s[total_size] = '\0';
2136 find_off = u - mtree->line.s;