apps/odroid_vm/components/helloworld/linux_userlevel/build/vchan_code/sel4_vchan_testsuite.c
static int vchantests_bigwrite_child(libvchan_t *ctrl, size_t sz) {
	int ret = 0, fd;
    char rbuf[VM_BIGWRITE_COMP_BUF_SIZE];

    fd = open(bigwrite_out, 0 | O_CREAT | O_TRUNC | O_RDWR, 0 | S_IRUSR | S_IWUSR);
    if(fd < 0) {
    	TERROR("bigwrite-child: failed to open output file '%s'", bigwrite_out);
    	return EXIT_FAILURE;
    }

	libvchan_t *writeback = libvchan_client_init(50, VM_BIGWRITE_PORT);
	if(writeback == NULL) {
		TERROR("bigwrite-child: failed to initialise readback channel\n");
		return EXIT_FAILURE;
	}

	while(sz > 0) {
    	TDPRINTF(4, "bigwrite (child): want %d;%d bytes from client\n", ret, (int) sz);
		ret = libvchan_read(writeback, rbuf, VM_BIGWRITE_COMP_BUF_SIZE);
		if(ret < 0) {
			TERROR("bigwrite-child: failed to read from readback channel\n");
			return EXIT_FAILURE;
		}
    	TDPRINTF(4, "bigwrite (child): got %d bytes from client\n", (int) ret);

    	if(write(fd, rbuf, ret) < 0) {
    		TERROR("bigwrite-child: error writing to output file\n");
			return EXIT_FAILURE;
    	}

		if(sz < VM_BIGWRITE_COMP_BUF_SIZE)
			sz = 0;
		else
			sz -= ret;
	}

    libvchan_close(writeback);

	return EXIT_SUCCESS;
}
/*
    vchantests_bigwrite - vchantests_bigwrite_child:
        Open up new vchan and use it to read back file as it is being sent
        Read back data gets placed into a file
*/
Open up new vchan and use it to read back file as it is being sent
Read back data gets placed into a file
Open up new vchan and use it to read back file as it is being sent Read back data gets placed into a file
static int vchantests_bigwrite_child(libvchan_t *ctrl, size_t sz) {
	int ret = 0, fd;
    char rbuf[VM_BIGWRITE_COMP_BUF_SIZE];
    fd = open(bigwrite_out, 0 | O_CREAT | O_TRUNC | O_RDWR, 0 | S_IRUSR | S_IWUSR);
    if(fd < 0) {
    	TERROR("bigwrite-child: failed to open output file '%s'", bigwrite_out);
    	return EXIT_FAILURE;
    }
	libvchan_t *writeback = libvchan_client_init(50, VM_BIGWRITE_PORT);
	if(writeback == NULL) {
		TERROR("bigwrite-child: failed to initialise readback channel\n");
		return EXIT_FAILURE;
	}
	while(sz > 0) {
    	TDPRINTF(4, "bigwrite (child): want %d;%d bytes from client\n", ret, (int) sz);
		ret = libvchan_read(writeback, rbuf, VM_BIGWRITE_COMP_BUF_SIZE);
		if(ret < 0) {
			TERROR("bigwrite-child: failed to read from readback channel\n");
			return EXIT_FAILURE;
		}
    	TDPRINTF(4, "bigwrite (child): got %d bytes from client\n", (int) ret);
    	if(write(fd, rbuf, ret) < 0) {
    		TERROR("bigwrite-child: error writing to output file\n");
			return EXIT_FAILURE;
    	}
		if(sz < VM_BIGWRITE_COMP_BUF_SIZE)
			sz = 0;
		else
			sz -= ret;
	}
    libvchan_close(writeback);
	return EXIT_SUCCESS;
}
static int vchantests_bigwrite_child ( libvchan_t * ctrl , size_t sz ) { int ret = 0 , fd ; char rbuf [ VM_BIGWRITE_COMP_BUF_SIZE ] ; fd = open ( bigwrite_out , 0 | O_CREAT | O_TRUNC | O_RDWR , 0 | S_IRUSR | S_IWUSR ) ; if ( fd < 0 ) { TERROR ( " " , bigwrite_out ) ; return EXIT_FAILURE ; } libvchan_t * writeback = libvchan_client_init ( 50 , VM_BIGWRITE_PORT ) ; if ( writeback == NULL ) { TERROR ( " \n " ) ; return EXIT_FAILURE ; } while ( sz > 0 ) { TDPRINTF ( 4 , " \n " , ret , ( int ) sz ) ; ret = libvchan_read ( writeback , rbuf , VM_BIGWRITE_COMP_BUF_SIZE ) ; if ( ret < 0 ) { TERROR ( " \n " ) ; return EXIT_FAILURE ; } TDPRINTF ( 4 , " \n " , ( int ) ret ) ; if ( write ( fd , rbuf , ret ) < 0 ) { TERROR ( " \n " ) ; return EXIT_FAILURE ; } if ( sz < VM_BIGWRITE_COMP_BUF_SIZE ) sz = 0 ; else sz -= ret ; } libvchan_close ( writeback ) ; return EXIT_SUCCESS ; }
vchantests_bigwrite - vchantests_bigwrite_child:
Open up new vchan and use it to read back file as it is being sent
Read back data gets placed into a file
vchantests_bigwrite - vchantests_bigwrite_child : Open up new vchan and use it to read back file as it is being sent Read back data gets placed into a file