srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 1 | #include <stdint.h> |
| 2 | #include <unistd.h> |
| 3 | #include <stdlib.h> |
| 4 | |
| 5 | #ifdef __APPLE__ |
| 6 | // Darwin (Mac OS) only: disk IOCTLs are different, and there is no lseek64 |
srs5694 | da79b85 | 2009-08-18 13:29:54 -0400 | [diff] [blame] | 7 | // This used to use __DARWIN_UNIX03 rather than __APPLE__, but __APPLE__ |
| 8 | // is more general. If the code fails to work on older versions of OS X/ |
| 9 | // Darwin, this may need to be changed back (and in various .cc files). |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 10 | #include <sys/disk.h> |
| 11 | #define lseek64 lseek |
| 12 | #else |
| 13 | |
| 14 | // Linux only.... |
| 15 | #include <linux/fs.h> |
| 16 | #endif |
| 17 | |
| 18 | #include <string> |
| 19 | |
| 20 | #ifndef __GPTSUPPORT |
| 21 | #define __GPTSUPPORT |
| 22 | |
| 23 | // Set this as a default |
| 24 | #define SECTOR_SIZE UINT32_C(512) |
| 25 | |
| 26 | using namespace std; |
| 27 | |
| 28 | // a GUID |
| 29 | struct GUIDData { |
| 30 | uint64_t data1; |
| 31 | uint64_t data2; |
| 32 | }; // struct GUIDData |
| 33 | |
| 34 | int GetNumber(int low, int high, int def, const char prompt[]); |
| 35 | char GetYN(void); |
| 36 | uint64_t GetLastSector(uint64_t low, uint64_t high, char prompt[]); |
| 37 | char* BytesToSI(uint64_t size, char theValue[]); |
| 38 | int GetBlockSize(int fd); |
| 39 | char* GUIDToStr(struct GUIDData theGUID, char* theString); |
| 40 | GUIDData GetGUID(void); |
srs5694 | 2a9f5da | 2009-08-26 00:48:01 -0400 | [diff] [blame] | 41 | int IsLittleEndian(void); // Returns 1 if CPU is little-endian, 0 if it's big-endian |
| 42 | void ReverseBytes(char* theValue, int numBytes); // Reverses byte-order of theValue |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 43 | uint64_t PowerOf2(int value); |
| 44 | |
| 45 | uint64_t disksize(int fd, int* err); |
| 46 | |
| 47 | #endif |