blob: d0b3e572ea8893763d38abc2ac403b295891592f [file] [log] [blame]
srs5694e7b4ff92009-08-18 13:16:10 -04001#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
srs5694da79b852009-08-18 13:29:54 -04007// 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).
srs5694e7b4ff92009-08-18 13:16:10 -040010#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
26using namespace std;
27
28// a GUID
29struct GUIDData {
30 uint64_t data1;
31 uint64_t data2;
32}; // struct GUIDData
33
34int GetNumber(int low, int high, int def, const char prompt[]);
35char GetYN(void);
36uint64_t GetLastSector(uint64_t low, uint64_t high, char prompt[]);
37char* BytesToSI(uint64_t size, char theValue[]);
38int GetBlockSize(int fd);
39char* GUIDToStr(struct GUIDData theGUID, char* theString);
40GUIDData GetGUID(void);
srs56942a9f5da2009-08-26 00:48:01 -040041int IsLittleEndian(void); // Returns 1 if CPU is little-endian, 0 if it's big-endian
42void ReverseBytes(char* theValue, int numBytes); // Reverses byte-order of theValue
srs5694e7b4ff92009-08-18 13:16:10 -040043uint64_t PowerOf2(int value);
44
45uint64_t disksize(int fd, int* err);
46
47#endif