source: buchla-68k/libcio/fsinit.c@ 599d89b

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

Point of no return.

  • Property mode set to 100644
File size: 4.1 KB
Line 
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(void);
19int _noper(void);
20
21char *Stdbufs; /* buffer chain pointer */
22
23char Wrkbuf[BPSEC]; /* sector work buffer */
24
25long Stdbuf[MAXDFILE][BUFSIZL]; /* standard buffers */
26
27FILE Cbuffs[NSTREAMS]; /* stream file control table */
28
29struct fcb _fcbtab[MAXDFILE]; /* fcb table */
30
31struct channel chantab[MAXCHAN]; /* channel table: relates fd's to devices */
32
33#if TBUFFER
34
35/* WARNING: this ONLY works for 512 byte sectors, 9 sectors per track */
36
37short _b_tbuf[9][256]; /* the track buffer */
38
39short _b_trak; /* current track */
40short _b_side; /* current side */
41short _b_sect; /* current sector */
42short _b_tsec; /* current base sector of current track */
43
44#endif
45
46/*
47
48*/
49
50/*
51 ============================================================================
52 _badfd() -- set "bad fd" error
53 ============================================================================
54*/
55
56int _badfd(void)
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 _noper(void)
69{
70 return(SUCCESS); /* return with a non-error indication */
71}
72
73/*
74
75*/
76
77/*
78 ============================================================================
79 InitCH() -- Initialize chantab structure entry
80 ============================================================================
81*/
82
83void InitCH(struct channel *cp, char rdi, char wri, char ioi, char ski, int (*cfp)(), io_arg charg)
84{
85 cp->c_read = rdi;
86 cp->c_write = wri;
87 cp->c_ioctl = ioi;
88 cp->c_seek = ski;
89 cp->c_close = cfp;
90 cp->c_arg = charg;
91}
92
93/*
94 ============================================================================
95 Init_CB() -- Initialize Cbuff structure entry
96 ============================================================================
97*/
98
99void Init_CB(FILE *fp, char unit, char flags, long *bufad, int bufsize)
100{
101 fp->_bp = (char *)0L;
102 fp->_bend = (char *)0L;
103 fp->_buff = (char *)bufad;
104 fp->_flags = flags;
105 fp->_unit = unit;
106 fp->_bytbuf = 0;
107 fp->_buflen = bufsize;
108};
109
110/*
111
112*/
113
114/*
115 ============================================================================
116 InitFS() -- Initialize file system
117 ============================================================================
118*/
119
120void InitFS(void)
121{
122 register int i;
123
124 memset(_fcbtab, 0, sizeof _fcbtab); /* clear fcb table */
125 memsetw(Stdbuf, 0, sizeof Stdbuf / 2); /* clear buffers */
126
127 Init_CB(stdin, _BUSY, 0, (char *)0L, BUFSIZ); /* stdin */
128 Init_CB(stdout, _BUSY, 1, (char *)0L, 1); /* stdout */
129 Init_CB(stderr, _BUSY, 2, (char *)0L, 1); /* stderr */
130
131 for (i = 3; i < NSTREAMS; i++)
132 Init_CB(&Cbuffs[i], 0, 0, (char *)0L, 0);
133
134 Stdbuf[0][0] = 0L; /* initialize the buffer list */
135
136 for (i = 1; i < MAXDFILE; i++)
137 Stdbuf[i][0] = (long)Stdbuf[i-1];
138
139 Stdbufs = Stdbuf[MAXDFILE-1];
140
141 InitCH(&chantab[0], 2, 0, 1, 0, _noper, (io_arg)CON_DEV ); /* 0 - stdin */
142 InitCH(&chantab[1], 0, 2, 1, 0, _noper, (io_arg)CON_DEV ); /* 1 - stdout */
143 InitCH(&chantab[2], 0, 2, 1, 0, _noper, (io_arg)CON_DEV ); /* 2 - stderr */
144
145 for (i = 3; i < MAXCHAN; i++) /* 3..MAXCHAN-1 - not preassigned */
146 InitCH(&chantab[i], 0, 0, 0, 0, _badfd, (io_arg)0L );
147
148 _bpbin = FALSE; /* BPB isn't in memory */
149 _dirin = FALSE; /* directory isn't in memory */
150 _fatin = FALSE; /* FAT isn't in memory */
151 _fatmod = FALSE; /* FAT hasn't been changed */
152 _dirmod = FALSE; /* directory hasn't been changed */
153
154#if TBUFFER
155 _b_trak = -1; /* no track in the buffer */
156 _b_side = -1; /* ... */
157#endif
158}
Note: See TracBrowser for help on using the repository browser.