void *dialect;
void (*free_dialect)(struct path_cxt *);
int (*redirect_on_enoent)(struct path_cxt *, const char *, int *);
+
+ const struct ul_vfs_ops *vfs;
};
struct path_cxt *ul_new_path(const char *dir, ...)
void *ul_path_get_dialect(struct path_cxt *pc);
int ul_path_set_enoent_redirect(struct path_cxt *pc, int (*func)(struct path_cxt *, const char *, int *));
+
+struct ul_vfs_ops;
+void ul_path_refer_vfs(struct path_cxt *pc, const struct ul_vfs_ops *vfs);
int ul_path_get_dirfd(struct path_cxt *pc);
void ul_path_close_dirfd(struct path_cxt *pc);
int ul_path_isopen_dirfd(struct path_cxt *pc);
}
}
+void ul_path_refer_vfs(struct path_cxt *pc, const struct ul_vfs_ops *vfs)
+{
+ if (pc)
+ pc->vfs = vfs;
+}
+
int ul_path_set_prefix(struct path_cxt *pc, const char *prefix)
{
char *p = NULL;
if (fd < 0)
return NULL;
- return fdopen(fd, mode);
+ return ul_vfs_fdopen(pc ? pc->vfs : NULL, fd, mode);
}
return -errno;
DBG(CXT, ul_debug(" reading '%s'", path));
- rc = ul_read_all(fd, buf, len);
+ rc = ul_vfs_read_all(pc ? pc->vfs : NULL, fd, buf, len);
errsv = errno;
- close(fd);
+ ul_vfs_close(pc ? pc->vfs : NULL, fd);
errno = errsv;
return rc;
}
if (fd < 0)
return -errno;
- rc = ul_write_all(fd, str, strlen(str));
+ rc = ul_vfs_write_all(pc ? pc->vfs : NULL, fd, str, strlen(str));
errsv = errno;
- close(fd);
+ ul_vfs_close(pc ? pc->vfs : NULL, fd);
errno = errsv;
return rc;
}
if (len < 0 || (size_t) len >= sizeof(buf))
rc = len < 0 ? -errno : -E2BIG;
else
- rc = ul_write_all(fd, buf, len);
+ rc = ul_vfs_write_all(pc ? pc->vfs : NULL, fd, buf, len);
errsv = errno;
- close(fd);
+ ul_vfs_close(pc ? pc->vfs : NULL, fd);
errno = errsv;
return rc;
}
if (len < 0 || (size_t) len >= sizeof(buf))
rc = len < 0 ? -errno : -E2BIG;
else
- rc = ul_write_all(fd, buf, len);
+ rc = ul_vfs_write_all(pc ? pc->vfs : NULL, fd, buf, len);
errsv = errno;
- close(fd);
+ ul_vfs_close(pc ? pc->vfs : NULL, fd);
errno = errsv;
return rc;
}