aboutsummaryrefslogtreecommitdiff
path: root/omar.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-04-29 17:41:12 -0400
committerIan Moffett <ian@osmora.org>2025-04-29 17:41:12 -0400
commitcc29eb5803c4652b509900ae3024be660ded9285 (patch)
tree55256a23efa20603b586b33caedc38a0aac07054 /omar.c
parent30514aa546485c75c9123c90deb55493416440d5 (diff)
Set lengths before setting nextptr
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'omar.c')
-rw-r--r--omar.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/omar.c b/omar.c
index 3244415..39421b7 100644
--- a/omar.c
+++ b/omar.c
@@ -105,6 +105,10 @@ file_push(const char *pathname, const char *name)
}
}
+ /* Set the lengths */
+ hdr.len = (pathname == NULL) ? 0 : sb.st_size;
+ hdr.namelen = strlen(name);
+
/*
* The next pointer being 0 indicates that we
* have reached the end of the archive. If we
@@ -113,11 +117,10 @@ file_push(const char *pathname, const char *name)
*/
if (pathname != NULL) {
hdr.nextptr = sizeof(hdr) + ALIGN_UP(hdr.len, BLOCK_SIZE);
+ printf("NEXT POINTER: %d\n", hdr.nextptr);
} else {
hdr.nextptr = 0;
}
- hdr.len = (pathname == NULL) ? 0 : sb.st_size;
- hdr.namelen = strlen(name);
memcpy(hdr.magic, "OMAR", sizeof(hdr.magic));
write(outfd, &hdr, sizeof(hdr));
write(outfd, name, hdr.namelen);