I am looking for Python code to read the blocks on the disk.img provided by the Professor. Attached to this dropbox is a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

I am looking for Python code to read the blocks on the disk.img provided by the Professor. Attached to this dropbox is a

Post by answerhappygod »

I am looking for Python code to read the blockson the disk.img provided by the Professor.
Attached to this dropbox is a “Disk” library which can be usedto read and write blocks in a binary file. Think of it like a diskdriver! It’s just a simple class, which holds a file handle to thebacking file and exposes “readBlock()” and “writeBlock()” methodswhich can be used to read/write one block at a time. It also keepstrack of how many block reads/writes have occurred, which you canprint by calling a third “printStats()” method. A small examplefile is also included, showing how it works.
Implementations in C/C++ and Python 3 are provided. If you’dlike to use another language, feel free, but you’ll need to firstimplement this class yourself in that language. Shouldn’t be toohard though, it’s well documented in the code. :)
Also attached to the dropbox is a “dFAT” disk image (like wediscussed in the lecture), containing several files anddirectories. It uses a block size of 512.
I’d like you to implement a “dbrowse” program of your own, likeI showed in the live demo, which is capable of performing theactions below. It should utilize the provided “Disk” class toaccess the underlying file, so that statistics can be printed atthe end. When run, it should print the disk label, and then let theuser do any of the following... •dirList contents of current directory. Print type,size (for files), and name. •cd <dir>Change directory (“cd ..” should go tothe parent directory) •read <file>Read and print the contents of afile. •pwdPrint the current working directory
As you work, test your program against the provided disk image.Ultimately you should be able to browse the directories in theimage, and read any files you find.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply