GithubHelp home page GithubHelp logo

mikeizbicki / ucr-cs100 Goto Github PK

View Code? Open in Web Editor NEW
479.0 93.0 407.0 29.16 MB

open source software construction course

License: Other

C++ 48.85% TeX 39.09% Makefile 2.90% C 5.02% Shell 3.48% Vim Script 0.66%

ucr-cs100's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ucr-cs100's Issues

How to output individual file information like ls -l

Im working on my code and i'm stuck in here:
129 while ((direntp = readdir(dirp)))
130 {
131 if (s.st_mode & S_IRUSR){
132 cout << 'r';
133 } else{
134 cout << '-';
135 }
136 if (s.st_mode & S_IWUSR){
137 cout << 'w';
138 } else{
139 cout << '-';
140 }
141 if (s.st_mode & S_IXUSR){
142 cout << 'x';
143 } else{
144 cout << '-';
145 }
146 files.push_back(direntp->d_name);
147 }

how can i output the individual files information? I removed the other information output, but when i call it, it all outputs it for just the current directory information. How can i make it output the individual files information. I pushed all the file/directory names into a string of vectors incase i could use it for the actual process. Any help will be appreciated!

Allocation of new/malloc memory

Hi guys,
Im redoing my user input into the array since we last learned how to completely use the malloc/new but in office hours, i don't remember what the sizeof(char_) refers to:
int x= how many params;
c = malloc(x * sizeof(char_));

and for the individual array indexs' we just allocate memory for the size of the word being put in there as well, correct?

Thank you.

calling ls on directories

So I'm having some weird problems calling ls on directories.

My code works when I call: ./a.out bin -l (or any other flags/combinations of flags)

But when I JUST call: ./a.out bin, I get the correct output, but with a few added error messages:

Here is my output when I call ./a.out bin
Error with stat: No such file or directory
Error with readdir: No such file or directory
Error with readdir: No such file or directory
rshell

Here is the correct output (ls bin)
rshell

So as you can see, mine outputs rshell in the end, but has three error messages that comes with it. And when I append flags, in any combination, any flags, any order, those error messages no longer occur.

makefile help

i am so confused on what to do inside the makefile, i know its late but ive never made one before and ive looked at tutorials online and not found them very helpful

bus error: 10

I'm getting the error: 'bus error: 10' when i run my code. I debugged and stepped through my code and when i reached line 55 in my code, i don't know if my code freezed or not but it looked like an infinite loop. however there's no loop started on that line. I called fork two lines earlier and i was able to step to the next line, so i don't know if that's the problem.

my code: https://github.com/kryne001/rshell/

Auto-Indent Solution

Hey guys,

I for one like my code to auto indent every line below my first indented line and VIM doesn't do it by default and I've been looking for a solution for a while and finally came across the answer!

type: echo set autoindent >> .vimrc in a terminal window. This will add to the default list and once you indent the first line, all lines below it will be indented as well.

Enjoy!

Homework 1 due date moved

I'm going to extend the due date of homework 1 until Thursday before class. Please use the weekend to start on the project so you can be prepared to ask questions on Monday. I'm expecting this first assignment to be high quality.

Deleting memory

I'm having a problem freeing my array of char**. i'm able to free the whole array without freeing each index first (which I know is wrong), but if I try to free each index, I get the following error in gdb:

malloc: *** error for object 0x7fff5fbff3a9: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

I've gone through and checked that there was indeed a value there, which there was, and I think I'm allocating the memory for each index correctly, so I don't know where I should look to fix it.

ls -l

when ls -l is entered, the first line says:
total 24

What part of the stat struct does that total number come from? Is it st_blocks?

Office hours

I will be hosting office hours Thursday August 14th 10-11am in WCH 110.

Testing &

I'm trying to do what Mike said in lecture today to test &, trying "cat /dev/random > rand &"
and > doesn't seem to work? It does not create a file called rand but it kind of does run in the background, the random numbers still show in the terminal but it allows me to write in commands.
Is there a reason that output redirection does not work ?

Makefile Issues

Hey everyone:

When I run my makefile with the make command, I get this error:

g++ -Wall -Werror -ansi src/main.cpp -o ./bin/rshell
/usr/bin/ld: cannot open output file ./bin/rshell: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [rshell] Error 1
g++: error: unrecognized command line option ‘-strict’

This line right here is pretty much the bulk of my makefile:
g++ -Wall -Werror -ansi -strict src/main.cpp -o ./bin/rshell

Any ideas? Thanks!

