#ifndef	_SYS_STAT_H
#define	_SYS_STAT_H
#include <_ansi.h>
#include <sys/types.h>
#include <sys/time.h>

#define	_ST_FSTYPSZ 16		/* array size for file system type name */

struct stat
  {
    dev_t st_dev;			/* Device.  */
    ino_t st_ino;			/* File serial number.	*/
    mode_t st_mode;			/* File mode.  */
    nlink_t st_nlink;			/* Link count.  */
    uid_t st_uid;			/* User ID of the file's owner.	*/
    gid_t st_gid;			/* Group ID of the file's group.*/
    dev_t st_rdev;			/* Device number, if device.  */
    off_t st_size;			/* Size of file, in bytes.  */
    blksize_t st_blksize;		/* Optimal block size for I/O.  */
    unsigned int __unused1;
    blkcnt_t st_blocks;		        /* Number 512-byte blocks allocated. */
    time_t st_atime;			/* Time of last access.  */
    unsigned int __unused2;
    time_t st_mtime;			/* Time of last modification.  */
    unsigned int __unused3;
    time_t st_ctime;			/* Time of last status change.  */
    unsigned int __unused4;
  };

#define	_IFMT		0170000	/* type of file */
#define		_IFDIR	0040000	/* directory */
#define		_IFCHR	0020000	/* character special */
#define		_IFBLK	0060000	/* block special */
#define		_IFREG	0100000	/* regular */
#define		_IFLNK	0120000	/* symbolic link */
#define		_IFSOCK	0140000	/* socket */
#define		_IFIFO	0010000	/* fifo */

#define	S_ISUID		0004000	/* set user id on execution */
#define	S_ISGID		0002000	/* set group id on execution */
#define	S_ISVTX		0001000	/* save swapped text even after use */
#define	S_IREAD		0000400	/* read permission, owner */
#define	S_IWRITE 	0000200	/* write permission, owner */
#define	S_IEXEC		0000100	/* execute/search permission, owner */
#define	S_ENFMT 	0002000	/* enforcement-mode locking */
#define	S_IFMT		_IFMT
#define	S_IFDIR		_IFDIR
#define	S_IFCHR		_IFCHR
#define	S_IFBLK		_IFBLK
#define	S_IFREG		_IFREG
#define	S_IFLNK		_IFLNK
#define	S_IFSOCK	_IFSOCK
#define	S_IFIFO		_IFIFO


#define	S_IRWXU 	0000700	/* rwx, owner */
#define		S_IRUSR	0000400	/* read permission, owner */
#define		S_IWUSR	0000200	/* write permission, owner */
#define		S_IXUSR	0000100	/* execute/search permission, owner */
#define	S_IRWXG		0000070	/* rwx, group */
#define		S_IRGRP	0000040	/* read permission, group */
#define		S_IWGRP	0000020	/* write permission, grougroup */
#define		S_IXGRP	0000010	/* execute/search permission, group */
#define	S_IRWXO		0000007	/* rwx, other */
#define		S_IROTH	0000004	/* read permission, other */
#define		S_IWOTH	0000002	/* write permission, other */
#define		S_IXOTH	0000001	/* execute/search permission, other */

#define	S_ISBLK(m)	(((m)&_IFMT) == _IFBLK)
#define	S_ISCHR(m)	(((m)&_IFMT) == _IFCHR)
#define	S_ISDIR(m)	(((m)&_IFMT) == _IFDIR)
#define	S_ISFIFO(m)	(((m)&_IFMT) == _IFIFO)
#define	S_ISREG(m)	(((m)&_IFMT) == _IFREG)
#define	S_ISLNK(m)	(((m)&_IFMT) == _IFLNK)
#define	S_ISSOCK(m)	(((m)&_IFMT) == _IFSOCK)

#ifdef __cplusplus
extern "C" {
#endif

int	_EXFUN(chmod,( const char *_path, mode_t _mode ));
int	_EXFUN(fstat,( int _fd, struct stat *_sbuf ));
int	_EXFUN(mkdir,( const char *_path, mode_t _mode ));
int	_EXFUN(mkfifo,( char *_path, mode_t _mode ));
int	_EXFUN(stat,( const char *_path, struct stat *_sbuf ));
mode_t	_EXFUN(umask,( mode_t _mask ));

#ifdef __cplusplus
}
#endif

#endif /* _SYS_STAT_H */
