Skip to content
Snippets Groups Projects
Commit 954e3133 authored by Hilde Jordal's avatar Hilde Jordal
Browse files

added some ideas and started on problem text

parent abfab896
No related branches found
No related tags found
No related merge requests found
### Ideas: # INF113 Obligatorisk Innlevering 3 - Eget filsystem i Python
1. fix null values being invalid
\ No newline at end of file ## Utlevert kode
I denne oppgaven får dere utlevert kode som simulerer et enkelt filsystem. Kjør ´``main.py`` for å generere filsystemet med noen eksempelfiler.
Filsystemet er som helhet lagret i en fil ``myfilesystem.fs`` og har headers, blokker osv. Les kommentarer og dokumentasjon i koden for å forstå koden bedre. Det er også mulig å åpne filsystemet som rå data ved å bruke kommando ``xxd myfilesystem.fs`` i terminal. Da vil du se en oversikt over filsystemet i hexadesimalt format.
## Oppgave 1:
# Ideas:
- Remove() should free the space taken by the file. New files should use the new free space if available instead of following the incremented block number.
- Load() should allow files to have \0 characters in them.
- Implement ls() to see all the files in the directory
- allow file sizes of multiple blocks?
- problem is perhaps recording that the extra blocks are taken since they probably wont be associated with a filename
- require change in most of the code?, so large task
## Todo:
- Add explanation of how the file system works in intro text?
...@@ -3,19 +3,15 @@ import sys ...@@ -3,19 +3,15 @@ import sys
# file system parameters # file system parameters
TOTAL_SIZE = 0x800 # 2kB TOTAL_SIZE = 0x800 # 2kB
# Metainfo block
HEADER_START = 0x0 HEADER_START = 0x0
# 1 byte counter for the number of files
COUNTER_BYTES = 0x1 COUNTER_BYTES = 0x1
# size of file info entry (filename, ...)
FILE_ENTRY_SIZE = 0x10 FILE_ENTRY_SIZE = 0x10
# size of a file block (content of a file)
FILE_BLOCK_SIZE = 0x100 FILE_BLOCK_SIZE = 0x100
# file block 0 is the metainfo block
# line 0 of metainfo contains the number of files
# lines 1.. contain the filenames.
# line N has the filename of the file in Block N
# file blocks 1.. contain just the file contents
# use "xxd myfilesystem.fs" to look at the raw contents # use "xxd myfilesystem.fs" to look at the raw contents
# internal exception to signal no file # internal exception to signal no file
...@@ -25,7 +21,7 @@ class NoFile(Exception): ...@@ -25,7 +21,7 @@ class NoFile(Exception):
def format(f): def format(f):
""" """
Formats the file system Formats the file system by writing the initial metadata.
""" """
f.write(b'\0' * TOTAL_SIZE) f.write(b'\0' * TOTAL_SIZE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment