void wipefs(const char *dir) { char fn[PATH_MAX]; struct stat stb; /* * Remove the user namespace. We do this separately because we * skip fidns because of loops. */ pfl_filewalk(dir, PFL_FILEWALKF_RECURSIVE, NULL, wipefs_user, NULL); /* remove the SLASH2 FID namespace */ xmkfn(fn, "%s/%s", dir, SL_RPATH_META_DIR, SL_RPATH_FIDNS_DIR); if (stat(fn, &stb) == 0 || errno != ENOENT) pfl_filewalk(fn, PFL_FILEWALKF_RECURSIVE, NULL, wipefs_fidns, NULL); }
/* * Build the pathname in the FID object root that corresponds to a FID, * allowing easily lookup of file metadata via FIDs. */ void sli_fg_makepath(const struct sl_fidgen *fg, char *fid_path) { char *p, str[(FID_PATH_DEPTH * 2) + 1]; uint64_t shift; int i; shift = BPHXC * (FID_PATH_START + FID_PATH_DEPTH - 1); for (p = str, i = 0; i < FID_PATH_DEPTH; i++, shift -= BPHXC) { *p = (fg->fg_fid & (0xf << shift)) >> shift; *p += *p < 10 ? '0' : 'a' - 10; p++; *p++ = '/'; } *p = '\0'; xmkfn(fid_path, "%s/%s/%"PRIx64"/%s/%s%016"PRIx64"_%"PRIx64, slcfg_local->cfg_fsroot, SL_RPATH_META_DIR, globalConfig.gconf_fsuuid, SL_RPATH_FIDNS_DIR, str, fg->fg_fid, fg->fg_gen); psclog_debug("fid="SLPRI_FID" fidpath=%s", fg->fg_fid, fid_path); }
int main(int argc, char *argv[]) { ssize_t nents = SLJ_MDS_JNENTS; char *endp, c, fn[PATH_MAX]; uint64_t uuid = 0; long l; pfl_init(); sl_subsys_register(); fn[0] = '\0'; progname = argv[0]; while ((c = getopt(argc, argv, "b:D:fn:qu:v")) != -1) switch (c) { case 'b': strlcpy(fn, optarg, sizeof(fn)); break; case 'D': datadir = optarg; break; case 'f': format = 1; break; case 'n': endp = NULL; l = strtol(optarg, &endp, 10); if (l <= 0 || l > INT_MAX || endp == optarg || *endp) errx(1, "invalid -n nentries: %s", optarg); nents = (ssize_t)l; break; case 'q': query = 1; break; case 'u': endp = NULL; uuid = (uint64_t)strtoull(optarg, &endp, 16); if (endp == optarg || *endp) errx(1, "invalid -u fsuuid: %s", optarg); break; case 'v': verbose = 1; break; default: usage(); } argc -= optind; if (argc) usage(); if (fn[0] == '\0') { if (mkdir(datadir, 0700) == -1) if (errno != EEXIST) err(1, "mkdir: %s", datadir); xmkfn(fn, "%s/%s", datadir, SL_FN_OPJOURNAL); } if (format) { if (!uuid) psc_fatalx("no fsuuid specified"); pjournal_format(fn, nents, SLJ_MDS_ENTSIZE, SLJ_MDS_READSZ, uuid); if (verbose) warnx("created log file %s with %zu %d-byte entries " "(uuid=%"PRIx64")", fn, nents, SLJ_MDS_ENTSIZE, uuid); } else if (query) pjournal_dump(fn); else usage(); exit(0); }