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 #define _XOPEN_SOURCE 600 13 #include <stdio.h> 14 #include <stdlib.h> 15 #include <unistd.h> 16 #include <sys/mman.h> 17 #include <sys/types.h> 18 #include <sys/stat.h> 19 #include <fcntl.h> 20 #include <string.h> 21 #include <errno.h> 22 #include "posixtest.h" 23 main(void)24int main(void) 25 { 26 int fd; 27 28 /* -1 is an invalid fd */ 29 30 fd = -1; 31 if (fsync(fd) == -1 && errno == EBADF) { 32 printf("Got EBADF when fd=-1\n"); 33 printf("Test PASSED\n"); 34 exit(PTS_PASS); 35 } else { 36 printf("Test FAILED: Expect EBADF, get: %s\n", strerror(errno)); 37 exit(PTS_FAIL); 38 } 39 } 40