Modify SD driver for direct i/o (no rdisk).
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/rdisk.h>
|
||||
#include <sys/disk.h>
|
||||
#include <ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
@@ -24,7 +24,7 @@ int strtonum(char *s)
|
||||
return 0;
|
||||
if(s[0]==0)
|
||||
return 0;
|
||||
|
||||
|
||||
if(s[0]=='0' && s[1]=='x')
|
||||
{
|
||||
return strtol(s+2,NULL,16);
|
||||
@@ -73,7 +73,7 @@ int write_mbr(int fd)
|
||||
sync(fd);
|
||||
printf("Calling ioctl to reread the partition table\n");
|
||||
sleep(1);
|
||||
ioctl(fd,RDREINIT);
|
||||
ioctl(fd, DIOCREINIT);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
@@ -294,9 +294,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
printf("Partition table not valid.\n");
|
||||
wipe = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ioctl(fd,RDGETMEDIASIZE,&blocks);
|
||||
ioctl(fd, DIOCGETMEDIASIZE, &blocks);
|
||||
|
||||
printf("%s: %d blocks of 1KB\n",device,blocks);
|
||||
|
||||
|
||||
@@ -8,5 +8,37 @@
|
||||
#define A_ACTIVE 4
|
||||
#define A_TYPE 5
|
||||
|
||||
struct chs {
|
||||
unsigned char head;
|
||||
struct {
|
||||
unsigned cylhigh : 2;
|
||||
unsigned sector : 6;
|
||||
} __attribute__((packed));
|
||||
unsigned char cyllow;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct partition {
|
||||
#define P_ACTIVE 0x80
|
||||
unsigned char status;
|
||||
struct chs start;
|
||||
unsigned char type;
|
||||
struct chs end;
|
||||
unsigned long lbastart;
|
||||
unsigned long lbalength;
|
||||
};
|
||||
|
||||
struct mbr {
|
||||
unsigned char bootstrap1[218];
|
||||
unsigned short pad0000;
|
||||
unsigned char biosdrive;
|
||||
unsigned char secs;
|
||||
unsigned char mins;
|
||||
unsigned char hours;
|
||||
unsigned char bootstrap2[216];
|
||||
unsigned int sig;
|
||||
unsigned short pad0001;
|
||||
struct partition partitions[4];
|
||||
unsigned short bootsig;
|
||||
}__attribute__((packed));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <sys/inode.h>
|
||||
#include <sys/rdisk.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define UMASK 0755
|
||||
@@ -88,10 +88,9 @@ int get_disk_size(char *fn)
|
||||
printf("Getting disk size for %s\n",fn);
|
||||
|
||||
// Is it a /dev entry?
|
||||
if(strncmp(fn,"/dev/",5)==0)
|
||||
{
|
||||
if (strncmp(fn,"/dev/",5) == 0) {
|
||||
fd = open(fn,O_RDONLY);
|
||||
ioctl(fd,RDGETMEDIASIZE,&size);
|
||||
ioctl(fd, DIOCGETMEDIASIZE, &size);
|
||||
close(fd);
|
||||
} else {
|
||||
lstat(fn,&sb);
|
||||
|
||||
Reference in New Issue
Block a user