/* * rm_poolset -- remove files parsed from poolset file */ static void rm_poolset(const char *file) { int ret = util_poolset_foreach_part(file, rm_poolset_cb, NULL); if (ret) { if (!force) { outv_err("cannot parse poolset file '%s'\n", file); exit(1); } return; } }
/* * rm_poolset -- remove files parsed from poolset file */ static void rm_poolset(const char *file) { int ret = util_poolset_foreach_part(file, rm_poolset_cb, NULL); if (ret) { if (ret == -1) { outv_err("parsing poolset failed: %s\n", out_get_errormsg()); exit(1); } if (!force) { outv_err("removing '%s' failed\n", file); exit(1); } return; } }
int main(int argc, char *argv[]) { START(argc, argv, "util_poolset_foreach"); out_init(LOG_PREFIX, LOG_LEVEL_VAR, LOG_FILE_VAR, MAJOR_VERSION, MINOR_VERSION); util_init(); if (argc < 2) FATAL("usage: %s file...", argv[0]); for (int i = 1; i < argc; i++) { char *fname = argv[i]; int ret = util_poolset_foreach_part(fname, cb, fname); OUT("util_poolset_foreach_part(%s): %d", fname, ret); } out_fini(); DONE(NULL); }
static inline #endif int pmempool_rmU(const char *path, int flags) { LOG(3, "path %s flags %x", path, flags); int ret; if (flags & ~PMEMPOOL_RM_ALL_FLAGS) { ERR("invalid flags specified"); errno = EINVAL; return -1; } int is_poolset = util_is_poolset_file(path); if (is_poolset < 0) { os_stat_t buff; ret = os_stat(path, &buff); if (!ret) { if (S_ISDIR(buff.st_mode)) { errno = EISDIR; ERR("removing file failed"); return -1; } } ERR_F(flags, "removing file failed"); if (CHECK_FLAG(flags, FORCE)) return 0; return -1; } if (!is_poolset) { LOG(2, "%s: not a poolset file", path); return rm_local(path, flags, 0); } LOG(2, "%s: poolset file", path); /* fill up pool_set structure */ struct pool_set *set = NULL; int fd = os_open(path, O_RDONLY); if (fd == -1 || util_poolset_parse(&set, path, fd)) { ERR_F(flags, "parsing poolset file failed"); if (fd != -1) os_close(fd); if (CHECK_FLAG(flags, FORCE)) return 0; return -1; } os_close(fd); if (set->remote) { /* ignore error - it will be handled in rm_remote() */ (void) util_remote_load(); } util_poolset_free(set); struct cb_args args; args.flags = flags; args.error = 0; ret = util_poolset_foreach_part(path, rm_cb, &args); if (ret == -1) { ERR_F(flags, "parsing poolset file failed"); if (CHECK_FLAG(flags, FORCE)) return 0; return ret; } ASSERTeq(ret, 0); if (args.error) return args.error; if (CHECK_FLAG(flags, POOLSET_LOCAL)) { ret = rm_local(path, flags, 0); if (ret) { ERR_F(flags, "removing pool set file failed"); } else { LOG(3, "%s: removed", path); } if (CHECK_FLAG(flags, FORCE)) return 0; return ret; } return 0; }