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

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

Id property added on files to allow for better conf. management

  • Property svn:keywords set to Id
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.