#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);
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);