Last active
August 29, 2015 13:57
-
-
Save scifisamurai/9926874 to your computer and use it in GitHub Desktop.
Example of writing a program that will mimic chmod behavior. NOTE: This is overly simple, not robust, & hardcoded/derived. Much more would be needed for a useful program.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*See man -s 2 chmod for more information */ | |
#include <stdio.h> | |
#include <sys/stat.h> | |
int main(void){ | |
/*mode_t mode = S_IXOTH */ | |
mode_t mode = 00755; /*Replace this with the actual mode you want. Ideally you'd want to ask the user */ | |
chmod("hi.txt", mode); /*This assumes hi.txt is present. You'd want to prompt the user for a filename in a real scenario */ | |
return 0; | |
} | |
/*gcc simple_chmod.c; ./a.out */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment