iPXE
cpio.h
Go to the documentation of this file.
1 #ifndef _IPXE_CPIO_H
2 #define _IPXE_CPIO_H
3 
4 /** @file
5  *
6  * CPIO archives
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <ipxe/image.h>
13 
14 /** A CPIO archive header
15  *
16  * All field are hexadecimal ASCII numbers padded with '0' on the
17  * left to the full width of the field.
18  */
19 struct cpio_header {
20  /** The string "070701" or "070702" */
21  char c_magic[6];
22  /** File inode number */
23  char c_ino[8];
24  /** File mode and permissions */
25  char c_mode[8];
26  /** File uid */
27  char c_uid[8];
28  /** File gid */
29  char c_gid[8];
30  /** Number of links */
31  char c_nlink[8];
32  /** Modification time */
33  char c_mtime[8];
34  /** Size of data field */
35  char c_filesize[8];
36  /** Major part of file device number */
37  char c_maj[8];
38  /** Minor part of file device number */
39  char c_min[8];
40  /** Major part of device node reference */
41  char c_rmaj[8];
42  /** Minor part of device node reference */
43  char c_rmin[8];
44  /** Length of filename, including final NUL */
45  char c_namesize[8];
46  /** Checksum of data field if c_magic is 070702, othersize zero */
47  char c_chksum[8];
48 } __attribute__ (( packed ));
49 
50 /** CPIO magic */
51 #define CPIO_MAGIC "070701"
52 
53 /** CPIO header length alignment */
54 #define CPIO_ALIGN 4
55 
56 /** Alignment for CPIO archives within an initrd */
57 #define INITRD_ALIGN 4096
58 
59 /**
60  * Get CPIO image name
61  *
62  * @v image Image
63  * @ret name Image name (not NUL terminated)
64  */
65 static inline __attribute__ (( always_inline )) const char *
66 cpio_name ( struct image *image ) {
67  return image->cmdline;
68 }
69 
70 extern void cpio_set_field ( char *field, unsigned long value );
71 extern size_t cpio_name_len ( struct image *image );
72 extern size_t cpio_header ( struct image *image, struct cpio_header *cpio );
73 
74 #endif /* _IPXE_CPIO_H */
char c_ino[8]
File inode number.
Definition: cpio.h:23
#define __attribute__(x)
Definition: compiler.h:10
char c_maj[8]
Major part of file device number.
Definition: cpio.h:37
size_t cpio_name_len(struct image *image)
Get CPIO image filename.
Definition: cpio.c:56
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
char c_filesize[8]
Size of data field.
Definition: cpio.h:35
A CPIO archive header.
Definition: cpio.h:19
char c_mtime[8]
Modification time.
Definition: cpio.h:33
An executable image.
Definition: image.h:24
char c_uid[8]
File uid.
Definition: cpio.h:27
char * cmdline
Command line to pass to image.
Definition: image.h:39
char c_gid[8]
File gid.
Definition: cpio.h:29
Executable images.
size_t cpio_header(struct image *image, struct cpio_header *cpio)
Construct CPIO header for image, if applicable.
Definition: cpio.c:102
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
char c_min[8]
Minor part of file device number.
Definition: cpio.h:39
char c_rmin[8]
Minor part of device node reference.
Definition: cpio.h:43
char c_mode[8]
File mode and permissions.
Definition: cpio.h:25
void cpio_set_field(char *field, unsigned long value)
Set field within a CPIO header.
Definition: cpio.c:43
char c_namesize[8]
Length of filename, including final NUL.
Definition: cpio.h:45
char c_nlink[8]
Number of links.
Definition: cpio.h:31
char c_magic[6]
The string "070701" or "070702".
Definition: cpio.h:21
char c_chksum[8]
Checksum of data field if c_magic is 070702, othersize zero.
Definition: cpio.h:47
char c_rmaj[8]
Major part of device node reference.
Definition: cpio.h:41
static const char * cpio_name(struct image *image)
Get CPIO image name.
Definition: cpio.h:66