2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
14 * Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
19 #include <sys/types.h>
25 #define FSIZE 256*1024*1024
27 static long fsize
= FSIZE
;
28 static int errflag
= 0;
29 static char *filename
= NULL
;
30 static int ftruncflag
= 0;
32 static void parse_options(int argc
, char *argv
[]);
37 (void) fprintf(stderr
,
38 "usage: %s [-s filesize] [-f] /path/to/file\n", execname
);
43 main(int argc
, char *argv
[])
47 parse_options(argc
, argv
);
50 fd
= open(filename
, O_RDWR
|O_CREAT
, 0666);
55 if (ftruncate(fd
, fsize
) < 0) {
64 if (truncate(filename
, fsize
) < 0) {
73 parse_options(int argc
, char *argv
[])
77 extern int optind
, optopt
;
79 while ((c
= getopt(argc
, argv
, "s:f")) != -1) {
88 (void) fprintf(stderr
,
89 "Option -%c requires an operand\n", optopt
);
94 (void) usage(argv
[0]);
99 (void) fprintf(stderr
, "No filename specified\n");
102 filename
= argv
[optind
];