2 * Copyright (c) 2004 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Test program that uses the same interfaces as mkfs.xfs for
21 * Linux, dumps out just the device size values from a driver.
28 #include <sys/ioctl.h>
29 #include <sys/mount.h>
32 # define BLKGETSIZE64 _IOR(0x12,114,size_t)
35 int main(int argc, char **argv)
42 fputs("insufficient arguments\n", stderr);
45 fd = open(argv[1], O_RDONLY);
51 error = ioctl(fd, BLKGETSIZE64, &size);
53 /* BLKGETSIZE64 returns size in bytes not 512-byte blocks */
54 sz = (long long)(size >> 9);
55 printf("%lld 512 byte blocks (BLKGETSIZE64)\n", sz);
57 /* If BLKGETSIZE64 fails, try BLKGETSIZE */
58 unsigned long tmpsize;
60 error = ioctl(fd, BLKGETSIZE, &tmpsize);
62 fprintf(stderr, "can't determine device size");
65 sz = (long long)tmpsize;
66 printf("%lld 512 byte blocks (BLKGETSIZE)\n", sz);