4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * Copyright (c) 2022 by Information2 Software, Inc. All rights reserved.
31 #include "file_common.h"
32 #include <sys/types.h>
38 * Call fadvise to prefetch data
40 static const char *execname
= "file_fadvise";
45 (void) fprintf(stderr
,
46 "usage: %s -f filename -a advise \n", execname
);
50 main(int argc
, char *argv
[])
52 char *filename
= NULL
;
57 while ((ch
= getopt(argc
, argv
, "a:f:")) != EOF
) {
60 advise
= atoll(optarg
);
66 (void) printf("unknown arg %c\n", optopt
);
73 (void) printf("Filename not specified (-f <file>)\n");
77 if (advise
< POSIX_FADV_NORMAL
|| advise
> POSIX_FADV_NOREUSE
) {
78 (void) printf("advise is invalid\n");
83 usage(); /* no return */
87 if ((fd
= open(filename
, O_RDWR
, 0666)) < 0) {
92 if (posix_fadvise(fd
, 0, 0, advise
) != 0) {
93 perror("posix_fadvise");