text: /*
   * Copyright (c) 2007 Open Kernel Labs, Inc. (Copyright Holder).
   * All rights reserved.
   *
   * 1. Redistribution and use of OKL4 (Software) in source and binary
   * forms, with or without modification, are permitted provided that the
   * following conditions are met:
   *
   *     (a) Redistributions of source code must retain this clause 1
   *         (including paragraphs (a), (b) and (c)), clause 2 and clause 3
   *         (Licence Terms) and the above copyright notice.
   *
   *     (b) Redistributions in binary form must reproduce the above
   *         copyright notice and the Licence Terms in the documentation and/or
   *         other materials provided with the distribution.
   *
   *     (c) Redistributions in any form must be accompanied by information on
   *         how to obtain complete source code for:
   *        (i) the Software; and
   *        (ii) all accompanying software that uses (or is intended to
   *        use) the Software whether directly or indirectly.  Such source
   *        code must:
   *        (iii) either be included in the distribution or be available
   *        for no more than the cost of distribution plus a nominal fee;
   *        and
   *        (iv) be licensed by each relevant holder of copyright under
   *        either the Licence Terms (with an appropriate copyright notice)
   *        or the terms of a licence which is approved by the Open Source
   *        Initative.  For an executable file, "complete source code"
   *        means the source code for all modules it contains and includes
   *        associated build and other files reasonably required to produce
   *        the executable.
   *
   * 2. THIS SOFTWARE IS PROVIDED ``AS IS'' AND, TO THE EXTENT PERMITTED BY
   * LAW, ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
   * THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
   * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED.  WHERE ANY WARRANTY IS
   * IMPLIED AND IS PREVENTED BY LAW FROM BEING DISCLAIMED THEN TO THE
   * EXTENT PERMISSIBLE BY LAW: (A) THE WARRANTY IS READ DOWN IN FAVOUR OF
   * THE COPYRIGHT HOLDER (AND, IN THE CASE OF A PARTICIPANT, THAT
   * PARTICIPANT) AND (B) ANY LIMITATIONS PERMITTED BY LAW (INCLUDING AS TO
   * THE EXTENT OF THE WARRANTY AND THE REMEDIES AVAILABLE IN THE EVENT OF
   * BREACH) ARE DEEMED PART OF THIS LICENCE IN A FORM MOST FAVOURABLE TO
   * THE COPYRIGHT HOLDER (AND, IN THE CASE OF A PARTICIPANT, THAT
   * PARTICIPANT). IN THE LICENCE TERMS, "PARTICIPANT" INCLUDES EVERY
   * PERSON WHO HAS CONTRIBUTED TO THE SOFTWARE OR WHO HAS BEEN INVOLVED IN
   * THE DISTRIBUTION OR DISSEMINATION OF THE SOFTWARE.
   *
   * 3. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ANY OTHER PARTICIPANT BE
   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
   * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
   * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
  #ifndef __STAT_H
  #define __STAT_H
  
  #include <sys/types.h>
  
  #define S_IFBLK 0x1
  #define S_IFCHR 0x2
  #define S_IFIFO 0x4
  #define S_IFREG 0x8
  #define S_IFDIR 0x10
  #define S_IFSOCK 0x20
  #define S_IFMT 0x3F
  
  #define S_IRUSR 0x40
  #define S_IWUSR 0x80
  #define S_IXUSR 0x100
  #define S_IRWXU 0x1C0
  
  #define S_IRGRP 0x200
  #define S_IWGRP 0x400
  #define S_IXGRP 0x800
  #define S_IRWXG 0xE00
  
  #define S_IROTH 0x1000
  #define S_IWOTH 0x2000
  #define S_IXOTH 0x4000
  #define S_IRWXO 0x7000
  
  #define S_ISUID 0x8000
  #define S_ISGID 0x10000
  #define S_ISVTX 0x20000
  
  
  struct stat {
      int fake;
      mode_t st_mode;
      ino_t st_ino;
      off_t st_size;
  
      time_t st_atime;
      time_t st_mtime;
      time_t st_ctime;  
  };
  
  #define S_ISREG(m)  ((m) & S_IFREG)
  #define S_ISCHR(m)  (0)
  #define S_ISDIR(m)  (0)
  #define S_ISFIFO(m) ((m) & S_IFIFO)
  #define S_ISLNK(m)  (0)
  #define S_ISSOCK(m) (0)
  #define S_ISBLK(m)  (0)
  
  /* Get file status; currently only size and flags
   *
   * @param fildes        file descriptor to get information about
   * @param buf           buffer to store the file status
   *
   * @return 0 on success, or -1 and set errno on error
   */
  int fstat(int fildes, struct stat *buf);
  
  /* Create a FIFO special file representing an inter-VM channel
   *
   * @param path          name of the file to be created
   * @param mode          type of file and access flags
   * @param dev           device number (must be 0)
   *
   * @return a file descriptor to the new file
   */
  int mknod(const char *path, mode_t mode, dev_t dev);
  
  #ifdef __USE_POSIX
  #include <posix/sys/stat.h>
  #endif /* __USE_POSIX */
  
  #endif /* __STAT_H */
  