| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include <mos/mos_global.h> |
| 6 | #include <mos/types.h> |
| 7 | |
| 8 | #define CPIO_MODE_FILE_TYPE 0170000 // This masks the file type bits. |
| 9 | #define CPIO_MODE_SOCKET 0140000 // File type value for sockets. |
| 10 | #define CPIO_MODE_SYMLINK 0120000 // File type value for symbolic links. For symbolic links, the link body is stored as file data. |
| 11 | #define CPIO_MODE_FILE 0100000 // File type value for regular files. |
| 12 | #define CPIO_MODE_BLOCKDEV 0060000 // File type value for block special devices. |
| 13 | #define CPIO_MODE_DIR 0040000 // File type value for directories. |
| 14 | #define CPIO_MODE_CHARDEV 0020000 // File type value for character special devices. |
| 15 | #define CPIO_MODE_FIFO 0010000 // File type value for named pipes or FIFOs. |
| 16 | #define CPIO_MODE_SUID 0004000 // SUID bit. |
| 17 | #define CPIO_MODE_SGID 0002000 // SGID bit. |
| 18 | #define CPIO_MODE_STICKY 0001000 // Sticky bit. |
| 19 | |
| 20 | typedef struct |
| 21 | { |
| 22 | char [6]; |
| 23 | char [8]; |
| 24 | char [8]; |
| 25 | char [8]; |
| 26 | char [8]; |
| 27 | char [8]; |
| 28 | char [8]; |
| 29 | |
| 30 | char [8]; |
| 31 | char [8]; |
| 32 | char [8]; |
| 33 | char [8]; |
| 34 | char [8]; |
| 35 | |
| 36 | char [8]; |
| 37 | char [8]; |
| 38 | } ; |
| 39 | |
| 40 | MOS_STATIC_ASSERT(sizeof(cpio_header_t) == 110, "cpio_newc_header has wrong size" ); |
| 41 | |
| 42 | typedef struct |
| 43 | { |
| 44 | size_t ; |
| 45 | size_t name_offset; |
| 46 | size_t name_length; |
| 47 | size_t data_offset; |
| 48 | size_t data_length; |
| 49 | } cpio_metadata_t; |
| 50 | |
| 51 | bool cpio_read_metadata(const char *target, cpio_header_t *, cpio_metadata_t *metadata); |
| 52 | |
| 53 | size_t read_initrd(void *buf, size_t size, size_t offset); |
| 54 | |