Basic VM and other minor improvements.

Not complete, probably not fully debugged or optimized.
This commit is contained in:
Ben Gras
2008-11-19 12:26:10 +00:00
parent c888305e21
commit c078ec0331
273 changed files with 10814 additions and 4305 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -479,3 +479,4 @@ char *argv[];
printf("\nwtmp begins %.16s \n", ctime(&wtmp_buffer[0].ut_time));
return(0);
}

View File

@@ -56,17 +56,8 @@
#define BIN 2
#define BINGRP 2
#define BIT_MAP_SHIFT 13
#define N_BLOCKS MAX_BLOCK_NR
#define N_BLOCKS16 (128L * 1024)
#define INODE_MAX ((unsigned) 65535)
/* You can make a really large file system on a 16-bit system, but the array
* of bits that get_block()/putblock() needs gets a bit big, so we can only
* prefill MAX_INIT blocks. (16-bit fsck can't check a file system larger
* than N_BLOCKS16 anyway.)
*/
#define MAX_INIT (sizeof(char *) == 2 ? N_BLOCKS16 : N_BLOCKS)
#ifdef DOS
maybedefine O_RDONLY 4 /* O_RDONLY | BINARY_BIT */
@@ -90,12 +81,12 @@ char *progname;
long current_time, bin_time;
char *zero, *lastp;
char umap[MAX_INIT / 8]; /* bit map tells if block read yet */
char *umap_array; /* bit map tells if block read yet */
int umap_array_elements = 0;
block_t zone_map; /* where is zone map? (depends on # inodes) */
int inodes_per_block;
int fs_version;
unsigned int block_size;
block_t max_nrblocks;
FILE *proto;
@@ -167,14 +158,12 @@ char *argv[];
i = 0;
fs_version = 3;
inodes_per_block = 0;
max_nrblocks = N_BLOCKS;
block_size = 0;
while ((ch = getopt(argc, argv, "12b:di:lotB:")) != EOF)
switch (ch) {
case '1':
fs_version = 1;
inodes_per_block = V1_INODES_PER_BLOCK;
max_nrblocks = 0xFFFF;
break;
case '2':
fs_version = 2;
@@ -262,12 +251,6 @@ char *argv[];
/* Read the line with the block and inode counts. */
getline(line, token);
blocks = atol(token[0]);
if (blocks > max_nrblocks) pexit("Block count too large");
if (sizeof(char *) == 2 && blocks > N_BLOCKS16) {
fprintf(stderr,
"%s: warning: FS is larger than the %dM that fsck can check!\n",
progname, (int) (N_BLOCKS16 / (1024L * 1024)));
}
inodes = atoi(token[1]);
/* Process mode line for root directory. */
@@ -305,7 +288,6 @@ char *argv[];
}
if (blocks < 5) pexit("Block count too small");
if (blocks > max_nrblocks) pexit("Block count too large");
if (i < 1) pexit("Inode count too small");
if (i > INODE_MAX && fs_version < 3) pexit("Inode count too large");
inodes = (ino_t) i;
@@ -320,6 +302,17 @@ char *argv[];
nrblocks = blocks;
nrinodes = inodes;
{
size_t bytes;
bytes = 1 + blocks/8;
if(!(umap_array = malloc(bytes))) {
fprintf(stderr, "mkfs: can't allocate block bitmap (%d bytes).\n",
bytes);
exit(1);
}
umap_array_elements = bytes;
}
/* Open special. */
special(argv[--optind]);
@@ -336,7 +329,7 @@ char *argv[];
}
testb[0] = 0x3245;
testb[1] = 0x11FF;
testb[block_size-1] = 0x1F2F;
testb[block_size/2-1] = 0x1F2F;
if ((w=write(fd, (char *) testb, block_size)) != block_size) {
if(w < 0) perror("write");
printf("%d/%d\n", w, block_size);
@@ -350,7 +343,7 @@ char *argv[];
testb[1] = 0;
nread = read(fd, (char *) testb, block_size);
if (nread != block_size || testb[0] != 0x3245 || testb[1] != 0x11FF ||
testb[block_size-1] != 0x1F2F) {
testb[block_size/2-1] != 0x1F2F) {
if(nread < 0) perror("read");
printf("nread = %d\n", nread);
printf("testb = 0x%x 0x%x 0x%x\n", testb[0], testb[1], testb[block_size-1]);
@@ -370,24 +363,6 @@ printf("testb = 0x%x 0x%x 0x%x\n", testb[0], testb[1], testb[block_size-1]);
cache_init();
#if (MACHINE == ATARI)
if (isdev) {
char block0[BLOCK_SIZE];
get_block((block_t) 0, block0);
/* Need to read twice; first time gets an empty block */
get_block((block_t) 0, block0);
/* Zero parts of the boot block so the disk won't be
* recognized as a tos disk any more. */
block0[0] = block0[1] = 0; /* branch code to boot code */
strncpy(&block0[2], "MINIX ", (size_t) 6);
block0[16] = 0; /* number of FATS */
block0[17] = block0[18] = 0; /* number of dir entries */
block0[22] = block0[23] = 0; /* sectors/FAT */
bzero(&block0[30], 480);/* boot code */
put_block((block_t) 0, block0);
} else
#endif
put_block((block_t) 0, zero); /* Write a null boot block. */
zone_shift = 0; /* for future use */
@@ -1229,12 +1204,14 @@ block_t n;
int w, s, mask, r;
if (sizeof(char *) == 2 && n >= MAX_INIT) pexit("can't initialize past 128M");
w = n / 8;
if(w >= umap_array_elements) {
pexit("umap array too small - this can't happen");
}
s = n % 8;
mask = 1 << s;
r = (umap[w] & mask ? 1 : 0);
umap[w] |= mask;
r = (umap_array[w] & mask ? 1 : 0);
umap_array[w] |= mask;
return(r);
}

View File

@@ -40,6 +40,7 @@
char *Tclr_all;
#if 0
int print_memory(struct pm_mem_info *pmi)
{
int h;
@@ -58,6 +59,7 @@ int print_memory(struct pm_mem_info *pmi)
return 1;
}
#endif
int print_load(double *loads, int nloads)
{
@@ -209,10 +211,13 @@ void showtop(int r)
int nloads, i, p, lines = 0;
static struct proc prev_proc[PROCS], proc[PROCS];
struct winsize winsize;
static struct pm_mem_info pmi;
/*
static struct pm_mem_info pmi;
*/
static int prev_uptime, uptime;
static struct mproc mproc[NR_PROCS];
struct tms tms;
int mem = 0;
uptime = times(&tms);
@@ -222,10 +227,13 @@ void showtop(int r)
exit(1);
}
#if 0
if(getsysinfo(PM_PROC_NR, SI_MEM_ALLOC, &pmi) < 0) {
fprintf(stderr, "getsysinfo() for SI_MEM_ALLOC failed.\n");
mem = 0;
exit(1);;
}
} else mem = 1;
#endif
if(getsysinfo(PM_PROC_NR, SI_KPROC_TAB, proc) < 0) {
fprintf(stderr, "getsysinfo() for SI_KPROC_TAB failed.\n");
@@ -247,7 +255,9 @@ void showtop(int r)
lines += print_load(loads, NLOADS);
lines += print_proc_summary(proc);
lines += print_memory(&pmi);
#if 0
if(mem) { lines += print_memory(&pmi); }
#endif
if(winsize.ws_row > 0) r = winsize.ws_row;
@@ -347,3 +357,4 @@ int main(int argc, char *argv[])
return 0;
}
int sys_hz() { return 50; }