+1(978)310-4246 credencewriters@gmail.com
  

Operating Systems
File Assignment
© DL, UTA, 2020, 2021, 2022
Assignment
• Maybe a top down approach might help
• There are disks, they are divided into fixed size sectors
• In this assignment you are using a file to emulate (to act as) a disk
• So you do not destroy the contents of your disk
• The name of the file, which acts like a disk is “disk01”
• That file is logically divided into 256 byte sectors
Assignment
• Logically this looks like
• “disk01”
•
0
• offset
256
512
768
1024
Assignment
What goes into these sectors? Of “disk01”
The contents of files. (You are copying the contents of a host file into
this file)
A simple (but not very useful) example is:
The Unix command
Assignment
What goes into these sectors? Of “disk01”
A simple (but not very useful) example is:
The Unix command:
cat file01 file02 file03 >disk01
This works on files of any type: jpg, text, executable files
But how can you later separate disk01 back into these separate files?
Assignment
What goes into these sectors? Of “disk01”?
But how can you later separate disk01 back into these separate files?
How do you know where file01 ends and file02 begins?
This is what directories do
They have meta information (additional info) that is not part of a files
contents
Assignment
What goes into these sectors? Of “disk01”?
Directory:
Has file names:
File01  location 0
File02  location 512
File03  location 768
Assignment
What goes into these sectors? Of “disk01”?
Directory:
Has file names:
File01  location 0
File02  location 512
File03  location 768
(notice that these are on sector boundaries, an integer number of
sectors)
Assignment
Directory:
File01  location 0
File02  location 512
File03  location 768
File01
File02
File03
Fi
0
512
768
Assignment
• Directory
• How large is each file? (in bytes)? We know in sectors (maybe), not in
bytes
• When was file created?
Assignment
Directory (split into simple parts):
File01  inode number 5
File02  inode number 3
File03  inode number 8
File01
5
File02
File03
3
8
Fi
Assignment
Directory (split into simple parts):
5
Size: 480, November 4
3
8
Size: 10, November 1
…. Fi
Assignment
Directory (split into simple parts):
5
Size: 480, Nov 4
where? Sector 11, sector 8
3
Size: 10, Nov 1
where? Sector 10
8
….
Fi
Assignment
• Free Space (“free” or unused disk blocks)
• “disk01”
•
0
256
512
768
1024 1280
Assignment
• Free Space (“free” or unused disk blocks)
• “disk01”
In Use
Free
In use
In use
U Free
•
0
256
512 768 1024 1280
• Bit Map of Free Space: 1 0 1 1 0, where 1 is in use, 0 is free
Assignment
• These files must be of type “binary”.
• https://stackoverflow.com/questions/979816/whats-a-binary-fileand-how-do-i-create-one
• In addition to the system calls: open, close, read,write (there are
many varients) you may need to use lseek.
• You may look at the contents of any file (binary, text, jpg, anything)
• With the utility: “od”, such as “od –A x –c disk01”
• Can also look at “xxd”, Hexedit or Ghex
Assignment
• File names stored in a directory
• Only name and pointer to additional information
• Called FNT (File Name Table)
• Entries:
• Name (max 50 characters)
• A number (DABPT index, or pointer) this is an “inode”
• (that is all)
Assignment
• File names stored in a directory
• Only name and pointer to additional information
• Called FNT (File Name Table)
• Entries:
• Name (max 50 characters)
• A number (DABPT index, or pointer) this is an “inode”
• (that is all)
Assignment
• File meta information
• DABPT (Directory block pointer table)
• Contains
• Current file size (integer)
• Time and date (integer)
• User Name (string)
• Pointer to another table (Block Pointer Table)
Assignment
• File meta information
• Block Pointer Table
• These are “pointers” (integers) for “actual disk blocks”
• Which in this case are just 256 byte groups in memory
• Or on the disk
•
Assignment
• File meta information
• Why these tables with pointers?
• These pointers are NOT memory pointers, they are an index (0,1,2…)
• These (hopefully):
• Simplify design (coding, debugging)
• Avoid variable length strings, groups of pointers, etc
• Variable length data is a pain, allocating max lengths is wasteful
(and may not work anyway)
Assignment
• Some people think better (easier) with pictures
• Draw them
• Or create data structures in code
• This can/should be developed incrementally
Last
Last
CSE 3320
Operating Systems
Summer 2022, © DL, UTA, 2022
Programming Assignment 3
File System Internals
Due: On Canvas
Description:
You will develop and implement a small file system (“FS”). It is similar to some
of the basics of Unix as well as CP/M file systems.
Your file system will not be part of an operating system, but, similar to most
modern file systems, it will run in several different operating systems to
provide a “portable” file system.
Details:
Your FS will use a file (for example “disk01”), rather than directly using
a physical flash or disk, to store data.
You may have several disk-like files (for example: disk01, disk02),
used to store data.
The data stored in disk01 may be a user’s programs, text files,
other data files, or any type of binary information. In addition to the data
stored, your FS will need to store other, meta-information, such as free space
(blocks), directory details, and possibly other information. The FS directory is flat
(one level) fixed sized, has a user name associated with each file, and has fixed
sized “blocks” (entries).
You should use fixed size blocks (similar to disk blocks) of size 256 (or 1KB,
your choice, examples based on 256) bytes to store files and all meta-data
in your “disk”.
(Your “disk” (for example “disk01” is logically divided into a number of “sectors”,
which are fixed size blocks. Everything that is stored (persistent) is in these
blocks)
Your program (the “FS” executable) should provide the following operations:
(These operations deal with the “disk”, not individual user files)
Createfs #ofblocks – creates a filesystem (disk) with #ofblocks size, each 256 bytes
For example Createfs 250 creates a “virtual disk”, a file that will be initialized to
250 blocks of 256 bytes each. It is created in memory, and initialized.
Formatfs #filenames #DABPTentries
For example Formatfs 64 48 reserves space for 64 file names and 48 file meta data,
Note that some file names may “point” to the same file metadata, in this example
there can only be 48 unique files.
Savefs name– save the “disk” image in a file “name”
Openfs name- use an existing disk image
For example Savefs disk01 or Openfs disk01
These commands same the memory “image” (contents) to an external file,
in this example, it is called disk01, but can be called anything, the openfs
command retrieves the image/contents from the file and puts into memory.
List – list files (and other meta-information) in a FS
List what is in “your” directory
Remove name –remove named file from fs
Delete a user file, should reclaim the directory entry and file sectors
Rename oldname newname – rename a file stored in the FS
Just change user file name
Put ExternalFile – put (store) Host OS file into the disk
Get ExternalFile – get disk file, copy from “disk” to host OS file system
These operations put and get a user file from “outside” to and from your file system
User name – show/change name of user who owns this file
Link/Unlink – Unix style file linking
These are some more, common, meta operations, only changes something in directory,
not the data file contents
Bonus: Set/Use file permissions for r/w/x, implement subdirectories, “check disk”
Implement in either the “Go” or “Rust” programming language (20 to 75 point bonus)
Implementation:
(Note: these names and acronyms are hints, there are other methods and data structures
that may also work.)
Your FS should have 4 (or more, if easier to implement) sections:
A FileNameTable (FNT), a directory and a disk attribute/block pointer table (DABPT),
and the data blocks.
The FNT should be of size allocated, each entry should contain a 50 char
(maximum) file name and an inode pointer (index to DABPT)(blocks).
The DABPT should be allocated from disk blocks, 4 entries per block, where each entry
should contain a file meta-information (FileSize, last time+date (secs), pointers to
data blocks), user name
The Block Pointer Table has direct pointers to data blocks, and one additional
pointer to another entry in the Table, if needed (for big files), these may be
chained for very large files. (Similar to CP/M extents)
Since disks (and some meta-information) are fixed size, many small or one
large file might not fit on the “disk”. File names, file attributes and other file
information stored in FS are restrictive (for example, file creation time).

Purchase answer to see full
attachment

  
error: Content is protected !!