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().
This commit is contained in:
apio 2023-05-27 19:58:23 +02:00
parent f12f58bacf
commit 1644ab59eb
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 7 additions and 1 deletions

View File

@ -71,7 +71,7 @@ int main(int argc, char** argv)
strncpy(metadata.path, argv[arg], sizeof(metadata.path)); strncpy(metadata.path, argv[arg], sizeof(metadata.path));
metadata.uid = st.st_uid; metadata.uid = st.st_uid;
metadata.gid = st.st_gid; metadata.gid = st.st_gid;
metadata.mtime = st.st_mtim.tv_sec; metadata.mtime = st.st_mtime;
metadata.size = length; metadata.size = length;
metadata.type = MTAR_REGULAR; metadata.type = MTAR_REGULAR;
metadata.mode = st.st_mode & ~S_IFMT; metadata.mode = st.st_mode & ~S_IFMT;

View File

@ -157,6 +157,7 @@ int main(int argc, char** argv)
} }
else if (entry.metadata.type == MTAR_FIFO) else if (entry.metadata.type == MTAR_FIFO)
{ {
#ifndef __luna__
if (create_parent_recursively(entry.metadata.path) < 0) goto fifo_err; if (create_parent_recursively(entry.metadata.path) < 0) goto fifo_err;
int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFIFO, 0); 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; exit_status = 1;
break; break;
} }
#endif
printf("fifo %s\n", entry.metadata.path); printf("fifo %s\n", entry.metadata.path);
} }
else if (entry.metadata.type == MTAR_BLKDEV) else if (entry.metadata.type == MTAR_BLKDEV)
{ {
#ifndef __luna__
if (create_parent_recursively(entry.metadata.path) < 0) goto blkdev_err; if (create_parent_recursively(entry.metadata.path) < 0) goto blkdev_err;
int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFBLK, int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFBLK,
@ -185,11 +188,13 @@ int main(int argc, char** argv)
exit_status = 1; exit_status = 1;
break; break;
} }
#endif
printf("blkdev %s (%u:%u)\n", entry.metadata.path, entry.metadata.devmajor, entry.metadata.devminor); printf("blkdev %s (%u:%u)\n", entry.metadata.path, entry.metadata.devmajor, entry.metadata.devminor);
} }
else if (entry.metadata.type == MTAR_CHRDEV) else if (entry.metadata.type == MTAR_CHRDEV)
{ {
#ifndef __luna__
if (create_parent_recursively(entry.metadata.path) < 0) goto chrdev_err; if (create_parent_recursively(entry.metadata.path) < 0) goto chrdev_err;
int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFCHR, int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFCHR,
@ -202,6 +207,7 @@ int main(int argc, char** argv)
exit_status = 1; exit_status = 1;
break; break;
} }
#endif
printf("chrdev %s (%u:%u)\n", entry.metadata.path, entry.metadata.devmajor, entry.metadata.devminor); printf("chrdev %s (%u:%u)\n", entry.metadata.path, entry.metadata.devmajor, entry.metadata.devminor);
} }