Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __COW_SYS_H__ |
2 | #define __COW_SYS_H__ | ||||
3 | |||||
4 | #include "kern_util.h" | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include "os.h" |
6 | #include "user.h" | ||||
Paolo 'Blaisorblade' Giarrusso | c13e569 | 2006-10-19 23:28:20 -0700 | [diff] [blame] | 7 | #include "um_malloc.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
9 | static inline void *cow_malloc(int size) | ||||
10 | { | ||||
Jeff Dike | 43f5b30 | 2008-05-12 14:01:52 -0700 | [diff] [blame] | 11 | return uml_kmalloc(size, UM_GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | } |
13 | |||||
14 | static inline void cow_free(void *ptr) | ||||
15 | { | ||||
16 | kfree(ptr); | ||||
17 | } | ||||
18 | |||||
19 | #define cow_printf printk | ||||
20 | |||||
21 | static inline char *cow_strdup(char *str) | ||||
22 | { | ||||
Jeff Dike | dc764e5 | 2007-05-06 14:51:41 -0700 | [diff] [blame] | 23 | return uml_strdup(str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | } |
25 | |||||
Paolo 'Blaisorblade' Giarrusso | fe1db50 | 2006-02-24 13:03:58 -0800 | [diff] [blame] | 26 | static inline int cow_seek_file(int fd, __u64 offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
Jeff Dike | dc764e5 | 2007-05-06 14:51:41 -0700 | [diff] [blame] | 28 | return os_seek_file(fd, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | } |
30 | |||||
Paolo 'Blaisorblade' Giarrusso | 52c7378 | 2006-04-10 22:53:41 -0700 | [diff] [blame] | 31 | static inline int cow_file_size(char *file, unsigned long long *size_out) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | { |
Jeff Dike | dc764e5 | 2007-05-06 14:51:41 -0700 | [diff] [blame] | 33 | return os_file_size(file, size_out); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | } |
35 | |||||
Paolo 'Blaisorblade' Giarrusso | 31bc5a3 | 2006-02-24 13:03:53 -0800 | [diff] [blame] | 36 | static inline int cow_write_file(int fd, void *buf, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | { |
Jeff Dike | a6ea4cc | 2007-05-06 14:51:43 -0700 | [diff] [blame] | 38 | return os_write_file(fd, buf, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | } |
40 | |||||
41 | #endif |