X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fmount_utils.c;h=f7a62ed64c5e189894cac2696d5d1d2dc4ffeedb;hb=fb24a9557979991b3debfc878ced86ae4f536159;hp=bb83f4514380cb84d0632756ff6fedd8206513b8;hpb=3e8c354c09725a97b90e477a77411cc6fb306f09;p=fs%2Flustre-release.git diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index bb83f45..f7a62ed 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -144,6 +144,43 @@ int get_param(char *buf, char *key, char **val) return ENOENT; } +int append_param(char *buf, char *key, char *val, char sep) +{ + int key_len, i, offset, old_val_len; + char *ptr = NULL, str[1024]; + + if (key) + ptr = strstr(buf, key); + + /* key doesn't exist yet, so just add it */ + if (ptr == NULL) + return add_param(buf, key, val); + + key_len = strlen(key); + + /* Copy previous values to str */ + for (i = 0; i < sizeof(str); ++i) { + if ((ptr[i+key_len] == ' ') || (ptr[i+key_len] == '\0')) + break; + str[i] = ptr[i+key_len]; + } + if (i == sizeof(str)) + return E2BIG; + old_val_len = i; + + offset = old_val_len+key_len; + + /* Move rest of buf to overwrite previous key and value */ + for (i = 0; ptr[i+offset] != '\0'; ++i) + ptr[i] = ptr[i+offset]; + + ptr[i] = '\0'; + + snprintf(str+old_val_len, sizeof(str)-old_val_len, "%c%s", sep, val); + + return add_param(buf, key, str); +} + char *strscat(char *dst, char *src, int buflen) { dst[buflen - 1] = 0; @@ -450,7 +487,7 @@ struct module_backfs_ops *load_backfs_module(enum ldd_mount_type mount_type) /* This deals with duplicate ldd_mount_types resolving to same OSD layer * plugin (e.g. ext3/ldiskfs/ldiskfs2 all being ldiskfs) */ - strncpy(fsname, mt_type(mount_type), sizeof(fsname)); + strlcpy(fsname, mt_type(mount_type), sizeof(fsname)); name = fsname + sizeof("osd-") - 1; /* change osd- to osd_ */ @@ -459,8 +496,23 @@ struct module_backfs_ops *load_backfs_module(enum ldd_mount_type mount_type) snprintf(filename, sizeof(filename), PLUGIN_DIR"/mount_%s.so", fsname); handle = dlopen(filename, RTLD_LAZY); + + /* Check for $LUSTRE environment variable from test-framework. + * This allows using locally built modules to be used. + */ + if (handle == NULL) { + char *dirname; + dirname = getenv("LUSTRE"); + if (dirname) { + snprintf(filename, sizeof(filename), + "%s/utils/.libs/mount_%s.so", + dirname, fsname); + handle = dlopen(filename, RTLD_LAZY); + } + } + + /* Do not clutter up console with missing types */ if (handle == NULL) - /* Do not clutter up console with missing types */ return NULL; ops = malloc(sizeof(*ops));