mirror of
https://github.com/vivier/EMILE.git
synced 2024-09-08 19:54:38 +00:00
Allow to identify disk on 2nd ide bus (generally cdrom (hdc) on PC)
This commit is contained in:
parent
9d5ff84740
commit
a57f6a8617
@ -16,13 +16,20 @@ int emile_get_dev_name(char *buffer, int driver, int disk, int partition)
|
||||
{
|
||||
switch(driver)
|
||||
{
|
||||
case MAJOR_HD:
|
||||
case MAJOR_IDE0:
|
||||
if (partition == 0)
|
||||
sprintf(buffer, "/dev/hd%c", 'a' + disk);
|
||||
else
|
||||
sprintf(buffer, "/dev/hd%c%d", 'a' + disk,
|
||||
partition);
|
||||
break;
|
||||
case MAJOR_IDE1:
|
||||
if (partition == 0)
|
||||
sprintf(buffer, "/dev/hd%c", 'c' + disk);
|
||||
else
|
||||
sprintf(buffer, "/dev/hd%c%d", 'c' + disk,
|
||||
partition);
|
||||
break;
|
||||
case MAJOR_LOOP:
|
||||
sprintf(buffer, "/dev/loop%d", disk);
|
||||
break;
|
||||
@ -53,7 +60,7 @@ int emile_scsi_get_dev(int fd, int* driver, int *disk, int *partition)
|
||||
|
||||
dev = S_ISREG(st.st_mode) ? st.st_dev : st.st_rdev;
|
||||
|
||||
major = (dev >> 8) & 0x0F; /* major number = driver id */
|
||||
major = (dev >> 8) & 0xFF; /* major number = driver id */
|
||||
minor = dev & 0xFF; /* minor number = disk id */
|
||||
|
||||
*driver = major;
|
||||
@ -67,10 +74,13 @@ int emile_scsi_get_dev(int fd, int* driver, int *disk, int *partition)
|
||||
*disk = minor & 0xFF;
|
||||
*partition = 0;
|
||||
break;
|
||||
case MAJOR_HD: /* ATA disks */
|
||||
case MAJOR_IDE0:
|
||||
*disk = minor >> 6;
|
||||
*partition = minor & 0x3F;
|
||||
break;
|
||||
case MAJOR_IDE1:
|
||||
*disk = minor >> 6;
|
||||
*partition = minor & 0x3F;
|
||||
default:
|
||||
fprintf(stderr, "Unknown device major number %d\n", major);
|
||||
return -1;
|
||||
|
@ -22,17 +22,21 @@ int emile_scsi_get_rdev(char* dev_name, int* driver, int *disk, int *partition)
|
||||
/* not a block device */
|
||||
return -1;
|
||||
|
||||
major = (st.st_rdev >> 8) & 0x0F;
|
||||
major = (st.st_rdev >> 8) & 0xFF;
|
||||
*driver = major;
|
||||
switch(major)
|
||||
{
|
||||
case MAJOR_SD:
|
||||
*disk = (st.st_rdev & 0xFF) >> 4;
|
||||
*partition = st.st_rdev & 0x0F;
|
||||
if (partition) *partition = st.st_rdev & 0x0F;
|
||||
break;
|
||||
case MAJOR_HD:
|
||||
case MAJOR_IDE0:
|
||||
*disk = (st.st_rdev & 0xFF) >> 6;
|
||||
*partition = st.st_rdev & 0x3F;
|
||||
if (partition) *partition = st.st_rdev & 0x3F;
|
||||
break;
|
||||
case MAJOR_IDE1:
|
||||
*disk = 2 + (st.st_rdev & 0xFF) >> 6;
|
||||
if (partition) *partition = st.st_rdev & 0x3F;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
|
@ -28,9 +28,10 @@ static __attribute__((used)) char* libemile_header = "$CVSHeader$";
|
||||
#define FIRST_LEVEL_SIZE (FLOPPY_SECTOR_SIZE * 2)
|
||||
#define BOOTBLOCK_SIZE (FLOPPY_SECTOR_SIZE * 2)
|
||||
|
||||
#define MAJOR_HD 3
|
||||
#define MAJOR_IDE0 3
|
||||
#define MAJOR_LOOP 7
|
||||
#define MAJOR_SD 8
|
||||
#define MAJOR_IDE1 22
|
||||
|
||||
enum {
|
||||
EEMILE_CANNOT_READ_FIRST = -2,
|
||||
|
Loading…
Reference in New Issue
Block a user