Like Tree1Likes
  • 1 Post By Clairvoyant1332

Strange chmod permissions?

This is a discussion on Strange chmod permissions? within the Tech Board forums, part of the Community Boards category; Hi, I'm looking at some Python code and I saw a very strange like like this: Code: os.chmod( filename, 33152 ...

  1. #1
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545

    Strange chmod permissions?

    Hi,
    I'm looking at some Python code and I saw a very strange like like this:
    Code:
    os.chmod( filename, 33152 )
    WTF?? I've never seen 5 digits in a chmod permissions number. What exactly does 33152 mean?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,497
    You probably need to convert it to octal to make sense of it - it's 100600
    User rw only, and some kind of "sticky bit"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    The 100000(octal) bit specifies "regular file." I wasn't actually aware that you could manipulate that bit via chmod(), but who knows.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    90
    A mode of 10xxxx means it's a regular file.

    From /usr/include/linux/stat.h:

    Code:
    #define S_IFSOCK 0140000
    #define S_IFLNK  0120000
    #define S_IFREG  0100000
    #define S_IFBLK  0060000
    #define S_IFDIR  0040000
    #define S_IFCHR  0020000
    #define S_IFIFO  0010000
    I imagine that chmod(2) only looks at the 4 least significant octal digits.
    Salem likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. chmod issues
    By DavidP in forum Tech Board
    Replies: 2
    Last Post: 03-20-2010, 06:09 AM
  2. Chmod command problem
    By JFonseka in forum C Programming
    Replies: 22
    Last Post: 10-22-2007, 07:09 AM
  3. file permissions
    By witek25 in forum Windows Programming
    Replies: 6
    Last Post: 06-30-2007, 09:36 PM
  4. C File permissions
    By vipers in forum C Programming
    Replies: 1
    Last Post: 04-24-2004, 12:00 PM
  5. File Permissions
    By anumandal in forum Linux Programming
    Replies: 2
    Last Post: 03-21-2002, 12:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21