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.
27 #include <sys/ioctl.h>
28 #include <sys/mount.h>
31 # define BLKGETSIZE64 _IOR(0x12,114,size_t)
34 int main(int argc, char **argv)
41 fputs("insufficient arguments\n", stderr);
44 fd = open(argv[1], O_RDONLY);
50 error = ioctl(fd, BLKGETSIZE64, &size);
52 /* BLKGETSIZE64 returns size in bytes not 512-byte blocks */
53 sz = (long long)(size >> 9);
54 printf("%lld 512 byte blocks (BLKGETSIZE64)\n", sz);
56 /* If BLKGETSIZE64 fails, try BLKGETSIZE */
57 unsigned long tmpsize;
59 error = ioctl(fd, BLKGETSIZE, &tmpsize);
61 fprintf(stderr, "can't determine device size");
64 sz = (long long)tmpsize;
65 printf("%lld 512 byte blocks (BLKGETSIZE)\n", sz);