From 1644ab59ebb89157a8caec13e07a1954cdcd218b Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 27 May 2023 19:58:23 +0200 Subject: [PATCH] fix: Add support for my own OS to examples Luna doesn't support FIFOs, and special device files are automatically created by the kernel, so there is no mknod(). --- examples/pack.c | 2 +- examples/untar.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/pack.c b/examples/pack.c index 19415be..c9863bd 100644 --- a/examples/pack.c +++ b/examples/pack.c @@ -71,7 +71,7 @@ int main(int argc, char** argv) strncpy(metadata.path, argv[arg], sizeof(metadata.path)); metadata.uid = st.st_uid; metadata.gid = st.st_gid; - metadata.mtime = st.st_mtim.tv_sec; + metadata.mtime = st.st_mtime; metadata.size = length; metadata.type = MTAR_REGULAR; metadata.mode = st.st_mode & ~S_IFMT; diff --git a/examples/untar.c b/examples/untar.c index 5a5183b..8d43272 100644 --- a/examples/untar.c +++ b/examples/untar.c @@ -157,6 +157,7 @@ int main(int argc, char** argv) } else if (entry.metadata.type == MTAR_FIFO) { +#ifndef __luna__ if (create_parent_recursively(entry.metadata.path) < 0) goto fifo_err; int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFIFO, 0); @@ -168,11 +169,13 @@ int main(int argc, char** argv) exit_status = 1; break; } +#endif printf("fifo %s\n", entry.metadata.path); } else if (entry.metadata.type == MTAR_BLKDEV) { +#ifndef __luna__ if (create_parent_recursively(entry.metadata.path) < 0) goto blkdev_err; int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFBLK, @@ -185,11 +188,13 @@ int main(int argc, char** argv) exit_status = 1; break; } +#endif printf("blkdev %s (%u:%u)\n", entry.metadata.path, entry.metadata.devmajor, entry.metadata.devminor); } else if (entry.metadata.type == MTAR_CHRDEV) { +#ifndef __luna__ if (create_parent_recursively(entry.metadata.path) < 0) goto chrdev_err; int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFCHR, @@ -202,6 +207,7 @@ int main(int argc, char** argv) exit_status = 1; break; } +#endif printf("chrdev %s (%u:%u)\n", entry.metadata.path, entry.metadata.devmajor, entry.metadata.devminor); }