Useful functions for hw2

I forgot to mention in class two more functions that you'll find useful for the assignment. The stat struct only gives you the userid, not the username. You can use the getpwuid function to get the username from the uid. Also, the time_t type is an int that represents the number of seconds since 1970. You can convert this into a readable time using the strftime function. This stackoverflow question has a worked example: http://stackoverflow.com/questions/18422384/how-to-print-time-t-in-a-specific-format

Parsing user input

Do we have to manually write a function to parse user input or can we use a library function?
I found a function named strtok that I believe I could use for user input
Is this allowed?

hw2 flag input

When testing, should we test with "./a.out ls -l -a" or "./a.out -l -a".

To word my question a little better, should we test with or without the ls, and when you guys do the final check, are you going to be typing in ls or not? And is this the correct way to test it?

Recursion Formatting

Can someone help me with the -R flag formatting? I have everything working, but I'm having a lot of trouble with formatting.

Instead of printing all the file+directory names first, then recursing into the directories and printing their contents, mine recurses into the directory as soon as it gets to it. I can post my code as well, just need to make sure I'm allowed to post it here first.

Thanks!

Script and Rshell executable

For some reason. as soon as I start script, my rshell executable will not execute. It works fine if script is not running... After I start script exec.script, I call ./rshell, and then it just hangs on a blank line.

git push

i'm trying to do the part of the lab where i type the following command:

$ git push origin master

it has me put my username and password for github, then says:

remote: Permission to mikeizbicki/ucr-cs100.git denied to kryne001.
fatal: unable to access 'https://github.com/mikeizbicki/ucr-cs100/': The requested URL returned error: 403

hw1 regrading

On my grading it says that my homework did not compile again even though I literally can only get it to compile and run on the well server. I was even showing Mike in office hours today how my program runs (albeit improperly) but it still ran. I don't see any possible way it doesn't compile and run.

What Time HW2 is Due

I am not too sure what time the homework is due. I vaguely remember it being due at 2, but am not too sure and don't know if it would be am or pm. Do any of you remember?

Assignment 3 - Parsing Input

So for assignment 1 I used the function strtok to parse the input and eliminate any spaces. For assignment 3 when we parse input, we should be looking for the following characters: <, >, >>, | correct? Then we have to remove them so we can run the commands on evec right? Can anyone can give me a hint as to what way would be the best way to parse my input? I'm rather stuck on this portion.

HW1 late submissions

Late submissions for HW 1 will be taken under the following conditions:

i) You needed more time to complete the assignment
ii) You did not follow the specifications and one or more of the following doesn't work for you homework:

$ git clone  http://github.com/yourusername/rshell.git
$ cd rshell
$ git checkout hw1
$ make
$ bin/rshell

By turning in a late submission you will acknowledge the following conditions:
i) Your grade for HW 1 will have a penalty of 25 points.
ii) Other penalties may occur
ii) Due date is Sunday August 10th @ 12PM.
iii) You will need to Notify me before the deadline that you making a late submission by stating so as a comment to this post. Failure to notify by the deadline with result in the grade standing as it was the first time it was graded.
iv) Late submission is not a reshow
v) Being able to turn in a late submission is a privilege that can be revoked without any question.

deleting a repository to start over

since i messed up and did not create a branch for homework 1, can i save my files in a different location, delete the repository and start over to make sure everything is fine?

Two Questions

Hey everybody,

I have two questions:

  1. Does anyone know how to properly use read?

This statement here is giving me compiler errors:

if(read(fd, "README", 6) == -1)
{
    perror("read failed");
    exit(1);
}

This is the compiler error I'm getting:

main.cpp:33:28: error: invalid conversion from ‘const void_’ to ‘void_’ [-fpermissive]
if(read(fd, "README", 6) == -1)
^
In file included from main.cpp:5:0:
/usr/include/unistd.h:360:16: error: initializing argument 2 of ‘ssize_t read(int, void*, size_t)’ [-fpermissive]
extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur;

  1. Second, does anyone know how I can update my git folder to sync with the ucr-cs100 one on github? I tried 'git fetch upstream' but it says I don't have correct access rights. I'm still very shaky with how to use git, so sorry!

Thanks!

hw2 branch

So when I clone my repository, it's unable to find the hw2 branch. On my computer, I can checkout to it fine, but it gives me this warning:

warning: refname 'hw2' is ambiguous
switched to branch 'hw2'

how do i fix this and push it back up to git?

passing in files for ls

