CS 3113: Project 4

File System Implementation (Files and Pipes)

Example Interaction

Note that below, you are seeing a mixture of the commands that are typed and the outputs from the programs. Also note that all error messages are printed via STDERR, and that all command lines are prefaced with '$ '.

Simple Interaction

$ ./myfs_format 64
$ ./myfs_list
../
./
$ ./myfs_touch foobar
$ ./myfs_list
../
./
foobar
$ ./myfs_more foobar
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 3
N_ALLOCATED_INDEX_NODES: 2
Block allocation table:
00: 07
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_inspect -index 0
Index node: 0
Type: DIRECTORY
Nreferences: 1
Content block: 2
Size: 3
$ ./myfs_inspect -dir 2
Directory at block 2:
Entry 0: name=".", index_node=0
Entry 1: name="..", index_node=0
Entry 2: name="foobar", index_node=1
Next block: 65534
$ ./myfs_inspect -index 1
Index node: 1
Type: FILE
Nreferences: 1
Content block: 65534
Size: 0
$ ./myfs_rm a
File not found
$ ./myfs_rm foobar
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 3
N_ALLOCATED_INDEX_NODES: 1
Block allocation table:
00: 07
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_inspect -index 0
Index node: 0
Type: DIRECTORY
Nreferences: 1
Content block: 2
Size: 2
$ ./myfs_inspect -dir 2
Directory at block 2:
Entry 0: name=".", index_node=0
Entry 1: name="..", index_node=0
Next block: 65534

Interaction with File Content

$ ./myfs_format 64
$ ./myfs_list
../
./
$ echo "foo bar baz" | ./myfs_create foo.txt
$ ./myfs_list
../
./
foo.txt
$ ./myfs_more foo.txt
foo bar baz
$ echo "foo bar baz" | ./myfs_append foo.txt
$ echo "foo bar baz" | ./myfs_append foo.txt
$ ./myfs_more foo.txt
foo bar baz
foo bar baz
foo bar baz
$ ./myfs_list
../
./
foo.txt
$ ./myfs_move foo.txt bar.txt
$ ./myfs_list
../
./
bar.txt
$ ./myfs_more bar.txt
foo bar baz
foo bar baz
foo bar baz
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 4
N_ALLOCATED_INDEX_NODES: 2
Block allocation table:
00: 0f
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_inspect -index 0
Index node: 0
Type: DIRECTORY
Nreferences: 1
Content block: 2
Size: 3
$ ./myfs_inspect -dir 2
Directory at block 2:
Entry 0: name=".", index_node=0
Entry 1: name="..", index_node=0
Entry 2: name="bar.txt", index_node=1
Next block: 65534
$ ./myfs_inspect -index 1
Index node: 1
Type: FILE
Nreferences: 1
Content block: 3
Size: 36
$ ./myfs_rm foo.txt
File not found
$ ./myfs_rm bar.txt
$ ./myfs_list
../
./
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 3
N_ALLOCATED_INDEX_NODES: 1
Block allocation table:
00: 07
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_inspect -index 0
Index node: 0
Type: DIRECTORY
Nreferences: 1
Content block: 2
Size: 2
$ ./myfs_inspect -dir 2
Directory at block 2:
Entry 0: name=".", index_node=0
Entry 1: name="..", index_node=0
Next block: 65534

Interaction with Complex File Content

$ ./myfs_format 64
$ cat myfs.h | ./myfs_append new.h
$ ./myfs_list
../
./
new.h
$ ./myfs_more new.h |head
/*******
 * Low-level file system definitions
 *
 * DO NOT CHANGE THIS DATA STRUCTURE
 *
 * Author: Andrew H. Fagg (CS 3113)
 *
* 
 */

