/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: stat.h 1.15 90/06/24 $"

#ifndef	_SYS_STAT_H_

/* $Log:	stat.h,v $
*/

#include "sys/types.h"

/*----------------------------------------------------------------------*
 * This file must meet the requirements in volume 2 of the X/Open	*
 * Portability Guide, Issue 3, which should be consulted before any	*
 * changes are made.							*
 *----------------------------------------------------------------------*/

/*____________________________________________________________________*
 * This file forms part of the POSIX requirement described in section *
 * 5.6.1 of 1003.1-1988 which should be refered to before making any  *
 * changes.							      *
 *____________________________________________________________________*/


/*
 * stat structure, used by stat(2) and fstat(2)
 */

struct	stat {
	dev_t	st_dev;
	ino_t	st_ino;
	mode_t 	st_mode;
	nlink_t	st_nlink;
	uid_t	st_uid;
	gid_t 	st_gid;
	dev_t	st_rdev;
	off_t	st_size;
	timeval_t	st_atimeval;
	timeval_t	st_mtimeval;
	timeval_t	st_ctimeval;
};

#define st_atime	st_atimeval.tv_sec
#define st_mtime	st_mtimeval.tv_sec
#define st_ctime	st_ctimeval.tv_sec

#define	S_IFMT	0170000		/* type of file */
#define		S_IFDIR	0040000	/* directory */
#define		S_IFCHR	0020000	/* character special */
#define		S_IFBLK	0060000	/* block special */
#define		S_IFREG	0100000	/* regular */
#define		S_IFIFO	0010000	/* fifo */
#ifndef	_POSIX_SOURCE
#define		S_IFLNK	0120000	/* symbolic link */
#define	S_ENFMT	S_ISGID		/* record locking enforcement flag */
#define	S_ISVTX	01000		/* save swapped text even after use */
#endif	/*_POSIX_SOURCE*/
#define	S_ISUID	04000		/* set user id on execution */
#define	S_ISGID	02000		/* set group id on execution */
#define	S_IREAD	00400		/* read permission, owner */
#define	S_IWRITE	00200	/* write permission, owner */
#define	S_IEXEC	00100		/* execute/search permission, owner */
#define	S_IRWXU	00700		/* read, write, execute: owner */
#define	S_IRUSR	00400		/* read permission: owner */
#define	S_IWUSR	00200		/* write permission: owner */
#define	S_IXUSR	00100		/* execute permission: owner */
#define	S_IRWXG	00070		/* read, write, execute: group */
#define	S_IRGRP	00040		/* read permission: group */
#define	S_IWGRP	00020		/* write permission: group */
#define	S_IXGRP	00010		/* execute permission: group */
#define	S_IRWXO	00007		/* read, write, execute: other */
#define	S_IROTH	00004		/* read permission: other */
#define	S_IWOTH	00002		/* write permission: other */
#define	S_IXOTH	00001		/* execute permission: other */

/* POSIX 1003.1-1988 5.6.1.1 */
/* The following macros test whether a file is of the specified type.
 * The macros evaluate to a non-zero value if the test is true, or zero
 * if the test is false.  These are provided for POSIX compliance.
 */

/* Test macro for a directory file */
#define	S_ISDIR(m)	((((int)(m) & S_IFMT) == S_IFDIR) ? 1 : 0)

/* Test macro for a character special file */
#define	S_ISCHR(m)	((((int)(m) & S_IFMT) == S_IFCHR) ? 1 : 0)

/* Test macro for a block special file */
#define	S_ISBLK(m)	((((int)(m) & S_IFMT) == S_IFBLK) ? 1 : 0)

/* Test macro for a regular file */
#define	S_ISREG(m)	((((int)(m) & S_IFMT) == S_IFREG) ? 1 : 0)

/* Test macro for a pipe or FIFO special file */
#define	S_ISFIFO(m)	((((int)(m) & S_IFMT) == S_IFIFO) ? 1 : 0)

#ifndef	_POSIX_SOURCE
/* Test macro for a symbolic link to a file (not a requirement of POSIX) */
#define	S_ISLNK(m)	((((int)(m) & S_IFMT) == S_IFLNK) ? 1 : 0)
#endif	/*_POSIX_SOURCE*/

#ifndef NO_XPG3_HDR
#ifndef INKERNEL
extern mode_t umask();
extern int chmod();
extern int fstat();
extern int mkdir();
extern int mkfifo();
extern int stat();
#endif	/* ! INKERNEL */
#endif	/* NO_XPG3_HDR */

#define	_SYS_STAT_H_
#endif	/*_SYS_STAT_H_*/
