Haiku: use native ioctls to detect geometry
This commit is contained in:
parent
588fa1e76e
commit
d143a610c6
1 changed files with 70 additions and 0 deletions
|
@ -101,6 +101,9 @@
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__HAIKU__)
|
||||||
|
#include <Drivers.h>
|
||||||
|
#endif
|
||||||
#include "fnctdsk.h"
|
#include "fnctdsk.h"
|
||||||
#include "ewf.h"
|
#include "ewf.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -564,6 +567,21 @@ static unsigned int disk_get_sector_size(const int hd_h, const char *device, con
|
||||||
#endif
|
#endif
|
||||||
return disk_get_sector_size_win32(handle, device, verbose);
|
return disk_get_sector_size_win32(handle, device, verbose);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
{
|
||||||
|
device_geometry g;
|
||||||
|
int error;
|
||||||
|
error = ioctl(hd_h, B_GET_GEOMETRY, &g, sizeof(g));
|
||||||
|
if(error==0)
|
||||||
|
{
|
||||||
|
if(verbose>1)
|
||||||
|
{
|
||||||
|
log_verbose("disk_get_sector_size B_GET_GEOMETRY %s sector_size=%u\n",device,g.bytes_per_sector);
|
||||||
|
}
|
||||||
|
return g.bytes_per_sector;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if(verbose>1)
|
if(verbose>1)
|
||||||
{
|
{
|
||||||
|
@ -694,6 +712,23 @@ static void disk_get_geometry(CHSgeometry_t *geom, const int hd_h, const char *d
|
||||||
#endif
|
#endif
|
||||||
return disk_get_geometry_win32(geom, handle, device, verbose);
|
return disk_get_geometry_win32(geom, handle, device, verbose);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
{
|
||||||
|
device_geometry g;
|
||||||
|
int error;
|
||||||
|
error = ioctl(hd_h, B_GET_GEOMETRY, &g, sizeof(g));
|
||||||
|
if(error==0)
|
||||||
|
{
|
||||||
|
if(verbose>1)
|
||||||
|
{
|
||||||
|
log_verbose("disk_get_geometry B_GET_GEOMETRY %s Ok\n", device);
|
||||||
|
}
|
||||||
|
geom->cylinders=g.cylinder_count;
|
||||||
|
geom->heads_per_cylinder=g.head_count;
|
||||||
|
geom->sectors_per_head=g.sectors_per_track;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if(geom->sectors_per_head>0 && geom->heads_per_cylinder>0)
|
if(geom->sectors_per_head>0 && geom->heads_per_cylinder>0)
|
||||||
return ;
|
return ;
|
||||||
|
@ -780,6 +815,23 @@ static uint64_t disk_get_size(const int hd_h, const char *device, const int verb
|
||||||
#endif
|
#endif
|
||||||
return disk_get_size_win32(handle, device, verbose);
|
return disk_get_size_win32(handle, device, verbose);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
{
|
||||||
|
device_geometry g;
|
||||||
|
int error;
|
||||||
|
error = ioctl(hd_h, B_GET_GEOMETRY, &g, sizeof(g));
|
||||||
|
if(error==0)
|
||||||
|
{
|
||||||
|
off_t o = (off_t)g.bytes_per_sector * g.sectors_per_track * g.cylinder_count * g.head_count;
|
||||||
|
if(verbose>1)
|
||||||
|
{
|
||||||
|
log_verbose("disk_get_size B_GET_GEOMETRY %s size %llu\n",
|
||||||
|
device, (long long unsigned)o);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return compute_device_size(hd_h, device, verbose, sector_size);
|
return compute_device_size(hd_h, device, verbose, sector_size);
|
||||||
}
|
}
|
||||||
|
@ -1399,6 +1451,24 @@ disk_t *file_test_availability(const char *device, const int verbose, int testdi
|
||||||
hd_h = -1;
|
hd_h = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
device_geometry g;
|
||||||
|
int readonly;
|
||||||
|
/* If the device can be opened read-write, then
|
||||||
|
* check whether BKROGET says that it is read-only.
|
||||||
|
* read-only loop devices may be openend read-write,
|
||||||
|
* use BKROGET to detect the problem
|
||||||
|
*/
|
||||||
|
if (ioctl(hd_h, B_GET_GEOMETRY, &g, sizeof(g)) >= 0)
|
||||||
|
{
|
||||||
|
if(g.read_only>0)
|
||||||
|
{
|
||||||
|
try_readonly=1;
|
||||||
|
close(hd_h);
|
||||||
|
hd_h = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue