1*5d4cadefSSoham Chakradeo// SPDX-License-Identifier: GPL-2.0 2*5d4cadefSSoham Chakradeo// Simplest possible test of open() and then sendfile(). 3*5d4cadefSSoham Chakradeo// We write some zeroes into a file (since packetdrill expects payloads 4*5d4cadefSSoham Chakradeo// to be all zeroes) and then open() the file, then use sendfile() 5*5d4cadefSSoham Chakradeo// and verify that the correct number of zeroes goes out. 6*5d4cadefSSoham Chakradeo 7*5d4cadefSSoham Chakradeo`./defaults.sh 8*5d4cadefSSoham Chakradeo/bin/rm -f /tmp/testfile 9*5d4cadefSSoham Chakradeo/bin/dd bs=1 count=5 if=/dev/zero of=/tmp/testfile status=none 10*5d4cadefSSoham Chakradeo` 11*5d4cadefSSoham Chakradeo 12*5d4cadefSSoham Chakradeo// Initialize connection 13*5d4cadefSSoham Chakradeo 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 14*5d4cadefSSoham Chakradeo +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 15*5d4cadefSSoham Chakradeo +0 bind(3, ..., ...) = 0 16*5d4cadefSSoham Chakradeo +0 listen(3, 1) = 0 17*5d4cadefSSoham Chakradeo 18*5d4cadefSSoham Chakradeo +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 10> 19*5d4cadefSSoham Chakradeo +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> 20*5d4cadefSSoham Chakradeo +0 < . 1:1(0) ack 1 win 514 21*5d4cadefSSoham Chakradeo 22*5d4cadefSSoham Chakradeo +0 accept(3, ..., ...) = 4 23*5d4cadefSSoham Chakradeo 24*5d4cadefSSoham Chakradeo +0 open("/tmp/testfile", O_RDONLY) = 5 25*5d4cadefSSoham Chakradeo +0 sendfile(4, 5, [0], 5) = 5 26*5d4cadefSSoham Chakradeo +0 > P. 1:6(5) ack 1 27