source: MondoRescue/trunk/mindi/Mindi/DiskSize/lib/DiskSize.c@ 1

Last change on this file since 1 was 1, checked in by bcornec, 19 years ago

Initial import from latest mondo-2.04_cvs_20050503/mindi-1.04_cvs_20050503 on http://www.mondorescue.org

File size: 381 bytes
Line 
1#include <fcntl.h>
2#include <sys/types.h>
3#include <sys/mount.h>
4#include "DiskSize.h"
5
6long
7get_size_of_disk(disk)
8 const char * disk;
9{
10 int fd;
11 unsigned long ul;
12 if ((fd = open (disk, O_RDONLY)) == -1) {
13 return 0; /* couldn't open */
14 }
15 if (ioctl (fd, BLKGETSIZE, &ul) == -1) {
16 return 0; /* couldn't ioctl */
17 }
18 close (fd);
19 return ul / 2;
20}
Note: See TracBrowser for help on using the repository browser.