understanding stat module names

D

David Bear

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__']Constants/functions for interpreting results of os.stat() and os.lstat().

Suggested usage: from stat import *
 
C

Claudio Grondi

David said:
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__']

Constants/functions for interpreting results of os.stat() and os.lstat().

Suggested usage: from stat import *
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
 
D

David Bear

Claudio said:
David said:
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__']
print stat.__doc__

Constants/functions for interpreting results of os.stat() and os.lstat().

Suggested usage: from stat import *
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

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

http://www.opengroup.org/onlinepubs/007908799/xsh/sysstat.h.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Understanding CHMOD 6

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top