diff options
author | srs5694 <srs5694@users.sourceforge.net> | 2009-08-29 15:00:31 -0400 |
---|---|---|
committer | srs5694 <srs5694@users.sourceforge.net> | 2009-08-29 15:00:31 -0400 |
commit | 221e08768de7fe42ba533ca22baf671420569c07 (patch) | |
tree | 64f0b26992dc4f1100ab57f5bc32351272e3c9d2 /mbr.h | |
parent | a0eb11a64b4a5b78caff58f804a5fb78ddf3a5df (diff) | |
download | sgdisk-221e08768de7fe42ba533ca22baf671420569c07.tar.gz |
New release: 0.4.0
This version adds support for FreeBSD and big-endian systems. It also
adds support for BSD disklabels and an assortment of other changes,
improvements, and bug fixes.
Diffstat (limited to 'mbr.h')
-rw-r--r-- | mbr.h | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -1,8 +1,12 @@ /* mbr.h -- MBR data structure definitions, types, and functions */ +/* This program is copyright (c) 2009 by Roderick W. Smith. It is distributed + under the terms of the GNU GPL version 2, as detailed in the COPYING file. */ + #include <stdint.h> #include <sys/types.h> #include <sys/ioctl.h> +#include "gptpart.h" #ifndef __MBRSTRUCTS #define __MBRSTRUCTS @@ -32,6 +36,17 @@ struct MBRRecord { uint32_t lengthLBA; }; // struct MBRRecord +// Create a 512-byte data structure into which the MBR can be loaded in one +// go, for the benefit of FreeBSD which seems to flake out when loading +// from block devices in multiples other than the block size.... +struct TempMBR { + uint8_t code[440]; + uint32_t diskSignature; + uint16_t nulls; + struct MBRRecord partitions[4]; + uint16_t MBRSignature; +}; // struct TempMBR + // Extended Boot Record (EBR) data, used to hold one logical partition's // data within an extended partition. Includes pointer to next record for // in-memory linked-list access. This is similar to MBRData, but with a @@ -75,7 +90,7 @@ public: void EmptyMBR(int clearBootloader = 1); void SetDiskSize(uint64_t ds) {diskSize = ds;} int ReadMBRData(char* deviceFilename); - void ReadMBRData(int fd); + void ReadMBRData(int fd, int checkBlockSize = 1); int WriteMBRData(void); void WriteMBRData(int fd); // ReadLogicalPart() returns last partition # read to logicals[] array, @@ -83,8 +98,9 @@ public: int ReadLogicalPart(int fd, uint32_t extendedStart, uint32_t diskOffset, int partNum); void DisplayMBRData(void); - void MakeProtectiveMBR(void); + void MakeProtectiveMBR(int clearBoot = 0); MBRValidity GetValidity(void) {return state;} + void ShowValidity(void); void ShowState(void); void MakePart(int num, uint32_t startLBA, uint32_t lengthLBA, int type = 0x07, int bootable = 0); @@ -99,6 +115,7 @@ public: uint8_t GetType(int i); uint32_t GetFirstSector(int i); uint32_t GetLength(int i); + GPTPart AsGPT(int i); }; // struct MBRData #endif |