00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __SYSINTERF_FD_H__
00011 #define __SYSINTERF_FD_H__ 1
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #define SYSFD_ACCESS 128
00031 #define SYSFD_CHDIR 129
00032 #define SYSFD_CHMOD 130
00033 #define SYSFD_CHOWN 131
00034 #define SYSFD_CHROOT 132
00035 #define SYSFD_CLOSE 133
00036 #define SYSFD_MKFS 134
00037 #define SYSFD_FCHDIR 135
00038 #define SYSFD_FCHMOD 136
00039 #define SYSFD_FCHOWN 137
00040 #define SYSFD_FCNTL 138
00041 #define SYSFD_FSTAT 139
00042 #define SYSFD_FSTATFS 140
00043 #define SYSFD_FSYNC 141
00044 #define SYSFD_FTIME 142
00045 #define SYSFD_FTRUNCATE 143
00046 #define SYSFD_GETCWD 144
00047 #define SYSFD_GETDENTS 145
00048 #define SYSFD_LCHOWN 145
00049 #define SYSFD_LINK 146
00050 #define SYSFD_LSEEK 147
00051 #define SYSFD_LSTAT 148
00052 #define SYSFD_MKDIR 149
00053 #define SYSFD_MKNOD 150
00054 #define SYSFD_MOUNT 151
00055 #define SYSFD_OPEN 152
00056 #define SYSFD_READDIR 153
00057 #define SYSFD_READLINK 154
00058 #define SYSFD_READ 155
00059 #define SYSFD_RENAME 156
00060 #define SYSFD_RMDIR 157
00061 #define SYSFD_STAT 158
00062 #define SYSFD_STATFS 159
00063 #define SYSFD_TRUNCATE 160
00064 #define SYSFD_UMOUNT 161
00065 #define SYSFD_UNLINK 162
00066 #define SYSFD_WRITE 163
00067 #define SYSFD_IOCTL 164
00068 #define SYSFD_DUMP 165
00069 #define SYSFD_POLL 166
00070 #define SYSFD_SUBMOUNT 167
00071 #define SYSFD_SUBUMOUNT 168
00072 #define SYSFD_CHMBR 169
00073 #define SYSFD_SYMLINK 170
00074 #define SYSFD_GETERR 171
00075
00076
00077
00078
00079 typedef struct s_sys_fd_lseek_args
00080 {
00081 int gate_id;
00082 off_t offset;
00083 int whence;
00084 pid_t pid;
00085 } t_sys_fd_lseek_args;
00086
00087 typedef struct s_sys_fd_mount_args
00088 {
00089 char *type;
00090 char *dir;
00091 int flags;
00092 void *data;
00093 pid_t pid;
00094 } t_sys_fd_mount_args;
00095
00096
00097
00098
00099 #define FIOATTACH _IOW('f', 42, pid_t)
00100 #define FIODETACH _IOW('f', 43, pid_t)
00101
00102
00103
00104
00105 struct utimbuf
00106 {
00107 time_t actime;
00108 time_t modtime;
00109 };
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 #define O_RDONLY 0x00000000
00120 #define O_WRONLY 0x00000001
00121 #define O_RDWR 0x00000002
00122 #define O_ACCMODE 0x00000003
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00133 #define FREAD 0x00000001
00134 #define FWRITE 0x00000002
00135 #endif
00136 #define O_NONBLOCK 0x00000004
00137 #define O_APPEND 0x00000008
00138 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00139 #define O_SHLOCK 0x00000010
00140 #define O_EXLOCK 0x00000020
00141 #define O_ASYNC 0x00000040
00142 #endif
00143 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
00144 (_POSIX_C_SOURCE - 0) >= 199309L || \
00145 (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
00146 (_XOPEN_SOURCE - 0) >= 500
00147 #define O_SYNC 0x00000080
00148 #endif
00149 #define O_CREAT 0x00000200
00150 #define O_TRUNC 0x00000400
00151 #define O_EXCL 0x00000800
00152
00153 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
00154 (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500
00155 #define O_DSYNC 0x00010000
00156 #define O_RSYNC 0x00020000
00157 #endif
00158
00159 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00160 #define O_ALT_IO 0x00040000
00161 #endif
00162
00163
00164 #define O_NOCTTY 0x008000
00165
00166
00167
00168
00169
00170
00171 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00172 #define FAPPEND O_APPEND
00173 #define FASYNC O_ASYNC
00174 #define O_FSYNC O_SYNC
00175 #define FNDELAY O_NONBLOCK
00176 #define O_NDELAY O_NONBLOCK
00177 #endif
00178 #if defined(_KERNEL)
00179 #define FNONBLOCK O_NONBLOCK
00180 #define FFSYNC O_SYNC
00181 #define FDSYNC O_DSYNC
00182 #define FRSYNC O_RSYNC
00183 #define FALTIO O_ALT_IO
00184 #endif
00185
00186
00187
00188
00189
00190
00191 #define F_DUPFD 0
00192 #define F_GETFD 1
00193 #define F_SETFD 2
00194 #define F_GETFL 3
00195 #define F_SETFL 4
00196 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00197 #define F_GETOWN 5
00198 #define F_SETOWN 6
00199 #endif
00200 #define F_GETLK 7
00201 #define F_SETLK 8
00202 #define F_SETLKW 9
00203
00204
00205 #define FD_CLOEXEC 1
00206
00207
00208 #define F_RDLCK 1
00209 #define F_UNLCK 2
00210 #define F_WRLCK 3
00211
00212
00213 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00214 #define F_PARAM_MASK 0xfff
00215 #define F_PARAM_LEN(x) (((x) >> 16) & F_PARAM_MASK)
00216 #define F_PARAM_MAX 4095
00217 #define F_FSCTL (int)0x80000000
00218 #define F_FSVOID (int)0x40000000
00219 #define F_FSOUT (int)0x20000000
00220 #define F_FSIN (int)0x10000000
00221 #define F_FSINOUT (F_FSIN | F_FSOUT)
00222 #define F_FSDIRMASK (int)0x70000000
00223 #define F_FSPRIV (int)0x00008000
00224
00225
00226
00227
00228
00229 #define _FCN(inout, num, len) \
00230 (F_FSCTL | inout | ((len & F_PARAM_MASK) << 16) | (num))
00231 #define _FCNO(c) _FCN(F_FSVOID, (c), 0)
00232 #define _FCNR(c, t) _FCN(F_FSIN, (c), (int)sizeof(t))
00233 #define _FCNW(c, t) _FCN(F_FSOUT, (c), (int)sizeof(t))
00234 #define _FCNRW(c, t) _FCN(F_FSINOUT, (c), (int)sizeof(t))
00235
00236
00237
00238
00239 #define _FCN_FSPRIV(inout, num, len) \
00240 (F_FSCTL | F_FSPRIV | inout | ((len & F_PARAM_MASK) << 16) | (num))
00241 #define _FCNO_FSPRIV(c) _FCN_FSPRIV(F_FSVOID, (c), 0)
00242 #define _FCNR_FSPRIV(c, t) _FCN_FSPRIV(F_FSIN, (c), (int)sizeof(t))
00243 #define _FCNW_FSPRIV(c, t) _FCN_FSPRIV(F_FSOUT, (c), (int)sizeof(t))
00244 #define _FCNRW_FSPRIV(c, t) _FCN_FSPRIV(F_FSINOUT, (c), (int)sizeof(t))
00245
00246 #endif
00247
00248
00249
00250
00251
00252 struct flock {
00253 off_t l_start;
00254 off_t l_len;
00255 pid_t l_pid;
00256 short l_type;
00257 short l_whence;
00258 };
00259
00260
00261 #define LOCK_SH 0x01
00262 #define LOCK_EX 0x02
00263 #define LOCK_NB 0x04
00264 #define LOCK_UN 0x08
00265
00266
00267 #ifndef SEEK_SET
00268 #define SEEK_SET 0
00269 #endif
00270 #ifndef SEEK_CUR
00271 #define SEEK_CUR 1
00272 #endif
00273 #ifndef SEEK_END
00274 #define SEEK_END 2
00275 #endif
00276
00277
00278
00279
00280 #define __NBBY 8
00281 typedef int32_t __fd_mask;
00282 #define __NFDBITS (sizeof(__fd_mask) * __NBBY)
00283
00284 #ifndef howmany
00285 #define __howmany(x, y) (((x) + ((y) - 1)) / (y))
00286 #else
00287 #define __howmany(x, y) howmany(x, y)
00288 #endif
00289
00290
00291
00292
00293
00294
00295
00296 #ifndef FD_SETSIZE
00297 #define FD_SETSIZE 256
00298 #endif
00299
00300 typedef struct fd_set
00301 {
00302 __fd_mask fds_bits[__howmany(FD_SETSIZE, __NFDBITS)];
00303 } fd_set;
00304
00305 #define FD_SET(n, p) \
00306 ((p)->fds_bits[(n)/__NFDBITS] |= (1 << ((n) % __NFDBITS)))
00307 #define FD_CLR(n, p) \
00308 ((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS)))
00309 #define FD_ISSET(n, p) \
00310 ((p)->fds_bits[(n)/__NFDBITS] & (1 << ((n) % __NFDBITS)))
00311 #define FD_ZERO(p) (void)memset((p), 0, sizeof(*(p)))
00312
00313
00314
00315
00316 typedef unsigned int nfds_t;
00317
00318 struct pollfd {
00319 int fd;
00320 short events;
00321 short revents;
00322 };
00323
00324
00325
00326
00327 #define POLLIN 0x0001
00328 #define POLLPRI 0x0002
00329 #define POLLOUT 0x0004
00330 #define POLLRDNORM 0x0040
00331 #define POLLWRNORM POLLOUT
00332 #define POLLRDBAND 0x0080
00333 #define POLLWRBAND 0x0100
00334
00335
00336
00337
00338 #define POLLERR 0x0008
00339 #define POLLHUP 0x0010
00340 #define POLLNVAL 0x0020
00341
00342
00343
00344
00345 #define INFTIM -1
00346
00347
00348
00349
00350 typedef struct s_pollrec
00351 {
00352 int fd;
00353 int gate;
00354 int gate_id;
00355 short events;
00356 short revents;
00357 } t_pollrec;
00358
00359
00360
00361
00362
00363
00364 #define IOCPARM_MASK 0x1fff
00365 #define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
00366 #define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16))
00367 #define IOCGROUP(x) (((x) >> 8) & 0xff)
00368
00369 #define IOCPARM_MAX NBPG
00370
00371 #define IOC_VOID (unsigned long)0x20000000
00372
00373 #define IOC_OUT (unsigned long)0x40000000
00374
00375 #define IOC_IN (unsigned long)0x80000000
00376
00377 #define IOC_INOUT (IOC_IN|IOC_OUT)
00378
00379 #define IOC_DIRMASK (unsigned long)0xe0000000
00380
00381 #define _IOC(inout,group,num,len) \
00382 (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
00383 #define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
00384 #define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
00385 #define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
00386
00387 #define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
00388
00389 struct stat
00390 {
00391 dev_t st_dev;
00392 ino_t st_ino;
00393 mode_t st_mode;
00394 nlink_t st_nlink;
00395 uid_t st_uid;
00396 gid_t st_gid;
00397 dev_t st_rdev;
00398 off_t st_size;
00399 blksize_t st_blksize;
00400 blkcnt_t st_blocks;
00401 time_t st_atime;
00402 time_t st_mtime;
00403 time_t st_ctime;
00404 };
00405 #define S_ISUID 0004000
00406 #define S_ISGID 0002000
00407 #define S_ISTXT 0001000
00408
00409 #define S_IRWXU 0000700
00410 #define S_IRUSR 0000400
00411 #define S_IWUSR 0000200
00412 #define S_IXUSR 0000100
00413
00414 #define S_IREAD S_IRUSR
00415 #define S_IWRITE S_IWUSR
00416 #define S_IEXEC S_IXUSR
00417
00418 #define S_IRWXG 0000070
00419 #define S_IRGRP 0000040
00420 #define S_IWGRP 0000020
00421 #define S_IXGRP 0000010
00422
00423 #define S_IRWXO 0000007
00424 #define S_IROTH 0000004
00425 #define S_IWOTH 0000002
00426 #define S_IXOTH 0000001
00427
00428 #define _S_IFMT 0170000
00429 #define _S_IFIFO 0010000
00430 #define _S_IFCHR 0020000
00431 #define _S_IFDIR 0040000
00432 #define _S_IFBLK 0060000
00433 #define _S_IFREG 0100000
00434 #define _S_IFLNK 0120000
00435 #define _S_ISVTX 0001000
00436 #define _S_IFSOCK 0140000
00437 #define _S_IFWHT 0160000
00438 #define _S_ARCH1 0200000
00439 #define _S_ARCH2 0400000
00440
00441 #define S_IFMT _S_IFMT
00442 #define S_IFIFO _S_IFIFO
00443 #define S_IFCHR _S_IFCHR
00444 #define S_IFDIR _S_IFDIR
00445 #define S_IFBLK _S_IFBLK
00446 #define S_IFREG _S_IFREG
00447 #define S_IFLNK _S_IFLNK
00448 #define S_ISVTX _S_ISVTX
00449
00450 #define S_IFSOCK _S_IFSOCK
00451 #define S_IFWHT _S_IFWHT
00452
00453 #define S_ARCH1 _S_ARCH1
00454 #define S_ARCH2 _S_ARCH2
00455
00456 #define S_ISDIR(m) ((m & _S_IFMT) == _S_IFDIR)
00457 #define S_ISCHR(m) ((m & _S_IFMT) == _S_IFCHR)
00458 #define S_ISBLK(m) ((m & _S_IFMT) == _S_IFBLK)
00459 #define S_ISREG(m) ((m & _S_IFMT) == _S_IFREG)
00460 #define S_ISFIFO(m) ((m & _S_IFMT) == _S_IFIFO)
00461 #define S_ISLNK(m) ((m & _S_IFMT) == _S_IFLNK)
00462 #define S_ISSOCK(m) ((m & _S_IFMT) == _S_IFSOCK)
00463 #define S_ISWHT(m) ((m & _S_IFMT) == _S_IFWHT)
00464
00465
00466 #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
00467
00468 #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
00469
00470 #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
00471
00472 #define S_BLKSIZE 512
00473
00474
00475
00476
00477
00478
00479 #define UF_SETTABLE 0x0000ffff
00480 #define UF_NODUMP 0x00000001
00481 #define UF_IMMUTABLE 0x00000002
00482 #define UF_APPEND 0x00000004
00483 #define UF_OPAQUE 0x00000008
00484
00485
00486
00487 #define SF_SETTABLE 0xffff0000
00488 #define SF_ARCHIVED 0x00010000
00489 #define SF_IMMUTABLE 0x00020000
00490 #define SF_APPEND 0x00040000
00491
00492
00493
00494
00495 #define MAXPATHLEN PATH_MAX
00496 #define MAXFSTYPELEN 32
00497 #define MAXSYMLINKS 32
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526 int gate_ftruncate(int gate, int gate_id, off_t length, pid_t pid);
00527 int gate_truncate(int gate, const char *path, off_t length, pid_t pid);
00528 ssize_t gate_write(int gate, int gate_id, const void *buf, size_t len, pid_t pid);
00529 ssize_t gate_read(int gate, int gate_id, void *buf, size_t len, pid_t pid);
00530 int gate_open(int gate, const char *path, int flags, mode_t mode, pid_t pid);
00531 int gate_close(int gate, int gate_id, pid_t pid);
00532 int gate_access(int gate, const char *path, int mode, pid_t pid);
00533 int gate_chmod(int gate, const char *path, mode_t mode, pid_t pid);
00534 int gate_getdents(int gate, int gate_id, char *buf, size_t nbytes, pid_t pid);
00535 int gate_chdir(int gate, const char *path, pid_t pid);
00536 int gate_mkdir(int gate, const char *path, mode_t mode, pid_t pid);
00537 int gate_rmdir(int gate, const char *path, pid_t pid);
00538 int gate_poll(int gate, t_pollrec *pollrecs, nfds_t npollrecs, pid_t pid);
00539 int gate_link(int gate, const char *path1, const char *path2, pid_t pid);
00540 int gate_symlink(int gate, const char *path1, const char *path2, pid_t pid);
00541 int gate_unlink(int gate, const char *path, pid_t pid);
00542 int gate_readlink(int gate, const char *path, char *buf, size_t bufsiz, pid_t pid);
00543 off_t gate_lseek(int gate, int gate_id, off_t offset, int whence, pid_t pid);
00544 int gate_mount(int gate, const char *type, const char *dir, int flags, void *data, pid_t pid);
00545 int gate_umount(int gate, const char *dir, pid_t pid);
00546 int gate_rename(int gate, char *path1, char *path2, pid_t pid);
00547 int gate_fstat(int gate, int gate_id, struct stat *sb, pid_t pid);
00548 int gate_stat(int gate, const char *path, struct stat *sb, pid_t pid);
00549 int gate_lstat(int gate, const char *path, struct stat *sb, pid_t pid);
00550 int gate_ioctl(int gate, int gate_id, unsigned long request, void *argp, pid_t pid);
00551 int gate_mkfs(int gate, int pdev, pid_t pid);
00552 int gate_writembr(int gate, int pdev, pid_t pid);
00553 #endif