ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / um / include / os.h
1 /* 
2  * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #ifndef __OS_H__
7 #define __OS_H__
8
9 #include "asm/types.h"
10 #include "../os/include/file.h"
11
12 #define OS_TYPE_FILE 1 
13 #define OS_TYPE_DIR 2 
14 #define OS_TYPE_SYMLINK 3 
15 #define OS_TYPE_CHARDEV 4
16 #define OS_TYPE_BLOCKDEV 5
17 #define OS_TYPE_FIFO 6
18 #define OS_TYPE_SOCK 7
19
20 struct openflags {
21         unsigned int r : 1;
22         unsigned int w : 1;
23         unsigned int s : 1;     /* O_SYNC */
24         unsigned int c : 1;     /* O_CREAT */
25         unsigned int t : 1;     /* O_TRUNC */
26         unsigned int a : 1;     /* O_APPEND */
27         unsigned int e : 1;     /* O_EXCL */
28         unsigned int cl : 1;    /* FD_CLOEXEC */
29 };
30
31 #define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \
32                                           .t = 0, .a = 0, .e = 0, .cl = 0 })
33
34 static inline struct openflags of_read(struct openflags flags)
35 {
36         flags.r = 1; 
37         return(flags);
38 }
39
40 static inline struct openflags of_write(struct openflags flags)
41 {
42         flags.w = 1; 
43         return(flags); 
44 }
45
46 static inline struct openflags of_rdwr(struct openflags flags)
47 {
48         return(of_read(of_write(flags)));
49 }
50
51 static inline struct openflags of_set_rw(struct openflags flags, int r, int w)
52 {
53         flags.r = r;
54         flags.w = w;
55         return(flags);
56 }
57
58 static inline struct openflags of_sync(struct openflags flags)
59
60         flags.s = 1; 
61         return(flags); 
62 }
63
64 static inline struct openflags of_create(struct openflags flags)
65
66         flags.c = 1; 
67         return(flags); 
68 }
69  
70 static inline struct openflags of_trunc(struct openflags flags)
71
72         flags.t = 1; 
73         return(flags); 
74 }
75  
76 static inline struct openflags of_append(struct openflags flags)
77
78         flags.a = 1; 
79         return(flags); 
80 }
81  
82 static inline struct openflags of_excl(struct openflags flags)
83
84         flags.e = 1; 
85         return(flags); 
86 }
87  
88 static inline struct openflags of_cloexec(struct openflags flags)
89
90         flags.cl = 1; 
91         return(flags); 
92 }
93   
94 extern int os_seek_file(int fd, __u64 offset);
95 extern int os_open_file(char *file, struct openflags flags, int mode);
96 extern int os_read_file(int fd, void *buf, int len);
97 extern int os_write_file(int fd, void *buf, int count);
98 extern int os_file_size(char *file, long long *size_out);
99 extern int os_pipe(int *fd, int stream, int close_on_exec);
100 extern int os_set_fd_async(int fd, int owner);
101 extern int os_set_fd_block(int fd, int blocking);
102 extern int os_accept_connection(int fd);
103 extern int os_shutdown_socket(int fd, int r, int w);
104 extern void os_close_file(int fd);
105 extern int os_rcv_fd(int fd, int *helper_pid_out);
106 extern int create_unix_socket(char *file, int len);
107 extern int os_connect_socket(char *name);
108 extern int os_file_type(char *file);
109 extern int os_file_mode(char *file, struct openflags *mode_out);
110
111 extern unsigned long os_process_pc(int pid);
112 extern int os_process_parent(int pid);
113 extern void os_stop_process(int pid);
114 extern void os_kill_process(int pid, int reap_child);
115 extern void os_usr1_process(int pid);
116 extern int os_getpid(void);
117
118 extern int os_map_memory(void *virt, int fd, unsigned long off, 
119                          unsigned long len, int r, int w, int x);
120 extern int os_protect_memory(void *addr, unsigned long len, 
121                              int r, int w, int x);
122 extern int os_unmap_memory(void *addr, int len);
123
124 #endif
125
126 /*
127  * Overrides for Emacs so that we follow Linus's tabbing style.
128  * Emacs will notice this stuff at the end of the file and automatically
129  * adjust the settings for this buffer only.  This must remain at the end
130  * of the file.
131  * ---------------------------------------------------------------------------
132  * Local variables:
133  * c-file-style: "linux"
134  * End:
135  */