| OLD | NEW |
| 1 /*- | 1 /*- |
| 2 * Copyright (c) 2007 Yahoo!, Inc. | 2 * Copyright (c) 2007 Yahoo!, Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * Written by: John Baldwin <jhb@FreeBSD.org> | 4 * Written by: John Baldwin <jhb@FreeBSD.org> |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 close(bfd); | 172 close(bfd); |
| 173 | 173 |
| 174 #ifdef LINUX | 174 #ifdef LINUX |
| 175 /* We use the syslinux GPT new protocol. This requires the GUID | 175 /* We use the syslinux GPT new protocol. This requires the GUID |
| 176 of the boot partition to be at offset 424 in the mbr. See the | 176 of the boot partition to be at offset 424 in the mbr. See the |
| 177 doc in the syslinux source: src/doc/gpt.txt */ | 177 doc in the syslinux source: src/doc/gpt.txt */ |
| 178 if (gpt_find(boot_entry, &boot_uuid, &gptboot) != 0) { | 178 if (gpt_find(boot_entry, &boot_uuid, &gptboot) != 0) { |
| 179 warnx("unable to find partition to make bootable."); | 179 warnx("unable to find partition to make bootable."); |
| 180 return; | 180 return; |
| 181 } | 181 } |
| 182 le_uuid_enc(((unsigned char*)mbr + 424), | 182 le_uuid_enc(&mbr->boot_guid, |
| 183 &((struct gpt_ent*)(gptboot->map_data))->ent_uuid); | 183 &((struct gpt_ent*)(gptboot->map_data))->ent_uuid); |
| 184 mbr->magic_number = htole16(MBR_MAGIC); |
| 184 #endif | 185 #endif |
| 185 gpt_write(fd, pmbr); | 186 gpt_write(fd, pmbr); |
| 186 | 187 |
| 187 #ifndef LINUX | 188 #ifndef LINUX |
| 188 /* Third step: open gptboot and obtain its size. */ | 189 /* Third step: open gptboot and obtain its size. */ |
| 189 bfd = open(gptboot_path, O_RDONLY); | 190 bfd = open(gptboot_path, O_RDONLY); |
| 190 if (bfd < 0 || fstat(bfd, &sb) < 0) { | 191 if (bfd < 0 || fstat(bfd, &sb) < 0) { |
| 191 warn("unable to open GPT boot loader"); | 192 warn("unable to open GPT boot loader"); |
| 192 return; | 193 return; |
| 193 } | 194 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 continue; | 296 continue; |
| 296 } | 297 } |
| 297 | 298 |
| 298 boot(fd); | 299 boot(fd); |
| 299 | 300 |
| 300 gpt_close(fd); | 301 gpt_close(fd); |
| 301 } | 302 } |
| 302 | 303 |
| 303 return (0); | 304 return (0); |
| 304 } | 305 } |
| OLD | NEW |