2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
10 #include "../os/include/file.h"
12 #define OS_TYPE_FILE 1
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
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 */
31 #define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \
32 .t = 0, .a = 0, .e = 0, .cl = 0 })
34 static inline struct openflags of_read(struct openflags flags)
40 static inline struct openflags of_write(struct openflags flags)
46 static inline struct openflags of_rdwr(struct openflags flags)
48 return(of_read(of_write(flags)));
51 static inline struct openflags of_set_rw(struct openflags flags, int r, int w)
58 static inline struct openflags of_sync(struct openflags flags)
64 static inline struct openflags of_create(struct openflags flags)
70 static inline struct openflags of_trunc(struct openflags flags)
76 static inline struct openflags of_append(struct openflags flags)
82 static inline struct openflags of_excl(struct openflags flags)
88 static inline struct openflags of_cloexec(struct openflags flags)
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);
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);
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);
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
131 * ---------------------------------------------------------------------------
133 * c-file-style: "linux"