source: buchla-68k/libcio/posit.c@ 6262b5c

Last change on this file since 6262b5c was 6262b5c, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added include files for global functions and variables.

  • Property mode set to 100644
File size: 1008 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
[6262b5c]8#include "all.h"
[f40a309]9
[7258c6a]10extern int16_t _seek(struct fcb *fcp);
[f40a309]11
12/*
13 =============================================================================
14 posit(fd, pos) -- position file 'fd' at sector 'pos'.
15 =============================================================================
16*/
17
[7258c6a]18int16_t posit(int16_t fd, uint16_t pos)
[f40a309]19{
20 register struct fcb *fp;
21
22 if ((fd < 0) OR (fd > MAXCHAN)) {
23
24 errno = EBADF;
25 return(FAILURE);
26 }
27
28 fp = chantab[fd].c_arg;
29
30 if ((chantab[fd].c_seek EQ 0)
31 OR ((pos << FILESHFT) > fp->curlen)) {
32
33 errno = EINVAL;
34 fp->modefl |= FC_ERR;
35 return(FAILURE);
36 }
37
38 fp->curlsn = pos;
39 fp->offset = 0;
40
41 if (_seek(fp) < 0) {
42
43 errno = EIO;
44 fp->modefl |= FC_ERR;
45 return(FAILURE);
46 }
47
48 return(SUCCESS);
49}
[6262b5c]50
Note: See TracBrowser for help on using the repository browser.