4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
39 static jmp_buf Dfailbuf
;
53 static void (*dsig
)();
55 static short dkrmode
[3] = { DKR_BLOCK
, 0, 0 };
56 static short dkeof
[3] = { 106, 0, 0 }; /* End of File signal */
69 dsig
=signal(SIGALRM
, dalarm
);
71 if (dkproto(Ofn
, dkp_ld
) < 0)
73 DEBUG(3, "%s\n", "No dkp_ld");
77 if((*Ioctl
)(Ofn
, DIOCRMODE
, dkrmode
) < 0) {
79 ret
=(*Ioctl
)(Ofn
, DIOCRMODE
, dkrmode
);
80 DEBUG(4, "dturnon: ret=%d, ", ret
);
81 DEBUG(4, "Ofn=%d, ", Ofn
);
82 DEBUG(4, "errno=%d\n", errno
);
92 (void) signal(SIGALRM
, dsig
);
97 * write message across Datakit link
98 * type -> message type
99 * str -> message body (ascii string)
100 * fn -> Datakit file descriptor
102 * SUCCESS -> message sent
103 * FAIL -> write failed
106 dwrmsg(type
, str
, fn
)
121 return((*Write
)(fn
, bufr
, (unsigned) strlen(bufr
) + 1) < 0 ? FAIL
: SUCCESS
);
125 * read message from Datakit link
126 * str -> message buffer
127 * fn -> Datakit file descriptor
129 * FAIL -> send timed out
130 * SUCCESS -> ok message in str
144 if( (len
= (*Read
)(fn
, str
, XBUFSIZ
)) <= 0) {
149 if (*(str
- 1) == '\0')
157 * read data from file fp1 and write
159 * fp1 -> file descriptor
160 * fn -> Datakit descriptor
162 * FAIL ->failure in Datakit link
170 register int len
, ret
;
176 while ((len
= read( fd1
, bufr
, XBUFSIZ
)) > 0) {
179 ret
= (*Write
)(fn
, bufr
, (unsigned) len
);
186 ASSERT(len
>= 0, "DISK READ ERROR", strerror(errno
), len
);
188 (*Ioctl
)(fn
, DIOCXCTL
, dkeof
);
190 ret
= (*Write
)(fn
, bufr
, (unsigned) 0);
195 * read data from Datakit link and
197 * fp2 -> file descriptor
198 * fn -> Datakit descriptor
201 * FAIL -> failure on Datakit link
209 register int ret
= SUCCESS
;
216 len
= drdblk(bufr
, XBUFSIZ
, fn
);
222 if( ret
== SUCCESS
&& write( fd2
, bufr
, len
) != len
)
231 * read block from Datakit link
233 * blk -> address of buffer
234 * len -> size to read
235 * fn -> Datakit descriptor
237 * FAIL -> link error timeout on link
238 * i -> # of bytes read
250 for (i
= 0; i
< len
; i
+= ret
) {
252 if ((ret
= (*Read
)(fn
, blk
, (unsigned) len
- i
)) < 0) {
257 if (ret
== 0) { /* zero length block contains only EOF signal */
258 ioctl(fn
, DIOCQQABO
, &why
);
259 if (why
.rcv_ctlchar
!= dkeof
[0])
267 #endif /* D_PROTOCOL */