* makebootable now checks if the partition/image/device is mounted via the
disk device API, and if that is the case, it will use the private BFS_IOCTL_UPDATE_BOOT_BLOCK ioctl to update the boot code. * Fixed inconsistent naming of "Bootcode" vs. "BootCode". git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28054 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
SubDir HAIKU_TOP src bin makebootable platform bios_ia32 ;
|
SubDir HAIKU_TOP src bin makebootable platform bios_ia32 ;
|
||||||
|
|
||||||
|
SubDirHdrs $(HAIKU_TOP) src add-ons kernel file_systems bfs ;
|
||||||
|
|
||||||
|
UsePrivateHeaders shared storage ;
|
||||||
|
|
||||||
# write the stage 1 boot loader into the makebootable resources
|
# write the stage 1 boot loader into the makebootable resources
|
||||||
AddFileDataResource makebootable : RAWT:666:BootCode : stage1.bin ;
|
AddFileDataResource makebootable : RAWT:666:BootCode : stage1.bin ;
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,13 @@
|
|||||||
|
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
# include <image.h>
|
# include <image.h>
|
||||||
|
|
||||||
|
# include <DiskDevice.h>
|
||||||
|
# include <DiskDeviceRoster.h>
|
||||||
|
# include <Partition.h>
|
||||||
|
# include <Path.h>
|
||||||
|
|
||||||
|
# include "bfs_control.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -46,9 +53,9 @@ static const char *kCommandName = "makebootable";
|
|||||||
|
|
||||||
static const int kBootCodeSize = 1024;
|
static const int kBootCodeSize = 1024;
|
||||||
static const int kFirstBootCodePartSize = 512;
|
static const int kFirstBootCodePartSize = 512;
|
||||||
static const int kSecondBootcodePartOffset = 676;
|
static const int kSecondBootCodePartOffset = 676;
|
||||||
static const int kSecondBootcodePartSize = kBootCodeSize
|
static const int kSecondBootCodePartSize = kBootCodeSize
|
||||||
- kSecondBootcodePartOffset;
|
- kSecondBootCodePartOffset;
|
||||||
static const int kPartitionOffsetOffset = 506;
|
static const int kPartitionOffsetOffset = 506;
|
||||||
|
|
||||||
static int kArgc;
|
static int kArgc;
|
||||||
@@ -285,7 +292,7 @@ main(int argc, const char *const *argv)
|
|||||||
int64 partitionOffset = 0;
|
int64 partitionOffset = 0;
|
||||||
fs_info info; // needs to be here (we use the device name later)
|
fs_info info; // needs to be here (we use the device name later)
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
#ifdef __BEOS__
|
#ifdef __HAIKU__
|
||||||
|
|
||||||
// a directory: get the device
|
// a directory: get the device
|
||||||
error = fs_stat_dev(st.st_dev, &info);
|
error = fs_stat_dev(st.st_dev, &info);
|
||||||
@@ -538,9 +545,46 @@ main(int argc, const char *const *argv)
|
|||||||
write_boot_code_part(fileName, fd, startOffset, bootCodeData, 0,
|
write_boot_code_part(fileName, fd, startOffset, bootCodeData, 0,
|
||||||
kFirstBootCodePartSize, dryRun);
|
kFirstBootCodePartSize, dryRun);
|
||||||
write_boot_code_part(fileName, fd, startOffset, bootCodeData,
|
write_boot_code_part(fileName, fd, startOffset, bootCodeData,
|
||||||
kSecondBootcodePartOffset, kSecondBootcodePartSize,
|
kSecondBootCodePartOffset, kSecondBootCodePartSize,
|
||||||
dryRun);
|
dryRun);
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
// check if this partition is mounted
|
||||||
|
BDiskDeviceRoster roster;
|
||||||
|
BPartition* partition;
|
||||||
|
BDiskDevice device;
|
||||||
|
status_t status = roster.GetPartitionForPath(fileName, &device,
|
||||||
|
&partition);
|
||||||
|
if (status != B_OK) {
|
||||||
|
status = roster.GetFileDeviceForPath(fileName, &device);
|
||||||
|
if (status == B_OK)
|
||||||
|
partition = &device;
|
||||||
|
}
|
||||||
|
if (status == B_OK && partition->IsMounted() && !dryRun) {
|
||||||
|
// This partition is mounted, we need to tell BFS to update its
|
||||||
|
// boot block (we are using part of the same logical block).
|
||||||
|
BPath path;
|
||||||
|
status = partition->GetMountPoint(&path);
|
||||||
|
if (status == B_OK) {
|
||||||
|
update_boot_block update;
|
||||||
|
update.offset = kSecondBootCodePartOffset - 512;
|
||||||
|
update.data = bootCodeData + kSecondBootCodePartOffset;
|
||||||
|
update.length = kSecondBootCodePartSize;
|
||||||
|
|
||||||
|
int mountFD = open(path.Path(), O_RDONLY);
|
||||||
|
if (ioctl(mountFD, BFS_IOCTL_UPDATE_BOOT_BLOCK, &update,
|
||||||
|
sizeof(update_boot_block)) != 0) {
|
||||||
|
fprintf(stderr, "Could not update BFS boot block: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
close(mountFD);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Could not update BFS boot code while the "
|
||||||
|
"partition is mounted!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // __HAIKU__
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user