understanding stat module names

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Bear

    #1

    understanding stat module names

    I'm trying to use os.chmod and am refered to the stat module.

    Is there are explanation of:
    * S_ISUID
    * S_ISGID
    * S_ENFMT
    * S_ISVTX
    * S_IREAD
    * S_IWRITE
    * S_IEXEC
    * S_IRWXU
    * S_IRUSR
    * S_IWUSR
    * S_IXUSR
    * S_IRWXG
    * S_IRGRP
    * S_IWGRP
    * S_IXGRP
    * S_IRWXO
    * S_IROTH
    * S_IWOTH
    * S_IXOTH

    this isn't much help:

    dir(stat)
    ['ST_ATIME', 'ST_CTIME', 'ST_DEV', 'ST_GID', 'ST_INO', 'ST_MODE',
    'ST_MTIME', 'ST_NLINK', 'ST_SIZE', 'ST_UID', 'S_ENFMT', 'S_IEXEC',
    'S_IFBLK', 'S_IFCHR', 'S_IFDIR', 'S_IFIFO', 'S_IFLNK', 'S_IFMT', 'S_IFREG',
    'S_IFSOCK', 'S_IMODE', 'S_IREAD', 'S_IRGRP', 'S_IROTH', 'S_IRUSR',
    'S_IRWXG', 'S_IRWXO', 'S_IRWXU', 'S_ISBLK', 'S_ISCHR', 'S_ISDIR',
    'S_ISFIFO', 'S_ISGID', 'S_ISLNK', 'S_ISREG', 'S_ISSOCK', 'S_ISUID',
    'S_ISVTX', 'S_IWGRP', 'S_IWOTH', 'S_IWRITE', 'S_IWUSR', 'S_IXGRP',
    'S_IXOTH', 'S_IXUSR', '__builtins__', '__doc__', '__file__', '__name__'][color=blue][color=green][color=darkred]
    >>> print stat.__doc__[/color][/color][/color]
    Constants/functions for interpreting results of os.stat() and os.lstat().

    Suggested usage: from stat import *




    --
    David Bear
    -- let me buy your intellectual property, I want to own your thoughts --
  • Claudio Grondi

    #2
    Re: understanding stat module names

    David Bear wrote:[color=blue]
    > I'm trying to use os.chmod and am refered to the stat module.
    >
    > Is there are explanation of:
    > * S_ISUID
    > * S_ISGID
    > * S_ENFMT
    > * S_ISVTX
    > * S_IREAD
    > * S_IWRITE
    > * S_IEXEC
    > * S_IRWXU
    > * S_IRUSR
    > * S_IWUSR
    > * S_IXUSR
    > * S_IRWXG
    > * S_IRGRP
    > * S_IWGRP
    > * S_IXGRP
    > * S_IRWXO
    > * S_IROTH
    > * S_IWOTH
    > * S_IXOTH
    >
    > this isn't much help:
    >
    > dir(stat)
    > ['ST_ATIME', 'ST_CTIME', 'ST_DEV', 'ST_GID', 'ST_INO', 'ST_MODE',
    > 'ST_MTIME', 'ST_NLINK', 'ST_SIZE', 'ST_UID', 'S_ENFMT', 'S_IEXEC',
    > 'S_IFBLK', 'S_IFCHR', 'S_IFDIR', 'S_IFIFO', 'S_IFLNK', 'S_IFMT', 'S_IFREG',
    > 'S_IFSOCK', 'S_IMODE', 'S_IREAD', 'S_IRGRP', 'S_IROTH', 'S_IRUSR',
    > 'S_IRWXG', 'S_IRWXO', 'S_IRWXU', 'S_ISBLK', 'S_ISCHR', 'S_ISDIR',
    > 'S_ISFIFO', 'S_ISGID', 'S_ISLNK', 'S_ISREG', 'S_ISSOCK', 'S_ISUID',
    > 'S_ISVTX', 'S_IWGRP', 'S_IWOTH', 'S_IWRITE', 'S_IWUSR', 'S_IXGRP',
    > 'S_IXOTH', 'S_IXUSR', '__builtins__', '__doc__', '__file__', '__name__']
    >[color=green][color=darkred]
    >>>>print stat.__doc__[/color][/color]
    >
    > Constants/functions for interpreting results of os.stat() and os.lstat().
    >
    > Suggested usage: from stat import *
    >
    >
    >
    >[/color]
    from stat.h of Microsoft Visual C++ .NET 2003:

    #define _S_IFMT 0170000 /* file type mask */
    #define _S_IFDIR 0040000 /* directory */
    #define _S_IFCHR 0020000 /* character special */
    #define _S_IFIFO 0010000 /* pipe */
    #define _S_IFREG 0100000 /* regular */
    #define _S_IREAD 0000400 /* read permission, owner */
    #define _S_IWRITE 0000200 /* write permission, owner */
    #define _S_IEXEC 0000100 /* execute/search permission,
    owner */
    #define S_IFMT _S_IFMT
    #define S_IFDIR _S_IFDIR
    #define S_IFCHR _S_IFCHR
    #define S_IFREG _S_IFREG
    #define S_IREAD _S_IREAD
    #define S_IWRITE _S_IWRITE
    #define S_IEXEC _S_IEXEC

    struct stat {
    _dev_t st_dev;
    _ino_t st_ino;
    unsigned short st_mode;
    short st_nlink;
    short st_uid;
    short st_gid;
    _dev_t st_rdev;
    _off_t st_size;
    time_t st_atime;
    time_t st_mtime;
    time_t st_ctime;
    };

    From MSDN Help:

    The _fstat function obtains information about the open file associated
    with fd and stores it in the structure pointed to by buffer. The _stat
    structure, defined in SYS\STAT.H, contains the following fields:

    st_atime
    Time of last file access.
    st_ctime
    Time of creation of file.
    st_dev
    If a device, fd; otherwise 0.
    st_mode
    Bit mask for file-mode information. The _S_IFCHR bit is set if fd refers
    to a device. The _S_IFREG bit is set if fd refers to an ordinary file.
    The read/write bits are set according to the file's permission mode.
    _S_IFCHR and other constants are defined in SYS\STAT.H.
    st_mtime
    Time of last modification of file.
    st_nlink
    Always 1 on non-NTFS file systems.
    st_rdev
    If a device, fd; otherwise 0.
    st_size
    Size of the file in bytes.

    Probably googling for the constants will show up some more useful
    information , too.

    Hope this helps.

    Claudio

    Comment

    • Marius Gedminas

      #3
      Re: understanding stat module names

      David Bear wrote:[color=blue]
      > I'm trying to use os.chmod and am refered to the stat module.
      >
      > Is there are explanation of:
      > * S_ISUID[/color]
      ....[color=blue]
      > * S_IXOTH[/color]

      These come from the POSIX standard. See


      HTH,
      Marius Gedminas

      Comment

      • David Bear

        #4
        Re: understanding stat module names

        Claudio Grondi wrote:
        [color=blue]
        > David Bear wrote:[color=green]
        >> I'm trying to use os.chmod and am refered to the stat module.
        >>
        >> Is there are explanation of:
        >> * S_ISUID
        >> * S_ISGID
        >> * S_ENFMT
        >> * S_ISVTX
        >> * S_IREAD
        >> * S_IWRITE
        >> * S_IEXEC
        >> * S_IRWXU
        >> * S_IRUSR
        >> * S_IWUSR
        >> * S_IXUSR
        >> * S_IRWXG
        >> * S_IRGRP
        >> * S_IWGRP
        >> * S_IXGRP
        >> * S_IRWXO
        >> * S_IROTH
        >> * S_IWOTH
        >> * S_IXOTH
        >>
        >> this isn't much help:
        >>
        >> dir(stat)
        >> ['ST_ATIME', 'ST_CTIME', 'ST_DEV', 'ST_GID', 'ST_INO', 'ST_MODE',
        >> 'ST_MTIME', 'ST_NLINK', 'ST_SIZE', 'ST_UID', 'S_ENFMT', 'S_IEXEC',
        >> 'S_IFBLK', 'S_IFCHR', 'S_IFDIR', 'S_IFIFO', 'S_IFLNK', 'S_IFMT',
        >> 'S_IFREG', 'S_IFSOCK', 'S_IMODE', 'S_IREAD', 'S_IRGRP', 'S_IROTH',
        >> 'S_IRUSR', 'S_IRWXG', 'S_IRWXO', 'S_IRWXU', 'S_ISBLK', 'S_ISCHR',
        >> 'S_ISDIR', 'S_ISFIFO', 'S_ISGID', 'S_ISLNK', 'S_ISREG', 'S_ISSOCK',
        >> 'S_ISUID', 'S_ISVTX', 'S_IWGRP', 'S_IWOTH', 'S_IWRITE', 'S_IWUSR',
        >> 'S_IXGRP', 'S_IXOTH', 'S_IXUSR', '__builtins__', '__doc__', '__file__',
        >> '__name__']
        >>[color=darkred]
        >>>>>print stat.__doc__[/color]
        >>
        >> Constants/functions for interpreting results of os.stat() and os.lstat().
        >>
        >> Suggested usage: from stat import *
        >>
        >>
        >>
        >>[/color]
        > from stat.h of Microsoft Visual C++ .NET 2003:
        >
        > #define _S_IFMT 0170000 /* file type mask */
        > #define _S_IFDIR 0040000 /* directory */
        > #define _S_IFCHR 0020000 /* character special */
        > #define _S_IFIFO 0010000 /* pipe */
        > #define _S_IFREG 0100000 /* regular */
        > #define _S_IREAD 0000400 /* read permission, owner */
        > #define _S_IWRITE 0000200 /* write permission, owner */
        > #define _S_IEXEC 0000100 /* execute/search permission,
        > owner */
        > #define S_IFMT _S_IFMT
        > #define S_IFDIR _S_IFDIR
        > #define S_IFCHR _S_IFCHR
        > #define S_IFREG _S_IFREG
        > #define S_IREAD _S_IREAD
        > #define S_IWRITE _S_IWRITE
        > #define S_IEXEC _S_IEXEC
        >
        > struct stat {
        > _dev_t st_dev;
        > _ino_t st_ino;
        > unsigned short st_mode;
        > short st_nlink;
        > short st_uid;
        > short st_gid;
        > _dev_t st_rdev;
        > _off_t st_size;
        > time_t st_atime;
        > time_t st_mtime;
        > time_t st_ctime;
        > };
        >
        > From MSDN Help:
        >
        > The _fstat function obtains information about the open file associated
        > with fd and stores it in the structure pointed to by buffer. The _stat
        > structure, defined in SYS\STAT.H, contains the following fields:
        >
        > st_atime
        > Time of last file access.
        > st_ctime
        > Time of creation of file.
        > st_dev
        > If a device, fd; otherwise 0.
        > st_mode
        > Bit mask for file-mode information. The _S_IFCHR bit is set if fd refers
        > to a device. The _S_IFREG bit is set if fd refers to an ordinary file.
        > The read/write bits are set according to the file's permission mode.
        > _S_IFCHR and other constants are defined in SYS\STAT.H.
        > st_mtime
        > Time of last modification of file.
        > st_nlink
        > Always 1 on non-NTFS file systems.
        > st_rdev
        > If a device, fd; otherwise 0.
        > st_size
        > Size of the file in bytes.
        >
        > Probably googling for the constants will show up some more useful
        > information , too.
        >
        > Hope this helps.
        >
        > Claudio[/color]

        Thnks for the info. I didn't even think I would have to look in a unix/c ref
        manual. This was usefull.



        --
        David Bear
        -- let me buy your intellectual property, I want to own your thoughts --

        Comment

        Working...