/*1* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 20092* The President and Fellows of Harvard College.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the University nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _SYS_STAT_H_30#define _SYS_STAT_H_3132/*33* Get struct stat and all the #defines from the kernel34*/35#include <kern/stat.h>36#include <kern/stattypes.h>3738/*39* Test macros for object types.40*/41#define S_ISDIR(mode) ((mode & _S_IFMT) == _S_IFDIR)42#define S_ISREG(mode) ((mode & _S_IFMT) == _S_IFREG)43#define S_ISDIR(mode) ((mode & _S_IFMT) == _S_IFDIR)44#define S_ISLNK(mode) ((mode & _S_IFMT) == _S_IFLNK)45#define S_ISIFO(mode) ((mode & _S_IFMT) == _S_IFIFO)46#define S_ISSOCK(mode) ((mode & _S_IFMT) ==_S_IFSOCK)47#define S_ISCHR(mode) ((mode & _S_IFMT) == _S_IFCHR)48#define S_ISBLK(mode) ((mode & _S_IFMT) == _S_IFBLK)4950/*51* Provide non-underscore names. These are not actually standard; for52* some reason only the test macros are.53*/54#define S_IFMT _S_IFMT55#define S_IFREG _S_IFREG56#define S_IFDIR _S_IFDIR57#define S_IFLNK _S_IFLNK58#define S_IFIFO _S_IFIFO59#define S_IFSOCK _S_IFSOCK60#define S_IFCHR _S_IFCHR61#define S_IFBLK _S_IFBLK6263/*64* stat is the same as fstat, only on a file that isn't already65* open. lstat is the same as stat, only if the name passed names a66* symlink, information about the symlink is returned rather than67* information about the file it points to. You don't need to68* implement lstat unless you're implementing symbolic links.69*/70int fstat(int filehandle, struct stat *buf);71int stat(const char *path, struct stat *buf);72int lstat(const char *path, struct stat *buf);7374/*75* The second argument to mkdir is the mode for the new directory.76* Unless you're implementing security and permissions, you can77* (and should) ignore it. See notes in unistd.h.78*/79int mkdir(const char *dirname, int ignore);808182#endif /* _SYS_STAT_H_ */838485