18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __COW_SYS_H__ 38c2ecf20Sopenharmony_ci#define __COW_SYS_H__ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <kern_util.h> 68c2ecf20Sopenharmony_ci#include <os.h> 78c2ecf20Sopenharmony_ci#include <um_malloc.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistatic inline void *cow_malloc(int size) 108c2ecf20Sopenharmony_ci{ 118c2ecf20Sopenharmony_ci return uml_kmalloc(size, UM_GFP_KERNEL); 128c2ecf20Sopenharmony_ci} 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic inline void cow_free(void *ptr) 158c2ecf20Sopenharmony_ci{ 168c2ecf20Sopenharmony_ci kfree(ptr); 178c2ecf20Sopenharmony_ci} 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define cow_printf printk 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic inline char *cow_strdup(char *str) 228c2ecf20Sopenharmony_ci{ 238c2ecf20Sopenharmony_ci return uml_strdup(str); 248c2ecf20Sopenharmony_ci} 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistatic inline int cow_seek_file(int fd, __u64 offset) 278c2ecf20Sopenharmony_ci{ 288c2ecf20Sopenharmony_ci return os_seek_file(fd, offset); 298c2ecf20Sopenharmony_ci} 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistatic inline int cow_file_size(char *file, unsigned long long *size_out) 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci return os_file_size(file, size_out); 348c2ecf20Sopenharmony_ci} 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic inline int cow_write_file(int fd, void *buf, int size) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci return os_write_file(fd, buf, size); 398c2ecf20Sopenharmony_ci} 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#endif 42