1 /*
2  * This file belongs to FreeMiNT. It's not in the original MiNT 1.12
3  * distribution. See the file CHANGES for a detailed log of changes.
4  *
5  *
6  * Copyright 2000 Frank Naumann <fnaumann@freemint.de>
7  * All rights reserved.
8  *
9  * This file is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * This file is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  *
24  * begin:	2001-03-01
25  * last change:	2001-03-01
26  *
27  * Author:	Frank Naumann <fnaumann@freemint.de>
28  *
29  * Please send suggestions, patches or bug reports to me or
30  * the MiNT mailing list.
31  *
32  */
33 
34 # ifndef _mint_fcntl_h
35 # define _mint_fcntl_h
36 
37 
38 /* flags for open() modes */
39 # define O_RDONLY	0x00000000	/* open for reading only */
40 # define O_WRONLY	0x00000001	/* open for writing only */
41 # define O_RDWR		0x00000002	/* open for reading and writing */
42 # define O_ACCMODE	0x00000003	/* mask for above modes */
43 # define O_RWMODE  	0x00000003	/* isolates file read/write mode */
44 # define O_EXEC		0x00000003	/* execute file; used by kernel only */
45 
46 # define O_NOATIME	0x00000004	/* Do not set atime.  */
47 # define O_APPEND	0x00000008	/* all writes go to end of file */
48 
49 /* file sharing modes (not POSIX) */
50 # define O_SHMODE	0x00000070	/* isolates file sharing mode */
51 #  define O_COMPAT	0x00000000	/* old TOS compatibility mode */
52 #  define O_DENYRW	0x00000010	/* deny both read and write access */
53 #  define O_DENYW	0x00000020	/* deny write access to others */
54 #  define O_DENYR	0x00000030	/* deny read access to others */
55 #  define O_DENYNONE	0x00000040	/* don't deny any access to others */
56 
57 # define O_NOINHERIT	0x00000080	/* private file (not passed to child) */
58 
59 # define O_NDELAY	0x00000100	/* don't block for I/O on this file */
60 # define O_CREAT	0x00000200	/* create new file if needed */
61 # define O_TRUNC	0x00000400	/* truncate file to 0 bytes if it does exist */
62 # define O_EXCL		0x00000800	/* error if file exists */
63 
64 # define O_DIRECTORY	0x00010000	/* a directory */
65 
66 # if 0
67 /* XXX missing */
68 # define O_SHLOCK	0x000000	/* open with shared file lock */
69 # define O_EXLOCK	0x000000	/* open with exclusive file lock */
70 # define O_ASYNC	0x000000	/* signal pgrp when data ready */
71 # define O_SYNC		0x000000	/* synchronous writes */
72 # define O_DSYNC	0x000000	/* write: I/O data completion */
73 # define O_RSYNC	0x000000	/* read: I/O completion as for write */
74 # endif
75 
76 # define O_USER		0x00000fff	/* isolates user-settable flag bits */
77 # define O_GLOBAL	0x00001000	/* OBSOLETE, DONT USE! */
78 # define O_TTY		0x00002000
79 # define O_HEAD		0x00004000
80 # define O_LOCK		0x00008000
81 
82 /*
83  * Constants used for fcntl(2)
84  */
85 
86 /* command values */
87 # define F_DUPFD	0		/* duplicate file descriptor */
88 # define F_GETFD	1		/* get file descriptor flags */
89 # define F_SETFD	2		/* set file descriptor flags */
90 # define F_GETFL	3		/* get file status flags */
91 # define F_SETFL	4		/* set file status flags */
92 # define F_GETLK	5		/* get record locking information */
93 # define F_SETLK	6		/* set record locking information */
94 # define F_SETLKW	7		/* F_SETLK; wait if blocked */
95 
96 #define F_DUPFD_CLOEXEC		1030
97 
98 /* file descriptor flags (F_GETFD, F_SETFD) */
99 # define FD_CLOEXEC	0x01		/* close-on-exec flag */
100 
101 /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
102 # define F_RDLCK	O_RDONLY	/* shared or read lock */
103 # define F_WRLCK	O_WRONLY	/* exclusive or write lock */
104 # define F_UNLCK	3		/* unlock */
105 
106 /* lseek() origins */
107 # define SEEK_SET	0		/* from beginning of file */
108 # define SEEK_CUR	1		/* from current location */
109 # define SEEK_END	2		/* from end of file */
110 
111 
112 # endif /* _mint_fcntl_h */
113