tools/llvm: Do not build with symbols
[minix3.git] / minix / commands / devsize / devsize.c
blob9c51508c2c0d575dc8f725f92c723d3e0208e5ad
1 /* Ben Gras
3 * Based on sizeup() in mkfs.c.
4 */
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <machine/partition.h>
9 #include <minix/partition.h>
10 #include <sys/ioc_disk.h>
11 #include <stdio.h>
12 #include <errno.h>
13 #include <fcntl.h>
14 #include <limits.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <time.h>
18 #include <unistd.h>
20 unsigned long sizeup(char *);
22 int main(int argc, char *argv[])
24 if(argc != 2) {
25 fprintf(stderr, "Usage: %s <device>\n", argv[0]);
26 return 1;
29 printf("%lu\n", sizeup(argv[1]));
30 return 0;
34 unsigned long sizeup(char *device)
36 int fd;
37 struct part_geom entry;
38 unsigned long d;
40 if ((fd = open(device, O_RDONLY)) == -1) {
41 perror("sizeup open");
42 exit(1);
44 if (ioctl(fd, DIOCGETP, &entry) == -1) {
45 perror("sizeup ioctl");
46 exit(1);
48 close(fd);
49 d = entry.size / 512;
50 return d;