feat: Add support for FIFOs
This commit is contained in:
parent
3772e9e3a6
commit
1f08cf4b31
@ -79,6 +79,8 @@ This enum lists all supported file types:
|
|||||||
|
|
||||||
`MTAR_HARDLINK`: Hard links
|
`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.
|
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
|
### minitar_entry_metadata
|
||||||
|
@ -110,6 +110,18 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
printf("link %s -> %s\n", entry.metadata.path, entry.metadata.link);
|
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
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -23,6 +23,7 @@ enum minitar_file_type
|
|||||||
MTAR_DIRECTORY,
|
MTAR_DIRECTORY,
|
||||||
MTAR_SYMLINK,
|
MTAR_SYMLINK,
|
||||||
MTAR_HARDLINK,
|
MTAR_HARDLINK,
|
||||||
|
MTAR_FIFO,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct minitar_entry_internal
|
struct minitar_entry_internal
|
||||||
|
@ -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 '3': minitar_handle_panic("Character devices are unsupported");
|
||||||
case '4': minitar_handle_panic("Block devices are unsupported");
|
case '4': minitar_handle_panic("Block devices are unsupported");
|
||||||
case '5': metadata->type = MTAR_DIRECTORY; break;
|
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().
|
// This case should have been previously handled by minitar_validate_header().
|
||||||
default: minitar_handle_panic("Unknown entry type in tar header");
|
default: minitar_handle_panic("Unknown entry type in tar header");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user