Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ECS 36B Spring 2023

Homework #1 (5%)

Due: April 12, 11:59 pm (no extension!!)

This assignment is related to C (not C++) and Unix tools such as Make –

[online resources for tar and make (and it is important for you to learn the concept of separate compilation]

https://www.interserver.net/tips/kb/use-tar-command-linux-examples/ 

https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/ 

https://www.cs.bu.edu/teaching/cpp/separate-compilation.html 

Part 1: split a large file into fixed-size pieces and re-join them

As common file/database size is getting much larger these days, it is handy to be able to break them into small pieces for the purpose of storage or internet transfer, and then to heal them back together to the original form whenever needed. For this homework assignment, we will build such tools (also to apply what you might have learned from ecs36a) --

(Programs) myHeal and myBreak are two utility programs for separating a giant file into smaller-sized chunks and re-assembling the chunks back to their original.

myBreak: the myBreak program will separate the source file, typically very large file size, into fixed-size chunks (for example, 1 MB a piece). You have the freedom to design how you like to separate them (of course, your own myHeal program will put them back correctly), but the program must take the following arguments:

usage: ./myBreak <source> <prefix> <chunk size (K)>

Here is an example è

(base) MBP:myBreakHeal sfwu$ ls -l toID_sorted_Lall_LIS.xls

-rw-r--r--  1 sfwu  staff  710779752 Sep 30 12:15 toID_sorted_Lall_LIS.xls

(base) MBP:myBreakHeal sfwu$ ./myBreak toID_sorted_Lall_LIS.xls myPrefix 65536

 starting myPrefix.00000000000000000000000000000000

 starting myPrefix.00000000000000000000000000000001

 starting myPrefix.00000000000000000000000000000002

 starting myPrefix.00000000000000000000000000000003

 starting myPrefix.00000000000000000000000000000004

 starting myPrefix.00000000000000000000000000000005

 starting myPrefix.00000000000000000000000000000006

 starting myPrefix.00000000000000000000000000000007

 starting myPrefix.00000000000000000000000000000008

 starting myPrefix.00000000000000000000000000000009

 starting myPrefix.00000000000000000000000000000010

done... [11] chunks produced for toID_sorted_Lall_LIS.xls

While you can design and implement your own version of myBreak program, the source code of a reference implementation of myBreak.c will be provided.

myHeal: the myHeal program will re-generate the original file broken by the myBreak program. For error handling, the program needs to detect if any chunk is missing and also the chunk size of incorrect.

Here is the example è

(base) MBP:myBreakHeal sfwu$ ./myheal source_toID.csv myPrefix 65536 11

 putting myPrefix.00000000000000000000000000000000

 putting myPrefix.00000000000000000000000000000001

 putting myPrefix.00000000000000000000000000000002

 putting myPrefix.00000000000000000000000000000003

 putting myPrefix.00000000000000000000000000000004

 putting myPrefix.00000000000000000000000000000005

 putting myPrefix.00000000000000000000000000000006

 putting myPrefix.00000000000000000000000000000007

 putting myPrefix.00000000000000000000000000000008

 putting myPrefix.00000000000000000000000000000009

 putting myPrefix.00000000000000000000000000000010

done... [11] chunks produced for source_toID.csv

(base) MBP:myBreakHeal sfwu$ ls -l source_toID.csv

-rw-r--r--  1 sfwu  staff  710779752 Sep 30 13:46 source_toID.csv

(base) MBP:myBreakHeal sfwu$ diff toID_sorted_Lall_LIS.xls source_toID.csv

(base) MBP:myBreakHeal sfwu$

Please note that the diff program is used to compare the original file and the healed version, and there is no difference which means the heal process was correctly done.

https://www.geeksforgeeks.org/diff-command-linux-examples/ 

For this part of homework, we will provide some testing scenarios.

For Part 1 of HW#1, please follow the steps:

· Create a subdirectory ecs36b_s2023, and then cd ecs36b_s2023. (mkdir, cd)

· Create a subdirectory hw1, and then cd hw1.

· Put all your programs and Makefile under the hw1 directory.

· You should also provide a README file to explain how to run your program.

· cd ..

· tar zcvf ecs36b_s2023_hw1_submission_<your_user_id>.tar.gz hw1

· upload ecs36b_f2020_hw1_submission_<your_user_id>.tar.gz to Canvas hw1.

The following three criteria will be considered for your hw1 grade –

(1) “diff” original file and healed one

(2) Chunk missing detected

(3) Chunk size mismatched (except the last one)