mirror of
https://github.com/ipxe/ipxe
synced 2026-04-16 03:00:10 +03:00
[cpio] Allow for the construction of pure directories
Allow for the possibility of creating empty directories (without having to include a dummy file inside the directory) using a zero-length image and a CPIO filename with a trailing slash, such as: initrd emptyfile /usr/share/oem/ Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
+5
-6
@@ -179,17 +179,16 @@ size_t cpio_header ( struct image *image, unsigned int index,
|
||||
/* Get filename length */
|
||||
name_len = cpio_name_len ( image, depth );
|
||||
|
||||
/* Calculate mode and length */
|
||||
if ( depth < max ) {
|
||||
/* Directory */
|
||||
/* Set directory mode or file mode as appropriate */
|
||||
if ( name[name_len] == '/' ) {
|
||||
mode = ( CPIO_MODE_DIR | CPIO_DEFAULT_DIR_MODE );
|
||||
len = 0;
|
||||
} else {
|
||||
/* File */
|
||||
mode |= CPIO_MODE_FILE;
|
||||
len = image->len;
|
||||
}
|
||||
|
||||
/* Set length on final header */
|
||||
len = ( ( depth < max ) ? 0 : image->len );
|
||||
|
||||
/* Construct CPIO header */
|
||||
memset ( cpio, '0', sizeof ( *cpio ) );
|
||||
memcpy ( cpio->c_magic, CPIO_MAGIC, sizeof ( cpio->c_magic ) );
|
||||
|
||||
Reference in New Issue
Block a user