$ ./myfs_more new.h > tmp.txt
$ diff tmp.txt myfs.h
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 23
N_ALLOCATED_INDEX_NODES: 2
Block allocation table:
00: ff
01: ff
02: 7f
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_inspect -index 0
Index node: 0
Type: DIRECTORY
Nreferences: 1
Content block: 2
Size: 3
$ ./myfs_inspect -dir 2
Directory at block 2:
Entry 0: name=".", index_node=0
Entry 1: name="..", index_node=0
Entry 2: name="new.h", index_node=1
Next block: 65534
$ ./myfs_inspect -index 1
Index node: 1
Type: FILE
Nreferences: 1
Content block: 3
Size: 5027
$ ./myfs_inspect -block 3
Block 3:
Next block: 4
$ ./myfs_inspect -block 4
Block 4:
Next block: 5
$ ./myfs_inspect -block 5
Block 5:
Next block: 6
$ ./myfs_inspect -block 6
Block 6:
Next block: 7
$ ./myfs_inspect -block 7
Block 7:
Next block: 8
$ ./myfs_inspect -block 8
Block 8:
Next block: 9
$ ./myfs_inspect -block 9
Block 9:
Next block: 10
$ ./myfs_inspect -block 10
Block 10:
Next block: 11
$ ./myfs_inspect -block 11
Block 11:
Next block: 12
$ ./myfs_inspect -block 12
Block 12:
Next block: 13
$ ./myfs_inspect -block 13
Block 13:
Next block: 14
$ ./myfs_inspect -block 14
Block 14:
Next block: 15
$ ./myfs_inspect -block 15
Block 15:
Next block: 16
$ ./myfs_inspect -block 16
Block 16:
Next block: 17
$ ./myfs_inspect -block 17
Block 17:
Next block: 18
$ ./myfs_inspect -block 18
Block 18:
Next block: 19
$ ./myfs_inspect -block 19
Block 19:
Next block: 20
$ ./myfs_inspect -block 20
Block 20:
Next block: 21
$ ./myfs_inspect -block 21
Block 21:
Next block: 22
$ ./myfs_inspect -block 22
Block 22:
Next block: 65534
$ ./myfs_inspect -data 3
Raw data at block 3:
  0: 2f /
  1: 2a *
  2: 2a *
  3: 2a *
  4: 2a *
  5: 2a *
  6: 2a *
  7: 2a *
  8: 0a
  9: 20  
 10: 2a *
 11: 20  
 12: 4c L
 13: 6f o
 14: 77 w
 15: 2d -
 16: 6c l
 17: 65 e
 18: 76 v
 19: 65 e
 20: 6c l
 21: 20  
 22: 66 f
 23: 69 i
 24: 6c l
 25: 65 e
 26: 20  
 27: 73 s
 28: 79 y
 29: 73 s
 30: 74 t
 31: 65 e
 32: 6d m
 33: 20  
 34: 64 d
 35: 65 e
 36: 66 f
 37: 69 i
 38: 6e n
 39: 69 i
 40: 74 t
 41: 69 i
 42: 6f o
 43: 6e n
 44: 73 s
 45: 0a
 46: 20  
 47: 2a *
 48: 0a
 49: 20  
 50: 2a *
 51: 20  
 52: 44 D
 53: 4f O
 54: 20  
 55: 4e N
 56: 4f O
 57: 54 T
 58: 20  
 59: 43 C
 60: 48 H
 61: 41 A
 62: 4e N
 63: 47 G
 64: 45 E
 65: 20  
 66: 54 T
 67: 48 H
 68: 49 I
 69: 53 S
 70: 20  
 71: 44 D
 72: 41 A
 73: 54 T
 74: 41 A
 75: 20  
 76: 53 S
 77: 54 T
 78: 52 R
 79: 55 U
 80: 43 C
 81: 54 T
 82: 55 U
 83: 52 R
 84: 45 E
 85: 0a
 86: 20  
 87: 2a *
 88: 0a
 89: 20  
 90: 2a *
 91: 20  
 92: 41 A
 93: 75 u
 94: 74 t
 95: 68 h
 96: 6f o
 97: 72 r
 98: 3a :
 99: 20  
