Thread: Strange chmod permissions?

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    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.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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.

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, 01:52 AM