I was wondering if anyone could give me a hint on how to pass in files for the assignment?
for example if i want to do "ls a.out"
If the user inputs a folder i can easily do ls commands with it but i'm kind of confused what i should do for files

git commit problem

Hey everyone:

When working at home, I've been getting this problem when trying to run:

git commit -m "added the first code"

This is what I get:

*** Please tell me who you are.

Run

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

However, when I try to run git config followed by my info, I get an error that says invalid key. Any ideas? Thanks!

ls -l column headings

Anyone know where we can find good answers on what exactly each part of ls -l is/what part of the struct stat it relates to?

macros

when i define my macros like

define a 1

define l 2

define R 3

it wants me to put semicolons at the end but i know you are not supposed to
what do i do to fix this?

lecture 5 file

is this a mistake? i dont recognize much things in this file

HW 1 re-grading grades.

My internet is done at the moment and not sure when it will come back today, so your HW 1 grades will not be up tonight and should be up by the end of Tuesday along with your HW 2 grades.

Un-Official Office hours

If anyone would like to come join a few of us at the ACM room right now, feel free to do so.
We have card access so it wouldn't be an issue getting you in.

HW2 grading question

I got -10 for not being able to take directories as parameters but I just checked and it can take directories as well as files as parameters

How is this being tested for grading?

Also, I got 10 points off for no perror but i'm pretty sure I have a perror for every sys call, I just double checked...

homework clarification

so in assignment 2 we have to take in the commands, for example ls -a, do we need to access each individual file or directory in the directory that we are in and print out each individually? and for -l we need to go in get all neccesary information about the files and print that out correct?

HW 2 grades

HW 2 will be graded by the end of Wednesday night. Sorry for the delay.

hw1 not compiling

I just saw my grade, which was given because my program did not compile, but I did all five steps shown in the homework,

git clone (myrepo)
cd rshell
git checkout hw1
make
bin/rshell

I've done it at least four times when I cloned four different repos and they worked each time without me doing anything other than those fives commands.

Having execv read in user input + Lecture 5 Notes

Does anyone have any idea how to do read in user input to execl/execv?

The idea I have so far is to parse the user input, then append it onto /bin if appropriate, and then have it be read into execv, but I'm not too sure how to do this.

Also, does anyone have the files that were used in lecture today? I can't seem to find them.

Thanks!

testing homework to make sure it works

when you guys are testing the homework you will not be writing git init right? because when i clone the repo and cd into rshell, when i type git checkout hw1 it only works when i type git init. is this ok? i dont know how else to upload it so i do not have to do this

Makefile Curiosity

Just to make sure I don't get marked off points for this but, can i have my makefile remove an existing bin folder if there is one in the current directory? I got tired of having to type the command "make clean" everytime I wanted to re-"make" my file. So now whenever I type "make", it always removes any existing bin folder and creates a new one with the newly compiled executables.

pull request

do we need to issue a pull request when we update our repo? i know we did this in lab but i wasnt sure if we have to for our homework

hw2 error for st_nlink

