source:
MondoRescue/trunk/mindi/Mindi/DiskSize/lib/DiskSize.c@
1
| Last change on this file since 1 was 1, checked in by , 20 years ago | |
|---|---|
| File size: 381 bytes | |
| Rev | Line | |
|---|---|---|
| [1] | 1 | #include <fcntl.h> |
| 2 | #include <sys/types.h> | |
| 3 | #include <sys/mount.h> | |
| 4 | #include "DiskSize.h" | |
| 5 | ||
| 6 | long | |
| 7 | get_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.
