goto out;
}
- ret = read_local_files(&mop);
+ ret = osd_read_ldd(mop.mo_device, &mop.mo_ldd);
if (ret) {
fatal();
fprintf(stderr, "Failed to read previous Lustre data from %s "
return 0;
}
+/* Read the server config files */
+int osd_read_ldd(char *dev, struct lustre_disk_data *ldd)
+{
+ int ret;
+
+ switch (ldd->ldd_mount_type) {
+ case LDD_MT_LDISKFS:
+ case LDD_MT_LDISKFS2:
+ ret = ldiskfs_read_ldd(dev, ldd);
+ break;
+ default:
+ fatal();
+ fprintf(stderr, "unknown fs type %d '%s'\n",
+ ldd->ldd_mount_type, MT_STR(ldd));
+ ret = EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
/* Was this device formatted for Lustre */
int osd_is_lustre(char *dev, unsigned *mount_type)
{
int loop_cleanup(struct mkfs_opts *mop);
/* generic target support */
+int osd_read_ldd(char *dev, struct lustre_disk_data *ldd);
int osd_is_lustre(char *dev, unsigned *mount_type);
int osd_prepare_lustre(struct mkfs_opts *mop,
char *default_mountopts, int default_len,
char *always_mountopts, int always_len);
+int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *ldd);
int ldiskfs_is_lustre(char *dev, unsigned *mount_type);
int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
char *default_mountopts, int default_len,
return ret;
}
-int read_local_files(struct mkfs_opts *mop)
+int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *mo_ldd)
{
char tmpdir[] = "/tmp/dirXXXXXX";
char cmd[PATH_MAX];
char filepnm[128];
- char *dev;
FILE *filep;
int ret = 0;
int cmdsz = sizeof(cmd);
return errno;
}
- 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 */
if (filep) {
size_t num_read;
vprint("Reading %s\n", MOUNT_DATA_FILE);
- num_read = fread(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+ num_read = fread(mo_ldd, sizeof(*mo_ldd), 1, filep);
if (num_read < 1 && ferror(filep)) {
fprintf(stderr, "%s: Unable to read from file %s: %s\n",
progname, filepnm, strerror(errno));