2 // C++ Interface: diskio
4 // Description: Class to handle low-level disk I/O for GPT fdisk
7 // Author: Rod Smith <rodsmith@rodsbooks.com>, (C) 2009
9 // Copyright: See COPYING file that comes with this distribution
12 // This program is copyright (c) 2009 by Roderick W. Smith. It is distributed
13 // under the terms of the GNU GPL version 2, as detailed in the COPYING file.
20 #include <sys/types.h>
25 #include <sys/ioctl.h>
28 #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
34 //#include "parttypes.h"
38 /***************************************
40 * DiskIO class and related structures *
42 ***************************************/
59 void MakeRealName(void);
60 int OpenForRead(const string & filename);
61 int OpenForRead(void);
62 int OpenForWrite(const string & filename);
63 int OpenForWrite(void);
65 int Seek(uint64_t sector);
66 int Read(void* buffer, int numBytes);
67 int Write(void* buffer, int numBytes);
68 int DiskSync(void); // resync disk caches to use new partitions
69 int GetBlockSize(void);
70 uint32_t GetNumHeads(void);
71 uint32_t GetNumSecsPerTrack(void);
72 int IsOpen(void) {return isOpen;}
73 int IsOpenForWrite(void) {return openForWrite;}
74 string GetName(void) const {return realFilename;}
76 uint64_t DiskSize(int* err);