source: buchla-68k/orig/IOLIB/FSINIT.C@ 0170798

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

Imported original source code.

  • Property mode set to 100755
File size: 4.3 KB
RevLine 
[3ae31e9]1/*
2 ============================================================================
3 fsinit.c -- Initialize file system
4 Version 9 -- 1988-01-31 -- D.N. Lynx Crowe
5 ============================================================================
6*/
7
8#define _FS_DEF_ /* define so that stdio.h and io.h get things right */
9
10#include "biosdefs.h"
11#include "errno.h"
12#include "io.h"
13#include "stdio.h"
14#include "stddefs.h"
15
16extern int _bpbin, _dirin, _fatin, _dirmod, _fatmod;
17
18int _badfd(), _noper();
19
20char *Stdbufs; /* buffer chain pointer */
21
22char Wrkbuf[BPSEC]; /* sector work buffer */
23
24long Stdbuf[MAXDFILE][BUFSIZL]; /* standard buffers */
25
26FILE Cbuffs[NSTREAMS]; /* stream file control table */
27
28struct fcb _fcbtab[MAXDFILE]; /* fcb table */
29
30struct channel chantab[MAXCHAN]; /* channel table: relates fd's to devices */
31
32#if TBUFFER
33
34/* WARNING: this ONLY works for 512 byte sectors, 9 sectors per track */
35
36short _b_tbuf[9][256]; /* the track buffer */
37
38short _b_trak; /* current track */
39short _b_side; /* current side */
40short _b_sect; /* current sector */
41short _b_tsec; /* current base sector of current track */
42
43#endif
44
45/*
46
47*/
48
49/*
50 ============================================================================
51 _badfd() -- set "bad fd" error
52 ============================================================================
53*/
54
55int
56_badfd()
57{
58 errno = EBADF; /* set bad fd code */
59 return(FAILURE); /* return with an error indication */
60}
61
62/*
63 ============================================================================
64 _noper() -- null return with no error condition
65 ============================================================================
66*/
67
68int
69_noper()
70{
71 return(SUCCESS); /* return with a non-error indication */
72}
73
74/*
75
76*/
77
78/*
79 ============================================================================
80 InitCH() -- Initialize chantab structure entry
81 ============================================================================
82*/
83
84InitCH(cp, rdi, wri, ioi, ski, cfp, charg)
85register struct channel *cp;
86char rdi, wri, ioi, ski;
87int (*cfp)();
88io_arg charg;
89{
90 cp->c_read = rdi;
91 cp->c_write = wri;
92 cp->c_ioctl = ioi;
93 cp->c_seek = ski;
94 cp->c_close = cfp;
95 cp->c_arg = charg;
96}
97
98/*
99 ============================================================================
100 Init_CB() -- Initialize Cbuff structure entry
101 ============================================================================
102*/
103
104Init_CB(fp, flags, unit, bufad, bufsize)
105register FILE *fp;
106char unit, flags;
107long *bufad;
108int bufsize;
109{
110 fp->_bp = (char *)0L;
111 fp->_bend = (char *)0L;
112 fp->_buff = (char *)bufad;
113 fp->_flags = flags;
114 fp->_unit = unit;
115 fp->_bytbuf = 0;
116 fp->_buflen = bufsize;
117};
118
119/*
120
121*/
122
123/*
124 ============================================================================
125 InitFS() -- Initialize file system
126 ============================================================================
127*/
128
129InitFS()
130{
131 register int i;
132
133 memset(_fcbtab, 0, sizeof _fcbtab); /* clear fcb table */
134 memsetw(Stdbuf, 0, sizeof Stdbuf / 2); /* clear buffers */
135
136 Init_CB(stdin, _BUSY, 0, (char *)0L, BUFSIZ); /* stdin */
137 Init_CB(stdout, _BUSY, 1, (char *)0L, 1); /* stdout */
138 Init_CB(stderr, _BUSY, 2, (char *)0L, 1); /* stderr */
139
140 for (i = 3; i < NSTREAMS; i++)
141 Init_CB(&Cbuffs[i], 0, 0, (char *)0L, 0);
142
143 Stdbuf[0][0] = 0L; /* initialize the buffer list */
144
145 for (i = 1; i < MAXDFILE; i++)
146 Stdbuf[i][0] = (long)Stdbuf[i-1];
147
148 Stdbufs = Stdbuf[MAXDFILE-1];
149
150 InitCH(&chantab[0], 2, 0, 1, 0, _noper, (io_arg)CON_DEV ); /* 0 - stdin */
151 InitCH(&chantab[1], 0, 2, 1, 0, _noper, (io_arg)CON_DEV ); /* 1 - stdout */
152 InitCH(&chantab[2], 0, 2, 1, 0, _noper, (io_arg)CON_DEV ); /* 2 - stderr */
153
154 for (i = 3; i < MAXCHAN; i++) /* 3..MAXCHAN-1 - not preassigned */
155 InitCH(&chantab[i], 0, 0, 0, 0, _badfd, (io_arg)0L );
156
157 _bpbin = FALSE; /* BPB isn't in memory */
158 _dirin = FALSE; /* directory isn't in memory */
159 _fatin = FALSE; /* FAT isn't in memory */
160 _fatmod = FALSE; /* FAT hasn't been changed */
161 _dirmod = FALSE; /* directory hasn't been changed */
162
163#if TBUFFER
164 _b_trak = -1; /* no track in the buffer */
165 _b_side = -1; /* ... */
166#endif
167}
Note: See TracBrowser for help on using the repository browser.