· 6 years ago · Nov 24, 2019, 12:42 AM
1/* filesys.c
2 *
3 * provides interface to virtual disk
4 *
5 * Ola Stefan Rudvin
6 * 51549217
7 *
8 */
9#include <stdio.h>
10#include <unistd.h>
11#include <string.h>
12#include <stdlib.h>
13#include "filesys.h"
14
15
16diskblock_t virtualDisk [MAXBLOCKS] ; // define our in-memory virtual, with MAXBLOCKS blocks
17fatentry_t FAT [MAXBLOCKS] ; // define a file allocation table with MAXBLOCKS 16-bit entries
18fatentry_t rootDirIndex = 0 ; // rootDir will be set by format
19direntry_t * currentDir = NULL ;
20fatentry_t currentDirIndex = 3 ;
21
22/* writedisk : writes virtual disk out to physical disk
23 *
24 * in: file name of stored virtual disk
25 */
26
27void writedisk ( const char * filename )
28{
29 //printf ( "writedisk> virtualdisk[0] = %s\n", virtualDisk[0].data ) ;
30 FILE * dest = fopen( filename, "w" ) ;
31 if ( fwrite ( virtualDisk, sizeof(virtualDisk), 1, dest ) < 0 )
32 fprintf ( stderr, "write virtual disk to disk failed\n" ) ;
33 //write( dest, virtualDisk, sizeof(virtualDisk) ) ;
34 fclose(dest) ;
35
36}
37
38void readdisk ( const char * filename )
39{
40 FILE * dest = fopen( filename, "r" ) ;
41 if ( fread ( virtualDisk, sizeof(virtualDisk), 1, dest ) < 0 )
42 fprintf ( stderr, "write virtual disk to disk failed\n" ) ;
43 //write( dest, virtualDisk, sizeof(virtualDisk) ) ;
44 fclose(dest) ;
45}
46
47
48/* the basic interface to the virtual disk
49 * this moves memory around
50 */
51
52void writeblock ( diskblock_t * block, int block_address )
53{
54 //printf ( "writeblock> block %d = %s\n", block_address, block->data ) ;
55 memmove ( virtualDisk[block_address].data, block->data, BLOCKSIZE ) ;
56 //printf ( "writeblock> virtualdisk[%d] = %s / %d\n", block_address, virtualDisk[block_address].data, (int)virtualDisk[block_address].data ) ;
57}
58
59/* the basic interface to the virtual disk
60 * this moves memory around
61 */
62
63diskblock_t readblock (int block_address)
64{
65 diskblock_t returnBlock;
66
67 //printf ( "readblock> block %d", block_address) ;
68 memmove (returnBlock.data, virtualDisk[block_address].data, BLOCKSIZE ) ;
69
70 //printf ( "readblock> virtualdisk[%d] = %s / %d\n", block_address, virtualDisk[block_address].data, (int)virtualDisk[block_address].data ) ;
71
72 return returnBlock;
73}
74
75
76/* read and write FAT
77 *
78 * please note: a FAT entry is a short, this is a 16-bit word, or 2 bytes
79 * our blocksize for the virtual disk is 1024, therefore
80 * we can store 512 FAT entries in one block
81 *
82 * how many disk blocks do we need to store the complete FAT:
83 * - our virtual disk has MAXBLOCKS blocks, which is currently 1024
84 * each block is 1024 bytes long
85 * - our FAT has MAXBLOCKS entries, which is currently 1024
86 * each FAT entry is a fatentry_t, which is currently 2 bytes
87 * - we need (MAXBLOCKS /(BLOCKSIZE / sizeof(fatentry_t))) blocks to store the
88 * FAT
89 * - each block can hold (BLOCKSIZE / sizeof(fatentry_t)) fat entries
90 */
91
92/* implement format()
93 */
94void format ( )
95{
96 diskblock_t block ;
97 direntry_t rootDir ;
98 int pos = 0 ;
99 int fatentry = 0 ;
100 int fatblocksneeded = (MAXBLOCKS / FATENTRYCOUNT ) ;
101
102 /* prepare block 0 : fill it with '\0',
103 * use strcpy() to copy some text to it for test purposes
104 * write block 0 to virtual disk
105 */
106
107 for ( int i = 0; i < BLOCKSIZE; i++){
108 block.data[i] = '\0';
109 };
110 strcpy( block.data, "CS3026 Operating Systems Assessment" );
111 writeblock( &block, 0 );
112
113 /* prepare FAT table
114 * write FAT blocks to virtual disk
115 */
116
117 for ( int i = 0; i < MAXBLOCKS; i++) {
118 FAT[i] = UNUSED;
119 };
120
121 FAT[0] = ENDOFCHAIN ;
122 FAT[1] = 2 ;
123 FAT[2] = ENDOFCHAIN ;
124 FAT[3] = ENDOFCHAIN ;
125
126 copyFat();
127
128 /* prepare root directory
129 * write root directory block to virtual disk
130 */
131
132 for ( int i = 0; i < BLOCKSIZE; i++){
133 block.data[i] = '\0';
134 };
135
136 block.dir.isdir = 1;
137 block.dir.nextEntry = 0;
138
139 for (int i = 0; i < DIRENTRYCOUNT; i++){
140 block.dir.entrylist[i].unused = TRUE;
141 }
142
143 rootDirIndex = 3;
144
145 writeblock( &block, rootDirIndex);
146}
147
148void copyFat ()
149{
150 // Divide FAT into two blocks.
151 // FAT = 1024
152 fatblock_t fatBlocks[2];
153
154 for (int i = 0; i < MAXBLOCKS; i++) {
155 if (i < FATENTRYCOUNT) {
156 fatBlocks[0][i] = FAT[i];
157 } else {
158 fatBlocks[1][i-FATENTRYCOUNT] = FAT[i];
159 };
160 }
161
162 for (int i = 0; i < 2; i++) {
163 writeblock(fatBlocks[i] , i+1);
164 }
165}
166
167/*
168 Implement myfopen()
169 Create a file called "testfile.txt" in your virtual disk.
170
171 • Opens a file on the virtual disk and manages a buffer for
172 it of size BLOCKSIZE, mode may be either “r” for readonly or “w”
173 for read/write/append (default “w”)
174 */
175MyFILE * myfopen ( const char * filename, const char * mode ){
176
177 // Count number of tokens
178 // If above 1, make the call.
179 // Then call mymkdir() with ones before last
180 // call changedir() with ones before last.
181
182 char * path = filename;
183
184 char * copy = strdup(path);
185
186 char *dir;
187 char *rest = copy;
188 int tokenCounter = 0;
189
190 while ((dir = strtok_r(rest, "/", &rest))){
191 tokenCounter ++;
192 }
193
194 if (tokenCounter > 1) {
195 // Extract filename
196 char *last = strrchr(path, '/');
197 if (last != NULL) {
198 filename = last+1;
199 }
200 int fileNameLen = strlen(filename);
201 int pathLen = strlen(path);
202 int cutOff = pathLen - fileNameLen;
203
204 char otherString[pathLen];
205
206 strncpy(otherString, path, cutOff);
207 otherString[cutOff] = '\0';
208
209 printf("myfopen creating directories for: '%s , %s'\n",otherString, filename);
210
211 mymkdir(otherString);
212 mychdir(otherString);
213 }
214
215 MyFILE * openFile = (MyFILE *) malloc(sizeof(MyFILE));
216
217 int found = FALSE;
218 int pos;
219 int i = 0;
220 int freeBlock;
221
222 diskblock_t block = virtualDisk[currentDirIndex];
223 // diskblock_t block = readblock(rootDirIndex);
224
225 for(int i = 0; i < DIRENTRYCOUNT; i++) {
226 if (block.dir.entrylist[i].unused) continue;
227 if (strcmp(block.dir.entrylist[i].name, filename) == 0) {
228 found = TRUE;
229 pos = i;
230 break;
231 }
232 }
233
234 if (found) {
235 openFile->pos = 0; // Which byte you're reading within the block
236 openFile->mode[0] = mode[0];
237 openFile->blockno = block.dir.entrylist[pos].firstblock;
238 openFile->buffer = virtualDisk[block.dir.entrylist[pos].firstblock];
239 openFile->dir_pos = pos;
240 } else {
241 for (int i = 0; i < DIRENTRYCOUNT; i ++) {
242 if (block.dir.entrylist[i].unused == TRUE) {
243 freeBlock = i;
244 break;
245 }
246 }
247
248 block.dir.entrylist[freeBlock].unused = FALSE;
249
250 int nextFreeFatEntry = nextUnusedFatEntry();
251
252 block.dir.entrylist[freeBlock].firstblock = nextFreeFatEntry;
253
254 strcpy(block.dir.entrylist[freeBlock].name, filename);
255
256 FAT[(int)nextFreeFatEntry] = ENDOFCHAIN;
257
258 copyFat();
259
260 writeblock(&block, currentDirIndex);
261
262 diskblock_t openFileBlock = virtualDisk[nextFreeFatEntry];
263
264 // Do stuff to file which is returned
265 openFile->pos = (int)0; // Which byte you're reading within the block
266 openFile->mode[0] = mode[0];
267 openFile->buffer = openFileBlock;
268 openFile->blockno = nextFreeFatEntry;
269 openFile->dir_pos = freeBlock;
270 }
271
272 return openFile;
273}
274
275void myfputc ( int b, MyFILE * stream ){
276
277 stream->writing = TRUE;
278
279 if (!stream) {
280 fprintf(stderr, "Error in myfputc(), stream pointer is null");
281 return;
282 }
283
284 // Depending on write policy either wait until block is full or write current block to memory.
285
286 diskblock_t buffer = stream->buffer;
287
288 // Check if pointer is too high for current block, then go to next FAT table
289 if (stream->pos >= BLOCKSIZE) {
290
291 writeblock(&buffer, stream->blockno);
292
293 if (FAT[stream->blockno] == ENDOFCHAIN) {
294 // FAT does not point anywhere, extend it.
295 int nextFreeFatEntry = nextUnusedFatEntry();
296
297 FAT[stream->blockno] = nextFreeFatEntry;
298 FAT[nextFreeFatEntry] = ENDOFCHAIN;
299 copyFat();
300
301 stream->blockno = nextFreeFatEntry;
302 } else {
303 // // FAT does point to next node, look at that instead.
304 // int lastFATChainIndex = getLastFatChainIndex(stream->blockno);
305 // stream->blockno = lastFATChainIndex;
306 // FAT[lastFATChainIndex] = ENDOFCHAIN;
307 // copyFat();
308 }
309
310 stream->pos = stream->pos - BLOCKSIZE;
311
312 for(int i = 0; i < BLOCKSIZE; i++) {
313 stream->buffer.data[i] = '\0';
314 }
315 }
316
317 virtualDisk[rootDirIndex].dir.entrylist[stream->dir_pos].filelength++;
318 stream->buffer.data[stream->pos] = (unsigned char) b;
319 stream->pos++;
320 stream->writing = FALSE;
321}
322
323int myfgetc ( MyFILE * stream ) {
324 // it has to be calculated whether all bytes of the files have been read by
325 // checking the amount of chars read
326 // against the file size stored in the directory entry. If the last byte of the
327 //file has been read, then at the next call of fgetc(), the function has to return EOF
328 direntry_t dir = virtualDisk[rootDirIndex].dir.entrylist[stream->dir_pos];
329
330 int maxLength = dir.filelength;
331 int currentLength = dir.entrylength;
332
333 if (stream->pos >= BLOCKSIZE) {
334 // No more blocks to get
335 if (FAT[stream->blockno] == ENDOFCHAIN) {
336 printf("\nEND of file reached due to FAT\n");
337 return -1;
338 }
339 stream->blockno = FAT[stream->blockno];
340 stream->pos = stream->pos - BLOCKSIZE;
341 }
342
343 char character = stream->buffer.data[stream->pos];
344
345 if (maxLength < currentLength) {
346 printf("\nEND of file reached due to file length %d\n", maxLength);
347 return -1;
348 }
349
350 stream->pos++;
351 virtualDisk[rootDirIndex].dir.entrylist[stream->dir_pos].entrylength++;
352
353 return character;
354}
355
356// Cycle through all FAT nodes until you find the last one
357fatentry_t getLastFatChainIndex(fatentry_t fatIndex){
358 if (FAT[fatIndex] == ENDOFCHAIN) {
359 return fatIndex;
360 } else {
361 return getLastFatChainIndex(FAT[fatIndex]);
362 }
363}
364
365int nextUnusedFatEntry(){
366 for ( int i = 0; i < MAXBLOCKS; i++) {
367 if (FAT[i] == UNUSED) {
368 return i;
369 };
370 };
371 return -1;
372}
373
374void myfclose ( MyFILE * stream )
375{
376 direntry_t dir = virtualDisk[rootDirIndex].dir.entrylist[stream->dir_pos];
377 printf("\nClosing, Final length of file: %i", dir.filelength);
378 printf("\nAmount of chars read: %i\n", dir.entrylength);
379
380 if (!stream) {
381 fprintf(stderr, "Error in myfclose(), stream pointer is null");
382 return;
383 }
384 // closes the file, writes out any blocks not written to disk
385 writeblock(&stream->buffer, stream->blockno);
386
387 free(stream);
388}
389
390
391/* use this for testing
392 */
393
394void printBlock ( int blockIndex )
395{
396 printf ( "virtualdisk[%d] = %s\n", blockIndex, virtualDisk[blockIndex].data ) ;
397}
398
399
400void mymkdir ( const char * path ) {
401 // Get first. If it exists, make that one the current dir.
402
403 // SEG FAULT : remember that pointers have to point to allocated memory and that string
404 // literals are allocated in the segment ‘.rodata’ and cannot be manipulated.
405
406 // direntry_t * currentDir = NULL ;
407 // fatentry_t currentDirIndex = 0 ;
408
409 char * copy = strdup(path);
410
411 char *dir;
412 char *rest = copy;
413
414 int freeBlock;
415 int found = FALSE;
416 int counter = 0;
417
418 // The dir used in 'this' method. So that currentDirIndex is not changed.
419 int thisDirIndex = currentDirIndex;
420
421 // If absolute path
422 if (path[0] == 47) {
423 thisDirIndex = rootDirIndex;
424 }
425
426 while ((dir = strtok_r(rest, "/", &rest))){
427
428 found = FALSE;
429
430 // Find dir from current directory
431 for(int i = 0; i < DIRENTRYCOUNT; i++) {
432 if (!virtualDisk[thisDirIndex].dir.entrylist[i].isdir) continue;
433
434 if (strcmp(virtualDisk[thisDirIndex].dir.entrylist[i].name, dir) == 0) {
435 printf("Dir %s already exists, no need to create it.\n", dir);
436
437 thisDirIndex = virtualDisk[thisDirIndex].dir.entrylist[i].firstblock;
438
439 found = TRUE;
440 }
441 }
442
443 if (!found) {
444
445 // printf("Dir \"%s\" does not exist, creating...\n", dir);
446 // Create new dir block
447 // Find empty FAT and set Directory
448
449 freeBlock = -1;
450
451 for (int i = 0; i < DIRENTRYCOUNT; i ++) {
452 if (virtualDisk[thisDirIndex].dir.entrylist[i].unused == TRUE) {
453 freeBlock = i;
454 break;
455 }
456 }
457
458 if (freeBlock == -1) {
459 fprintf ( stderr, "Not enough room in dir to make path %s\n", dir ) ;
460 return;
461 }
462
463 virtualDisk[thisDirIndex].dir.entrylist[freeBlock].unused = FALSE;
464
465 int nextFreeFatEntry = nextUnusedFatEntry();
466
467 // printf ("Next Free FAT Entry: %d\n", nextFreeFatEntry);
468
469 virtualDisk[thisDirIndex].dir.entrylist[freeBlock].firstblock = nextFreeFatEntry;
470
471 virtualDisk[thisDirIndex].dir.entrylist[freeBlock].isdir = TRUE;
472 virtualDisk[thisDirIndex].dir.entrylist[freeBlock].entrylength = 0;
473 virtualDisk[thisDirIndex].dir.entrylist[freeBlock].filelength = 0;
474
475 printf("Created Dir %s.\n", dir);
476
477 strcpy(virtualDisk[thisDirIndex].dir.entrylist[freeBlock].name, dir);
478
479 FAT[(int)nextFreeFatEntry] = ENDOFCHAIN;
480
481 writeblock(&virtualDisk[thisDirIndex], thisDirIndex);
482
483 copyFat();
484
485 thisDirIndex = nextFreeFatEntry;
486
487 // Make new dirblock!
488
489 diskblock_t block;
490
491 for ( int i = 0; i < BLOCKSIZE; i++){
492 block.data[i] = '\0';
493 };
494
495 block.dir.isdir = 1;
496
497 for (int i = 0; i < DIRENTRYCOUNT; i++){
498 block.dir.entrylist[i].unused = TRUE;
499 }
500
501 writeblock(&block, nextFreeFatEntry);
502 }
503 }
504};
505
506
507char ** mylistdir (const char * path){
508 char * copy = strdup(path);
509
510 char *dir;
511 char *rest = copy;
512
513 int freeBlock;
514
515 int found = FALSE;
516
517 char ** output = malloc(12*sizeof(char**));
518
519 // The dir used in 'this' method. So that currentDirIndex is not changed.
520 int thisDirIndex = currentDirIndex;
521
522 if (path[0] == 47) {
523 thisDirIndex = rootDirIndex;
524 }
525
526 // Output root directory if path is '/'
527 if (path[1] == 0) {
528 for (int i = 0; i < DIRENTRYCOUNT; i ++) {
529
530 char * x = malloc(sizeof(char*)*200);
531
532 strcpy(x, virtualDisk[thisDirIndex].dir.entrylist[i].name);
533
534 output[i] = x;
535 }
536 return output;
537 }
538
539 while ((dir = strtok_r(rest, "/", &rest))){
540
541 found = FALSE;
542
543 // Find dir from current directory
544 for(int i = 0; i < DIRENTRYCOUNT; i++) {
545 if (!virtualDisk[thisDirIndex].dir.entrylist[i].isdir) continue;
546
547 //printf("Entries in current Dir: %s\n", dirBlock.dir.entrylist[i].name);
548
549 if (strcmp(virtualDisk[thisDirIndex].dir.entrylist[i].name, dir) == 0) {
550 // printf("Dir %s found.\n", dir);
551
552 thisDirIndex = virtualDisk[thisDirIndex].dir.entrylist[i].firstblock;
553
554 found = TRUE;
555 }
556 }
557
558 if (!found) {
559 fprintf ( stderr, "You are trying to find path %s Which does not exist in the current directory.\n", dir ) ;
560 return -1;
561 }
562 }
563 for (int i = 0; i < DIRENTRYCOUNT; i ++) {
564
565 char * x = malloc(sizeof(char*)*200);
566
567 strcpy(x, virtualDisk[thisDirIndex].dir.entrylist[i].name);
568
569 output[i] = x;
570 }
571 return output;
572};
573
574//this function will change into an existing directory, using path, e.g. mkdir (“/first/second/third”)
575//creates directory “third” in parent dir “second”, which is a subdir of directory “first”, and “first
576//is a sub directory of the root directory
577
578void mychdir ( const char * path ) {
579 char * copy = strdup(path);
580
581 char *dir;
582 char *rest = copy;
583
584 int found = FALSE;
585
586 // The dir used in 'this' method. So that currentDirIndex is not changed.
587 int thisDirIndex = currentDirIndex;
588
589 if (path[0] == 47) {
590 thisDirIndex = rootDirIndex;
591 }
592
593 // Output root directory if path is '/'
594 if (path[1] == 0) {
595 return;
596 }
597
598 while ((dir = strtok_r(rest, "/", &rest))){
599
600 found = FALSE;
601
602 // Find dir from current directory
603 for(int i = 0; i < DIRENTRYCOUNT; i++) {
604 if (!virtualDisk[thisDirIndex].dir.entrylist[i].isdir) continue;
605
606 if (strcmp(virtualDisk[thisDirIndex].dir.entrylist[i].name, dir) == 0) {
607 //printf("Dir %s found.\n", dir);
608
609 thisDirIndex = virtualDisk[thisDirIndex].dir.entrylist[i].firstblock;
610
611 found = TRUE;
612 }
613 }
614
615 if (!found) {
616 fprintf ( stderr, "You are trying to find path %s Which does not exist in the current directory.\n", dir ) ;
617 return;
618 }
619 currentDirIndex = thisDirIndex;
620 }
621
622 printf("Moved to dir Index: %d\n", currentDirIndex);
623}
624
625void myremove ( const char * path ) {
626
627 char * copy = strdup(path);
628
629 char *dir;
630 char *rest = copy;
631
632 int found = FALSE;
633
634 // The dir used in 'this' method. So that currentDirIndex is not changed.
635 int thisDirIndex = currentDirIndex;
636
637 if (path[0] == 47) {
638 thisDirIndex = rootDirIndex;
639 }
640
641 // Output root directory if path is '/'
642 if (path[1] == 0) {
643 return;
644 }
645
646 while ((dir = strtok_r(rest, "/", &rest))){
647
648 found = FALSE;
649
650 for(int i = 0; i < DIRENTRYCOUNT; i++) {
651
652 if (!virtualDisk[thisDirIndex].dir.entrylist[i].isdir) {
653
654 if (strcmp(virtualDisk[thisDirIndex].dir.entrylist[i].name, dir) == 0) {
655
656 printf("Deleting file: %s\n", dir);
657
658 int deleteIndex = virtualDisk[thisDirIndex].dir.entrylist[i].firstblock;
659
660 // Free FAT
661 FAT[deleteIndex] = UNUSED;
662 copyFat();
663
664 // Free parent dirblock
665 diskblock_t block1;
666 for ( int i = 0; i < BLOCKSIZE; i++){
667 block1.data[i] = '\0';
668 };
669 direntry_t emptyDirEntry = block1.dir.entrylist[0];
670
671 virtualDisk[thisDirIndex].dir.entrylist[i] = emptyDirEntry;
672 virtualDisk[thisDirIndex].dir.entrylist[i].unused = TRUE;
673
674 writeblock(&virtualDisk[thisDirIndex], thisDirIndex);
675
676 // Overwrite memory
677 diskblock_t block;
678 for ( int i = 0; i < BLOCKSIZE; i++){
679 block.data[i] = '\0';
680 };
681
682 writeblock(&block,deleteIndex);
683
684 return;
685 }
686 continue;
687 }
688
689 if (strcmp(virtualDisk[thisDirIndex].dir.entrylist[i].name, dir) == 0) {
690 thisDirIndex = virtualDisk[thisDirIndex].dir.entrylist[i].firstblock;
691 found = TRUE;
692 }
693 }
694
695 if (!found) {
696 fprintf ( stderr, "You are trying to find path %s Which does not exist in the current directory.\n", dir ) ;
697 return;
698 }
699 }
700}
701
702// this function removes an existing directory, using path,
703//e.g. myrmdir (“/first/second/third”) removes directory “third” in
704//parent dir “second”, which is a subdir of directory “first”, and “first
705//is a sub directory of the root directory
706void myrmdir ( const char * path ) {
707
708 char * copy = strdup(path);
709
710 char *dir;
711 char *rest = copy;
712
713 int found = FALSE;
714
715 // The dir used in 'this' method. So that currentDirIndex is not changed.
716 int thisDirIndex = currentDirIndex;
717
718 if (path[0] == 47) {
719 thisDirIndex = rootDirIndex;
720 }
721
722 // Output root directory if path is '/'
723 if (path[1] == 0) {
724 return;
725 }
726
727 int pos;
728 int previousDir;
729
730 while ((dir = strtok_r(rest, "/", &rest))){
731
732 found = FALSE;
733
734 for(int i = 0; i < DIRENTRYCOUNT; i++) {
735
736 if (!virtualDisk[thisDirIndex].dir.entrylist[i].isdir) continue;
737
738 if (strcmp(virtualDisk[thisDirIndex].dir.entrylist[i].name, dir) == 0) {
739
740 pos = i;
741 previousDir = thisDirIndex;
742
743 thisDirIndex = virtualDisk[thisDirIndex].dir.entrylist[i].firstblock;
744 found = TRUE;
745 }
746 }
747
748 if (!found) {
749 fprintf ( stderr, "You are trying to find path %s Which does not exist in the current directory.\n", dir ) ;
750 return;
751 }
752 }
753
754 for(int i = 0; i < DIRENTRYCOUNT; i++) {
755 if (!virtualDisk[thisDirIndex].dir.entrylist[i].unused) {
756 fprintf ( stderr, "Cannot remove a directory which has files in it.\n", dir ) ;
757 return;
758 }
759 }
760
761
762 // Free FAT
763 FAT[thisDirIndex] = UNUSED;
764 copyFat();
765
766 // Free parent dirblock
767 diskblock_t block1;
768 for ( int i = 0; i < BLOCKSIZE; i++){
769 block1.data[i] = '\0';
770 };
771
772 direntry_t emptyDirEntry = block1.dir.entrylist[0];
773
774 virtualDisk[previousDir].dir.entrylist[pos] = emptyDirEntry;
775 virtualDisk[previousDir].dir.entrylist[pos].unused = TRUE;
776
777 writeblock(&virtualDisk[thisDirIndex], thisDirIndex);
778
779 // Overwrite memory
780 diskblock_t block;
781 for ( int i = 0; i < BLOCKSIZE; i++){
782 block.data[i] = '\0';
783 };
784
785 writeblock(&block,thisDirIndex);
786
787 return;
788}