MCPcopy Create free account
hub / github.com/ading2210/linuxpdf / fs_create

Function fs_create

tinyemu/fs_disk.c:263–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263static 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
293static int fs_readdir(FSDevice *fs, FSFile *f, uint64_t offset,
294 uint8_t *buf, int count)

Callers

nothing calls this directly

Calls 5

p9_flags_to_hostFunction · 0.85
errno_to_p9Function · 0.85
stat_to_qidFunction · 0.85
fs_closeFunction · 0.70
compose_pathFunction · 0.70

Tested by

no test coverage detected