#include <limits.h>
#ifdef __linux__
-/* kp30.h is not really needed here, but on SLES10/PPC, fs.h includes idr.h which
+/* libcfs.h is not really needed here, but on SLES10/PPC, fs.h includes idr.h which
* requires BITS_PER_LONG to be defined */
-#include <libcfs/kp30.h>
+#include <libcfs/libcfs.h>
#include <linux/fs.h> /* for BLKGETSIZE64 */
#include <linux/version.h>
#endif
#include <lustre_param.h>
#include <lnet/lnetctl.h>
#include <lustre_ver.h>
+#include <mount_utils.h>
#ifndef PATH_MAX
#define PATH_MAX 4096
int mo_mgs_failnodes;
};
-static char *progname;
-static int verbose = 1;
+char *progname;
+int verbose = 1;
static int print_only = 0;
static int failover = 0;
#define vprint if (verbose > 0) printf
#define verrprint if (verbose >= 0) printf
-static void fatal(void)
-{
- verbose = 0;
- fprintf(stderr, "\n%s FATAL: ", progname);
-}
-
/*================ utility functions =====================*/
char *strscat(char *dst, char *src, int buflen) {
return version;
}
-int run_command(char *cmd, int cmdsz)
-{
- char log[] = "/tmp/mkfs_logXXXXXX";
- int fd = -1, rc;
-
- if ((cmdsz - strlen(cmd)) < 6) {
- fatal();
- fprintf(stderr, "Command buffer overflow: %.*s...\n",
- cmdsz, cmd);
- return ENOMEM;
- }
-
- if (verbose > 1) {
- printf("cmd: %s\n", cmd);
- } else {
- if ((fd = mkstemp(log)) >= 0) {
- close(fd);
- strcat(cmd, " >");
- strcat(cmd, log);
- }
- }
- strcat(cmd, " 2>&1");
-
- /* Can't use popen because we need the rv of the command */
- rc = system(cmd);
- if (rc && (fd >= 0)) {
- char buf[128];
- FILE *fp;
- fp = fopen(log, "r");
- if (fp) {
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- printf(" %s", buf);
- }
- fclose(fp);
- }
- }
- if (fd >= 0)
- remove(log);
- return rc;
-}
-
static int check_mtab_entry(char *spec)
{
FILE *fp;
if (strstr(debugfs_cmd, "unsupported feature")) {
disp_old_e2fsprogs_msg("an unknown", 0);
}
+ pclose(fp);
return -1;
}
pclose(fp);
strscat(mop->mo_mkfsopts, " -O dir_index", sizeof(mop->mo_mkfsopts));
+ /* Upstream e2fsprogs called our uninit_groups feature uninit_bg,
+ * check for both of them when testing e2fsprogs features. */
if (is_e2fsprogs_feature_supp("uninit_groups") == 0)
strscat(mop->mo_mkfsopts, ",uninit_groups",
sizeof(mop->mo_mkfsopts));
+ else if (is_e2fsprogs_feature_supp("uninit_bg") == 0)
+ strscat(mop->mo_mkfsopts, ",uninit_bg",
+ sizeof(mop->mo_mkfsopts));
else
- disp_old_e2fsprogs_msg("uninit_groups", 1);
+ disp_old_e2fsprogs_msg("uninit_bg", 1);
ret = uname(&uts);
if (ret)
dev = mop->mo_device;
+ /* TODO: it's worth observing the get_mountdata() function that is
+ in mount_utils.c for getting the mountdata out of the
+ filesystem */
+
/* Construct debugfs command line. */
snprintf(cmd, cmdsz, "debugfs -c -R 'dump /%s %s/mountdata' %s",
MOUNT_DATA_FILE, tmpdir, dev);
return 1;
rc = add_param(mop->mo_ldd.ldd_params, PARAM_FAILNODE,
nids);
- /* Combo needs to add MDT failnodes as MGS failnodes
- as well */
- if (!rc && IS_MGS(&mop->mo_ldd)) {
- rc = add_param(mop->mo_ldd.ldd_params,
- PARAM_MGSNODE, nids);
- }
free(nids);
if (rc)
return rc;