/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
- * Copyright (c) 2012, 2013, Intel Corporation.
+ *
+ * Copyright (c) 2012, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#endif /* HAVE_CONFIG_H */
#include "mount_utils.h"
+#include <mntent.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
+#include <unistd.h>
#include <config.h>
#include <lustre_disk.h>
#include <lustre_ver.h>
+#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <linux/loop.h>
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;
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));