1570af302Sopenharmony_ci#include "stdio_impl.h" 2570af302Sopenharmony_ci#include <fcntl.h> 3570af302Sopenharmony_ci#include <string.h> 4570af302Sopenharmony_ci 5570af302Sopenharmony_ciFILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t len) 6570af302Sopenharmony_ci{ 7570af302Sopenharmony_ci memset(f, 0, sizeof *f); 8570af302Sopenharmony_ci 9570af302Sopenharmony_ci f->fd = sys_open(filename, O_RDONLY|O_CLOEXEC); 10570af302Sopenharmony_ci if (f->fd < 0) return 0; 11570af302Sopenharmony_ci __syscall(SYS_fcntl, f->fd, F_SETFD, FD_CLOEXEC); 12570af302Sopenharmony_ci#ifndef __LITEOS__ 13570af302Sopenharmony_ci fdsan_exchange_owner_tag(f->fd, 0, __get_file_tag(f)); 14570af302Sopenharmony_ci#endif 15570af302Sopenharmony_ci f->flags = F_NOWR | F_PERM; 16570af302Sopenharmony_ci f->buf = buf + UNGET; 17570af302Sopenharmony_ci f->buf_size = len - UNGET; 18570af302Sopenharmony_ci f->read = __stdio_read; 19570af302Sopenharmony_ci f->seek = __stdio_seek; 20570af302Sopenharmony_ci f->close = __stdio_close; 21570af302Sopenharmony_ci f->lock = -1; 22570af302Sopenharmony_ci 23570af302Sopenharmony_ci return f; 24570af302Sopenharmony_ci} 25