source: buchla-68k/libcio/posit.c@ 6099cac

Last change on this file since 6099cac was 8973acd, checked in by Thomas Lopatic <thomas@…>, 7 years ago

No more warnings in libcio.

  • Property mode set to 100644
File size: 976 bytes
RevLine 
[f40a309]1/*
2 =============================================================================
3 posit.c -- position a file to a specific relative sector
4 Version 4 -- 1987-06-29 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
[b28a12e]8#include "ram.h"
[f40a309]9
10/*
11 =============================================================================
12 posit(fd, pos) -- position file 'fd' at sector 'pos'.
13 =============================================================================
14*/
15
[8973acd]16int16_t posit(int16_t fd, int16_t pos)
[f40a309]17{
18 register struct fcb *fp;
19
20 if ((fd < 0) OR (fd > MAXCHAN)) {
21
22 errno = EBADF;
23 return(FAILURE);
24 }
25
26 fp = chantab[fd].c_arg;
27
28 if ((chantab[fd].c_seek EQ 0)
[8973acd]29 OR (((int32_t)pos << FILESHFT) > fp->curlen)) {
[f40a309]30
31 errno = EINVAL;
32 fp->modefl |= FC_ERR;
33 return(FAILURE);
34 }
35
36 fp->curlsn = pos;
37 fp->offset = 0;
38
39 if (_seek(fp) < 0) {
40
41 errno = EIO;
42 fp->modefl |= FC_ERR;
43 return(FAILURE);
44 }
45
46 return(SUCCESS);
47}
[6262b5c]48
Note: See TracBrowser for help on using the repository browser.