6 * Structures used to handle cpio payloads within rpm packages.
8 * @warning Rpm's cpio implementation may be different than standard cpio.
9 * The implementation is pretty close, but it has some behaviors which are
10 * more to RPM's liking. I tried to document the differing behavior in cpio.c,
11 * but I may have missed some (ewt).
16 * @note CPIO_CHECK_ERRNO bit is set only if errno is valid.
18 #define CPIOERR_CHECK_ERRNO 0x00008000
22 enum cpioErrorReturns {
23 CPIOERR_BAD_MAGIC = 2,
24 CPIOERR_BAD_HEADER = 3,
25 CPIOERR_OPEN_FAILED = 4 | CPIOERR_CHECK_ERRNO,
26 CPIOERR_CHMOD_FAILED = 5 | CPIOERR_CHECK_ERRNO,
27 CPIOERR_CHOWN_FAILED = 6 | CPIOERR_CHECK_ERRNO,
28 CPIOERR_WRITE_FAILED = 7 | CPIOERR_CHECK_ERRNO,
29 CPIOERR_UTIME_FAILED = 8 | CPIOERR_CHECK_ERRNO,
30 CPIOERR_UNLINK_FAILED = 9 | CPIOERR_CHECK_ERRNO,
31 CPIOERR_RENAME_FAILED = 10 | CPIOERR_CHECK_ERRNO,
32 CPIOERR_SYMLINK_FAILED = 11 | CPIOERR_CHECK_ERRNO,
33 CPIOERR_STAT_FAILED = 12 | CPIOERR_CHECK_ERRNO,
34 CPIOERR_LSTAT_FAILED = 13 | CPIOERR_CHECK_ERRNO,
35 CPIOERR_MKDIR_FAILED = 14 | CPIOERR_CHECK_ERRNO,
36 CPIOERR_RMDIR_FAILED = 15 | CPIOERR_CHECK_ERRNO,
37 CPIOERR_MKNOD_FAILED = 16 | CPIOERR_CHECK_ERRNO,
38 CPIOERR_MKFIFO_FAILED = 17 | CPIOERR_CHECK_ERRNO,
39 CPIOERR_LINK_FAILED = 18 | CPIOERR_CHECK_ERRNO,
40 CPIOERR_READLINK_FAILED = 19 | CPIOERR_CHECK_ERRNO,
41 CPIOERR_READ_FAILED = 20 | CPIOERR_CHECK_ERRNO,
42 CPIOERR_COPY_FAILED = 21 | CPIOERR_CHECK_ERRNO,
43 CPIOERR_LSETFCON_FAILED = 22 | CPIOERR_CHECK_ERRNO,
44 CPIOERR_HDR_SIZE = 23,
45 CPIOERR_HDR_TRAILER = 24,
46 CPIOERR_UNKNOWN_FILETYPE= 25,
47 CPIOERR_MISSING_HARDLINK= 26,
48 CPIOERR_DIGEST_MISMATCH = 27,
49 CPIOERR_INTERNAL = 28,
50 CPIOERR_UNMAPPED_FILE = 29,
52 CPIOERR_ENOTEMPTY = 31,
53 CPIOERR_SETCAP_FAILED = 32 | CPIOERR_CHECK_ERRNO,
54 CPIOERR_FILE_SIZE = 33,
58 * Size limit for individual files in "new ascii format" cpio archives.
59 * The max size of the entire archive is unlimited from cpio POV,
60 * but subject to filesystem limitations.
62 #define CPIO_FILESIZE_MAX UINT32_MAX
64 #define CPIO_NEWC_MAGIC "070701"
65 #define CPIO_CRC_MAGIC "070702"
66 #define CPIO_TRAILER "TRAILER!!!"
69 * Cpio archive header information.
71 struct cpioCrcPhysicalHeader {
85 char checksum[8]; /* ignored !! */
88 #define PHYS_HDR_SIZE 110 /* Don't depend on sizeof(struct) */
90 typedef struct rpmcpio_s * rpmcpio_t;
97 * Create CPIO file object
100 * @return CPIO object
102 rpmcpio_t rpmcpioOpen(FD_t fd, char mode);
104 int rpmcpioClose(rpmcpio_t cpio);
106 off_t rpmcpioTell(rpmcpio_t cpio);
108 rpmcpio_t rpmcpioFree(rpmcpio_t cpio);
112 * @retval fsm file path and stat info
114 * @return 0 on success
117 int rpmcpioHeaderWrite(rpmcpio_t cpio, char * path, struct stat * st);
119 ssize_t rpmcpioWrite(rpmcpio_t cpio, void * buf, size_t size);
123 * @retval fsm file path and stat info
125 * @return 0 on success
128 int rpmcpioHeaderRead(rpmcpio_t cpio, char ** path, struct stat * st);
130 ssize_t rpmcpioRead(rpmcpio_t cpio, void * buf, size_t size);
133 * Return formatted error message on payload handling failure.
134 * @param rc error code
135 * @return formatted error string
137 /* XXX should be RPM_GNUC_INTERNAL too but build/pack.c uses */
138 const char * rpmcpioStrerror(int rc);