#include <stdio.h>
#include <fcntl.h>
#include <linux/fs.h>

int
main(int argc, char* argv[])
{
    int sz = 0;
    int fd;

    if ((fd = open(argv[1], O_RDONLY)) < 0) {
	perror("open failed");
	return 1;
    }

    if (ioctl(fd, BLKGETSIZE, &sz) < 0) {
	perror("ioctl BLKGETSIZE failed");
	close(fd);
	return 1;
    }

    close(fd);

    printf("ioctl BLKGETSIZE returned size of %d\n", sz);
    return 0;
}