100: 41 A
101: 6e n
102: 64 d
103: 72 r
104: 65 e
105: 77 w
106: 20  
107: 48 H
108: 2e .
109: 20  
110: 46 F
111: 61 a
112: 67 g
113: 67 g
114: 20  
115: 28 (
116: 43 C
117: 53 S
118: 20  
119: 33 3
120: 31 1
121: 31 1
122: 33 3
123: 29 )
124: 0a
125: 20  
126: 2a *
127: 0a
128: 2a *
129: 20  
130: 0a
131: 20  
132: 2a *
133: 2f /
134: 0a
135: 0a
136: 2f /
137: 2f /
138: 20  
139: 4f O
140: 6e n
141: 6c l
142: 79 y
143: 20  
144: 65 e
145: 76 v
146: 61 a
147: 6c l
148: 75 u
149: 61 a
150: 74 t
151: 65 e
152: 20  
153: 74 t
154: 68 h
155: 65 e
156: 73 s
157: 65 e
158: 20  
159: 64 d
160: 65 e
161: 66 f
162: 69 i
163: 6e n
164: 69 i
165: 74 t
166: 69 i
167: 6f o
168: 6e n
169: 73 s
170: 20  
171: 6f o
172: 6e n
173: 63 c
174: 65 e
175: 2c ,
176: 20  
177: 65 e
178: 76 v
179: 65 e
180: 6e n
181: 20  
182: 69 i
183: 66 f
184: 20  
185: 69 i
186: 6e n
187: 63 c
188: 6c l
189: 75 u
190: 64 d
191: 65 e
192: 64 d
193: 20  
194: 6d m
195: 75 u
196: 6c l
197: 74 t
198: 69 i
199: 70 p
200: 6c l
201: 65 e
202: 20  
203: 74 t
204: 69 i
205: 6d m
206: 65 e
207: 73 s
208: 0a
209: 23 #
210: 69 i
211: 66 f
212: 6e n
213: 64 d
214: 65 e
215: 66 f
216: 20  
217: 46 F
218: 49 I
219: 4c L
220: 45 E
221: 5f _
222: 53 S
223: 54 T
224: 52 R
225: 55 U
226: 43 C
227: 54 T
228: 53 S
229: 5f _
230: 48 H
231: 0a
232: 23 #
233: 64 d
234: 65 e
235: 66 f
236: 69 i
237: 6e n
238: 65 e
239: 20  
240: 46 F
241: 49 I
242: 4c L
243: 45 E
244: 5f _
245: 53 S
246: 54 T
247: 52 R
248: 55 U
249: 43 C
250: 54 T
251: 53 S
Next block: 4
$ ./myfs_mkd project
$ ./myfs_list
../
./
new.h
project/
$ ./myfs_move new.h project
$ ./myfs_list
../
./
project/
$ ./myfs_list project
../
./
new.h
$ ./myfs_more project/new.h |head
/*******
 * Low-level file system definitions
 *
 * DO NOT CHANGE THIS DATA STRUCTURE
 *
 * Author: Andrew H. Fagg (CS 3113)
 *
* 
 */

Interaction with Hard Links

$ ./myfs_format 64
$ echo "foo bar baz" | ./myfs_append test.txt
$ ./myfs_list
../
./
test.txt
$ ./myfs_more test.txt
foo bar baz
$ ./myfs_link test.txt test2.txt
$ ./myfs_list
../
./
test.txt
test2.txt
$ ./myfs_more test2.txt
foo bar baz
$ echo "next line" | ./myfs_append test2.txt
$ ./myfs_more test2.txt
foo bar baz
next line
$ ./myfs_more test.txt
foo bar baz
next line
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 4
N_ALLOCATED_INDEX_NODES: 2
Block allocation table:
00: 0f
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_inspect -dir 2
Directory at block 2:
Entry 0: name=".", index_node=0
Entry 1: name="..", index_node=0
Entry 2: name="test.txt", index_node=1
Entry 3: name="test2.txt", index_node=1
Next block: 65534
$ ./myfs_inspect -index 1
Index node: 1
Type: FILE
Nreferences: 2
Content block: 3
Size: 22
$ echo "one next line" | ./myfs_append test.txt
$ ./myfs_more test.txt
foo bar baz
next line
one next line
$ ./myfs_more test2.txt
foo bar baz
next line
one next line
$ ./myfs_mkd project
$ ./myfs_link test.txt project/test3.txt
$ ./myfs_list project
../
./
test3.txt
$ ./myfs_more project/test3.txt
foo bar baz
next line
one next line
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 5
N_ALLOCATED_INDEX_NODES: 3
Block allocation table:
00: 1f
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_rm test.txt
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 5
N_ALLOCATED_INDEX_NODES: 3
Block allocation table:
00: 1f
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_rm test2.txt
$ ./myfs_more project/test3.txt
foo bar baz
next line
one next line
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 5
N_ALLOCATED_INDEX_NODES: 3
Block allocation table:
00: 1f
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00
$ ./myfs_rm project/test3.txt
$ ./myfs_inspect -volume
N_BLOCKS: 64
N_ALLOCATED_BLOCKS: 4
N_ALLOCATED_INDEX_NODES: 2
Block allocation table:
00: 17
01: 00
02: 00
03: 00
04: 00
05: 00
06: 00
07: 00

