fs_tlist *fs_tlist_open(fs_backend *be, fs_rid model, int flags) { fs_tlist *l; if (fs_backend_model_dirs(be)) { char hash[17]; sprintf(hash, "%016llx", model); hash[16] = '\0'; char *dirname = g_strdup_printf(fs_get_tlist_dird_format(), fs_backend_get_kb(be), fs_backend_get_segment(be), hash[0], hash[1], hash[2], hash[3]); struct stat buf; int ret = stat(dirname, &buf); if (ret) mkdir(dirname, FS_FILE_MODE + 0100); char *filename = g_strdup_printf(fs_get_tlist_dir_format(), fs_backend_get_kb(be), fs_backend_get_segment(be), hash[0], hash[1], hash[2], hash[3], hash+4); l = fs_tlist_open_filename(filename, flags); g_free(filename); } else { char *filename = g_strdup_printf(fs_get_tlist_format(), fs_backend_get_kb(be), fs_backend_get_segment(be), model); l = fs_tlist_open_filename(filename, flags); g_free(filename); } return l; }
fs_tree *fs_tree_open(fs_backend *be, const char *name, int flags) { char *file = g_strdup_printf(FS_TREE, fs_backend_get_kb(be), fs_backend_get_segment(be), name); fs_tree *t = fs_tree_open_filename(be, name, file, flags); return t; }
fs_mhash *fs_mhash_open(fs_backend *be, const char *label, int flags) { char *filename = g_strdup_printf(FS_MHASH, fs_backend_get_kb(be), fs_backend_get_segment(be), label); fs_mhash *mh = fs_mhash_open_filename(filename, flags); g_free(filename); return mh; }
fs_ptree *fs_ptree_open(fs_backend *be, fs_rid pred, char pk, int flags, fs_ptable *chain) { char *filename = g_strdup_printf(FS_PTREE, fs_backend_get_kb(be), fs_backend_get_segment(be), pk, pred); fs_ptree *pt = fs_ptree_open_filename(filename, flags, chain); g_free(filename); return pt; }
static unsigned char * handle_start_import (fs_backend *be, fs_segment segment, unsigned int length, unsigned char *content) { if (segment > be->segments) { fs_error(LOG_ERR, "invalid segment number: %d", segment); return fsp_error_new(segment, "invalid segment number"); } if (length > 0) { fs_error(LOG_ERR, "start_import(%d) extraneous content", segment); return fsp_error_new(segment, "extraneous content"); } float free_space = fs_free_disk(fs_backend_get_kb(be)); if (free_space < be->min_free) { fs_error(LOG_ERR, "segment %d only has %.1f%% free space", segment, free_space); return fsp_error_new(segment, "low disk space"); } fs_start_import(be, segment); return message_new(FS_DONE_OK, segment, 0); }
static char *fname_from_label(fs_backend *be, const char *label) { return g_strdup_printf(FS_TBCHAIN, fs_backend_get_kb(be), fs_backend_get_segment(be), label); }
static char *fname_from_label(fs_backend *be, const char *label) { return g_strdup_printf(fs_get_ptable_format(), fs_backend_get_kb(be), fs_backend_get_segment(be), label); }