commit 7cda4b11fea3fbaea57848853f7e6fe7204812ee9f4477f2303e7e83d50d11ae from: Stefan Sperling date: Wed Feb 25 08:44:42 2026 UTC add PACKED and DELTIFIED flags to raw objects for future use ok op@ commit - a5fb4de1927f211101c0b9a47b68f2764834954aca1c26f3386a6a30b744d97d commit + 7cda4b11fea3fbaea57848853f7e6fe7204812ee9f4477f2303e7e83d50d11ae blob - c116f12340df41a78134dc2501fd96e3d6ad3c6c76052529dc9ed5b800141a7b blob + 466de69000e375badc1529f54563086b9c3918212a251c7d701be8f835b8599b --- lib/got_lib_object.h +++ lib/got_lib_object.h @@ -45,6 +45,10 @@ struct got_raw_object { size_t hdrlen; int refcnt; /* > 0 if open and/or cached */ + int flags; +#define GOT_RAW_OBJ_FLAG_PACKED 0x01 +#define GOT_RAW_OBJ_FLAG_DELTIFIED 0x02 + got_object_raw_close_cb *close_cb; void *close_arg; }; blob - 65b591fcc427ea032cc86439a27ebc17616c57deacb1ab1cfc7f34562ff615d6 blob + 0b00b774dbea0d479f6eda97ebdf7e1c914ab87c290550dba235ec48dba23eba --- lib/got_lib_privsep.h +++ lib/got_lib_privsep.h @@ -301,6 +301,7 @@ struct got_imsg_blob { struct got_imsg_raw_obj { off_t size; size_t hdrlen; + int flags; /* * If size <= GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX, object data follows @@ -740,9 +741,9 @@ const struct got_error *got_privsep_get_imsg_obj(struc const struct got_error *got_privsep_recv_obj(struct got_object **, struct imsgbuf *); const struct got_error *got_privsep_send_raw_obj(struct imsgbuf *, off_t, - size_t, uint8_t *); + size_t, int, uint8_t *); const struct got_error *got_privsep_recv_raw_obj(uint8_t **, off_t *, size_t *, - struct imsgbuf *); + int *, struct imsgbuf *); const struct got_error *got_privsep_send_commit(struct imsgbuf *, struct got_commit_object *); const struct got_error *got_privsep_recv_commit(struct got_commit_object **, blob - 9a56cc93f0887155cc2fcabd1296edad9ebb86097ddb7cec82452f6379eb1324 blob + 6d4215ce5d837e1833850ee71c933b22c152ed7992e8c4be6fdee2f065dbc06e --- lib/object_open_io.c +++ lib/object_open_io.c @@ -191,8 +191,8 @@ wrap_fd(FILE **f, int wrapped_fd) static const struct got_error * read_packed_object_raw(uint8_t **outbuf, off_t *size, size_t *hdrlen, - int outfd, struct got_pack *pack, struct got_packidx *packidx, int idx, - struct got_object_id *id) + int *flags, int outfd, struct got_pack *pack, + struct got_packidx *packidx, int idx, struct got_object_id *id) { const struct got_error *err = NULL; uint64_t raw_size = 0; @@ -202,6 +202,7 @@ read_packed_object_raw(uint8_t **outbuf, off_t *size, *outbuf = NULL; *size = 0; *hdrlen = 0; + *flags = GOT_RAW_OBJ_FLAG_PACKED; err = got_packfile_open_object(&obj, pack, packidx, idx, id); if (err) @@ -211,6 +212,7 @@ read_packed_object_raw(uint8_t **outbuf, off_t *size, err = got_pack_get_max_delta_object_size(&raw_size, obj, pack); if (err) goto done; + *flags |= GOT_RAW_OBJ_FLAG_DELTIFIED; } else raw_size = obj->size; @@ -276,6 +278,7 @@ got_object_raw_open(struct got_raw_object **obj, int * off_t size = 0; size_t hdrlen = 0; char *path_packfile = NULL; + int flags = 0; *obj = got_repo_get_cached_raw_object(repo, id); if (*obj != NULL) { @@ -303,7 +306,7 @@ got_object_raw_open(struct got_raw_object **obj, int * if (err) goto done; } - err = read_packed_object_raw(&outbuf, &size, &hdrlen, + err = read_packed_object_raw(&outbuf, &size, &hdrlen, &flags, tempfd, pack, packidx, idx, id); if (err) goto done; @@ -342,6 +345,8 @@ got_object_raw_open(struct got_raw_object **obj, int * GOT_DELTA_RESULT_SIZE_CACHED_MAX, hdrlen, size); if (err) goto done; + + (*obj)->flags = flags; err = got_repo_cache_raw_object(repo, id, *obj); if (err) { blob - 4951c8b38af62bdf07b844695a6e6e9140c5a3b29f38a7cecc79fc14624e2a61 blob + b3a1d145a308f92d8a155c08904fb679735e22c3e661c90248ed7ab96ae534bc --- lib/object_open_privsep.c +++ lib/object_open_privsep.c @@ -112,7 +112,8 @@ done: static const struct got_error * request_packed_object_raw(uint8_t **outbuf, off_t *size, size_t *hdrlen, - int outfd, struct got_pack *pack, int idx, struct got_object_id *id) + int *flags, int outfd, struct got_pack *pack, int idx, + struct got_object_id *id) { const struct got_error *err = NULL; struct imsgbuf *ibuf = pack->privsep_child->ibuf; @@ -136,7 +137,7 @@ request_packed_object_raw(uint8_t **outbuf, off_t *siz if (err) return err; - err = got_privsep_recv_raw_obj(outbuf, size, hdrlen, ibuf); + err = got_privsep_recv_raw_obj(outbuf, size, hdrlen, flags, ibuf); if (err) return err; @@ -161,8 +162,8 @@ read_packed_object_privsep(struct got_object **obj, static const struct got_error * read_packed_object_raw_privsep(uint8_t **outbuf, off_t *size, size_t *hdrlen, - int outfd, struct got_pack *pack, struct got_packidx *packidx, int idx, - struct got_object_id *id) + int *flags, int outfd, struct got_pack *pack, struct got_packidx *packidx, + int idx, struct got_object_id *id) { const struct got_error *err = NULL; @@ -172,8 +173,8 @@ read_packed_object_raw_privsep(uint8_t **outbuf, off_t return err; } - return request_packed_object_raw(outbuf, size, hdrlen, outfd, pack, - idx, id); + return request_packed_object_raw(outbuf, size, hdrlen, flags, + outfd, pack, idx, id); } const struct got_error * @@ -294,8 +295,8 @@ request_object(struct got_object **obj, struct got_obj } static const struct got_error * -request_raw_object(uint8_t **outbuf, off_t *size, size_t *hdrlen, int outfd, - struct got_object_id *id, struct got_repository *repo, int infd) +request_raw_object(uint8_t **outbuf, off_t *size, size_t *hdrlen, int *flags, + int outfd, struct got_object_id *id, struct got_repository *repo, int infd) { const struct got_error *err = NULL; struct imsgbuf *ibuf; @@ -315,7 +316,7 @@ request_raw_object(uint8_t **outbuf, off_t *size, size if (err) return err; - return got_privsep_recv_raw_obj(outbuf, size, hdrlen, ibuf); + return got_privsep_recv_raw_obj(outbuf, size, hdrlen, flags, ibuf); } static const struct got_error * @@ -410,21 +411,21 @@ got_object_read_header_privsep(struct got_object **obj static const struct got_error * read_object_raw_privsep(uint8_t **outbuf, off_t *size, size_t *hdrlen, - int outfd, struct got_object_id *id, struct got_repository *repo, - int obj_fd) + int *flags, int outfd, struct got_object_id *id, + struct got_repository *repo, int obj_fd) { const struct got_error *err; if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].imsg_fd != -1) - return request_raw_object(outbuf, size, hdrlen, outfd, id, - repo, obj_fd); + return request_raw_object(outbuf, size, hdrlen, flags, + outfd, id, repo, obj_fd); err = start_child(repo, GOT_REPO_PRIVSEP_CHILD_OBJECT); if (err) return err; - return request_raw_object(outbuf, size, hdrlen, outfd, id, repo, - obj_fd); + return request_raw_object(outbuf, size, hdrlen, flags, + outfd, id, repo, obj_fd); } const struct got_error * @@ -474,6 +475,7 @@ got_object_raw_open(struct got_raw_object **obj, int * off_t size = 0; size_t hdrlen = 0; char *path_packfile = NULL; + int flags = 0; *obj = got_repo_get_cached_raw_object(repo, id); if (*obj != NULL) { @@ -504,7 +506,7 @@ got_object_raw_open(struct got_raw_object **obj, int * goto done; } err = read_packed_object_raw_privsep(&outbuf, &size, &hdrlen, - *outfd, pack, packidx, idx, id); + &flags, *outfd, pack, packidx, idx, id); if (err) goto done; } else if (err->code == GOT_ERR_NO_OBJ) { @@ -513,8 +515,8 @@ got_object_raw_open(struct got_raw_object **obj, int * err = got_object_open_loose_fd(&fd, id, repo); if (err) goto done; - err = read_object_raw_privsep(&outbuf, &size, &hdrlen, *outfd, - id, repo, fd); + err = read_object_raw_privsep(&outbuf, &size, &hdrlen, &flags, + *outfd, id, repo, fd); if (err) goto done; } @@ -524,6 +526,8 @@ got_object_raw_open(struct got_raw_object **obj, int * if (err) goto done; + (*obj)->flags = flags; + err = got_repo_cache_raw_object(repo, id, *obj); done: free(path_packfile); blob - cd8ca43fd87ef72900e77f2be18e9582551c3bcb0bf9437fa62384097ed5b537 blob + b3d4b17c03aaec5cf7ec7bafaa43357c2ccc1b0f46ae043dd902967d353b67f0 --- lib/privsep.c +++ lib/privsep.c @@ -275,7 +275,7 @@ got_privsep_send_raw_obj_outfd(struct imsgbuf *ibuf, i const struct got_error * got_privsep_send_raw_obj(struct imsgbuf *ibuf, off_t size, size_t hdrlen, - uint8_t *data) + int flags, uint8_t *data) { struct got_imsg_raw_obj iobj; size_t len = sizeof(iobj); @@ -284,6 +284,7 @@ got_privsep_send_raw_obj(struct imsgbuf *ibuf, off_t s memset(&iobj, 0, sizeof(iobj)); iobj.hdrlen = hdrlen; iobj.size = size; + iobj.flags = flags; if (data && size + hdrlen <= GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX) len += (size_t)size + hdrlen; @@ -306,7 +307,7 @@ got_privsep_send_raw_obj(struct imsgbuf *ibuf, off_t s const struct got_error * got_privsep_recv_raw_obj(uint8_t **outbuf, off_t *size, size_t *hdrlen, - struct imsgbuf *ibuf) + int *flags, struct imsgbuf *ibuf) { const struct got_error *err = NULL; struct imsg imsg; @@ -330,6 +331,7 @@ got_privsep_recv_raw_obj(uint8_t **outbuf, off_t *size iobj = imsg.data; *size = iobj->size; *hdrlen = iobj->hdrlen; + *flags = iobj->flags; if (datalen == sizeof(*iobj)) { /* Data has been written to file descriptor. */ blob - 7cb534920a663e4d905c574b41b5be23bf612a354abee856bc54aca00f513daf blob + bf22336430d8a990ed2a0003618d591678166973725366d1e73b8fa424295304 --- libexec/got-read-object/got-read-object.c +++ libexec/got-read-object/got-read-object.c @@ -79,7 +79,7 @@ send_raw_obj(struct imsgbuf *ibuf, struct got_object * if (err) goto done; - err = got_privsep_send_raw_obj(ibuf, size, hdrlen, data); + err = got_privsep_send_raw_obj(ibuf, size, hdrlen, 0, data); done: free(data); if (close(fd) == -1 && err == NULL) blob - 3155c9473a878ff3bad765fec4142ff2b31bb3d44000cebfefd9059142c6c1af blob + 648393cf062ff65d428f8c1726f76723fdc54f3b9d29550d1245a70678174ae9 --- libexec/got-read-pack/got-read-pack.c +++ libexec/got-read-pack/got-read-pack.c @@ -833,6 +833,7 @@ raw_object_request(struct imsg *imsg, struct imsgbuf * struct got_object *obj; struct got_object_id id; size_t datalen; + int flags = GOT_RAW_OBJ_FLAG_PACKED; datalen = imsg->hdr.len - IMSG_HEADER_SIZE; if (datalen != sizeof(iobj)) @@ -858,6 +859,7 @@ raw_object_request(struct imsg *imsg, struct imsgbuf * err = got_pack_get_max_delta_object_size(&size, obj, pack); if (err) goto done; + flags |= GOT_RAW_OBJ_FLAG_DELTIFIED; } else size = obj->size; @@ -870,7 +872,8 @@ raw_object_request(struct imsg *imsg, struct imsgbuf * if (err) goto done; - err = got_privsep_send_raw_obj(ibuf, obj->size, obj->hdrlen, buf); + err = got_privsep_send_raw_obj(ibuf, obj->size, obj->hdrlen, + flags, buf); done: free(buf); if (outfile && fclose(outfile) == EOF && err == NULL)