void FileSystemTestSetup::make_dirs_(const fs::path& pfx) const { fs::create_directories(source_dir()); fs::create_directories(mount_dir(pfx)); fs::create_directories(clustercache_dir(pfx)); fs::create_directories(scocache_mountpoint(pfx)); fs::create_directories(tlog_dir(pfx)); fs::create_directories(mdstore_dir(pfx)); fs::create_directories(dump_on_halt_dir(pfx)); fs::create_directories(failovercache_dir(topdir_)); fs::create_directories(fdriver_cache_dir(pfx)); }
void create_mounts(char *user, char *group, char *base, mode_t mode) { struct hpage_pool pools[MAX_POOLS]; char path[PATH_MAX]; char options[OPT_MAX]; char limits[OPT_MAX]; char scaled[OPT_MAX]; int cnt, pos; struct passwd *pwd; struct group *grp; uid_t uid = 0; gid_t gid = 0; if (geteuid() != 0) { ERROR("Mounts can only be created by root\n"); exit(EXIT_FAILURE); } if (user) { pwd = getpwnam(user); if (!pwd) { ERROR("Could not find specified user %s\n", user); exit(EXIT_FAILURE); } uid = pwd->pw_uid; } else if (group) { grp = getgrnam(group); if (!grp) { ERROR("Could not find specified group %s\n", group); exit(EXIT_FAILURE); } gid = grp->gr_gid; } if (ensure_dir(base, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH, 0, 0)) exit(EXIT_FAILURE); cnt = hpool_sizes(pools, MAX_POOLS); if (cnt < 0) { ERROR("Unable to obtain pools list\n"); exit(EXIT_FAILURE); } for (pos=0; cnt--; pos++) { scaled[0] = 0; scale_size(scaled, pools[pos].pagesize); if (user) snprintf(path, PATH_MAX, "%s/%s/pagesize-%s", base, user, scaled); else if (group) snprintf(path, PATH_MAX, "%s/%s/pagesize-%s", base, group, scaled); else snprintf(path, PATH_MAX, "%s/pagesize-%s", base, scaled); snprintf(options, OPT_MAX, "pagesize=%ld", pools[pos].pagesize); /* Yes, this could be cleverer */ if (opt_limit_mount_size && opt_limit_mount_inodes) snprintf(limits, OPT_MAX, ",size=%lu,nr_inodes=%d", opt_limit_mount_size, opt_limit_mount_inodes); else { if (opt_limit_mount_size) snprintf(limits, OPT_MAX, ",size=%lu", opt_limit_mount_size); if (opt_limit_mount_inodes) snprintf(limits, OPT_MAX, ",nr_inodes=%d", opt_limit_mount_inodes); } /* Append limits if specified */ if (limits[0] != 0) { size_t maxlen = OPT_MAX - strlen(options); if (maxlen > strlen(limits)) strcat(options, limits); else WARNING("String limitations met, cannot append limitations onto mount options string. Increase OPT_MAX"); } if (ensure_dir(path, mode, uid, gid)) exit(EXIT_FAILURE); if (mount_dir(path, options, mode, uid, gid)) exit(EXIT_FAILURE); } }