1 /////////////////////////////////////////////////////////////////////////
2 // $Id: cdrom_beos.cc,v 1.3 2008/01/26 22:24:00 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
5 #include <SupportDefs.h>
11 #include "cdrom_beos.h"
14 GetLogicalBlockSize(int fd
)
16 partition_info p_info
;
18 if (ioctl(fd
, B_GET_PARTITION_INFO
, &p_info
) == B_NO_ERROR
)
20 //dprintf("GetLogicalBlockSize: ioctl suceed\n");
21 return p_info
.logical_block_size
;
23 else //dprintf("GetLogicalBlockSize = ioctl returned error\n");
28 GetDeviceBlockSize(int fd
)
33 if (ioctl(fd
, B_GET_GEOMETRY
, &dg
) < 0)
35 if (fstat(fd
, &st
) < 0 || S_ISDIR(st
.st_mode
))
37 return 512; /* just assume it's a plain old file or something */
40 return dg
.bytes_per_sector
;
44 GetNumDeviceBlocks(int fd
, int block_size
)
49 if (ioctl(fd
, B_GET_GEOMETRY
, &dg
) >= 0)
51 return (off_t
)dg
.cylinder_count
*
52 (off_t
)dg
.sectors_per_track
*
56 /* if the ioctl fails, try just stat'ing in case it's a regular file */
57 if (fstat(fd
, &st
) < 0)
60 return st
.st_size
/ block_size
;