I'm trying to get all the info to print out for -l and when I try to output st_nlink I get an error.
I haven't really changed much code from what is given to us from the assignment, this is what i have:
while((direntp = readdir(dirp)))
{
cout<d_name<<endl;
struct stat s;
stat(direntp->d_name,&s);
cout<<"st_nlink: " << s.st_nlink<<endl;
}
Here's what happens when I try to run a.out:
kgall005@well $ ./a.out
.
what is st_nlink : 2
..
what is st_nlink : 9
*** glibc detected *** ./a.out: double free or corruption (top): 0x00000000100ab010 ***
======= Backtrace: =========
/lib64/libc.so.6[0x329027174f]
/lib64/libc.so.6(cfree+0x4b)[0x3290275a4b]
/lib64/libc.so.6(closedir+0xd)[0x32902963dd]
./a.out(__gxx_personality_v0+0x254)[0x400c14]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x329021d9c4]
./a.out(__gxx_personality_v0+0x39)[0x4009f9]
======= Memory map: ========
00400000-00402000 r-xp 00000000 00:1c 20236672 /home/csmajs/kgall005/cs100/ls/a.out
00601000-00602000 rw-p 00001000 00:1c 20236672 /home/csmajs/kgall005/cs100/ls/a.out
100ab000-100cc000 rw-p 100ab000 00:00 0 [heap]
328fe00000-328fe1c000 r-xp 00000000 09:00 41619551 /lib64/ld-2.5.so
329001c000-329001d000 r--p 0001c000 09:00 41619551 /lib64/ld-2.5.so
329001d000-329001e000 rw-p 0001d000 09:00 41619551 /lib64/ld-2.5.so
3290200000-329034f000 r-xp 00000000 09:00 41619552 /lib64/libc-2.5.so
329034f000-329054f000 ---p 0014f000 09:00 41619552 /lib64/libc-2.5.so
329054f000-3290553000 r--p 0014f000 09:00 41619552 /lib64/libc-2.5.so
3290553000-3290554000 rw-p 00153000 09:00 41619552 /lib64/libc-2.5.so
3290554000-3290559000 rw-p 3290554000 00:00 0
3290600000-3290682000 r-xp 00000000 09:00 41619556 /lib64/libm-2.5.so
3290682000-3290881000 ---p 00082000 09:00 41619556 /lib64/libm-2.5.so
3290881000-3290882000 r--p 00081000 09:00 41619556 /lib64/libm-2.5.so
3290882000-3290883000 rw-p 00082000 09:00 41619556 /lib64/libm-2.5.so
3294e00000-3294e0d000 r-xp 00000000 09:00 41619558 /lib64/libgcc_s-4.1.2-20080825.so.1
3294e0d000-329500d000 ---p 0000d000 09:00 41619558 /lib64/libgcc_s-4.1.2-20080825.so.1
329500d000-329500e000 rw-p 0000d000 09:00 41619558 /lib64/libgcc_s-4.1.2-20080825.so.1
3295600000-32956e6000 r-xp 00000000 09:00 3299568 /usr/lib64/libstdc++.so.6.0.8
32956e6000-32958e5000 ---p 000e6000 09:00 3299568 /usr/lib64/libstdc++.so.6.0.8
32958e5000-32958eb000 r--p 000e5000 09:00 3299568 /usr/lib64/libstdc++.so.6.0.8
32958eb000-32958ee000 rw-p 000eb000 09:00 3299568 /usr/lib64/libstdc++.so.6.0.8
32958ee000-3295900000 rw-p 32958ee000 00:00 0
2b77ac472000-2b77ac475000 rw-p 2b77ac472000 00:00 0
2b77ac4a5000-2b77ac4a7000 rw-p 2b77ac4a5000 00:00 0
7fffa4aed000-7fffa4b02000 rw-p 7ffffffe9000 00:00 0 [stack]
7fffa4bfd000-7fffa4c00000 r-xp 7fffa4bfd000 00:00 0 [vdso]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vsyscall]
Aborted

Quiz 3 - sizeof

Can someone explain the last part of quiz 3 with the structs or point me to a link that can do so? I have the answers, but especially for the first column (sizeof(s1), sizeof(s2), sizeof(s3), etc) I don't really understand the answers the compiler is giving back. Thanks!

vim-adventures

Hi, I just finished vim-adventures and I remember that we were told that you get a certificate or something at the end of the game but it just goes to a black screen.
What am I supposed to show in order to get the extra credit? I did screenshot the final screen

char *dirName

I'm getting a warning from the code given in assignment two from this line of code:

char *dirName = ".";

The warning is: warning:deprecated conversion from string constant to 'char*'

HW2 ls flags

The command line args are supposed to tell us what version of ls we're supposed to do right? So when the program is run it should be something like, "./a.out ls -al" ?
How are we supposed to differentiate between if they were to put -la or -al or any combination of the three possible flags ? I can't think of a way to do it that just isn't checking for each possibility one by one which is way too long.
Can anyone give me some hints?

input for assignment 3

since we are running bin/rhsell for this assignment, we have to modify the .cpp file from our assignment 1 correct?

HW2 question

I'm trying to make sure I understand all aspects of the assignment so I wanted to clarify some things.
We are creating the ls.cpp separate from our rshell.cpp file but they will be in the same repository, right?
How should we set up user input? Can we make it so when the program runs we take one ls command and then the program quits
Or do we have to do something like we continuously take commands until they exit the program?

readdir error with recursion

I'm getting a readdir error ONLY with the -R flag, and only when it's recursing into a directory/folder. The perror that I'm getting is "No such file or directory". I suspect it's because it's trying to read it some files that start with . that are there, but I'm pretty sure I already check for them. Another thing is it still outputs the correct things, just with a whole bunch of readdir errors. Example below.

correct output for recursion:
./tests:
exec.script

my output:
./tests:
Error with readdir: No such file or directory
Error with readdir: No such file or directory
Error with readdir: No such file or directory
exec.script

Any help would be greatly appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.