Changes for 0.0.8
[omfsprogs.git] / disksize.c
blob80cbc79a4753288150166e3ad00fe32c59001bb6
1 /*
2 * disksize.c - Try to get the size of a disk.
4 * At present this relies on fseeko and such. Could do something
5 * smarter here like a binary search if this needs to be more portable.
6 */
7 #define _GNU_SOURCE
8 #define _FILE_OFFSET_BITS 64
10 #include <stdio.h>
11 #include "disksize.h"
13 int get_disk_size(char *device, u64 *size)
15 FILE *fp = fopen(device, "r");
16 if (!fp)
17 return 0;
19 fseeko(fp, 0, SEEK_END);
20 *size = ftello(fp);
21 return 1;