Interaction with Pipes

$ ./myfs_format 128
$ ./myfs_mkp unixfile foo.txt
$ ./myfs_list
../
./
foo.txt|
$ ./myfs_inspect -dir 2
Directory at block 2:
Entry 0: name=".", index_node=0
Entry 1: name="..", index_node=0
Entry 2: name="foo.txt", index_node=1
Next block: 65534
$ ./myfs_inspect -index 1
Index node: 1
Type: PIPE
Nreferences: 1
Content block: 3
Size: 0
$ ./myfs_inspect -data 3 | head
Raw data at block 3:
  0: 75 u
  1: 6e n
  2: 69 i
  3: 78 x
  4: 66 f
  5: 69 i
  6: 6c l
  7: 65 e
  8: 00
$ ./myfs_more foo.txt
Unable to open host file (unixfile)
$ echo "foo bar baz" | ./myfs_append foo.txt
$ ./myfs_more foo.txt
foo bar baz
$ echo "foo bar baz" | ./myfs_append foo.txt
$ ./myfs_more foo.txt
foo bar baz
foo bar baz
$ cat unixfile 
foo bar baz
foo bar baz
$ echo "other line" >> unixfile
$ cat unixfile 
foo bar baz
foo bar baz
other line
$ ./myfs_more foo.txt
foo bar baz
foo bar baz
other line
$ ./myfs_link foo.txt bar.txt
$ ./myfs_more bar.txt
foo bar baz
foo bar baz
other line
$ echo "last line" | ./myfs_append foo.txt
$ ./myfs_more bar.txt
foo bar baz
foo bar baz
other line
last line
$ cat unixfile 
foo bar baz
foo bar baz
other line
last line
$ ./myfs_copy bar.txt baz.txt
$ ./myfs_more baz.txt
foo bar baz
foo bar baz
other line
last line
$ ./myfs_inspect -dir 2
Directory at block 2:
Entry 0: name=".", index_node=0
Entry 1: name="..", index_node=0
Entry 2: name="foo.txt", index_node=1
Entry 3: name="bar.txt", index_node=1
Entry 4: name="baz.txt", index_node=2
Next block: 65534
$ echo "really the last line" | ./myfs_append foo.txt
$ ./myfs_more bar.txt
foo bar baz
foo bar baz
other line
last line
really the last line
$ ./myfs_more baz.txt
foo bar baz
foo bar baz
other line
last line

Interaction with LC

$ ./myfs_format 64
$ echo "foo bar baz" | ./myfs_append myfile
$ echo "foo bar baz" | ./myfs_append myfile
$ echo "foo bar baz" | ./myfs_append myfile
$ ./myfs_more myfile
foo bar baz
foo bar baz
foo bar baz
$ ./myfs_lc myfile
3 36
$ cat myfs.h | ./myfs_append myfs.h
$ ./myfs_list
../
./
myfile
myfs.h
$ ./myfs_lc myfs.h
185 5027
$ wc myfs.h
 185  617 5027 myfs.h


Back to Project 4


andrewhfagg at gmail.com

Last modified: Tue Nov 17 18:30:12 2020