source: trunk/mindi/Mindi/DiskSize/lib/DiskSize.c @ 127

Last change on this file since 127 was 127, checked in by bcornec, 14 years ago

merge -r 125:126 $SVN_M/branches/2.05

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