UbixOS  2.0
descrip.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _KERN_DESCRIP_H
30 #define _KERN_DESCRIP_H
31 
32 #include <sys/thread.h>
33 #include <sys/sysproto_posix.h>
34 
35 #include <vfs/file.h>
36 #include <vfs/stat.h>
37 
38 #include <sys/fcntl.h>
39 
40 /* Limits */
41 //#define MAX_FILES 256
42 #define MAX_FILES 256
43 
44 typedef __mode_t mode_t;
46 
47 struct fileOps;
48 struct file;
49 struct uio;
50 //TMP
51 struct ucred;
52 //TMP
53 
54 /* Function Protos */
55 typedef int fo_rdwr_t(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td);
56 typedef int fo_stat_t(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td);
57 typedef int fo_close_t(struct file *fp, struct thread *td);
58 
59 struct ucred {
60  char pad;
61 };
62 
63 struct uio {
64  char pad;
65 };
66 
67 struct file {
70  struct fileOps *f_ops;
72  int fd_type;
73  int socket;
74  void *data;
75 };
76 
77 struct fileOps {
82 };
83 
84 #ifdef _BALLS
85 struct stat {
86  __dev_t st_dev; /* inode's device */
87  ino_t st_ino; /* inode's number */
88  mode_t st_mode; /* inode protection mode */
89  nlink_t st_nlink; /* number of hard links */
90  uid_t st_uid; /* user ID of the file's owner */
91  gid_t st_gid; /* group ID of the file's group */
92  __dev_t st_rdev; /* device type */
93 #if __BSD_VISIBLE
94  struct timespec st_atimespec; /* time of last access */
95  struct timespec st_mtimespec; /* time of last data modification */
96  struct timespec st_ctimespec; /* time of last file status change */
97 #else
98  time_t st_atime; /* time of last access */
99  long __st_atimensec; /* nsec of last access */
100  time_t st_mtime; /* time of last data modification */
101  long __st_mtimensec; /* nsec of last data modification */
102  time_t st_ctime; /* time of last file status change */
103  long __st_ctimensec; /* nsec of last file status change */
104 #endif
105  off_t st_size; /* file size, in bytes */
106  blkcnt_t st_blocks; /* blocks allocated for file */
107  blksize_t st_blksize; /* optimal blocksize for I/O */
108  fflags_t st_flags; /* user defined flags for file */
109  __uint32_t st_gen; /* file generation number */
111 #if __BSD_VISIBLE
112  struct timespec st_birthtimespec; /* time of file creation */
113  /*
114  * Explicitly pad st_birthtimespec to 16 bytes so that the size of
115  * struct stat is backwards compatible. We use bitfields instead
116  * of an array of chars so that this doesn't require a C99 compiler
117  * to compile if the size of the padding is 0. We use 2 bitfields
118  * to cover up to 64 bits on 32-bit machines. We assume that
119  * CHAR_BIT is 8...
120  */
121  unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
122  unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
123 #else
124  time_t st_birthtime; /* time of file creation */
125  long st_birthtimensec; /* nsec of file creation */
126  unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
127  unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
128 #endif
129 };
130 #endif
131 
132 int fcntl(struct thread*, struct sys_fcntl_args*);
133 int close(struct thread *, struct close_args *);
134 int falloc(struct thread *, struct file **, int *);
135 int getdtablesize(struct thread *, struct getdtablesize_args *);
136 int fstat(struct thread *, struct sys_fstat_args *);
137 int ioctl(struct thread *, struct ioctl_args *);
138 int getfd(struct thread *td, struct file **fp, int fd);
139 
140 int_kern_openat(struct thread *, int, char *, int);
141 
142 #endif
143 
144 /***
145  END
146  ***/
stat::st_size
off_t st_size
Definition: stat.h:58
stat
Definition: stat.h:44
ucred
Definition: descrip.h:59
sys_fstat_args
Definition: sysproto_posix.h:467
stat::__st_atimensec
long __st_atimensec
Definition: stat.h:53
stat::st_mtime
time_t st_mtime
Definition: stat.h:54
__dev_t
__uint32_t __dev_t
Definition: _types.h:48
fcntl.h
fileOps::stat
fo_stat_t * stat
Definition: descrip.h:80
file.h
stat::st_uid
uid_t st_uid
Definition: stat.h:49
fstat
int fstat(struct thread *, struct sys_fstat_args *)
Definition: descrip.c:184
gid_t
__gid_t gid_t
Definition: types.h:123
stat::st_lspare
__int32_t st_lspare
Definition: stat.h:63
fflags_t
__fflags_t fflags_t
Definition: types.h:126
file::data
void * data
Definition: descrip.h:74
__uint32_t
unsigned int __uint32_t
Definition: _types.h:38
file::f_flag
uint32_t f_flag
Definition: descrip.h:68
__mode_t
__uint16_t __mode_t
Definition: _types.h:49
fileDescriptor
Definition: file.h:62
ucred::pad
char pad
Definition: descrip.h:60
stat::st_blocks
blkcnt_t st_blocks
Definition: stat.h:59
sysproto_posix.h
close_args
Definition: sysproto_posix.h:372
fo_rdwr_t
int fo_rdwr_t(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
Definition: descrip.h:55
stat::st_nlink
__nlink_t st_nlink
Definition: stat.h:48
file
Definition: descrip.h:67
thread
Definition: thread.h:40
stat::st_mode
__mode_t st_mode
Definition: stat.h:47
sys_fcntl_args
Definition: sysproto_posix.h:252
ino_t
__ino_t ino_t
Definition: types.h:93
ioctl
int ioctl(struct thread *, struct ioctl_args *)
ioctl functionality not implimented yet
Definition: descrip.c:203
fcntl
int fcntl(struct thread *, struct sys_fcntl_args *)
Definition: descrip.c:41
stat::st_ctime
time_t st_ctime
Definition: stat.h:56
falloc
int falloc(struct thread *, struct file **, int *)
Definition: descrip.c:97
file::fd_type
int fd_type
Definition: descrip.h:72
file::f_type
uint16_t f_type
Definition: descrip.h:69
uint16_t
__uint16_t uint16_t
Definition: types.h:45
fileOps
Definition: descrip.h:77
file::f_ops
struct fileOps * f_ops
Definition: descrip.h:70
ioctl_args
Definition: sysproto_posix.h:475
int_kern_openat
int_kern_openat(struct thread *, int, char *, int)
file::fd
fileDescriptor_t * fd
Definition: descrip.h:71
mode_t
__mode_t mode_t
Definition: descrip.h:44
stat::__st_ctimensec
long __st_ctimensec
Definition: stat.h:57
fileOps::read
fo_rdwr_t * read
Definition: descrip.h:78
blksize_t
__blksize_t blksize_t
Definition: types.h:125
stat::st_rdev
__dev_t st_rdev
Definition: stat.h:51
fo_close_t
int fo_close_t(struct file *fp, struct thread *td)
Definition: descrip.h:57
getfd
int getfd(struct thread *td, struct file **fp, int fd)
get pointer to file fd in specified thread
Definition: descrip.c:213
blkcnt_t
__blkcnt_t blkcnt_t
Definition: types.h:124
uint32_t
__uint32_t uint32_t
Definition: types.h:46
stat::st_flags
fflags_t st_flags
Definition: stat.h:61
stat::st_ino
ino_t st_ino
Definition: stat.h:46
close
int close(struct thread *, struct close_args *)
Definition: descrip.c:161
__int32_t
int __int32_t
Definition: _types.h:37
time_t
__time_t time_t
Definition: _timespec.h:7
nlink_t
__nlink_t nlink_t
Definition: descrip.h:45
getdtablesize_args
Definition: sysproto_posix.h:435
stat::st_dev
__dev_t st_dev
Definition: stat.h:45
fileOps::close
fo_close_t * close
Definition: descrip.h:81
stat::int
unsigned int
Definition: stat.h:66
stat.h
stat::st_atime
time_t st_atime
Definition: stat.h:52
__timespec
Definition: stat.h:39
getdtablesize
int getdtablesize(struct thread *, struct getdtablesize_args *)
return data table size
Definition: descrip.c:175
__nlink_t
__uint16_t __nlink_t
Definition: _types.h:49
stat::st_birthtimensec
long st_birthtimensec
Definition: stat.h:65
off_t
__int64_t off_t
Definition: types.h:119
stat::st_birthtime
time_t st_birthtime
Definition: stat.h:64
stat::st_gid
gid_t st_gid
Definition: stat.h:50
timespec
Definition: _timespec.h:11
uid_t
__uid_t uid_t
Definition: types.h:122
file::socket
int socket
Definition: descrip.h:73
stat::st_blksize
blksize_t st_blksize
Definition: stat.h:60
uio
Definition: descrip.h:63
fileOps::write
fo_rdwr_t * write
Definition: descrip.h:79
fo_stat_t
int fo_stat_t(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td)
Definition: descrip.h:56
thread.h
stat::__st_mtimensec
long __st_mtimensec
Definition: stat.h:55
stat::st_gen
__uint32_t st_gen
Definition: stat.h:62
uio::pad
char pad
Definition: descrip.h:64