#include <sys/utsname.h>
#include <linux/lustre_disk.h>
-#include <portals/ptlctl.h>
+//#include <portals/ptlctl.h>
#include "obdctl.h"
int verbose;
exit(out != stdout);
}
-int get_os_version()
-{
- static int version = 0;
-
- if (!version) {
- int fd;
- char release[4] = "";
-
- fd = open("/proc/sys/kernel/osrelease", O_RDONLY);
- if (fd < 0)
- fprintf(stderr, "Warning: Can't resolve kernel version,"
- " assuming 2.6\n");
- else {
- read(fd, release, 4);
- close(fd);
- }
- if (strncmp(release, "2.4.", 4) == 0)
- version = 24;
- else
- version = 26;
- }
- return version;
-}
-
static int load_module(char *module_name)
{
char buf[256];
return rc;
}
-static int load_modules(struct lustre_mount_data *lmd)
+static int load_modules()
{
int rc = 0;
- if (lmd_is_client(lmd)) {
- rc = load_module("lustre");
- } else {
- rc = load_module("mds");
- if (rc) return rc;
- rc = load_module("oss");
- }
+ rc = load_module("lustre");
+ rc = load_module("mds");
+ rc = load_module("ost");
return rc;
}
return rc;
}
-int
-init_options(struct lustre_mount_data *lmd)
-{
- memset(lmd, 0, sizeof(*lmd));
- //gethostname(lmd->lmd_hostname, sizeof lmd->lmd_hostname);
- //lmd->lmd_server_nid = PTL_NID_ANY;
- //ptl_parse_nid(&lmd->lmd_nid, lmd->lmd_hostname);
- //lmd->lmd_port = 988; /* XXX define LUSTRE_DEFAULT_PORT */
- //lmd->lmd_nal = SOCKNAL;
- //ptl_parse_ipaddr(&lmd->lmd_ipaddr, lmd->lmd_hostname);
- lmd->lmd_magic = LMD_MAGIC;
- lmd->lmd_flags = LMD_FLG_MNTCNF;
- lmd->lmd_mgmtnid.primary = PTL_NID_ANY;
- lmd->lmd_mgmtnid.backup = PTL_NID_ANY;
- return 0;
-}
-
-int
-print_options(struct lustre_mount_data *lmd)
-{
- printf("mgmt primary nid: %x\n", /*libcfs_nid2str*/(lmd->lmd_mgmtnid.primary));
- printf("mgmt backup nid: %x\n", /*libcfs_nid2str*/(lmd->lmd_mgmtnid.backup));
- printf("device: %s\n", lmd->lmd_dev);
- printf("mount point: %s\n", lmd->lmd_mtpt);
- printf("options: %s\n", lmd->lmd_opts);
- printf("flags: %x\n", lmd->lmd_flags);
- if (lmd_is_client(lmd))
- printf("CLIENT\n");
- else
- printf("SERVER\n");
-
- return 0;
-}
/*****************************************************************************
*
const struct opt_map *opt;
for (opt = &opt_map[0]; opt->opt != NULL; opt++) {
- if (strcmp(check, opt->opt) == 0) {
+ if (strncmp(check, opt->opt, strlen(opt->opt)) == 0) {
if (opt->inv)
*flagp &= ~(opt->mask);
else
return 0;
}
-int parse_options(char *options, struct lustre_mount_data *lmd, int *flagp)
+int parse_options(char *orig_options, int *flagp)
{
int val;
- char *opt, *opteq;
+ char *options, *opt, *opteq;
+
+ options = malloc(strlen(orig_options) + 1);
+ strcpy(options, orig_options);
*flagp = 0;
/* parsing ideas here taken from util-linux/mount/nfsmount.c */
if ((opteq = strchr(opt, '='))) {
val = atoi(opteq + 1);
*opteq = '\0';
- if (0) {
- /* All the network options have gone :)) */
- } else {
- fprintf(stderr, "%s: unknown option '%s'\n",
- progname, opt);
- usage(stderr);
- }
+ /* All the network options have gone :)) */
+ fprintf(stderr, "%s: unknown option '%s'. "
+ "Ignoring.\n", progname, opt);
} else {
if (parse_one_option(opt, flagp))
continue;
fprintf(stderr, "%s: unknown option '%s'\n",
progname, opt);
- usage(stderr);
}
}
+ free(options);
return 0;
}
-int
-build_data(char *source, char *target, char *options,
- struct lustre_mount_data *lmd, int *flagp)
-{
- char buf[1024];
- char *nid = NULL;
- char *devname = NULL;
- char *s;
- int rc;
-
- if (lmd_bad_magic(lmd))
- return 4;
-
- if (strlen(source) >= sizeof(buf)) {
- fprintf(stderr, "%s: device name too long\n",
- progname);
- return 1;
- }
- strcpy(buf, source);
-
- if ((s = strchr(buf, ':'))) {
- /* Client */
- if (verbose)
- printf("CLIENT\n");
- lmd->lmd_flags |= LMD_FLG_CLIENT;
-
- /* <mgmtnid>[,<alt mgmtnid>]:/fsname[/fsetname[/subdir/]]
- nid=mgmtnid, devname=fsname */
- nid = buf;
- *s = '\0';
- while (*++s == '/') /*spin*/;
- devname = s;
-
- rc = parse_options(options, lmd, flagp);
- if (rc)
- return rc;
-
- if (lmd->lmd_mgmtnid.primary != PTL_NID_ANY)
- /* In case it was defined as -o mgmtnode= */
- //FIXME set_nid_pair(&lmd->lmd_mgmtnid, nid);
- if (lmd->lmd_mgmtnid.primary == PTL_NID_ANY) {
- fprintf(stderr, "%s: can't parse nid '%s'\n",
- progname, nid);
- return 1;
- }
- } else {
- /* Server */
- if (verbose)
- printf("SERVER\n");
-
- devname = source;
-
- /* We have to keep the loop= option in the mtab file
- in order for umount to free the loop device. The strtok
- in parse_options terminates the options list at the first
- comma, so we're saving a local copy here. */
- strcpy(buf, options);
- rc = parse_options(options, lmd, flagp);
- if (rc)
- return rc;
- strcpy(options, buf);
-
- // move into lustre: rc = read_mount_options(source, target, lmd);
- }
-
- if (strlen(devname) + 1 > sizeof(lmd->lmd_dev)) {
- fprintf(stderr, "%s: device name too long\n", progname);
- return(1);
- }
- strcpy(lmd->lmd_dev, devname);
-
- if (strlen(target) + 1 > sizeof(lmd->lmd_mtpt)) {
- fprintf(stderr, "%s: mount point too long\n", progname);
- return(1);
- }
- strcpy(lmd->lmd_mtpt, target);
-
- if (verbose)
- print_options(lmd);
- return 0;
-}
int main(int argc, char *const argv[])
{
progname = strrchr(argv[0], '/');
progname = progname ? progname + 1 : argv[0];
+ printf("starting %s\n", progname);
+
while ((opt = getopt_long(argc, argv, "fhno:v",
long_opt, NULL)) != EOF){
switch (opt) {
if (!force && check_mtab_entry(source, target, "lustre"))
exit(32);
- init_options(&lmd);
- rc = build_data(source, target, options, &lmd, &flags);
+ rc = parse_options(options, &flags);
if (rc) {
+ fprintf(stderr, "%s: can't parse options: %s\n",
+ progname, options);
exit(1);
}
}
/* FIXME remove */
- if ((rc = load_modules(&lmd))) {
+ if ((rc = load_modules())) {
return rc;
}
/* flags and target get to lustre_get_sb, but not
lustre_fill_super. Lustre ignores the flags, but mount
does not. */
- rc = mount(source, target, "lustre", flags, (void *)&lmd);
+ rc = mount(source, target, "lustre", flags, (void *)options);
if (rc) {
- fprintf(stderr, "%s: mount(%s, %s) failed: %s\n", source,
- target, progname, strerror(errno));
+ fprintf(stderr, "%s: mount(%s, %s) failed: %s\n", progname,
+ source, target, strerror(errno));
if (errno == ENODEV)
fprintf(stderr, "Are the lustre modules loaded?\n"
"Check /etc/modules.conf and /proc/filesystems\n");