[ipxe-devel] Multiple initrd files and their permissions

Michael Brown mbrown at fensystems.co.uk
Fri Aug 3 01:30:18 UTC 2012


On Wednesday 01 Aug 2012 20:48:09 Me wrote:
> Digging through the iPXE source I found the acquire function that actually
> pulls the file off the server, and it's pretty much just wget (if I'm
> reading this right), which explains why I'm losing file permissions and
> such.
> 
> Which finally leads me to my question: how can I set file permissions in
> iPXE after the file has been acquired?

Standalone files are built into initrd images on-the-fly by 
bzimage_load_initrd() in arch/i386/image/bzimage.c.  This code currently does:

		memset ( &cpio, '0', sizeof ( cpio ) );
		memcpy ( cpio.c_magic, CPIO_MAGIC, sizeof ( cpio.c_magic ) );
		cpio_set_field ( cpio.c_mode, 0100644 );
		cpio_set_field ( cpio.c_nlink, 1 );
		cpio_set_field ( cpio.c_filesize, initrd->len );
		cpio_set_field ( cpio.c_namesize, name_len );

i.e. all files will have mode 0644, be owned by root, and have zero (i.e. Jan 1 
1970) for all timestamp fields.

There's no support for modifying any of these fields.  You could potentially 
add support for this.  The logic at present is that if any non-kernel image 
has a "command line", then that image will be treated as a standalone file and 
wrapped with a cpio header.  Since filenames generally don't have spaces, it 
would be viable to have a syntax such as:

  initrd http://web/boot/bootlocal.sh /opt/bootlocal.sh mode=0755

i.e. treat the first portion of the "command line" as the filename, and parse 
the remainder for argument strings of the form "key=value", similar to the 
parsing we currently do for "vga=" and "mem=" in bzimage_parse_cmdline().

I can see the utility of being able to specify a file mode of 0755 in order to 
be able to mark a file as executable.  I suspect that there's no point in being 
able to specify timestamps or file ownership.

Michael



More information about the ipxe-devel mailing list