Lines Matching refs:part
43 static void message_free_part(sd_bus_message *m, struct bus_body_part *part) { in message_free_part() argument
45 assert(part); in message_free_part()
47 if (part->memfd >= 0) { in message_free_part()
50 explicit_bzero_safe(part->data, part->size); in message_free_part()
52 close_and_munmap(part->memfd, part->mmap_begin, part->mapped); in message_free_part()
53 } else if (part->munmap_this) in message_free_part()
56 munmap(part->mmap_begin, part->mapped); in message_free_part()
60 explicit_bzero_safe(part->data, part->size); in message_free_part()
62 if (part->free_this) in message_free_part()
63 free(part->data); in message_free_part()
66 if (part != &m->body) in message_free_part()
67 free(part); in message_free_part()
71 struct bus_body_part *part; in message_reset_parts() local
75 part = &m->body; in message_reset_parts()
77 struct bus_body_part *next = part->next; in message_reset_parts()
78 message_free_part(m, part); in message_reset_parts()
79 part = next; in message_reset_parts()
1197 struct bus_body_part *part; in message_append_part() local
1205 part = &m->body; in message_append_part()
1206 zero(*part); in message_append_part()
1210 part = new0(struct bus_body_part, 1); in message_append_part()
1211 if (!part) { in message_append_part()
1216 m->body_end->next = part; in message_append_part()
1219 part->memfd = -1; in message_append_part()
1220 m->body_end = part; in message_append_part()
1223 return part; in message_append_part()
1226 static void part_zero(struct bus_body_part *part, size_t sz) { in part_zero() argument
1227 assert(part); in part_zero()
1232 assert(!part->data); in part_zero()
1233 assert(part->memfd < 0); in part_zero()
1235 part->size = sz; in part_zero()
1236 part->is_zero = true; in part_zero()
1237 part->sealed = true; in part_zero()
1242 struct bus_body_part *part, in part_make_space() argument
1249 assert(part); in part_make_space()
1250 assert(!part->sealed); in part_make_space()
1255 if (part->allocated == 0 || sz > part->allocated) { in part_make_space()
1259 n = realloc(part->data, new_allocated); in part_make_space()
1265 part->data = n; in part_make_space()
1266 part->allocated = new_allocated; in part_make_space()
1267 part->free_this = true; in part_make_space()
1271 *q = part->data ? (uint8_t*) part->data + part->size : NULL; in part_make_space()
1273 part->size = sz; in part_make_space()
1344 struct bus_body_part *part = NULL; in message_extend_body() local
1357 part = message_append_part(m); in message_extend_body()
1358 if (!part) in message_extend_body()
1361 part_zero(part, padding); in message_extend_body()
1364 part = message_append_part(m); in message_extend_body()
1365 if (!part) in message_extend_body()
1368 r = part_make_space(m, part, sz, &p); in message_extend_body()
1375 part = m->body_end; in message_extend_body()
1376 op = part->data; in message_extend_body()
1377 os = part->size; in message_extend_body()
1379 start_part = ALIGN_TO(part->size, align); in message_extend_body()
1382 r = part_make_space(m, part, end_part, &p); in message_extend_body()
1394 … c->array_size = adjust_pointer(c->array_size, op, os, part->data); in message_extend_body()
1396 … m->error.message = (const char*) adjust_pointer(m->error.message, op, os, part->data); in message_extend_body()
2650 struct bus_body_part *part; in sd_bus_message_append_array_memfd() local
2703 part = message_append_part(m); in sd_bus_message_append_array_memfd()
2704 if (!part) in sd_bus_message_append_array_memfd()
2707 part->memfd = copy_fd; in sd_bus_message_append_array_memfd()
2708 part->memfd_offset = offset; in sd_bus_message_append_array_memfd()
2709 part->sealed = true; in sd_bus_message_append_array_memfd()
2710 part->size = size; in sd_bus_message_append_array_memfd()
2726 struct bus_body_part *part; in sd_bus_message_append_string_memfd() local
2790 part = message_append_part(m); in sd_bus_message_append_string_memfd()
2791 if (!part) in sd_bus_message_append_string_memfd()
2794 part->memfd = copy_fd; in sd_bus_message_append_string_memfd()
2795 part->memfd_offset = offset; in sd_bus_message_append_string_memfd()
2796 part->sealed = true; in sd_bus_message_append_string_memfd()
2797 part->size = size; in sd_bus_message_append_string_memfd()
2898 struct bus_body_part *part; in sd_bus_message_seal() local
2967 MESSAGE_FOREACH_PART(part, i, m) in sd_bus_message_seal()
2968 if (part->memfd >= 0 && in sd_bus_message_seal()
2969 !part->sealed && in sd_bus_message_seal()
2970 (part->size > MEMFD_MIN_SIZE || m->bus->use_memfd < 0) && in sd_bus_message_seal()
2971 part != m->body_end) { /* The last part may never be sent as memfd */ in sd_bus_message_seal()
2977 bus_body_part_unmap(part); in sd_bus_message_seal()
2980 sz = part->size; in sd_bus_message_seal()
2981 r = memfd_set_size(part->memfd, sz); in sd_bus_message_seal()
2986 if (memfd_set_sealed(part->memfd) >= 0) in sd_bus_message_seal()
2987 part->sealed = true; in sd_bus_message_seal()
3001 int bus_body_part_map(struct bus_body_part *part) { in bus_body_part_map() argument
3005 assert_se(part); in bus_body_part_map()
3007 if (part->data) in bus_body_part_map()
3010 if (part->size <= 0) in bus_body_part_map()
3014 if (part->memfd < 0 && part->is_zero && part->size < 8) { in bus_body_part_map()
3016 part->data = (void*) zeroes; in bus_body_part_map()
3020 shift = PAGE_OFFSET(part->memfd_offset); in bus_body_part_map()
3021 psz = PAGE_ALIGN(part->size + shift); in bus_body_part_map()
3023 if (part->memfd >= 0) in bus_body_part_map()
3024 … p = mmap(NULL, psz, PROT_READ, MAP_PRIVATE, part->memfd, part->memfd_offset - shift); in bus_body_part_map()
3025 else if (part->is_zero) in bus_body_part_map()
3033 part->mapped = psz; in bus_body_part_map()
3034 part->mmap_begin = p; in bus_body_part_map()
3035 part->data = (uint8_t*) p + shift; in bus_body_part_map()
3036 part->munmap_this = true; in bus_body_part_map()
3041 void bus_body_part_unmap(struct bus_body_part *part) { in bus_body_part_unmap() argument
3043 assert_se(part); in bus_body_part_unmap()
3045 if (part->memfd < 0) in bus_body_part_unmap()
3048 if (!part->mmap_begin) in bus_body_part_unmap()
3051 if (!part->munmap_this) in bus_body_part_unmap()
3054 assert_se(munmap(part->mmap_begin, part->mapped) == 0); in bus_body_part_unmap()
3056 part->mmap_begin = NULL; in bus_body_part_unmap()
3057 part->data = NULL; in bus_body_part_unmap()
3058 part->mapped = 0; in bus_body_part_unmap()
3059 part->munmap_this = false; in bus_body_part_unmap()
3132 struct bus_body_part *part; in find_part() local
3139 part = m->cached_rindex_part; in find_part()
3142 part = &m->body; in find_part()
3146 while (part) { in find_part()
3150 if (index + sz <= begin + part->size) { in find_part()
3152 r = bus_body_part_map(part); in find_part()
3157 *p = part->data ? (uint8_t*) part->data + index - begin in find_part()
3160 m->cached_rindex_part = part; in find_part()
3163 return part; in find_part()
3166 begin += part->size; in find_part()
3167 part = part->next; in find_part()
3268 struct bus_body_part *part; in message_peek_body() local
3282 part = find_part(m, *rindex, padding, (void**) &q); in message_peek_body()
3283 if (!part) in message_peek_body()
3293 part = find_part(m, start, nbytes, (void**) &q); in message_peek_body()
3294 if (!part || (nbytes > 0 && !q)) in message_peek_body()
5561 struct bus_body_part *part; in bus_message_get_blob() local
5574 MESSAGE_FOREACH_PART(part, i, m) in bus_message_get_blob()
5575 e = mempcpy(e, part->data, part->size); in bus_message_get_blob()