diff --git a/docs/API.md b/docs/API.md index 9e6ce78..5c04750 100644 --- a/docs/API.md +++ b/docs/API.md @@ -79,6 +79,8 @@ This enum lists all supported file types: `MTAR_HARDLINK`: Hard links +`MTAR_FIFO`: FIFO special files + Other file types supported in tar archives, such as block/character devices or FIFOs, are not supported and minitar will throw an error when encountering one of them. This behavior can be controlled by passing `-DMINITAR_IGNORE_UNSUPPORTED_TYPES=ON` to CMake when configuring, which will make minitar silently ignore such entries instead of panicking. ### minitar_entry_metadata diff --git a/examples/untar.c b/examples/untar.c index 67c0c86..fa236d0 100644 --- a/examples/untar.c +++ b/examples/untar.c @@ -110,6 +110,18 @@ int main(int argc, char** argv) printf("link %s -> %s\n", entry.metadata.path, entry.metadata.link); } + else if (entry.metadata.type == MTAR_FIFO) + { + int status = mknod(entry.metadata.path, entry.metadata.mode | S_IFIFO, 0); + + if (status != 0) + { + fprintf(stderr, "Failed to create FIFO %s: %s\n", entry.metadata.path, strerror(errno)); + break; + } + + printf("fifo %s\n", entry.metadata.path); + } } else break; diff --git a/minitar.h b/minitar.h index 455725e..ec78925 100644 --- a/minitar.h +++ b/minitar.h @@ -23,6 +23,7 @@ enum minitar_file_type MTAR_DIRECTORY, MTAR_SYMLINK, MTAR_HARDLINK, + MTAR_FIFO, }; struct minitar_entry_internal diff --git a/src/util.c b/src/util.c index cea552f..bcf358e 100644 --- a/src/util.c +++ b/src/util.c @@ -193,7 +193,7 @@ void minitar_parse_metadata_from_tar_header(const struct tar_header* hdr, struct case '3': minitar_handle_panic("Character devices are unsupported"); case '4': minitar_handle_panic("Block devices are unsupported"); case '5': metadata->type = MTAR_DIRECTORY; break; - case '6': minitar_handle_panic("FIFOs are unsupported"); + case '6': metadata->type = MTAR_FIFO; break; // This case should have been previously handled by minitar_validate_header(). default: minitar_handle_panic("Unknown entry type in tar header"); }