summaryrefslogtreecommitdiff
path: root/com32/lib
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-11-05 15:35:35 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-05 15:35:35 +0000
commitc44fe85310a4efb1334b4e807b999870ab90e3f6 (patch)
tree2ca413b43932e71a072eb4b533a97df6776d6c94 /com32/lib
parentdd59314c304ec83bee927af7395af5ceb4942f66 (diff)
parent28b3a9d4d7eb932b827122f3e641ce14fb2cbd03 (diff)
downloadsyslinux-c44fe85310a4efb1334b4e807b999870ab90e3f6.tar.gz
Merge branch 'multi_initrd2-5.00-pre9' of git://git.zytor.com/users/sha0/syslinux into elflink
Pull multi-initrd patches from Shao Miller, These patches provide two new options for the linux.c32 module. The "initrd+=" option allows you to append initramfs-style blobs (files which can be produced with 'cpio -o -H newc') to whatever "initrd" was specified via the "initrd=" option (or was specified indirectly via the INITRD directive). The "initrdfile=" option allows you to load a file and encapsulate it as though you had used 'cpio -o -H newc', and pass the resulting blob alongside the other items that might have been specified with "initrd=" or "initrd+=". * 'multi_initrd2-5.00-pre9' of git://git.zytor.com/users/sha0/syslinux: initramfs chain handling: Accounting fixes for padding, etc. linux.c32: Introduce initrdfile= option linux.c32: Add new initrd+= option for multiple initrds linux.c32: Move some initrd=x,y,z code out of main linux.c32: Add find_arguments function
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/syslinux/initramfs_file.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/com32/lib/syslinux/initramfs_file.c b/com32/lib/syslinux/initramfs_file.c
index 763eff28..7eb55b5e 100644
--- a/com32/lib/syslinux/initramfs_file.c
+++ b/com32/lib/syslinux/initramfs_file.c
@@ -65,7 +65,7 @@ static size_t initramfs_mkdirs(const char *filename, void *buffer,
const char *p = filename;
char *bp = buffer;
int len;
- size_t bytes = 0;
+ size_t bytes = 0, hdr_sz;
int pad;
while ((p = strchr(p, '/'))) {
@@ -81,15 +81,17 @@ static size_t initramfs_mkdirs(const char *filename, void *buffer,
while ((p = strchr(p, '/'))) {
if (p != filename && p[-1] != '/') {
len = p - filename;
+ hdr_sz = ((sizeof(struct cpio_header) + len + 1) + 3) & ~3;
bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x"
"%08x%08x%08x%08x", next_ino++, S_IFDIR | 0755,
0, 0, 1, 0, 0, 0, 1, 0, 1, len + 1, 0);
memcpy(bp, filename, len);
bp += len;
- pad = (-(sizeof(struct cpio_header) + len) & 3) + 1;
+ pad = hdr_sz - (sizeof(struct cpio_header) + len);
memset(bp, 0, pad);
bp += pad;
}
+ p++;
}
}
@@ -104,7 +106,7 @@ int initramfs_mknod(struct initramfs *ihead, const char *filename,
int do_mkdir,
uint16_t mode, size_t len, uint32_t major, uint32_t minor)
{
- size_t bytes;
+ size_t bytes, hdr_sz;
int namelen = strlen(filename);
int pad;
char *buffer, *bp;
@@ -114,7 +116,8 @@ int initramfs_mknod(struct initramfs *ihead, const char *filename,
else
bytes = 0;
- bytes += ((sizeof(struct cpio_header) + namelen + 1) + 3) & ~3;
+ hdr_sz = ((sizeof(struct cpio_header) + namelen + 1) + 3) & ~3;
+ bytes += hdr_sz;
bp = buffer = malloc(bytes);
if (!buffer)
@@ -127,8 +130,8 @@ int initramfs_mknod(struct initramfs *ihead, const char *filename,
"%08x%08x%08x%08x", next_ino++, mode,
0, 0, 1, 0, len, 0, 1, major, minor, namelen + 1, 0);
memcpy(bp, filename, namelen);
- bp += len;
- pad = (-(sizeof(struct cpio_header) + namelen) & 3) + 1;
+ bp += namelen;
+ pad = hdr_sz - (sizeof(struct cpio_header) + namelen);
memset(bp, 0, pad);
if (initramfs_add_data(ihead, buffer, bytes, bytes, 4)) {