struct file_descriptor *fd_open(struct path *path, int flags, bool is_tag) { int fh = -1; if (!is_tag) { fh = open(path->realpath, flags); if (fh < 0) { print_debug("lulz %s\n", strerror(errno)); return ERR_PTR(-errno); } } struct file_descriptor *fd = calloc(sizeof*fd, 1); if (!fd) return ERR_PTR(-ENOMEM); if (!strcmp(path->filename, TAG_FILENAME)) fd->is_tag_file = true; if (is_tag) fd->tag = tag_get(path->filename); else fd->file = file_get(path->filename); fd->is_tag = is_tag; fd->path = path; fd->fh = fh; return fd; }
void tag_label(metafile_t *mf, unsigned long t, const char *str) { tag_t *tag = tag_get(mf, t); tag->label = g_string_chunk_insert(mf->gsc, str); }