Bringing flexcat 2.15 into the main branch (again)
[AROS.git] / arch / all-darwin / hostdisk / geometry.c
blobe1bd216c92d73fad1124572aebc590566b45a725
1 /* This routine differs in different UNIX variants (using different IOCTLs) */
3 #include <aros/debug.h>
4 #include <devices/trackdisk.h>
5 #include <exec/memory.h>
6 #include <proto/hostlib.h>
8 #include <sys/disk.h>
10 #include "hostdisk_host.h"
11 #include "hostdisk_device.h"
13 ULONG Host_DeviceGeometry(int file, struct DriveGeometry *dg, struct HostDiskBase *hdskBase)
15 int ret, err;
17 HostLib_Lock();
19 ret = hdskBase->iface->ioctl(file, DKIOCGETBLOCKSIZE, &dg->dg_SectorSize);
21 if (ret != -1)
22 ret = hdskBase->iface->ioctl(file, DKIOCGETBLOCKCOUNT, &dg->dg_TotalSectors);
24 err = *hdskBase->errnoPtr;
26 HostLib_Unlock();
28 if (ret == -1)
30 D(bug("hostdisk: Error %d\n", err));
32 return err;
35 D(bug("hostdisk: %u sectors per %u bytes\n", dg->dg_TotalSectors, dg->dg_SectorSize));
38 * This is all we can do on Darwin. They dropped CHS completely,
39 * so we stay with LBA (CylSectors == 1)
41 dg->dg_Cylinders = dg->dg_TotalSectors;
43 return 0;