• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
3  * This file is licensed under the GPL license.  For the full content
4  * of this license, see the COPYING file at the top level of this
5  * source tree.
6 
7  * The fsync() function shall fail if:
8  * [EBADF] The fildes argument is not a valid descriptor.
9  *
10  */
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <unistd.h>
15 #include <sys/mman.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <fcntl.h>
19 #include <string.h>
20 #include <errno.h>
21 #include "posixtest.h"
22 
main(void)23 int main(void)
24 {
25 	int fd;
26 
27 	/* -1 is an invalid fd */
28 
29 	fd = -1;
30 	if (fsync(fd) == -1 && errno == EBADF) {
31 		printf("Got EBADF when fd=-1\n");
32 		printf("Test PASSED\n");
33 		exit(PTS_PASS);
34 	} else {
35 		printf("Test FAILED: Expect EBADF, get: %s\n", strerror(errno));
36 		exit(PTS_FAIL);
37 	}
38 }
39