|
|
1.1 root 1: /*
2: * static char ID_initc[] = "@(#) init.c: 1.1 1/7/82";
3: */
4:
5: sdpinit(dir_name, file_status, spacenbr)
6: char *dir_name;
7: int file_status, spacenbr;
8: {
9:
10: register int index1, index2, limit1, limit2;
11: char call_string[NAMELENG+7];
12: int fdes;
13: HEADER *gframe;
14:
15: /*
16: * The UN*X directory name must fit into local storage.
17: *
18: * The file status and space number must be valid.
19: */
20:
21: if( (strlen(dir_name)+1+strlen(TEMPLATE)+1 > NAMELENG)
22: || (strlen(dir_name) == 0) )
23: return( fatal("SDP directory name is illegal") );
24:
25: if( (spacenbr < 0) || (spacenbr > MAXSP) )
26: return( fatal("illegal address space number") );
27:
28: if( file_status != CREATE )
29: return( fatal("unknown file status") );
30:
31: /*
32: * If sdpinit has not been called before, set up the frame managers
33: */
34:
35: if( callstatus == NOTCALLEDBEFORE ) {
36:
37: limit1 = 0;
38: for( index1 = 0; index1 < num_partitions; index1++ ) {
39:
40: limit2 = limit1 + partitions[index1];
41: for( index2 = limit1; index2 < limit2; index2++ ) {
42: manager[index2].page_id = EMPTY;
43: manager[index2].lock_count = 0;
44: manager[index2].forward = index2+1;
45: manager[index2].backward = index2-1;
46: manager[index2].ref_chng = RNLY;
47: manager[index2].partition = index1;
48: manager[index2].frame_pntr = &(frames[index2][0]);
49: }
50:
51: manager[limit1].backward = LAMDA;
52: manager[limit2-1].forward = LAMDA;
53:
54: lru[index1] = limit1;
55: mru[index1] = limit2-1;
56: num_linked[index1] = limit2 - limit1;
57: partusage[index1] = 0;
58:
59: limit1 = limit2;
60:
61: }
62: partusage[num_partitions] = 0;
63:
64: for( index1 = 0; index1 < MAXATTACH; index1++ )
65: open_spacenumbers[index1] = NO;
66:
67: }
68: else
69: if( open_spacenumbers[spacenbr] == YES )
70: return( fatal("address space already opened") );
71:
72: /*
73: * Create the paging file
74: */
75:
76: gframe = &global_frames[spacenbr];
77:
78: gframe->maxpage = 0;
79: gframe->curpage = EMPTY;
80: gframe->curoffset = PAGESIZE;
81: gframe->numbfiles = DFILES;
82: for( index1 = 0; index1 < DFILES; index1++ ) {
83: gframe->filesize[index1] = file_size[index1];
84: gframe->filedes[index1] = NOTMADE;
85: }
86:
87: sprintf(call_string, "mkdir %s", dir_name);
88: if( system(call_string) != 0 )
89: return( fatal("creation of SDP directory failed") );
90:
91: sprintf(call_string, "%s/%s0", dir_name, TEMPLATE);
92: if( (fdes = creat(call_string,MODE)) == SYSERR )
93: return( fatal("creation of SDP paging file failed") );
94:
95: if( close(fdes) == SYSERR )
96: return( fatal("close of SDP paging file failed") );
97:
98: if( (gframe->filedes[0] = open(call_string,RW)) == SYSERR )
99: return( fatal("open of SDP paging file failed") );
100:
101: open_spacenumbers[spacenbr] = YES;
102: sprintf(&direct_names[spacenbr][0], "%s", dir_name);
103:
104: num_spaces++;
105:
106: callstatus = CALLEDBEFORE;
107:
108: return( spacenbr );
109: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.