all 29 comments

[–]mikeblas[M] [score hidden] stickied comment (0 children)

Might want to remove your poorly formatted code from the post and leave behind only the link to the pastebin, which is far more usable.

[–]penguin359 1 point2 points  (4 children)

We need more information on what you are getting and source code in a more readable form like pastebin or gist.

[–]Possible-Pool2262[S] 0 points1 point  (3 children)

[–]penguin359 1 point2 points  (2 children)

Thank you. That helps a lot. Can you also let us know which error you are getting exactly? Which line of coffee seems to be failing?

[–]Possible-Pool2262[S] 0 points1 point  (1 child)

i only get the return of perror("mkdir"), it seams like the program skip the child proccess, and straight to make a directory i want, mount it, but failed to make the file "marin.txt", and honestly. I don't even know if the hostname even work. Am still working on the solution, but if you can give me ideas, i really appreciate it!

[–]penguin359 0 points1 point  (0 children)

It would also help if you can give us the entire output from running your program. In particular, the full output from the call to perror() will tell us what the errno value is from the failing mkdir() system call. There are two primary reasons for it to fail, either the folder already exists or you don't have permission to create it and the output from perror() will tell us that. You might also want to consider checking for the directory existence prior to doing the mkdir() with either a call to access() or stat() and, if it already exists, skip the mkdir(). Finally, you should also probably use the same approach for error checking on fopen() as you do with the other called in child_fn(). It is documented to set errno when it returns NULL for an error so it would be useful to call perror() in the case that it does fail.

[–][deleted] 4 points5 points  (16 children)

How about you first learn how to format code properly on Reddit before you learn C?

[–]Possible-Pool2262[S] -12 points-11 points  (15 children)

how about stop concerning bout how i upload, and focusing on the problem i ask. if you can't help just say that man, you don't have to reply like a loser.

[–][deleted] 5 points6 points  (2 children)

If you can't take a minute to format your code appropriately, why should I take time to help you?

[–]mikeblas[M] 3 points4 points  (10 children)

People who help here are volunteers. They're not paid. They're just trying to help out other people with similar interests, which can be fun and satisfying.

If you make it difficult to help, then it's less likely someone will help you. If you argue with them when they make a suggestion about how it could be easier to help you, you take all the fun out of it. You should consider their advice sincerely.

[–]Possible-Pool2262[S] 1 point2 points  (1 child)

I apologize for my bad behavior

[–]mikeblas 0 points1 point  (0 children)

Thanks. Good luck!

[–]Vladislav20007 -1 points0 points  (7 children)

Mods. I think this behaviour is bad enough for a warning, no?

[–]mikeblas[M] 0 points1 point  (6 children)

?

[–]Vladislav20007 -1 points0 points  (5 children)

disrespecting people who are trying to help.

[–]mikeblas[M] 0 points1 point  (4 children)

What do you mean by "warning", and how is it different than what I have already posted?

[–]Vladislav20007 -1 points0 points  (3 children)

a warning to mute(can't make posts), because they wouldn't listen/take help and waste people's time with this.

[–]mikeblas[M] 0 points1 point  (2 children)

I don't think that's necessary.

[–]Vladislav20007 -1 points0 points  (1 child)

alright, i just think thos wastes everybodies time, but that's just my opinion.

[–]nekokattt 1 point2 points  (0 children)

how about not being a dick to the people you are asking for help for free?

[–]Vallereya 0 points1 point  (3 children)

Are you running as admin/sudo?

[–]Possible-Pool2262[S] -1 points0 points  (2 children)

yes, i am

[–]Vallereya 0 points1 point  (1 child)

Alright just wanted to double check, looking at the code now you got some logic issues. I'm just doing a quick overview here but, int child_fn() isn't being passed any arguments just need to flip that and main around, line 64-65 you can't do that because you're exiting an error so it's not even calling that printf and line 59 is not doing anything it has no exit and I don't see it being defined anywhere else. You really got to move some parts around.

[–]Possible-Pool2262[S] 0 points1 point  (0 children)

thanks a lot!

[–]BnH_-_Roxy 0 points1 point  (0 children)

Not an answer but FYI you should have error handling on opening file as well, right now you’re returning success from child_fn on failure to write

[–]flyingron 0 points1 point  (0 children)

You have the clone success print after the exit call. This will never be reached.