199767f8919635c4928607450d9e0abb932109ceToomas Soome/*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1982, 1986, 1989, 1993
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (c) UNIX System Laboratories, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All or some portions of this file are derived from material licensed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to the University of California by American Telephone and Telegraph
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Co. or Unix System Laboratories, Inc. and are reproduced herein with
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the permission of UNIX System Laboratories, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * are met:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 4. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * @(#)stat.h 8.12 (Berkeley) 6/16/95
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SYS_STAT_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SYS_STAT_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/cdefs.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/_timespec.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/_types.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _BLKSIZE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __blksize_t blksize_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _BLKSIZE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _BLKCNT_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __blkcnt_t blkcnt_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _BLKCNT_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _DEV_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __dev_t dev_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _DEV_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _FFLAGS_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __fflags_t fflags_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _FFLAGS_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _GID_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __gid_t gid_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _GID_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _INO_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __ino_t ino_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _INO_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _MODE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __mode_t mode_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _MODE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _NLINK_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __nlink_t nlink_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _NLINK_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _OFF_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __off_t off_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _OFF_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _UID_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __uid_t uid_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _UID_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if !defined(_KERNEL) && __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * XXX We get miscellaneous namespace pollution with this.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/time.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct ostat {
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint16_t st_dev; /* inode's device */
199767f8919635c4928607450d9e0abb932109ceToomas Soome ino_t st_ino; /* inode's number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome mode_t st_mode; /* inode protection mode */
199767f8919635c4928607450d9e0abb932109ceToomas Soome nlink_t st_nlink; /* number of hard links */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint16_t st_uid; /* user ID of the file's owner */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint16_t st_gid; /* group ID of the file's group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint16_t st_rdev; /* device type */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __int32_t st_size; /* file size, in bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_atim; /* time of last access */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_mtim; /* time of last data modification */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_ctim; /* time of last file status change */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __int32_t st_blksize; /* optimal blocksize for I/O */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __int32_t st_blocks; /* blocks allocated for file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome fflags_t st_flags; /* user defined flags for file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint32_t st_gen; /* file generation number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct stat {
199767f8919635c4928607450d9e0abb932109ceToomas Soome __dev_t st_dev; /* inode's device */
199767f8919635c4928607450d9e0abb932109ceToomas Soome ino_t st_ino; /* inode's number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome mode_t st_mode; /* inode protection mode */
199767f8919635c4928607450d9e0abb932109ceToomas Soome nlink_t st_nlink; /* number of hard links */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uid_t st_uid; /* user ID of the file's owner */
199767f8919635c4928607450d9e0abb932109ceToomas Soome gid_t st_gid; /* group ID of the file's group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __dev_t st_rdev; /* device type */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_atim; /* time of last access */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_mtim; /* time of last data modification */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_ctim; /* time of last file status change */
199767f8919635c4928607450d9e0abb932109ceToomas Soome off_t st_size; /* file size, in bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome blkcnt_t st_blocks; /* blocks allocated for file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome blksize_t st_blksize; /* optimal blocksize for I/O */
199767f8919635c4928607450d9e0abb932109ceToomas Soome fflags_t st_flags; /* user defined flags for file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint32_t st_gen; /* file generation number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __int32_t st_lspare;
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_birthtim; /* time of file creation */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Explicitly pad st_birthtim to 16 bytes so that the size of
199767f8919635c4928607450d9e0abb932109ceToomas Soome * struct stat is backwards compatible. We use bitfields instead
199767f8919635c4928607450d9e0abb932109ceToomas Soome * of an array of chars so that this doesn't require a C99 compiler
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to compile if the size of the padding is 0. We use 2 bitfields
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to cover up to 64 bits on 32-bit machines. We assume that
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CHAR_BIT is 8...
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
199767f8919635c4928607450d9e0abb932109ceToomas Soome unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct nstat {
199767f8919635c4928607450d9e0abb932109ceToomas Soome __dev_t st_dev; /* inode's device */
199767f8919635c4928607450d9e0abb932109ceToomas Soome ino_t st_ino; /* inode's number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint32_t st_mode; /* inode protection mode */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint32_t st_nlink; /* number of hard links */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uid_t st_uid; /* user ID of the file's owner */
199767f8919635c4928607450d9e0abb932109ceToomas Soome gid_t st_gid; /* group ID of the file's group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __dev_t st_rdev; /* device type */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_atim; /* time of last access */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_mtim; /* time of last data modification */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_ctim; /* time of last file status change */
199767f8919635c4928607450d9e0abb932109ceToomas Soome off_t st_size; /* file size, in bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome blkcnt_t st_blocks; /* blocks allocated for file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome blksize_t st_blksize; /* optimal blocksize for I/O */
199767f8919635c4928607450d9e0abb932109ceToomas Soome fflags_t st_flags; /* user defined flags for file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome __uint32_t st_gen; /* file generation number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct timespec st_birthtim; /* time of file creation */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * See above about the following padding.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
199767f8919635c4928607450d9e0abb932109ceToomas Soome unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define st_atime st_atim.tv_sec
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define st_mtime st_mtim.tv_sec
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define st_ctime st_ctim.tv_sec
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define st_birthtime st_birthtim.tv_sec
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* For compatibility. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define st_atimespec st_atim
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define st_mtimespec st_mtim
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define st_ctimespec st_ctim
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define st_birthtimespec st_birthtim
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_KERNEL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISUID 0004000 /* set user id on execution */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISGID 0002000 /* set group id on execution */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISTXT 0001000 /* sticky bit */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IRWXU 0000700 /* RWX mask for owner */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IRUSR 0000400 /* R for owner */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IWUSR 0000200 /* W for owner */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IXUSR 0000100 /* X for owner */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IREAD S_IRUSR
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IWRITE S_IWUSR
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IEXEC S_IXUSR
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IRWXG 0000070 /* RWX mask for group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IRGRP 0000040 /* R for group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IWGRP 0000020 /* W for group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IXGRP 0000010 /* X for group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IRWXO 0000007 /* RWX mask for other */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IROTH 0000004 /* R for other */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IWOTH 0000002 /* W for other */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IXOTH 0000001 /* X for other */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __XSI_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFMT 0170000 /* type of file mask */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFIFO 0010000 /* named pipe (fifo) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFCHR 0020000 /* character special */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFDIR 0040000 /* directory */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFBLK 0060000 /* block special */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFREG 0100000 /* regular */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFLNK 0120000 /* symbolic link */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFSOCK 0140000 /* socket */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISVTX 0001000 /* save swapped text even after use */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_IFWHT 0160000 /* whiteout */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISFIFO(m) (((m) & 0170000) == 0010000) /* fifo or socket */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISSOCK(m) (((m) & 0170000) == 0140000) /* socket */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_ISWHT(m) (((m) & 0170000) == 0160000) /* whiteout */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* 7777 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* 0666 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define S_BLKSIZE 512 /* block size used in the stat struct */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Definitions of flags stored in file flags word.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Super-user and owner changeable flags.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_NODUMP 0x00000001 /* do not dump file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_APPEND 0x00000004 /* writes to file may only append */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * These two bits are defined in MacOS X. They are not currently used in
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FreeBSD.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if 0
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_COMPRESSED 0x00000020 /* file is compressed */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_TRACKED 0x00000040 /* renames and deletes are tracked */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_SYSTEM 0x00000080 /* Windows system file bit */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_SPARSE 0x00000100 /* sparse file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_OFFLINE 0x00000200 /* file is offline */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_REPARSE 0x00000400 /* Windows reparse point file bit */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_ARCHIVE 0x00000800 /* file needs to be archived */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_READONLY 0x00001000 /* Windows readonly file bit */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* This is the same as the MacOS X definition of UF_HIDDEN. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UF_HIDDEN 0x00008000 /* file is hidden */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Super-user changeable flags.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define SF_ARCHIVED 0x00010000 /* file is archived */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define SF_APPEND 0x00040000 /* writes to file may only append */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define SF_SNAPSHOT 0x00200000 /* snapshot inode */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Shorthand abbreviations of above.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define OPAQUE (UF_OPAQUE)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define APPEND (UF_APPEND | SF_APPEND)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NOUNLINK (UF_NOUNLINK | SF_NOUNLINK)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __BSD_VISIBLE */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200809
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UTIME_NOW -1
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define UTIME_OMIT -2
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome__BEGIN_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint chflags(const char *, unsigned long);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint chflagsat(int, const char *, unsigned long, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint chmod(const char *, mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint fchflags(int, unsigned long);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint fchmod(int, mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200809
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint fchmodat(int, const char *, mode_t, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint futimens(int fd, const struct timespec times[2]);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint utimensat(int fd, const char *path, const struct timespec times[2],
199767f8919635c4928607450d9e0abb932109ceToomas Soome int flag);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint fstat(int, struct stat *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint lchflags(const char *, unsigned long);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint lchmod(const char *, mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint lstat(const char * __restrict, struct stat * __restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mkdir(const char *, mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mkfifo(const char *, mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if !defined(_MKNOD_DECLARED) && __XSI_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mknod(const char *, mode_t, dev_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _MKNOD_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint stat(const char * __restrict, struct stat * __restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soomemode_t umask(mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200809
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint fstatat(int, const char *, struct stat *, int);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mkdirat(int, const char *, mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mkfifoat(int, const char *, mode_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __XSI_VISIBLE >= 700
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint mknodat(int, const char *, mode_t, dev_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome__END_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_KERNEL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_SYS_STAT_H_ */