| 261 | } |
| 262 | |
| 263 | static int fs_create(FSDevice *fs, FSQID *qid, FSFile *f, const char *name, |
| 264 | uint32_t flags, uint32_t mode, uint32_t gid) |
| 265 | { |
| 266 | struct stat st; |
| 267 | char *path; |
| 268 | int ret, fd; |
| 269 | |
| 270 | fs_close(fs, f); |
| 271 | |
| 272 | path = compose_path(f->path, name); |
| 273 | fd = open(path, p9_flags_to_host(flags) | O_CREAT, mode); |
| 274 | if (fd < 0) { |
| 275 | free(path); |
| 276 | return -errno_to_p9(errno); |
| 277 | } |
| 278 | ret = lstat(path, &st); |
| 279 | if (ret != 0) { |
| 280 | free(path); |
| 281 | close(fd); |
| 282 | return -errno_to_p9(errno); |
| 283 | } |
| 284 | free(f->path); |
| 285 | f->path = path; |
| 286 | f->is_opened = TRUE; |
| 287 | f->is_dir = FALSE; |
| 288 | f->u.fd = fd; |
| 289 | stat_to_qid(qid, &st); |
| 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | static int fs_readdir(FSDevice *fs, FSFile *f, uint64_t offset, |
| 294 | uint8_t *buf, int count) |
nothing calls this directly
no test coverage detected