Lines Matching defs:mtree

90 struct mtree {
113 struct mtree *, struct mtree_entry *, int *);
116 struct mtree *, struct mtree_entry *, int *);
117 static int parse_keyword(struct archive_read *, struct mtree *,
121 static ssize_t readline(struct archive_read *, struct mtree *, char **, ssize_t);
192 struct mtree *mtree;
198 mtree = (struct mtree *)malloc(sizeof(*mtree));
199 if (mtree == NULL) {
201 "Can't allocate mtree data");
204 memset(mtree, 0, sizeof(*mtree));
205 mtree->fd = -1;
207 r = __archive_read_register_format(a, mtree, "mtree",
211 free(mtree);
218 struct mtree *mtree;
221 mtree = (struct mtree *)(a->format->data);
223 p = mtree->entries;
231 archive_string_free(&mtree->line);
232 archive_string_free(&mtree->current_dir);
233 archive_string_free(&mtree->contents_name);
234 archive_entry_linkresolver_free(mtree->resolver);
236 free(mtree->buff);
237 free(mtree);
322 * Compare characters with a mtree keyword.
323 * Returns the length of a mtree keyword if matched.
353 * Test whether the characters 'p' has is mtree keyword.
420 * Test whether there is a set of mtree keywords.
528 * a mtree format ``NetBSD's mtree -D'' creates, which
571 const char *signature = "#mtree";
585 * There is not a mtree signature. Let's try to detect mtree format.
597 int form_D = 0;/* The archive is generated by `NetBSD mtree -D'
667 * to assume that this file is a mtree
705 * The extended mtree format permits multiple lines specifying
708 * to read the entire mtree file into memory up front.
822 process_add_entry(struct archive_read *a, struct mtree *mtree,
844 mtree->entries = entry;
919 read_mtree(struct archive_read *a, struct mtree *mtree)
928 mtree->archive_format = ARCHIVE_FORMAT_MTREE;
929 mtree->archive_format_name = "mtree";
937 len = readline(a, mtree, &p, 65536);
939 mtree->this_entry = mtree->entries;
958 r = process_add_entry(a, mtree, &global, p, len,
984 * Read in the entire mtree file into memory on the first request.
990 struct mtree *mtree;
994 mtree = (struct mtree *)(a->format->data);
996 if (mtree->fd >= 0) {
997 close(mtree->fd);
998 mtree->fd = -1;
1001 if (mtree->entries == NULL) {
1002 mtree->resolver = archive_entry_linkresolver_new();
1003 if (mtree->resolver == NULL)
1005 archive_entry_linkresolver_set_strategy(mtree->resolver,
1007 r = read_mtree(a, mtree);
1012 a->archive.archive_format = mtree->archive_format;
1013 a->archive.archive_format_name = mtree->archive_format_name;
1016 if (mtree->this_entry == NULL)
1018 if (strcmp(mtree->this_entry->name, "..") == 0) {
1019 mtree->this_entry->used = 1;
1020 if (archive_strlen(&mtree->current_dir) > 0) {
1022 p = mtree->current_dir.s
1023 + mtree->current_dir.length - 1;
1024 while (p >= mtree->current_dir.s && *p != '/')
1026 if (p >= mtree->current_dir.s)
1028 mtree->current_dir.length
1029 = p - mtree->current_dir.s + 1;
1032 if (!mtree->this_entry->used) {
1034 r = parse_file(a, entry, mtree, mtree->this_entry, &use_next);
1038 mtree->this_entry = mtree->this_entry->next;
1049 struct mtree *mtree, struct mtree_entry *mentry, int *use_next)
1062 archive_string_empty(&mtree->contents_name);
1066 r = parse_line(a, entry, mtree, mentry, &parsed_kws);
1085 r1 = parse_line(a, entry, mtree, mp,
1097 size_t n = archive_strlen(&mtree->current_dir);
1099 archive_strcat(&mtree->current_dir, "/");
1100 archive_strcat(&mtree->current_dir, mentry->name);
1101 archive_entry_copy_pathname(entry, mtree->current_dir.s);
1103 mtree->current_dir.length = n;
1109 * this here so that getting a listing of an mtree
1117 mtree->fd = -1;
1118 if (archive_strlen(&mtree->contents_name) > 0)
1119 path = mtree->contents_name.s;
1125 mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
1126 __archive_ensure_cloexec_flag(mtree->fd);
1127 if (mtree->fd == -1 &&
1129 archive_strlen(&mtree->contents_name) > 0)) {
1137 if (mtree->fd >= 0) {
1138 if (fstat(mtree->fd, st) == -1) {
1143 close(mtree->fd);
1144 mtree->fd = -1;
1185 if (mtree->fd >= 0)
1186 close(mtree->fd);
1187 mtree->fd = -1;
1195 "mtree specification has different type for %s",
1253 archive_entry_linkify(mtree->resolver, &entry, &sparse_entry);
1264 mtree->cur_size = archive_entry_size(entry);
1265 mtree->offset = 0;
1275 struct mtree *mtree, struct mtree_entry *mp, int *parsed_kws)
1281 r1 = parse_keyword(a, mtree, entry, iter, parsed_kws);
1287 "Missing type keyword in mtree specification");
1328 parse_keyword(struct archive_read *a, struct mtree *mtree,
1348 * The mtree processing is not recursive, so
1370 archive_strcpy(&mtree->contents_name, val);
1462 /* Replicate an old mtree bug:
1542 struct mtree *mtree;
1544 mtree = (struct mtree *)(a->format->data);
1545 if (mtree->fd < 0) {
1551 if (mtree->buff == NULL) {
1552 mtree->buffsize = 64 * 1024;
1553 mtree->buff = malloc(mtree->buffsize);
1554 if (mtree->buff == NULL) {
1561 *buff = mtree->buff;
1562 *offset = mtree->offset;
1563 if ((int64_t)mtree->buffsize > mtree->cur_size - mtree->offset)
1564 bytes_to_read = (size_t)(mtree->cur_size - mtree->offset);
1566 bytes_to_read = mtree->buffsize;
1567 bytes_read = read(mtree->fd, mtree->buff, bytes_to_read);
1576 mtree->offset += bytes_read;
1585 struct mtree *mtree;
1587 mtree = (struct mtree *)(a->format->data);
1588 if (mtree->fd >= 0) {
1589 close(mtree->fd);
1590 mtree->fd = -1;
1801 readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limit)
1831 if (archive_string_ensure(&mtree->line,
1837 memcpy(mtree->line.s + total_size, t, bytes_read);
1841 mtree->line.s[total_size] = '\0';
1843 for (u = mtree->line.s + find_off; *u; ++u) {
1845 *start = mtree->line.s;
1851 *start = mtree->line.s;
1862 total_size - (u - mtree->line.s) + 1);
1870 find_off = u - mtree->line.s;