memset(&mkop, 0, sizeof(mkop));
mkop.mo_ldd = *ldd;
mkop.mo_ldd.ldd_flags &= ~LDD_F_UPDATE;
- strcpy(mkop.mo_device, source);
+ if (strlen(source) > sizeof(mkop.mo_device)-1) {
+ fatal();
+ fprintf(stderr, "Device name too long: %s\n", source);
+ return -E2BIG;
+ }
+ strncpy(mkop.mo_device, source, sizeof(mkop.mo_device));
ret = osd_prepare_lustre(&mkop,
default_mountopts, sizeof(default_mountopts),
return rc;
}
- if (ldd->ldd_flags & LDD_F_NEED_INDEX) {
+ if ((IS_MDT(ldd) || IS_OST(ldd)) &&
+ (ldd->ldd_flags & LDD_F_NEED_INDEX)) {
fprintf(stderr, "%s: %s has no index assigned "
"(probably formatted with old mkfs)\n",
progname, source);
for (i = 0, rc = -EAGAIN; i <= mop.mo_retry && rc != 0; i++) {
rc = mount(mop.mo_source, mop.mo_target, "lustre",
flags, (void *)options);
- if (rc) {
+ if (rc == 0) {
+ /* change label from <fsname>:<index> to
+ * <fsname>-<index> to indicate the device has
+ * been registered. only if the label is
+ * supposed to be changed and target service
+ * is supposed to start */
+ if (mop.mo_ldd.ldd_flags &
+ (LDD_F_VIRGIN | LDD_F_WRITECONF)) {
+ if (mop.mo_nosvc == 0)
+ (void)osd_label_lustre(&mop);
+ }
+ } else {
if (verbose) {
fprintf(stderr, "%s: mount %s at %s "
"failed: %s retries left: "
} else if (!mop.mo_nomtab) {
rc = update_mtab_entry(mop.mo_usource, mop.mo_target, "lustre",
mop.mo_orig_options, 0,0,0);
-
- /* change label from <fsname>:<index> to <fsname>-<index>
- * to indicate the device has been registered.
- * only if the label is supposed to be changed and
- * target service is supposed to start */
- if (mop.mo_ldd.ldd_flags & (LDD_F_VIRGIN | LDD_F_WRITECONF)) {
- if (mop.mo_nosvc == 0 )
- (void) osd_label_lustre(&mop);
- }
- }
+ }
free(options);
/* mo_usource should be freed, but we can rely on the kernel */