-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
98 lines (91 loc) · 2.94 KB
/
test.c
File metadata and controls
98 lines (91 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// Created by Sarah Depew on 4/25/18.
//
#include "filesystem.h"
#include <stdio.h>
#include <stdlib.h>
int main() {
setup();
int index_into_mount_table = -1;
f_mount("test1", "ignore", &index_into_mount_table);
printf("index into mount table: %d\n", index_into_mount_table);
//create a basic disk image to use
// inode *inode1 = malloc(sizeof(inode));
//set fields
// inode1->filename[0] = 'T';
// inode1->filename[1] = 'e';
// inode1->filename[2] = 's';
// inode1->filename[3] = 't';
// inode1->filename[4] = '\0';
// inode1->disk_identifier = 0;
// inode1->parent_inode_index = -1;
// inode1->next_inode = -1;
// // inode1->f_stats = malloc(sizeof(stat));
// inode1->size = 0; //TODO: figure this out later, hardcoding a reasonable size to be less than a block!
// inode1->uid = 0;
// inode1->gid = 0;
// inode1->ctime = 0;
// inode1->mtime = 0;
// inode1->atime = 0;
// inode1->type = REG;
// inode1->permission = SUPER; //TODO: see how struct affects this?
// inode1->inode_index = 0; //index in the inode region
// inode1->dblocks[0] = 0;
// // inode1->access = READ;
// //dont need any other blocks, since this is one block sized
//
// FILE *disk_image = fopen("Disk Image", "w+");
//
// FILE *test_file = fopen("Test", "r+");
// if(fseek(test_file, 0L, SEEK_END) == -1) {
// perror("fseek failed.\n");
// return FALSE;
// }
// long inputFileSize = ftell(test_file);
// if(inputFileSize == -1) {
// perror("File size error.\n");
// return FALSE;
// }
// rewind(test_file);
//
// //todo: read in block at a time!
// void *allOfInputFile = malloc(inputFileSize);
// if (allOfInputFile == NULL) {
// perror("Malloc failed.\n");
// return FALSE;
// }
//
// if(fread(allOfInputFile, inputFileSize, 1, test_file) < 1) {
// perror("Error reading in disk image.\n");
// return FALSE;
// }
// printf("%s\n", (char *) allOfInputFile);
//
// inode1->size = inputFileSize;
// fwrite(inode1, sizeof(inode), 1, disk_image); //TODO: binary write! (binary disk...)
// fwrite(allOfInputFile, inputFileSize, 1, disk_image);
// fclose(disk_image);
//
// /* typedef struct cluster {
// boolean read;
// boolean write;
// boolean execute;
// } cluster;
//
// //TODO: ask dianna about how to model this value? (byte operators)
// typedef struct permission_value {
// struct cluster cluster_owner;
// struct cluster cluster_group;
// struct cluster cluster_others;
// } permission_value;
// */
//test f_open
permission_value *permissions = malloc(sizeof(permission_value));
permissions->owner = '\a';
permissions->group = '\a';
permissions->others = '\a';
free(permissions);
// f_mount("Disk Image", "point");
// f_open("path", READ, permissions);
return 0;
}