kern_descrip.h

Go to the documentation of this file.
00001 /*****************************************************************************************
00002  Copyright (c) 2002-2004 The UbixOS Project
00003  All rights reserved.
00004 
00005  Redistribution and use in source and binary forms, with or without modification, are
00006  permitted provided that the following conditions are met:
00007 
00008  Redistributions of source code must retain the above copyright notice, this list of
00009  conditions, the following disclaimer and the list of authors.  Redistributions in binary
00010  form must reproduce the above copyright notice, this list of conditions, the following
00011  disclaimer and the list of authors in the documentation and/or other materials provided
00012  with the distribution. Neither the name of the UbixOS Project nor the names of its
00013  contributors may be used to endorse or promote products derived from this software
00014  without specific prior written permission.
00015 
00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
00017  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00018  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
00019  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00020  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00021  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00022  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00023  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00024  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 
00026  $Id: kern__descrip_8h-source.html 88 2016-01-12 00:11:29Z reddawg $
00027 
00028 *****************************************************************************************/
00029 
00030 #ifndef _KERN_DESCRIP_H
00031 #define _KERN_DESCRIP_H
00032 
00033 #include <sys/thread.h>
00034 #include <sys/sysproto.h>
00035 
00036 #include <vfs/file.h>
00037 
00038 typedef  __mode_t        mode_t;
00039 typedef  __nlink_t       nlink_t;
00040 
00041 /* command values */
00042 #define F_DUPFD         0               /* duplicate file descriptor */
00043 #define F_GETFD         1               /* get file descriptor flags */
00044 #define F_SETFD         2               /* set file descriptor flags */
00045 #define F_GETFL         3               /* get file status flags */
00046 #define F_SETFL         4               /* set file status flags */
00047 #define F_GETOWN        5               /* get SIGIO/SIGURG proc/pgrp */
00048 #define F_SETOWN        6               /* set SIGIO/SIGURG proc/pgrp */
00049 #define F_GETLK         7               /* get record locking information */
00050 #define F_SETLK         8               /* set record locking information */
00051 #define F_SETLKW        9               /* F_SETLK; wait if blocked */
00052 
00053 /* Flag Values */
00054 #define FREAD           0x0001
00055 #define FWRITE          0x0002
00056 #define O_NONBLOCK      0x0004          /* no delay */
00057 #define O_APPEND        0x0008          /* set append mode */
00058 #define O_SHLOCK        0x0010          /* open with shared file lock */
00059 #define O_EXLOCK        0x0020          /* open with exclusive file lock */
00060 #define O_ASYNC         0x0040          /* signal pgrp when data ready */
00061 #define O_FSYNC         0x0080          /* synchronous writes */
00062 #define O_SYNC          0x0080          /* POSIX synonym for O_FSYNC */
00063 #define O_NOFOLLOW      0x0100          /* don't follow symlinks */
00064 #define O_CREAT         0x0200          /* create if nonexistent */
00065 #define O_TRUNC         0x0400          /* truncate to zero length */
00066 #define O_EXCL          0x0800          /* error if already exists */
00067 #define O_DIRECT        0x00010000
00068 #define O_RDONLY        0x0000          /* open for reading only */
00069 #define O_WRONLY        0x0001          /* open for writing only */
00070 #define O_RDWR          0x0002          /* open for reading and writing */
00071 #define O_ACCMODE       0x0003          /* mask for above modes */
00072 
00073 
00074 #define FHASLOCK        0x4000          /* descriptor holds advisory lock */
00075 
00076 
00077 /* F MAPPERS */
00078 #define FAPPEND         O_APPEND        /* kernel/compat */
00079 #define FASYNC          O_ASYNC         /* kernel/compat */
00080 #define FFSYNC          O_FSYNC         /* kernel */
00081 #define FNONBLOCK       O_NONBLOCK      /* kernel */
00082 #define FNDELAY         O_NONBLOCK      /* compat */
00083 #define O_NDELAY        O_NONBLOCK      /* compat */
00084 #define FPOSIXSHM       O_NOFOLLOW
00085 
00086 
00087 
00088 #define FCNTLFLAGS      (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT)
00089 
00090 #define FFLAGS(oflags)  ((oflags) + 1)
00091 #define OFLAGS(fflags)  ((fflags) - 1)
00092 
00093 struct file {
00094   int f_flag;
00095   char path[1024];
00096   fileDescriptor *fd;
00097   };
00098 
00099 /* TEMP */
00100 struct __timespec {
00101         __time_t tv_sec;        /* seconds */
00102         long    tv_nsec;        /* and nanoseconds */
00103 };
00104 
00105 struct stat {
00106         __dev_t   st_dev;               /* inode's device */
00107         ino_t     st_ino;               /* inode's number */
00108         mode_t    st_mode;              /* inode protection mode */
00109         nlink_t   st_nlink;             /* number of hard links */
00110         uid_t     st_uid;               /* user ID of the file's owner */
00111         gid_t     st_gid;               /* group ID of the file's group */
00112         __dev_t   st_rdev;              /* device type */
00113 #if __BSD_VISIBLE
00114         struct  timespec st_atimespec;  /* time of last access */
00115         struct  timespec st_mtimespec;  /* time of last data modification */
00116         struct  timespec st_ctimespec;  /* time of last file status change */
00117 #else
00118         time_t    st_atime;             /* time of last access */
00119         long      __st_atimensec;       /* nsec of last access */
00120         time_t    st_mtime;             /* time of last data modification */
00121         long      __st_mtimensec;       /* nsec of last data modification */
00122         time_t    st_ctime;             /* time of last file status change */
00123         long      __st_ctimensec;       /* nsec of last file status change */
00124 #endif
00125         off_t     st_size;              /* file size, in bytes */
00126         blkcnt_t st_blocks;             /* blocks allocated for file */
00127         blksize_t st_blksize;           /* optimal blocksize for I/O */
00128         fflags_t  st_flags;             /* user defined flags for file */
00129         __uint32_t st_gen;              /* file generation number */
00130         __int32_t st_lspare;
00131 #if __BSD_VISIBLE
00132         struct timespec st_birthtimespec; /* time of file creation */
00133         /*
00134          * Explicitly pad st_birthtimespec to 16 bytes so that the size of
00135          * struct stat is backwards compatible.  We use bitfields instead
00136          * of an array of chars so that this doesn't require a C99 compiler
00137          * to compile if the size of the padding is 0.  We use 2 bitfields
00138          * to cover up to 64 bits on 32-bit machines.  We assume that
00139          * CHAR_BIT is 8...
00140          */
00141         unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
00142         unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
00143 #else
00144         time_t    st_birthtime;         /* time of file creation */
00145         long      st_birthtimensec;     /* nsec of file creation */
00146         unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
00147         unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
00148 #endif
00149 };
00150 
00151 
00152 int fcntl(struct thread *, struct fcntl_args *);
00153 int close(struct thread *,struct close_args *);
00154 int falloc(struct thread *, struct file **, int *);
00155 int getdtablesize(struct thread *, struct getdtablesize_args *);
00156 int fstat(struct thread *, struct fstat_args *);
00157 int ioctl(struct thread *, struct ioctl_args *);
00158 int getfd(struct thread *td,struct file **fp,int fd);
00159 
00160 
00161 #endif
00162 
00163 /***
00164  END
00165  ***/

Generated on Fri Dec 15 11:18:54 2006 for UbixOS V2 by  doxygen 1.4.7