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

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

Unix line breaks.

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