aboutsummaryrefslogtreecommitdiff
path: root/sys/ki/kzwrmt.x
blob: 74ae0dd96fdc5ae935f1db8cb7e64c492e5832f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<mach.h>
include	<config.h>
include	"ki.h"

# KZWRMT -- Asynchronous write to a magtape file.

procedure kzwrmt (chan, buf, nbytes, offset)

int	chan			#I magtape channel
char	buf[ARB]		#I buffer containing data
int	nbytes			#I nbytes to write
long	offset			#I file offset

int	server
int	ki_send()
include	"kichan.com"
include	"kii.com"

begin
	server = k_node[chan]

	if (server == NULL) {
	    call zzwrmt (k_oschan[chan], buf, nbytes, offset)
	    return
	}

	# Ignore zero writes and requests on a node closed by an error.
	if (nbytes <= 0) {
	    k_status[chan] = 0
	    return
	}

	# Send the request followed by the data block.  We do not read anything
	# back from the remote server until ZAWT is called.  Set k_status[chan]
	# to WRITE_IN_PROGRESS to tell ZAWT that an await call is needed.

	p_arg[1] = k_oschan[chan]
	p_arg[2] = nbytes
	p_arg[3] = offset

	if (ki_send (server, KI_ZFIOMT, MT_WR) == ERR)
	    k_status[chan] = ERR
	else {
	    call ks_awrite (server, buf, nbytes)
	    call ks_await  (server, k_status[chan])
	}
end