FireBirdLib - Topfield TMS PVR TAP Programming Library
SendHDDCommand.c
Go to the documentation of this file.
1#include "FBLib_hdd.h"
2#include "libFireBird.h"
3
4int SendHDDCommand(dword Command, const byte *CommandBlock, int BufferSize)
5{
7
8 #include <sys/ioctl.h>
9 #include <unistd.h>
10 #include <linux/hdreg.h>
11 #include <fcntl.h>
12 #include <linux/fs.h>
13
14 int fd, ret, i;
15 unsigned short int *p;
16
17 //Open the hard drive
18 fd = open("/dev/sda", O_RDONLY | O_NONBLOCK);
19 //fd = open("/dev/sdb", O_RDONLY | O_NONBLOCK);
20 if(fd < 0)
21 {
22 TRACEEXIT();
23 return 1;
24 }
25
26 //DumpMemory(CommandBlock, 7, 16);
27
28 ret = ioctl(fd, Command, CommandBlock);
29
30 //DumpMemory(CommandBlock, 7, 16);
31
32 close(fd);
33
34 if(ret)
35 {
36 TRACEEXIT();
37 return 1;
38 }
39
40 //Swap endianess of the whole buffer
41 p = (unsigned short int*)&CommandBlock[4];
42 i = BufferSize;
43 while(i > 0)
44 {
46 p++;
47 i -= 2;
48 }
49
50 TRACEEXIT();
51 return 0;
52}
#define endian_swap_word(x)
Definition: FBLib_hdd.h:59
dword BufferSize
Definition: INIOpenFile.c:7
int SendHDDCommand(dword Command, const byte *CommandBlock, int BufferSize)
Definition: SendHDDCommand.c:4
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243