aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filesystem/README.rst0
-rw-r--r--filesystem/disk.h17
-rw-r--r--filesystem/disk.obin0 -> 3352 bytes
-rw-r--r--filesystem/tfs.c133
4 files changed, 150 insertions, 0 deletions
diff --git a/filesystem/README.rst b/filesystem/README.rst
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/filesystem/README.rst
diff --git a/filesystem/disk.h b/filesystem/disk.h
new file mode 100644
index 0000000..7bf6ad0
--- /dev/null
+++ b/filesystem/disk.h
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define TRACKS 128
+#define SECTORS 4096
+
+/* 10ms per track change */
+/* 10ms/SECTORS per unit sector distance > 1 */
+
+void dinit();
+
+void rsector(int t,int s,unsigned char *b);
+
+void wsector(int t,int s,unsigned char *b);
+
+
diff --git a/filesystem/disk.o b/filesystem/disk.o
new file mode 100644
index 0000000..b1a36f8
--- /dev/null
+++ b/filesystem/disk.o
Binary files differ
diff --git a/filesystem/tfs.c b/filesystem/tfs.c
new file mode 100644
index 0000000..2d4bdfd
--- /dev/null
+++ b/filesystem/tfs.c
@@ -0,0 +1,133 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "disk.h"
+
+#define MAX_INODES 10
+
+struct block_ptr {
+ char track;
+ short sector;
+};
+
+struct meta_data{
+ char name[8];
+ int size;
+ int read;
+ int write;
+ int create;
+ };
+
+struct inode {
+ struct meta_data info;
+ struct block_ptr data[20];
+};
+
+typedef struct filestuff{
+ int fd;
+ struct inode file;
+};
+
+
+struct inode i_table[MAX_INODES];
+
+char bitmap[128][4096/8];
+
+int check_bitmap(t,s)
+int t,s;
+{
+ char tmp;
+ tmp = bitmap[t][s/8];
+ tmp &= (1 << (7-(s % 8)));
+ return (int) tmp;
+}
+
+void set_bitmap(t,s)
+int t,s;
+{
+ bitmap[t][s/8] |= (1 << (7-(s % 8)));
+}
+
+void print_bitmap()
+{
+ int i,j;
+ for(i = 0; i < 4096; i++) {
+ printf("\n%4d ", i);
+ for (j = 0; j < 128; j++) {
+ printf("%02x", bitmap[j][i]);
+ if (j == 63) {
+ printf("\n%4d ",i);
+ }
+ }
+ }
+}
+
+int search_inodes(name)
+char *name;
+{
+
+}
+
+/*
+int tfs_init()
+{
+ int n = MAX_INODES / 4;
+ int i;
+ char *ptr;
+ if (MAX_INODES % 4 > 0)
+ n++;
+
+ char buf[512 * n];
+
+ for (i =0; i < n; i++) {
+ rsector(0, i, &buf + (512 * i));
+ }
+ ptr = &buf;
+
+ for(i=0; i< MAX_INODES; i++) {
+ memcpy(&i_table[i], ptr, 64);
+ ptr + 64;
+ }
+}
+*/
+
+int open(fname, mode)
+char *fname, *mode;
+{
+
+}
+
+int close(fd)
+int fd;
+{
+
+}
+
+int read(fd, buf)
+int fd;
+char *buf;
+{
+
+}
+
+int write(fd, buf)
+int fd;
+char *buf;
+{
+
+}
+
+int ulink(fname)
+char *fname;
+{
+
+}
+
+int main()
+{
+ setBitmap(1,1);
+ setBitmap(2,2);
+
+ printf("test 1,1: %d, test 2,2: %d\n", checkBitmap(1,1), checkBitmap(2,2));
+ printBitmap();
+}