CS3841
Operating Systems
# <mark>Bug Fixes</mark> <mark>Please see <a href="Lab1BugFix">Lab1 Bug Fix</a> for instructions on fixing bugs. Please see <a href="VMSetup#ssh">VM Setup's SSH section</a> if you want to use SSH keys instead of typing your username and password every time you hit Git.</mark> # Introduction Please follow the [lab handout](lab1res/CS3841LinuxIntroductionLab.pdf), <mark>noting that the [Lab1 Checklist](lab1res/CS3841Lab1Checklist.pdf) is the final authority on what should be included in the lab -- and could be in a different order and certainly has other minor differences from Dr. Schilling's deliverables at the end of the lab handout.</mark> <!-- I recommend using Microsoft Word to create your report. Be sure to check that the file size is below 1MB. You can save the PDF with the minimum size option enabled to help with this: ![radio button: Minimum size (publishing online)](lab1res/minsize.png) --> * Submit your report in hard-copy at the start of the week 2 lab period, with the [Lab1 Checklist](lab1res/CS3841Lab1Checklist.pdf) stapled on top of it. <mark>Because you are submitting your report in hard-copy, it is not necessary to submit a PDF, even though the lab assignment may say it is required.</mark> <!--through [MSOE's esubmit](https://esubmit.msoe.edu/login) --> * Submit your code through github classroom by forking [the lab 1 repository (navigate to link within blackboard)](http://msoe.blackboard.com). Place the link to your github repository by your name on the first page after the checklist. For example, Phileas might write: <div align=center><big>Lab 1: Virtual Machine<br>Phileas Fogg</big><br> cs3841-2018-lab-1-foggp<br>...</div> I require a more formal lab report this quarter than I usually do. Read it through to check that ***every*** word is spelled correctly and see the checklist for more details. # Resources * [Lab Handout](lab1res/CS3841LinuxIntroductionLab.pdf) * [An Introduction to Linux](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics) (also available from the [wayback machine](https://web.archive.org/web/20180502225424/https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics)) * [Lab1 Checklist](lab1res/CS3841Lab1Checklist.pdf) * [VirtualBox Installer](https://www.virtualbox.org/wiki/Downloads) * [VM Baseline Image](http://www.walterschilling.org/msoe/fall20182019cs3841/SE3910CS3841Fall2018BaselineVM.ova) * [VM Baseline Image (zipped)](http://www.walterschilling.org/msoe/fall20182019cs3841/SE3910CS3841Fall2018BaselineVM.zip) * YouTube: [Importing C Code Files Into Eclipse](https://www.youtube.com/watch?v=DIaRhRgNfx4) (Dr. Schilling) * YouTube: [Git GUI Linux Demonstration](https://www.youtube.com/watch?v=Ilkch3eW9J4) (Dr. Schilling) * The listings in the Listings section below # Hints You may want to start downloading the VM Baseline image (see Resources above) while VirtualBox is installing, since this image is very large. # Listings To aid in copying the example files to your computer, the following listings are provided. ## hello.c ``` /********************************** * hello.c * Written by: H. Welch - 11/26/2006 * Modified W. Schilling - 8/15/2009 * * * Demonstrate basic C-program along with * system call requiring struct and pointer * manipulation. ***********************************/ #include <stdio.h> #include <sys/utsname.h> #include <stdlib.h> int main (int argc, char* argv[]) { /* Get system information using the uts system interface.*/ /* Declare a buffer to store information about the system. */ struct utsname buf; /* Declare a pointer to the user information. */ char *usr; /* Populate the buffer with data from the system. */ uname(&buf); /* Get information about the user from the system. */ usr=getenv("USER"); /* Print out system information to the console. */ printf("Hello %s:%s:%s:%s:z%s\n", buf.sysname, buf.nodename, buf.release,buf.version,buf.machine); printf("The size of the UTS structure is %d.\n", sizeof(buf)); /* Print out the user information if the pointer is not NULL. */ if (usr != NULL) { printf("%s\n",usr); } else { printf("User information not returned by the operating system."); } /* Return to O/S */ return 0; } ``` ## Makefile I recommend naming this ```Makefile```, capitalized, so that it it is sorted before the rest of your source files. All indentation in a Makefile must be done with a tab, not spaces! My markdown styler automatically replaces each tab with four spaces. Therefore, you must either: * Replace the four spaces at the start of each line with a tab. * View the source for this webpage, and copy the file from there. <br> ```Makefile SHELL = /bin/sh SRCDIR = . CC = gcc YACC = bison -y CDEBUG = -g COMPLIANCE_FLAGS = CFLAGS = -save-temps $(COMPLIANCE_FLAGS) $(CDEBUG) -I. -I$(SRCDIR) LDFLAGS = -g LIBS = ################################################################################################# # List your sources here. The sources are all of the .c files that are part of the project. SOURCES = hello.c ################################################################################################# ################################################################################################# # list the name of your output program here. (i.e. myfirstprogram EXECUTABLE = hello ################################################################################################# # Create the names of the object files (each .c file becomes a .o file) OBJS = $(patsubst %.c, %.o, $(SOURCES)) include $(SOURCES:.c=.d) all : $(OBJS) $(EXECUTABLE) $(EXECUTABLE) : $(OBJS) $(CC) -o $(EXECUTABLE) $(LDFLAGS) $(OBJS) $(LIBS) %.o : %.c #Defines how to translate a single c file into an object file. echo compiling $< echo $(CC) $(CFLAGS) -c $< $(CC) $(CFLAGS) -c $< echo done compiling $< %.d : %.c #Defines how to generate the dependencies for the given files. -M gcc option generates dependencies. @set -e; rm -f $@; \ $(CC) $(COMPLIANCE_FLAGS ) -M $< > $@.$$$$; \ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ clean : # Delete any and all artifacts from the build. The only thing which is kept is the source rm -f *.o rm -f *.i rm -f *.s rm -f *.S rm -f *.o rm -f *d rm -f $(EXECUTABLE) ```