Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: chmod permissions
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
jftuga
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jan 2004
Posts: 139
Location: Athens, GA

PostPosted: Sun May 30, 2004 4:01 pm    Post subject: HOWTO: chmod permissions Reply with quote

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;
}
Code:
Back to top
View user's profile Send private message
madmanuk
n00b
n00b


Joined: 01 Nov 2003
Posts: 62
Location: England

PostPosted: Mon May 31, 2004 1:35 am    Post subject: Reply with quote

lol nice
_________________
-mark-
Back to top
View user's profile Send private message
qzec
Tux's lil' helper
Tux's lil' helper


Joined: 19 Jul 2004
Posts: 89

PostPosted: Wed Aug 18, 2004 1:13 am    Post subject: Reply with quote

nice :)

Q
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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