View previous topic :: View next topic |
Author |
Message |
jftuga Tux's lil' helper
Joined: 21 Jan 2004 Posts: 139 Location: Athens, GA
|
Posted: Sun May 30, 2004 4:01 pm Post subject: HOWTO: chmod permissions |
|
|
To help users transition from -rwx-rwx--- style permissions to 0770 style permissions, I wrote a program that creates 4096 file wilth every single possible permission type, ranging from 0000 to 7777.
How to run:
Code: |
Save the code as umask_test.c, then compile with:
gcc umask_test.c -o umask_test
mkdir test
cd test
../umask_test
ls -lr | less
|
You will see that the first column permissions correspond to the octal value in the last column
Hope this helps someone.
-John
Code: |
/* umask_test.c */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
int fp,loop;
char fname[128];
umask(0);
for(loop=0; loop < 4096; loop++) {
sprintf(fname,"%#o", loop);
printf("%s\n", fname);
if( (fp = open(fname, O_RDWR|O_CREAT, loop )) < 0 )
return fprintf(stderr, "\nUnable to open %s\n", fname);
close(fp);
}
printf("\n");
return 0;
}
|
|
|
Back to top |
|
|
madmanuk n00b
Joined: 01 Nov 2003 Posts: 63 Location: England
|
Posted: Mon May 31, 2004 1:35 am Post subject: |
|
|
lol nice _________________ -madmanuk- |
|
Back to top |
|
|
qzec Tux's lil' helper
Joined: 19 Jul 2004 Posts: 89
|
Posted: Wed Aug 18, 2004 1:13 am Post subject: |
|
|
nice
Q |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|