Assignment_1/A Minimal List of Unix Commands.txt A Minimal List of Unix Commands: bashBourne-Again Shell bgbackground catshow each file in sequence chmodchange the permission on a file...

1 answer below »
"Assignment 1.doc" --> a Microsoft document contains the project details
and the related files to review and complete the assignment was also attached in the zip folder.


Assignment_1/A Minimal List of Unix Commands.txt A Minimal List of Unix Commands: bashBourne-Again Shell bgbackground catshow each file in sequence chmodchange the permission on a file chownchange the owner of a file cmpcompare two files dfshow mounted volumes, etc dushow disk blocks used for one or more directories emacsthe all-powerful text/binary editor; try xemacs also envlists the current environment variables fgforeground grepprint lines matching a pattern killkills a running program lncreates a link between two files; try ln -s lslist contents of directory; try ls -lisa makemaintain, update, and regenerate related programs and files manshow reference manual pages; try man -k mkfsmake (construct) a file volume nohuprun a command immune to hangups odoctal dump; try od -x file-name psshows current processes setset/get and show the values of shell variables sourceshell built-in: execute the cmds in a file timea prefix to commands, times the command and prints page faults etc. umaskget/set the file mode creation mask wwho is on the system, and what they are doing Assignment_1/Assignment 1.docx Assignment 1 The project for the current term is to implement (on a simulated disk) a file system based on the design explored in the lectures.  This project is divided into four pieces.   You must read and follow the Project Expectations.  Study the grading sheet given below. This is Part 0 of the project for this term.  You are expected to study and modify the source code files given in source.tbz and achieve the functionality described below.  Do not use source code files of others or even those of mine but from prior terms.  Be Considerate. Do make sure that you are not using up too much space (say > 10 MB) in your home directory.  The following will show your disk space usage:  du -s ~ 1. Learn Unix Commands Coming into the course, you are expected to be comfortable with Unix commands. Try all the commands of the Minimal List of Unix Commands  You cannot claim to be Unix-familiar unless you have used them all a few times.  Use script (read man script) to demonstrate that you invoked  the commands.  A few commands cannot be run unless you are super user; for such commands, just capture its message. Turn this file in as a file named cmdsTried.txt. 2. Studying a Program By the time P1 is due, we would have covered the process management necessary for this project. The tar ball source.tbz is a collection of files given so that (i) you can get started quickly with our project, and (ii) you can see the style of how larger systems programs are written. Download source.tbz from the link above.  In the OSIS Lab, it can be un-tar-ed as follows:  tar xvvfj source.tbz The functionality of  source.tbz  is described in What Is Given. Some details of the code are/were explained in the lectures and in ReadMe.txt. Study the provided source code so thoroughly that you could have written it. At this point, you can focus on the files fs33types.hpp and shell.cppThen, answer the itemized questions below in a file named answers.txt. 1. The following are standard library routines: dup2, creat, pipe, fork, pthread_create, system, printf Look up their functionality in both the Stevens' book and the on-line man pages.  Describe their functionality briefly, one sentence each, in your own words. 2. In the file shell.cpp, what is the point of the last line of the function invokeCmd? 3. Learn to Use GDB Coming into the course, you are expected to be comfortable with gdb. Debugging large programs requires the construction of (extra) observer methods. Using gdb or some other debugger is not as effective as invoking observers and studying their output in a peaceful place ("under a tree"). Nevertheless, gdb can be useful as a last resort, and you must be able to use it well. 1. Start script. Make P0 as given. Run our program P0 through gdb. 2. Set a breakpoint at immediately after main()  Examine the values of buf, arg, types, nArgs while tracing down the code 3. Type in a command to our shell, such as mkfs D1. Trace the execution from the above breakpoint onwards by single stepping until you reach the end of the fucntion invokeCmd. 4. Type in !ls request and trace. Do you notice a difference? 5. End the script.  Turn in this script as a file named gdbSession.txt 4. Additions and Improvements Part of large program development is independently, but wisely, deciding what to do for certain "erroneous" situations. Should we ask the professor for what to do for every possible error you can think of? [Answer: No. You think about it. You take a reasonable action. You document this in your source code, and in ReadMe.txt. And, be ready to defend your choice should it be questioned.] Remember that one of the goals of CEG 433/633 is to make you think about larger programs. Part of this is to supply missing, but needed, details in the problem description. 4.0 What Is Given As given, the files of source.tbz implement the following.  fs33% mkfs D1 creates an initially empty file volume on the simulated disk named D1.dsk. At this point, we do not need to discuss all the specifics anout the structure of the disk fs33% ls prints a listing, much like the Unix ls -lisa, of all the files in the root directory of the current file volume. Here is a stdTestScriptP1.txt.  Use it as in ./P0 < stdtestscriptp1.txt .="" 4.1="" redirection="" implement="" redirection="" for="" the="" given="" shell="" as="" discussed="" in="" class.="" use="" the="" operator =""> to redirect the output of a command into a file on the host's file system. It is safe to assume that the redirection operator appears only once in the command line. 4.2 Piping Implement piping as discussed in class for commands executed on the host. For example, the command ls | !cat executes both commands on the host. However, the piping needs to be performed in your shell! It is sufficent if your shell supports single piping, i.e. the concatenation of two commands. Bonus points are available if you achieve multiple piping. 4.3 Executing in the background Allow your shell to execute commands in the background using the &. The command prompt should return immediately after issuing the command no matter how long the execution takes. It is safe to assume that the character & only appears once in the command. Your shell should support the execution of all types of commands in the background, i.e. local commands operating on the virtual file system as well as commands running on the host. 4.4 A Simple Test Session Only the additional elements compared to the given source code are described below.   Add these appropriately to the test script.  Our path name syntax is the same as Unix path names.   Obviously, not every arbitrary string is a valid path or name.  Also, the dot and the dot-dot are not permissible as arguments in some contexts below.  Nevertheless these commands must be robust. fs33% ls > test lists the contents of the current directory of our own file system and redirects the output into the file test of the local directory of the host's file system. fs33% ls | !cat pipes the output of ls into the local command cat. fs33% !cat test shows the contents of the file test of the host's file system (which should contain the output of ls if previously executed as above). fs33% !sleep 15 & waits 15 seconds (since it is executed in the background the command prompt should be available immediately, though). Assignment_1/ReadMe.txt CEG 433/633 P0 ReadMe.txt [email protected] The files in this directory constitute a simple implementation of a file system written in C++, but using minimal features of OOP. Efficiency or good OOP style was not a goal. But, illustrating good systems programming style was a goal. The code segments that invoke TODO() are for you to develop in later projects. The design follows faithfully the details of i-node based file volumes, described in the lectures. So, these notes highlight only the non-obvious. Robustness: There are a few robustness checks that I often omitted in order to keep the main logic of the code clear. E.g., we *should* check that the new operator does return a non-0 pointer. Several buffers are declared to be 1024 or so long; even so, we must check that these not overflowing. The methods named create() and reCreate() are our "constructors." The name create is used when the simulated disk is "fresh" and a file volume is yet to be made out of it. The name reCreate is used when re-creating the objects from the file volume image that is already present on the sim disk. Similarly, the methods named destroy() are destructors. As explained in the lectures, this gives us greater control over when the objects are initialized and finalized. iNodes.cpp: A well designed class has an invariant that holds true for all methods except the constructors and destructors. Make sure that you understand the following class invariant: (i) No block number appears more than once in the i-nodes. (ii) If a 0 appears as a block number in an i-node or indirect blocks, all subsequent entries for that file must be 0 also. (iii) If fbvb[x] == 1, then block numbered x must not apear in any i-node direct entries, or indirect blocks, and (iv) if an x appears any i-node direct entries, or indirect blocks, then fbvb[x] must be 0. Note that in our design, (i) a single iNode must never be bigger than a single disk block, and (ii) a block contains a fixed number (iNodesPerBlock) of iNodes snugly, i.e., iNodesPerBlock * iHeight * iWidth == nBytesPerBlock. There is no class for a single iNode. Instead, one block of iNodes at a time is loaded from disk into uintBuffer, and the variable named pin (pointer to iNode) points into uintBuffer as an array of iNode entries. The method getINode(n, 0) calculates this pointer for iNode numbered n. pin[0], pin[1], ... , pin[iDirect-1] are direct block numbers; pin[iDirect]is the single indirect block number; pin[iDirect+1] is the double indirect block number; pin[iDirect+2]is the triple indirect block number; pin[iHeight - 1] is fileSize; Note how the various numbers (double-indirect, filesize, e.g.) are stored at different positions in the i-node. The iNode width is assumed to be 4 bytes. I used a trivial heuristic to decide the number of indirect entries. When we create a fresh iNode, all its entries must be zero. But as we free and re-use iNodes we must be sure that the iNode is zeroed out before reuse. volume.cpp: Note that that one block equals one sector. For now. For you TODO: How will you verify that there is indeed a previously made file volume on a simDisk? The code given in this solution is valid but *weak*. directory.cpp: The dirEntry is allocated in the
Answered 6 days AfterSep 25, 2021

Answer To: Assignment_1/A Minimal List of Unix Commands.txt A Minimal List of Unix Commands: bashBourne-Again...

Ali Asgar answered on Oct 01 2021
134 Votes
cmdsTried.txt
Script started on 2021-10-01 06:20:52-04:00 [TERM="xterm-256color" TTY="/dev/pts/0" COLUMNS="237" LINES="53"]

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31mc�[0m�[39m�[38;2;153;153;153mhmod 777 secureapp�[39m�[18D��[1m�[31mc�[1m�[31ma�[0m�[39m�[38;2;153;153;153mt�[38;2;153;153;153m �[38;2;153;153;153mu�[38;2;153;153;153mn�[38;2;153;153;153mf�[38;2;153;153;153ma�[38;2;153;153;153mi�[38;2;153;153;153mr�[38;2;153;153;153m_�[38;2;153;153;153mg�[38;2;153;153;153ma�[38;2;153;153;153mm�[38;2;153;153;153me�[38;2;153;153;153m.�[38;2;153;153;153mc�[38;2;153;153;153m �[38;2;153;153;153m|�[38;2;153;153;153m grep FLAG�[39m�[27D���[0m�[32mc�[0m�[32ma�[32mt�[39m�[39m
Completing file
�[01;32mA\ Minimal\ List\ of\ Unix\ Commands.txt�[0m* �[01;34mP0-2020-Fall�[0m/ �[01;32mReadMe.txt�[0m* �[01;32mstdTestScriptP1.txt�[0m*
�[J�[01;32mAssignment\ 1.docx�[0m* �[Jques1.log �[J�[01;32msource.tar.bz2�[0m* �[J �[3A�[0m�[27m�[24m�[0m�[39m
�[4C�[32mcat�[39m �[38;2;153;153;153munfair_game.c | grep FLAG�[39m�[K�[0m�[39m�[25D��[39mr�[38;2;153;153;153mo�[38;2;153;153;153mc�[38;2;153;153;153mk�[38;2;153;153;153my�[38;2;153;153;153mo�[38;2;153;153;153mu�[38;2;153;153;153m.�[38;2;153;153;153mt�[38;2;153;153;153mx�[38;2;153;153;153mt�[38;2;153;153;153m �[38;2;153;153;153m|�[38;2;153;153;153m �[38;2;153;153;153mg�[38;2;153;153;153mr�[38;2;153;153;153me�[38;2;153;153;153mp�[38;2;153;153;153m �[38;2;153;153;153m-�[38;2;153;153;153mo�[38;2;153;153;153mP�[38;2;153;153;153m �[38;2;153;153;153m"�[38;2;153;153;153m^�[38;2;153;153;153m[[:alnum:]]{32}" > newpass.txt�[39m�[54D�[39me�[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[53Dad�����[4mR�[4me�[4ma�[4md�[4mMe.txt�[24m�[1m �[0m��[0m ��[?1l�>�[?2004l
�[JCEG 433/633 P0 ReadMe.txt
[email protected]
The files in this directory constitute a simple implementation of a
file system written in C++, but using minimal features of OOP.
Efficiency or good OOP style was not a goal. But, illustrating good
systems programming style was a goal.
The code segments that invoke TODO() are for you to develop in later
projects.
The design follows faithfully the details of i-node based file
volumes, described in the lectures. So, these notes highlight only
the non-obvious.
Robustness: There are a few robustness checks that I often omitted in
order to keep the main logic of the code clear. E.g., we *should*
check that the new operator does return a non-0 pointer. Several
buffers are declared to be 1024 or so long; even so, we must check
that these not overflowing.
The methods named create() and reCreate() are our "constructors." The
name create is used when the simulated disk is "fresh" and a file
volume is yet to be made out of it. The name reCreate is used when
re-creating the objects from the file volume image that is already
present on the sim disk. Similarly, the methods named destroy() are
destructors. As explained in the lectures, this gives us greater
control over when the objects are initialized and finalized.
iNodes.cpp:
A well designed class has an invariant that holds true for all methods
except the constructors and destructors. Make sure that you understand
the following class invariant: (i) No block number appears more than
once in the i-nodes. (ii) If a 0 appears as a block number in an
i-node or indirect blocks, all subsequent entries for that file must
be 0 also. (iii) If fbvb[x] == 1, then block numbered x must not
apear in any i-node direct entries, or indirect blocks, and (iv) if an
x appears any i-node direct entries, or indirect blocks, then fbvb[x]
must be 0.
Note that in our design, (i) a single iNode must never be bigger than
a single disk block, and (ii) a block contains a fixed number
(iNodesPerBlock) of iNodes snugly, i.e., iNodesPerBlock * iHeight *
iWidth == nBytesPerBlock.
There is no class for a single iNode. Instead, one block of iNodes at
a time is loaded from disk into uintBuffer, and the variable named pin
(pointer to iNode) points into uintBuffer as an array of iNode
entries. The method getINode(n, 0) calculates this pointer for iNode
numbered n.
pin[0], pin[1], ... , pin[iDirect-1] are direct block numbers;
pin[iDirect]    is the single indirect block number;
pin[iDirect+1]     is the double indirect block number;
pin[iDirect+2]    is the triple indirect block number;
pin[iHeight - 1] is fileSize;
Note how the various numbers (double-indirect, filesize, e.g.) are
stored at different positions in the i-node.
The iNode width is assumed to be 4 bytes. I used a trivial heuristic
to decide the number of indirect entries.
When we create a fresh iNode, all its entries must be zero. But as we free
and re-use iNodes we must be sure tha
t the iNode is zeroed out before
reuse.
volume.cpp:
Note that that one block equals one sector. For now.
For you TODO: How will you verify that there is indeed a previously
made file volume on a simDisk? The code given in this solution is
valid but *weak*.
directory.cpp:
The dirEntry is allocated in the (re)creates. It is used to return a
directory entry (pair of file-name string followed by the inumber).
Class invariant: (i) Every directory has the dot and dot-dot
entries. (ii) No name appears more than once. (iii) No name is empty,
or contains illegal (such as blanks, tabs, slash) chars.
shell.cpp:
Several unrelated routines (e.g., TODO, (un)packNumber) are collected
here just to keep the total number of files low.
Note that doMakeDiskArgs(Arg * a) no longer (cf. P0) writes to
diskparams.dat
Note that mkfs subsumes the mkdisk command.
-eof-
�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31mc�[0m�[39m�[38;2;153;153;153mat ReadMe.txt�[39m�[13D��[1m�[31mc�[1m�[31ma�[0m�[39m���[0m�[32mc�[0m�[32ma�[32mt�[39m�[39m
Completing file
�[01;32mA\ Minimal\ List\ of\ Unix\ Commands.txt�[0m* �[01;34mP0-2020-Fall�[0m/ �[01;32mReadMe.txt�[0m* �[01;32mstdTestScriptP1.txt�[0m*
�[J�[01;32mAssignment\ 1.docx�[0m* �[Jques1.log �[J�[01;32msource.tar.bz2�[0m* �[J �[3A�[0m�[27m�[24m�[0m�[39m
�[4C�[32mcat�[39m �[38;2;153;153;153mReadMe.txt�[39m�[K�[0m�[39m�[10D��[39m�[4ms�[24m�[38;2;153;153;153me�[38;2;153;153;153mc�[38;2;153;153;153mu�[38;2;153;153;153mr�[38;2;153;153;153me�[38;2;153;153;153ma�[38;2;153;153;153mp�[38;2;153;153;153mp�[39m�[39m �[9D��[4ms�[39m�[4mt�[24m�[39m �[39m �[39m �[39m �[39m �[39m �[39m ���������[4mt�[4mdTestScriptP1.txt�[24m�[1m �[0m��[0m ��[?1l�>�[?2004l
�[J# stdTestScriptP0.txt
!rm -f test
mkfs D2
ls
ls > test
ls | cat
!cat test
!time
!sleep 15 &
!time
quit
�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31mc�[0m�[39m�[38;2;153;153;153mat stdTestScriptP1.txt�[39m�[22D��[1m�[31mc�[1m�[31ma�[0m�[39m���[0m�[32mc�[0m�[32ma�[32mt�[39m�[39m
Completing file
�[01;32mA\ Minimal\ List\ of\ Unix\ Commands.txt�[0m* �[01;34mP0-2020-Fall�[0m/ �[01;32mReadMe.txt�[0m* �[01;32mstdTestScriptP1.txt�[0m*
�[J�[01;32mAssignment\ 1.docx�[0m* �[Jques1.log �[J�[01;32msource.tar.bz2�[0m* �[J �[3A�[0m�[27m�[24m�[0m�[39m
�[4C�[32mcat�[39m �[38;2;153;153;153mstdTestScriptP1.txt�[39m�[K�[0m�[39m�[19D��[39ma�[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[18D\� ���[38;2;153;153;153ms�[38;2;153;153;153mtdTestScriptP1.txt�[39m�[19D�[39m�[4mA�[24m�[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[18D��[4mA�[4m\�[24m
�[J�[A�[10C���[4mA�[24m�[24m ���[24m�[38;2;153;153;153ms�[38;2;153;153;153mtdTestScriptP1.txt�[39m�[19D�[39m�[4mA�[24m�[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[18D��[4mA�[4m\�[24m��[4m\�[4m �[24m����[24mA�[24m\�[24m M� ������[4mA�[4m\�[4m �[24m��[4m �[4mM�[24m��[4mM�[4mi�[24m��[4mi�[4mnimal\ List\ of\ Unix\ Commands.txt�[24m�[1m �[0m��[0m ��[?1l�>�[?2004l
�[JA Minimal List of Unix Commands:
bash    Bourne-Again Shell
bg    background
cat    show each file in sequence
chmod    change the permission on a file
chown    change the owner of a file
cmp    compare two files
df    show mounted volumes, etc
du    show disk blocks used for one or more directories
emacs    the all-powerful text/binary editor; try xemacs also
env    lists the current environment variables
fg    foreground
grep    print lines matching a pattern
kill    kills a running program
ln    creates a link between two files; try ln -s
ls    list contents of directory; try ls -lisa
make    maintain, update, and regenerate related programs and files
man    show reference manual pages; try man -k
mkfs    make (construct) a file volume
nohup    run a command immune to hangups
od    octal dump; try od -x file-name
ps    shows current processes
set    set/get and show the values of shell variables
source    shell built-in: execute the cmds in a file
time    a prefix to commands, times the command and prints page faults etc.
umask    get/set the file mode creation mask
w    who is on the system, and what they are doing
�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[?1l�>�[?2004l

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[32mw�[39m�[?1l�>�[?2004l
06:22:36 up 1 day, 5:33, 1 user, load average: 0.01, 0.05, 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
kali tty7 :0 Tue10 3days 38:46 1.01s xfce4-session

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31mp�[0m�[39m�[38;2;153;153;153mython3 bof_demo/new.py�[39m�[22D��[0m�[32mp�[32ms�[39m�[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[21D�[?1l�>�[?2004l
PID TTY TIME CMD
19694 pts/1 00:00:00 zsh
19722 pts/1 00:00:00 ps

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[32ml�[39m�[38;2;153;153;153ms�[39m���[32ml�[32ms�[39m �[35m-�[39m��[35m-�[35ml�[39m��[35ml�[35mi�[39m��[35mi�[35ms�[39m��[35ms�[35ma�[39m�[?1l�>�[?2004l
total 72
4458609 4 drwxr-xr-x 3 kali kali 4096 Oct 1 06:20 �[0m�[01;34m.�[0m
4456450 4 drwxr-xr-x 26 kali kali 4096 Oct 1 06:20 �[01;34m..�[0m
4459403 4 -rwxrwx--- 1 kali kali 1086 Oct 1 03:13 �[01;32m'A Minimal List of Unix Commands.txt'�[0m
4459494 20 -rwxrwx--- 1 kali kali 19394 Oct 1 03:13 �[01;32m'Assignment 1.docx'�[0m
4469377 4 drwx------ 2 kali kali 4096 Nov 7 2020 �[01;34mP0-2020-Fall�[0m
4469651 12 -rw-r--r-- 1 kali kali 12288 Oct 1 06:22 ques1.log
4468922 4 -rwxrwx--- 1 kali kali 3947 Oct 1 03:13 �[01;32mReadMe.txt�[0m
4469000 16 -rwxrwx--- 1 kali kali 15916 Oct 1 03:13 �[01;32msource.tar.bz2�[0m
4469028 4 -rwxrwx--- 1 kali kali 112 Oct 1 03:13 �[01;32mstdTestScriptP1.txt�[0m

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[?1l�>�[?2004l

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31md�[0m�[39m��[0m�[32md�[32mf�[39m�[?1l�>�[?2004l
Filesystem 1K-blocks Used Available Use% Mounted on
udev 721904 0 721904 0% /dev
tmpfs 151424 936 150488 1% /run
/dev/sda1 81000912 10789128 66051172 15% /
tmpfs 757120 0 757120 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
Kali 255998972 113044772 142954200 45% /media/sf_Kali
tmpfs 151424 76 151348 1% /run/user/1000

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31mb�[0m�[39m��[1m�[31mb�[1m�[31ma�[0m�[39m���[1m�[31mb�[1m�[31ma�[1m�[31ms�[0m�[39m����[0m�[32mb�[0m�[32ma�[0m�[32ms�[32mh�[39m�[?1l�>�[?2004l
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m ��
�[?2004l
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m
�[?2004l
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m �bg ?��[K-h�
�[?2004l
bash: bg: -h: invalid option
bg: usage: bg [job_spec ...]
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m bg
�[?2004l
bash: bg: current: no such job
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m fg
�[?2004l
bash: fg: current: no such job
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m du
�[?2004l
100    ./P0-2020-Fall
168    .
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m ��env
�[?2004l
SHELL=/usr/bin/zsh
SESSION_MANAGER=local/kali:@/tmp/.ICE-unix/6239,unix/kali:/tmp/.ICE-unix/6239
WINDOWID=0
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
XDG_MENU_PREFIX=xfce-
LANGUAGE=
LESS_TERMCAP_se=�[0m
LESS_TERMCAP_so=�[01;33m
POWERSHELL_TELEMETRY_OPTOUT=1
SSH_AUTH_SOCK=/tmp/ssh-CPqBRvu3QUjt/agent.6239
DESKTOP_SESSION=lightdm-xsession
SSH_AGENT_PID=6322
GTK_MODULES=gail:atk-bridge
XDG_SEAT=seat0
PWD=/home/kali/unixfs
XDG_SESSION_DESKTOP=lightdm-xsession
LOGNAME=kali
QT_QPA_PLATFORMTHEME=qt5ct
XDG_SESSION_TYPE=x11
XAUTHORITY=/home/kali/.Xauthority
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/kali
COMMAND_NOT_FOUND_INSTALL_PROMPT=1
GDM_LANG=en_US.utf8
HOME=/home/kali
LANG=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
XDG_CURRENT_DESKTOP=XFCE
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
TERM=xterm-256color
LESS_TERMCAP_mb=�[1;31m
LESS_TERMCAP_me=�[0m
LESS_TERMCAP_md=�[1;36m
USER=kali
COLORFGBG=15;0
DISPLAY=:0.0
LESS_TERMCAP_ue=�[0m
SHLVL=3
LESS_TERMCAP_us=�[1;32m
XDG_VTNR=7
XDG_SESSION_ID=69
XDG_RUNTIME_DIR=/run/user/1000
QT_AUTO_SCREEN_SCALE_FACTOR=0
XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
GDMSESSION=lightdm-xsession
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
_JAVA_OPTIONS=-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
OLDPWD=/home/kali/unixfs
_=/usr/bin/env
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m ema�acs
�[?2004l
emaacs: command not found
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m emacs
�[?2004l
Command 'emacs' not found, did you mean:
command 'jmacs' from deb joe
command 'jmacs' from deb joe-jupp
Try: sudo apt install
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m kill
�[?2004l
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m ps
�[?2004l
PID TTY TIME CMD
19694 pts/1 00:00:00 zsh
19733 pts/1 00:00:00 bash
19840 pts/1 00:00:00 ps
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m kil ��[Kl 19733
�[?2004l
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m
�[?2004l
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m
�[?2004l
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m max��[Kn emacs
�[?2004l
No manual entry for emacs
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m �man no hu�p
�[?2004l
No manual entry for no
No manual entry for hup
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m man no hup�����[C=hup�����[1Phup�����[1Phup���
�[?2004l
�[?1049h�[22;0;0t�[?1h�=
NOHUP(1) User Commands NOHUP(1)�[m
�[m
�[1;36mNAME�[0m�[m
nohup - run a command immune to hangups, with output to a non-tty�[m
�[m
�[1;36mSYNOPSIS�[0m�[m
�[1;36mnohup�[0m �[1;32mCOMMAND�[0m [�[1;32mARG�[0m]...�[m
�[1;36mnohup�[0m �[1;32mOPTION�[0m�[m
�[m
�[1;36mDESCRIPTION�[0m�[m
Run COMMAND, ignoring hangup signals.�[m
�[m
�[1;36m--help�[0m display this help and exit�[m
�[m
�[1;36m--version�[0m�[m
output version information and exit�[m
�[m
If standard input is a terminal, redirect it from an unreadable file. If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it to�[m
standard output. To save output to FILE, use 'nohup COMMAND > FILE'.�[m
�[m
NOTE: your shell may have its own version of nohup, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.�[m
�[m
�[1;36mAUTHOR�[0m�[m
Written by Jim Meyering.�[m
�[m
�[1;36mREPORTING�[0m �[1;36mBUGS�[0m�[m
GNU coreutils online help: �[m
Report any translation bugs to �[m
�[m
�[1;36mCOPYRIGHT�[0m�[m
Copyright © 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later .�[m
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.�[m
�[m
�[1;36mSEE�[0m �[1;36mALSO�[0m�[m
Full documentation �[m
or available locally via: info '(coreutils) nohup invocation'�[m
�[m
GNU coreutils 8.32 September 2020 NOHUP(1)�[m
�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KB�B
�[K�
�[K�[01;33m Manual page nohup(1) line 1/38 (END) (press h for help or q to quit)�[0m�[K
�[K�[?1l�>�[?1049l�[23;0;0t
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m
�[?2004l
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m �man bg
�[?2004l
No manual entry for bg
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m man fg
�[?2004l
No manual entry for fg
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m cay ��[K��[Kt /�
bin/ .cache/ etc/ initrd.img lib/ lib64/ lost+found/ mnt/ proc/ run/ srv/ tmp/ var/ vmlinuz.old
boot/ dev/ home/ initrd.img.old lib32/ libx32/ media/ opt/ root/ sbin/ sys/ usr/ vmlinuz
�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m cat /��[K��[K��[K��[K��[K���ls
�[?2004l
�[0m�[01;32m'A Minimal List of Unix Commands.txt'�[0m �[01;32m'Assignment 1.docx'�[0m �[01;34mP0-2020-Fall�[0m ques1.log �[01;32mReadMe.txt�[0m �[01;32msource.tar.bz2�[0m �[01;32mstdTestScriptP1.txt�[0m
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m cd��[Kat /p��[KP0���[K��[K��[K��[K Po��[K0-2020-Fall/f�a���[Ks33types.hpp
�[?2004l
/*
* fs33types.hpp of CEG 433/633 File Sys Project
* [email protected]
*/
#include         // not all these are needed every where,
#include         // but we take the simple way out
#include
#include
#include
typedef unsigned char byte;
typedef unsigned short int ushort;
typedef unsigned int uint;
typedef unsigned long int ulong;
enum { LabelSZ = 15, SectorsMAX = 2048, BytesPerSectorMAX = 4096 };
uint TODO();
uint TODO(char * p);
uint bytesNeeded(uint);
ulong unpackNumber(void * p, uint width);
void * packNumber(void * p, ulong n, uint width);
uint isAlphaNumDot(char c);
class FileVolume;        // forward declaration
class SimDisk {
public:
byte name[LabelSZ + 1];
uint nSectorsPerDisk;
uint nBytesPerSector;
uint simDiskNum;
SimDisk(byte * simDiskName, uint diskNumber);
uint isOK();
uint writeSector(uint nSector, void * p);
uint readSector(uint nSector, void * p);
FileVolume * make33fv(uint nInodes, uint htInode, uint nSecPerBlock);
FileVolume * make33fv();
private:
int makeDiskImage();
int openDiskImage(uint mode);
class DiskParams {
public:
uint maxfnm, nInodes, iHeight;
} diskParams;
};
class SuperBlock {        // RAM resident
public:
uint nTotalBlocks;
uint nBytesPerBlock;        // must == nSecPerBlock * nBytesPerSector
uint nSecPerBlock;
uint nBlocksFbvBlocks;    // #blocks occupied by fbv of blocks
uint nBlocksFbvInodes;    // #blocks occupied by fbv of inodes
uint nBlockBeginInodes;    // where do the i-nodes begin?
uint nBlocksOfInodes;        // #blocks on disk occupied by i-nodes
uint inodesPerBlock;        // one block will contain this many inodes
uint nInodes;            // total number of inodes
uint iWidth;            // inode size on disk == iWidth * iHeight
uint iHeight;            // iHeight includes size, and type fields
uint iDirect;            // 0 <= iIndirect <= 3
uint nBlockBeginFiles;    // == nBlockBeginInodes + nBlocksInode
uint fileNameLengthMax;
};
class BitVector {
public:
uint create(FileVolume * fv, uint nBits, uint nBeginBlock);
uint reCreate(FileVolume * fv, uint nBits, uint nBeginBlock);
uint getBit(uint indexOfBit);
void setBit(uint indexOfBit, uint newValue);
uint getFreeBit();
private:
uint nBits;            // #bits in this vector
uint nBlockBegin;        // at what block does the vector begin?
byte *bitVector;        // ptr to one block-long area of mem
FileVolume * fv;
};
enum {iTypeOrdinary = 1, iTypeDirectory = 2, iTypeSoftLink = 3};
class Inodes {
public:
uint create(FileVolume * fv, uint nBegin, uint nInodes, uint htInode);
uint reCreate(FileVolume * fv);    // in == i-node number
uint getFree();
uint setFree(uint in);
uint getBlockNumber(uint in, uint nth);
uint addBlockNumber(uint in, uint bn);
uint setLastBlockNumber(uint in, uint bn);
uint getFileSize(uint in);
uint setFileSize(uint in, uint sz);
uint incFileSize(uint in, int increment);
uint getType(uint in);
uint setType(uint in, uint value);
uint show(uint in);
private:
uint * uintbuffer;        // inodes from one block
FileVolume * fv;
uint *getInode(uint in, uint * ne);    // return ptr to inode in
uint putInode(uint in);
uint getEntry(uint in, uint x);
uint setEntry(uint in, uint x, uint tp);
uint getBlockNumberTripleIndirect(uint bn, uint nth);
uint getBlockNumberDoubleIndirect(uint bn, uint nth);
uint getBlockNumberSingleIndirect(uint bn, uint nth);
uint setSingleIndirect(uint * pbn, uint nu, uint bn);
uint setDoubleIndirect(uint * pbn, uint nu, uint bn);
uint setTripleIndirect(uint * pbn, uint nu, uint bn);
};
class File {
public:
uint nInode;            // inode number of this file
File(FileVolume * fv, uint nInode);
~File();
uint readBlock(uint xthBlock, void * p);
uint writeBlock(uint xthBlock, void * p);
uint getNextByte();
uint appendOneBlock(void * p, uint iz);
uint appendBytes(byte *newContent, uint nBytes);
uint deletePrecedingBytes(uint howManyBytes);
private:
                // bsz is tentatively added, TBD
uint bsz;            // == fv->superBlock.nBytesPerBlock
uint nBlocksSoFar;
byte * fileBuf;        // buffer for read/writes
uint nBytesInFileBuf;
uint xNextByte;        // index of next byte in fileBuf
FileVolume * fv;
uint fillLastBlock(byte *newContentBp, uint nBytes);
};
class Directory {
public:
uint nInode;            // inode number of this directory
byte * dirEntry;        // area of mem for file name + i-num
Directory(FileVolume * fv, uint in, uint parent);
~Directory();
uint iNumberOf(byte *leafnm);
byte * nameOf(uint in);
void addLeafName(byte * leafnm, uint in);
uint createFile(byte * leafnm, uint dirFlag);
uint deleteFile(byte * leafnm, uint releaseFlag);
uint moveFile(uint pn, byte * leafnm);
uint ls();
FileVolume * fv;
private:
File * dirf;            // this dir viewed as a normal file
void namesEnd();        // done with file names
byte * nextName();
uint setDirEntry(byte * name);
uint lsPrivate(uint in, uint printfFlag);
};
class FileVolume {
public:
SimDisk * simDisk;
SuperBlock superBlock;
BitVector fbvBlocks;
BitVector fbvInodes;
Inodes inodes;
Directory * root;
FileVolume(SimDisk * simDisk, uint nInodes, uint szInode, uint nSecPerBlock);
FileVolume(uint diskNumber);
~FileVolume();
uint isOK();
File * findFile(byte * leafnm);
uint read33file(byte * fs33leafnm, byte * unixFilePath);
uint write33file(byte * unixFilePath, byte * fs33leafnm);
uint copy33file(byte * from33leafnm, byte * to33leafnm);
uint deleteFile(byte * fs33leafnm);
uint move(uint pn, byte * srcleafnm, uint wn, uint jn, byte * dstleafnm);
File * createFile(byte * leafnm, uint dirFlag);
uint writeBlock(uint nBlock, void * p);
uint readBlock(uint nBlock, void * p);
uint getFreeBlock();
private:
uint rdwrBlock(uint nBlock, void *p, uint writeFlag);
};
// VNIN -- volume# i#
typedef unsigned long VNIN;
#define mkVNIN(x, y) (VNIN) (x << 16 | y)
#define volumeNumber(a) (uint)(a >> 16)
#define inodeNumber(a) (uint)(a & 0xFFFF)
class MountEntry {
public:
MountEntry(VNIN which, VNIN where);
~MountEntry();
byte * pathName(VNIN vnjn);
VNIN pathNameVNIN(byte *pathnm, VNIN vnjn);
uint move(byte * srcPathName, byte * dstPathName);
VNIN createFile(byte *fs33name, uint dirFlag);
uint write33file(byte *unixFilePath, byte *fs33name);
uint read33file(byte * fs33leafnm, byte * unixFilePath);
uint copy33file(byte *from33name, byte *to33name);
uint rm(byte *pathnm, uint freeInodeFlag);
VNIN setCwd(byte * pnm);
VNIN mount(uint volNumber, byte * mountPath);
VNIN umount(byte * mountPath, uint volNumber);
VNIN rootVNIN();
uint print();
private:
VNIN which;            // num of volume mounted, i# == 1
VNIN where;            // above volume is mounted here
MountEntry * next;        // stack
VNIN whatIsMountedAt(VNIN mp);
VNIN whereMounted(VNIN vnin);
uint isDir(VNIN vnin);
VNIN leafNameVNIN(byte * leafName, VNIN vnin);
VNIN lastParentDir(byte *pnm, byte ** leafnm);
VNIN parentOf(VNIN vnjn);
void iPathName(VNIN vnjn);
};
// -eof-
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m cat P-��[K0-2020-Fall/sh�ell.cpp
�[?2004l
/*
* shell.C -- CEG433 File Sys Project shell
* [email protected]
*/
#include "fs33types.hpp"
extern MountEntry *mtab;
extern VNIN cwdVNIN;
FileVolume * fv; // Suspicious!
Directory * wd; // Suspicious!
#define nArgsMax 10
char types[1+nArgsMax];        // +1 for \0
/* An Arg-ument for one of our commands is either a "word" (a null
* terminated string), or an unsigned integer. We store both
* representations of the argument. */
class Arg {
public:
char *s;
uint u;
} arg[nArgsMax];
uint nArgs = 0;
uint TODO()
{
printf("to be done!\n");
return 0;
}
uint TODO(char *p)
{
printf("%s to be done!\n", p);
return 0;
}
uint isDigit(char c)
{
return '0' <= c && c <= '9';
}
uint isAlphaNumDot(char c)
{
return c == '.' || 'a' <= c && c <= 'z'
|| 'A' <= c && c <= 'Z' || '0' <= c && c <= '9';
}
int toNum(const char *p)
{
return (p != 0 && '0' <= *p && *p <= '9' ? atoi(p) : 0);
}
SimDisk * mkSimDisk(byte *name)
{
SimDisk * simDisk = new SimDisk(name, 0);
if (simDisk->nSectorsPerDisk == 0) {
printf("Failed to find/create simDisk named %s\n", name);
delete simDisk;
simDisk = 0;
}
return simDisk;
}
void doMakeDisk(Arg * a)
{
SimDisk * simDisk = mkSimDisk((byte *) a[0].s);
if (simDisk == 0)
return;
printf("new SimDisk(%s) = %p, nSectorsPerDisk=%d,"
     "nBytesPerSector=%d, simDiskNum=%d)\n",
     simDisk->name, (void*) simDisk, simDisk->nSectorsPerDisk,
     simDisk->nBytesPerSector, simDisk->simDiskNum);
delete simDisk;
}
void doWriteDisk(Arg * a)
{
SimDisk * simDisk = mkSimDisk((byte *) a[0].s);
if (simDisk == 0)
return;
char *st = a[2].s;        // arbitrary word
if (st == 0)            // if it is NULL, we use ...
st = "CEG433/633/Mateti";
char buf[1024];        // assuming nBytesPerSectorMAX < 1024
for (uint m = strlen(st), n = 0; n < 1024 - m; n += m)
memcpy(buf + n, st, m);    // fill with several copies of st
uint r = simDisk->writeSector(a[1].u, (byte *) buf);
printf("write433disk(%d, %s...) == %d to Disk %s\n", a[1].u, st, r, a[0].s);
delete simDisk;
}
void doReadDisk(Arg * a)
{
SimDisk * simDisk = mkSimDisk((byte *) a[0].s);
if (simDisk == 0)
return;
char buf[1024];        // assuming nBytesPerSectorMAX < 1024
uint r = simDisk->readSector(a[1].u, (byte *) buf);
buf[10] = 0;            // sentinel
printf("read433disk(%d, %s...) = %d from Disk %s\n", a[1].u, buf, r, a[0].s);
delete simDisk;
}
void doQuit(Arg * a)
{
exit(0);
}
void doEcho(Arg * a)
{
printf("%s#%d, %s#%d, %s#%d, %s#%d\n", a[0].s, a[0].u,
     a[1].s, a[1].u, a[2].s, a[2].u, a[3].s, a[3].u);
}
void doMakeFV(Arg * a)
{
SimDisk * simDisk = mkSimDisk((byte *) a[0].s);
if (simDisk == 0)
return;
fv = simDisk->make33fv();
printf("make33fv() = %p, Name == %s, Disk# == %d\n",
     (void*) fv, a[0].s, simDisk->simDiskNum);
if (fv) {
wd = new Directory(fv, 1, 0);
cwdVNIN = mkVNIN(simDisk->simDiskNum, 1);
}
}
void doCopyTo(byte* from, byte* to)
{
uint r = fv->write33file(to, from);
printf("write33file(%s, %s) == %d\n", to, from, r);
}
void doCopyFrom(byte* from, byte* to)
{
uint r = fv->read33file(to, from);
printf("read33file(%s, %s) == %d\n", to, from, r);
}
void doCopy33(byte* from, byte* to)
{
uint r = fv->copy33file(to, from);
printf("copy33file(%s, %s) == %d\n", to, from, r);
}
void doCopy(Arg * a)
{
byte* to = (byte *) a[0].s;
byte* from = (byte *) a[1].s;
if (a[0].s[0] == '@' && a[1].s[0] != '@') {
doCopyTo(from, (to + 1));
}
else if (a[0].s[0] != '@' && a[1].s[0] == '@') {
doCopyFrom((from + 1), to);
}
else if (a[0].s[0] != '@' && a[1].s[0] != '@') {
doCopy33(from, to);
}
else {
puts("Wrong arguments to cp.");
}
}
void doLsLong(Arg * a)
{
printf("\nDirectory listing for disk %s, cwdVNIN == 0x%0lx begins:\n",
     wd->fv->simDisk->name, (ulong) cwdVNIN);
wd->ls(); // Suspicious!
printf("Directory listing ends.\n");
}
void doRm(Arg * a)
{
uint in = wd->fv->deleteFile((byte *) a[0].s);
printf("rm %s returns %d.\n", a[0].s, in);
}
void doInode(Arg * a)
{
uint ni = a[0].u;
wd->fv->inodes.show(ni);
}
void doMkDir(Arg * a)
{
TODO("doMkDir");
}
void doChDir(Arg * a)
{
TODO("doChDir");
}
void doPwd(Arg * a)
{
TODO("doPwd");
}
void doMv(Arg * a)
{
TODO("doMv");
}
void doMountDF(Arg * a)        // arg a ignored
{
TODO("doMountDF");
}
void doMountUS(Arg * a)
{
TODO("doMountUS");
}
void doUmount(Arg * a)
{
TODO("doUmount");
}
/* The following describes one entry in our table of commands. For
* each cmmdName (a null terminated string), we specify the arguments
* it requires by a sequence of letters. The letter s stands for
* "that argument should be a string", the letter u stands for "that
* argument should be an unsigned int." The data member (func) is a
* pointer to the function in our code that implements that command.
* globalsNeeded identifies whether we need a volume ("v"), a simdisk
* ("d"), or a mount table ("m"). See invokeCmd() below for exact
* details of how all these flags are interpreted.
*/
class CmdTable {
public:
char *cmdName;
char *argsRequired;
char *globalsNeeded;        // need d==simDisk, v==cfv, m=mtab
void (*func) (Arg * a);
} cmdTable[] = {
{"cd", "s", "v", doChDir},
{"cp", "ss", "v", doCopy},
{"echo", "ssss", "", doEcho},
{"inode", "u", "v", doInode},
{"ls", "", "v", doLsLong},
{"lslong", "", "v", doLsLong},
{"mkdir", "s", "v", doMkDir},
{"mkdisk", "s", "", doMakeDisk},
{"mkfs", "s", "", doMakeFV},
{"mount", "us","", doMountUS},
{"mount", "", "", doMountDF},
{"mv", "ss", "v", doMv},
{"rddisk", "su", "", doReadDisk},
{"rmdir", "s", "v", doRm},
{"rm", "s", "v", doRm},
{"pwd", "", "v", doPwd},
{"q", "", "", doQuit},
{"quit", "", "", doQuit},
{"umount", "u", "m", doUmount},
{"wrdisk", "sus", "", doWriteDisk}
};
uint ncmds = sizeof(cmdTable) / sizeof(CmdTable);
void usage()
{
printf("The shell has only the following cmds:\n");
for (uint i = 0; i < ncmds; i++)
printf("\t%s\t%s\n", cmdTable[i].cmdName, cmdTable[i].argsRequired);
printf("Start with ! to invoke a Unix shell cmd\n");
}
/* pre:: k >= 0, arg[] are set already;; post:: Check that args are
* ok, and the needed simDisk or cfv exists before invoking the
* appropriate action. */
void invokeCmd(int k, Arg *arg)
{
uint ok = 1;
if (cmdTable[k].globalsNeeded[0] == 'v' && cwdVNIN == 0) {
ok = 0;
printf("Cmd %s needs the cfv to be != 0.\n", cmdTable[k].cmdName);
}
else if (cmdTable[k].globalsNeeded[0] == 'm' && mtab == 0) {
ok = 0;
printf("Cmd %s needs the mtab to be != 0.\n", cmdTable[k].cmdName);
}
char *req = cmdTable[k].argsRequired;
uint na = strlen(req);
for (uint i = 0; i < na; i++) {
if (req[i] == 's' && (arg[i].s == 0 || arg[i].s[0] == 0)) {
ok = 0;
printf("arg #%d must be a non-empty string.\n", i);
}
if ((req[i] == 'u') && (arg[i].s == 0 || !isDigit(arg[i].s[0]))) {
    ok = 0;
    printf("arg #%d (%s) must be a number.\n", i, arg[i].s);
}
}
if (ok)
(*cmdTable[k].func) (arg);
}
/* pre:: buf[] is the command line as typed by the user, nMax + 1 ==
* sizeof(types);; post:: Parse the line, and set types[], arg[].s and
* arg[].u fields.
*/
void setArgsGiven(char *buf, Arg *arg, char *types, uint nMax)
{
for (uint i = 0; i < nMax; i++) {
arg[i].s = 0;
types[i] = 0;
}
types[nMax] = 0;
strtok(buf, " \t\n");        // terminates the cmd name with a \0
for (uint i = 0; i < nMax;) {
char *q = strtok(0, " \t");
if (q == 0 || *q == 0) break;
arg[i].s = q;
arg[i].u = toNum(q);
types[i] = isDigit(*q)? 'u' : 's';
nArgs = ++i;
}
}
/* pre:: name pts to the command token, argtypes[] is a string of
* 's'/'u' indicating the types of arguments the user gave;; post::
* Find the row number of the (possibly overloaded) cmd given in
* name[]. Return this number if found; return -1 otherwise. */
int findCmd(char *name, char *argtypes)
{
for (uint i = 0; i < ncmds; i++) {
if (strcmp(name, cmdTable[i].cmdName) == 0
    && strcmp(argtypes, cmdTable[i].argsRequired) == 0) {
return i;
}
}
return -1;
}
void ourgets(char *buf) {
fgets(buf, 1024, stdin);
char * p = index(buf, '\n');
if (p) *p = 0;
}
int main()
{
char buf[1024];        // better not type longer than 1023 chars
usage();
for (;;) {
*buf = 0;            // clear old input
printf("%s", "sh33% ");    // prompt
ourgets(buf);
printf("cmd [%s]\n", buf);    // just print out what we got as-is
if (buf[0] == 0)
continue;
if (buf[0] == '#')
continue;            // this is a comment line, do nothing
if (buf[0] == '!')        // begins with !, execute it as
system(buf + 1);        // a normal shell cmd
else {
setArgsGiven(buf, arg, types, nArgsMax);
int k = findCmd(buf, types);
if (k >= 0)
    invokeCmd(k, arg);
else
    usage();
}
}
}
// -eof-
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m man printf
�[?2004l
�[?1049h�[22;0;0t�[?1h�=
PRINTF(1) User Commands PRINTF(1)�[m
�[m
�[1;36mNAME�[0m�[m
printf - format and print data�[m
�[m
�[1;36mSYNOPSIS�[0m�[m
�[1;36mprintf�[0m �[1;32mFORMAT�[0m [�[1;32mARGUMENT�[0m]...�[m
�[1;36mprintf�[0m �[1;32mOPTION�[0m�[m
�[m
�[1;36mDESCRIPTION�[0m�[m
Print ARGUMENT(s) according to FORMAT, or execute according to OPTION:�[m
�[m
�[1;36m--help�[0m display this help and exit�[m
�[m
�[1;36m--version�[0m�[m
output version information and exit�[m
�[m
FORMAT controls the output as in C printf. Interpreted sequences are:�[m
�[m
\" double quote�[m
�[m
\\ backslash�[m
�[m
\a alert (BEL)�[m
�[m
\b backspace�[m
�[m
\c produce no further output�[m
�[m
\e escape�[m
�[m
\f form feed�[m
�[m
\n new line�[m
�[m
\r carriage return�[m
�[m
\t horizontal tab�[m
�[m
\v vertical tab�[m
�[m
\NNN byte with octal value NNN (1 to 3 digits)�[m
�[m
\xHH byte with hexadecimal value HH (1 to 2 digits)�[m
�[m
\uHHHH Unicode (ISO/IEC 10646) character with hex value HHHH (4 digits)�[m
�[m
\UHHHHHHHH�[m
Unicode character with hex value HHHHHHHH (8 digits)�[m
�[m
%% a single %�[m
�[m
�[01;33m Manual page printf(1) line 1 (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KA�A
�[K�
�[K�[01;33m Manual page printf(1) line 1 (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KA�A
�[K�
�[K�[01;33m Manual page printf(1) line 1 (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KA�A
�[K�
�[K�[01;33m Manual page printf(1) line 1 (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KA�A
�[K�
�[K�[01;33m Manual page printf(1) line 1 (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KA�A
�[K�
�[K�[01;33m Manual page printf(1) line 1 (press h for help or q to quit)�[0m�[K
�[K �[KESC���ESC�[KO�O�[KA�A
�[K�
�[K�[01;33m Manual page printf(1) line 1 (press h for help or q to quit)�[0m�[K
�[K�[?1l�>�[?1049l�[23;0;0t
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m
�[?2004l
�[?2004h�]0;kali@kali: ~/unixfs��[;32m┌──(�[1;34mkali㉿kali�[;32m)-[�[0;1m~/unixfs�[;32m]
�[;32m└─�[1;34m$�[0m exit
�[?2004l
exit

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[?1l�>�[?2004l

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[4mq�[24m�[38;2;153;153;153muit�[39m�����[4mq�[39m�[4mu�[24m���[24m�[1m�[31mq�[24m�[1m�[31mu�[1m�[31mi�[0m�[39m��[1m�[31mi�[1m�[31mt�[0m�[39m�[?1l�>�[?2004l
Command 'quit' not found, did you mean:
command 'luit' from deb x11-utils
command 'qgit' from deb qgit
command 'quilt' from deb quilt
Try: sudo apt install

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[226C 127 �[31m�[1m�[31m⨯�[0m�[31m�[39m�[232D�[?1h�=�[?2004h�[1m�[31me�[0m�[39m�[38;2;153;153;153mcho supersecurepass
gdbSession.txt
Script started on 2021-10-01 06:38:09-04:00 [TERM="xterm-256color" TTY="/dev/pts/0" COLUMNS="237" LINES="53"]

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31mm�[0m�[39m�[38;2;153;153;153man script�[39m�[9D��[1m�[31mm�[1m�[31ma�[0m�[39m���[1m�[31mm�[1m�[31ma�[1m�[31mk�[0m�[39m�[38;2;153;153;153me�[39m�[39m �[39m �[39m �[39m �[39m �[39m �����������[0m�[32mm�[0m�[32ma�[0m�[32mk�[32me�[39m �[38;2;153;153;153mclean�[39m������[39m�[4m.�[24m�[39m �[39m �[39m �[39m ������[4m.�[4m/�[24m��[4m/�[4mP�[24m��[4mP�[4m0�[24m��[4m0�[4m-2020-Fall�[1m�[4m/�[0m�[24m���[4ml�[24m�[0m�[24m ��[?1l�>�[?2004l
make: Nothing to be done for 'P0-2020-Fall'.

�]0;kali@kali: ~/unixfs�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[4mc�[24m�[38;2;153;153;153mat A\ Minimal\ List\ of\ Unix\ Commands.txt�[39m�[43D��[24m�[32mc�[32md�[39m�[38;2;153;153;153m �[38;2;153;153;153m.�[38;2;153;153;153m.�[39m�[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[42D�[39m �[39m�[4mP�[24m�[39m ���[4mP�[4m0�[24m��[4m0�[4m-2020-Fall�[1m�[4m/�[0m�[24m���[4ml�[24m�[0m�[24m ��[?1l�>�[?2004l

�]0;kali@kali: ~/unixfs/P0-2020-Fall�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs/P0-2020-Fall�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31mk�[0m�[39m�[38;2;153;153;153mali�[39m�����[0m�[39m �[39m �[39m �[39m �����[32ml�[39m�[38;2;153;153;153ms -lisa�[39m���������[32ml�[32ms�[39m�[39m �[39m �[39m �[39m �[39m �[39m �������[?1l�>�[?2004l
bitvector.cpp directory.cpp diskParams.dat file.cpp fs33types.hpp inodes.cpp Makefile mount.cpp shell.cpp shell.cpp~ simdisk.cpp typescript user.cpp volume.cpp

�]0;kali@kali: ~/unixfs/P0-2020-Fall�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs/P0-2020-Fall�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[4mm�[24m�[38;2;153;153;153make ./P0-2020-Fall�[39m�[18D��[24m�[1m�[31mm�[1m�[31ma�[0m�[39m���[1m�[31mm�[1m�[31ma�[1m�[31mk�[0m�[39m����[0m�[32mm�[0m�[32ma�[0m�[32mk�[32me�[39m�[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[39m �[15D�[?1l�>�[?2004l
g++ -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses -c simdisk.cpp
g++ -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses -c bitvector.cpp
g++ -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses -c directory.cpp
g++ -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses -c file.cpp
g++ -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses -c inodes.cpp
g++ -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses -c volume.cpp
g++ -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses -c mount.cpp
g++ -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses -c shell.cpp
g++ -o P0 -g -Wall -ansi -pedantic -Wno-write-strings -Wno-parentheses simdisk.o bitvector.o directory.o file.o inodes.o volume.o mount.o shell.o

�]0;kali@kali: ~/unixfs/P0-2020-Fall�
�[0m�[27m�[24m�[J�[32m┌──(�[1m�[32m�[34mkali㉿kali�[0m�[34m�[32m)-[�[1m�[32m�[39m~/unixfs/P0-2020-Fall�[0m�[32m]
└─�[1m�[32m�[34m$�[0m�[34m�[39m �[K�[?1h�=�[?2004h�[1m�[31mg�[0m�[39m�[38;2;153;153;153medit pawn.py�[39m�[12D��[1m�[31mg�[1m�[31md�[0m�[39m�[38;2;153;153;153mb�[38;2;153;153;153m �[38;2;153;153;153ma�[38;2;153;153;153m.�[38;2;153;153;153mo�[38;2;153;153;153mu�[38;2;153;153;153mt�[39m�[39m �[39m �[39m �[39m �[11D���[0m�[32mg�[0m�[32md�[32mb�[39m�[39m �[39mp�[39m �[39m �[39m �[39m ������[38;2;153;153;153ma�[38;2;153;153;153m.out�[39m������[39m�[4mP�[24m�[39m �[39m �[39m �[39m ������[4mP�[4m0�[24m�[?1l�>�[?2004l
�[35;1m�[35;1mGNU gdb �[m�[35;1m(Debian 10.1-2) �[m�[35;1m10.1.90.20210103-git�[m�[35;1m
�[m�[mCopyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from �[32mP0�[m...
�[?2004h(gdb)
�[?2004l
�[?2004h(gdb) break ��[K��[K��[K��[K��[K��[K�break script��[K��[K��[K��[K��[Khell.cpp ��[K:357
�[?2004l
Breakpoint 1 at �[34m0x6248�[m: file �[32mshell.cpp�[m, line 359.
�[?2004h(gdb) n��[Kn
�[?2004l
The program is not being run.
�[?2004h(gdb) n
�[?2004l
The program is not being run.
�[?2004h(gdb) run
�[?2004l
Starting program: /home/kali/unixfs/P0-2020-Fall/P0
Breakpoint 1, �[33mmain�[m () at �[32mshell.cpp�[m:359
359     �[01musage�[m�[31m();�[m
�[?2004h�[?2004l
�[?2004h(gdb) n
�[?2004l
The shell has only the following cmds:
    cd    s
    cp    ss
    echo    ssss
    inode    u
    ls    
    lslong    
    mkdir    s
    mkdisk    s
    mkfs    s
    mount    us
    mount    
    mv    ss
    rddisk    su
    rmdir    s
    rm    s
    pwd    
    q    
    quit    
    umount    u
    wrdisk    sus
Start with ! to invoke a Unix shell cmd
361     �[31m*�[mbuf �[31m=�[m �[35m0�[m�[31m;�[m            �[36m// clear old input�[m
�[?2004h�[?2004l
�[?2004h(gdb) n
�[?2004l
362     �[01mprintf�[m�[31m(�[m�[31m"%s"�[m�[31m,�[m �[31m"sh33% "�[m�[31m);�[m    �[36m// prompt�[m
�[?2004h�[?2004l
�[?2004h(gdb) n
�[?2004l
363     �[01mourgets�[m�[31m(�[mbuf�[31m);�[m
�[?2004h�[?2004l
�[?2004h(gdb) n
�[?2004l
sh33% n
364     �[01mprintf�[m�[31m(�[m�[31m"cmd [%s]�[m�[35m\n�[m�[31m"�[m�[31m,�[m buf�[31m);�[m    �[36m// just print out what we got as-is�[m
�[?2004h�[?2004l
�[?2004h(gdb) n
�[?2004l
cmd [n]
365     �[01;34mif�[m �[31m(�[mbuf�[31m[�[m�[35m0�[m�[31m]�[m �[31m==�[m �[35m0�[m�[31m)�[m
�[?2004h�[?2004l
�[?2004h(gdb) n
�[?2004l
367     �[01;34mif�[m �[31m(�[mbuf�[31m[�[m�[35m0�[m�[31m]�[m �[31m==�[m �[31m'#'�[m�[31m)�[m
�[?2004h�[?2004l
�[?2004h(gdb) n
�[?2004l
369     �[01;34mif�[m �[31m(�[mbuf�[31m[�[m�[35m0�[m�[31m]�[m �[31m==�[m �[31m'!'�[m�[31m)�[m        �[36m// begins with !, execute it as�[m
�[?2004h�[?2004l
�[?2004h(gdb) n
�[?2004l
372     �[01msetArgsGiven�[m�[31m(�[mbuf�[31m,�[m arg�[31m,�[m types�[31m,�[m...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here