Search code examples
cposixminix

Making a subdirectory with the mkdir posix command


The latest assignment in my Operating Systems class required us to create a subdirectory(named tmpFolder) using the mkdir command, with no context whatsoever. The code I currently have is based off of the Minix3 appendix and the manual for mkdir My professor isn't the most helpful and the rest of the class is also having trouble with it so I figured I'd ask about it here.

Here is my relevant code:

#include <sys/stat.h>

{
    int tmpFolder;
    tmpFolder = mkdir(tmpFolder, 0777);
}

Can someone please explain to me why that is wrong because it is very frustrating having the professor not explaining why I'm wrong


Solution

  • mkdir's first argument is the path you want to create. You're providing tmpFolder which is an int. Something like this would make more sense:

    int status;
    status = mkdir("/tmp/subdir", 0777)