-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory.py
More file actions
29 lines (20 loc) · 706 Bytes
/
memory.py
File metadata and controls
29 lines (20 loc) · 706 Bytes
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
from bcolors import *
from dir_table import get_dir_table
import ram
def blocksConsumedByFile(filename, current_inode):
filename = filename;
dir_table = get_dir_table(current_inode)
if filename in dir_table:
return 0, ram.inode_table[dir_table[filename]][9]
else:
# file_not_found()
return -11, -11
def freeBlocks():
blocks_consumed = ram.free_blocks.count(ram.out_scope_block)
blocks_left = len(ram.free_blocks) - blocks_consumed
return blocks_left
def showMasterBlock():
mblock = ""
for blockGroup in ram.master_block:
mblock = mblock +"\t"+blockGroup+"\t\t"+str(ram.master_block[blockGroup]) + "\n"
return mblock