| 34 | } |
| 35 | |
| 36 | int _disk_dump(const char *filepath, size_t pos, size_t bytes) { |
| 37 | struct filemgr_ops *ops = get_filemgr_ops(); |
| 38 | int fd = ops->open(filepath, O_CREAT| O_RDWR, 0666); |
| 39 | if (fd < 0) { |
| 40 | fprintf(stderr, "failure to open %s\n", filepath); |
| 41 | return fd; |
| 42 | } |
| 43 | char *buf = (char *)malloc(bytes); |
| 44 | if (!buf) { |
| 45 | return -2; |
| 46 | } |
| 47 | if (ops->pwrite(fd, buf, bytes, pos) != (int) bytes) { |
| 48 | return -1; |
| 49 | } |
| 50 | ops->close(fd); |
| 51 | free(buf); |
| 52 | return fd; |
| 53 | } |
| 54 | |
| 55 | void logCallbackFunc(int err_code, |
| 56 | const char *err_msg, |