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 * [EINVAL] The fildes argument does not refer to a file 9 * on which this operation is possible. 10 * 11 * Test Step: 12 * 1. Create a pipe; 13 * 2. fsync on the pipe, should fail with EINVAL; 14 * 15 */ 16 17#define _XOPEN_SOURCE 600 18#include <stdio.h> 19#include <stdlib.h> 20#include <unistd.h> 21#include <sys/mman.h> 22#include <sys/types.h> 23#include <sys/stat.h> 24#include <fcntl.h> 25#include <string.h> 26#include <errno.h> 27#include "posixtest.h" 28 29#define TNAME "fsync/7-1.c" 30 31int main() 32{ 33 int fd[2]; 34 35 if (pipe(fd) == -1) 36 { 37 printf(TNAME " Test UNRESOLVED: Error at pipe: %s\n", 38 strerror(errno)); 39 exit(PTS_UNRESOLVED); 40 } 41 42 if (fsync(fd[1]) == -1 && errno == EINVAL) 43 { 44 printf("Got EINVAL when fsync on pipe\n"); 45 printf("Test PASSED\n"); 46 close(fd[0]); 47 close(fd[1]); 48 exit(PTS_PASS); 49 } 50 else 51 { 52 printf(TNAME " Test Fail: Expect EINVAL, get: %s\n", 53 strerror(errno)); 54 close(fd[0]); 55 close(fd[1]); 56 exit(PTS_FAIL); 57 } 58} 59