diff options
| author | Michael Brown | 2005-05-17 18:44:57 +0200 |
|---|---|---|
| committer | Michael Brown | 2005-05-17 18:44:57 +0200 |
| commit | 1097cf8685cd81f0003bd6f17d050e5174a85b90 (patch) | |
| tree | 47a39f2a1e980cca43c28c4d1a6dfdf431b910b2 /contrib/mkffwnb/Extendinitrd.pm | |
| parent | Quickly hacked to use a buffer rather than a processor. (diff) | |
| download | ipxe-1097cf8685cd81f0003bd6f17d050e5174a85b90.tar.gz ipxe-1097cf8685cd81f0003bd6f17d050e5174a85b90.tar.xz ipxe-1097cf8685cd81f0003bd6f17d050e5174a85b90.zip | |
Initial revision
Diffstat (limited to 'contrib/mkffwnb/Extendinitrd.pm')
| -rw-r--r-- | contrib/mkffwnb/Extendinitrd.pm | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/contrib/mkffwnb/Extendinitrd.pm b/contrib/mkffwnb/Extendinitrd.pm new file mode 100644 index 000000000..3b919ad13 --- /dev/null +++ b/contrib/mkffwnb/Extendinitrd.pm @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w + +sub status_system ($$) { + my ($command, $message) = @_; + + $status = system($command); + $status <<= 8; + if ($status < 0) { + print STDERR "$!\n"; + } + if ($status != 0) { + print STDERR "$message\n"; + } +} + +sub extendinitrd ($$) { + my ($initrd, $nblocks) = @_; + + if ($nblocks <= 1440) { + print STDERR "nblocks must be >= 1440\n"; + return (1); + } + (undef, $type, undef, $fnlen, undef) = split(' ', `file $initrd`, 5); + print "$type $fnlen\n"; + if ($type ne 'Minix' || $fnlen != 30) { + die "Can only handle Minix initrds with 30 char filenames\n"; + return (1); + } + status_system("dd if=/dev/zero of=newinitrd bs=1k count=$nblocks", "Cannot create new initrd\n"); + status_system("mkfs.minix -n 30 newinitrd $nblocks", "Cannot mkfs.minix new initrd\n"); + mkdir("initrd.from") || print STDERR "Cannot make temp mount point initrd.from\n"; + mkdir("initrd.to") || print STDERR "Cannot make temp mount point initrd.to\n"; + status_system("mount -o ro,loop $initrd initrd.from", "Cannot mount $initrd on initrd.from"); + status_system("mount -o loop newinitrd initrd.to", "Cannot mount newinitrd on initrd.to"); + status_system("cp -a initrd.from/* initrd.to/", "Cannot copy initrd to newinitrd"); + status_system("umount initrd.from", "Cannot umount initrd.from"); + status_system("umount initrd.to", "Cannot umount initrd.to"); + rmdir("initrd.from") || print STDERR "Cannot remove temp mount point initrd.from\n"; + rmdir("initrd.to") || print STDERR "Cannot remove temp mount point initrd.to\n"; + return (0); +} + +1; |
