4 * Write a compressed CPIO file
15 int cpio_pad(struct backend *be)
17 static char pad[4]; /* Up to 4 zero bytes */
19 return write_data(be, pad, -be->dbytes & 3);
24 int cpio_hdr(struct backend *be, uint32_t mode, size_t datalen,
27 static uint32_t inode = 2;
29 int nlen = strlen(filename)+1;
34 sprintf(hdr, "%06o%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x",
41 be->now, /* c_mtime */
42 datalen, /* c_filesize */
47 nlen, /* c_namesize */
49 rv |= write_data(be, hdr, 6+13*8);
50 rv |= write_data(be, filename, nlen);
55 int cpio_mkdir(struct backend *be, const char *filename)
57 return cpio_hdr(be, MODE_DIR, 0, filename);
60 int cpio_writefile(struct backend *be, const char *filename,
61 const void *data, size_t len)
65 rv = cpio_hdr(be, MODE_FILE, len, filename);
66 rv |= write_data(be, data, len);
72 int cpio_close(struct backend *be)
74 return cpio_hdr(be, 0, 0, "TRAILER!!!");