From: adilger Date: Sat, 22 Oct 2005 07:36:18 +0000 (+0000) Subject: Branch b1_4 X-Git-Tag: v1_7_100~1^103~4^2~260^2~15 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=8854f4ac757ffad5fc58678017bd6a7c3ea62291;p=fs%2Flustre-release.git Branch b1_4 Save "options" from the wrath of strtok() so we can save them into /etc/mtab. This is needed for buffalo testing of new features, among other things. --- diff --git a/lustre/utils/llmount.c b/lustre/utils/llmount.c index af5882c..0e78d74 100644 --- a/lustre/utils/llmount.c +++ b/lustre/utils/llmount.c @@ -130,11 +130,12 @@ init_options(struct lustre_mount_data *lmd) } int -print_options(struct lustre_mount_data *lmd) +print_options(struct lustre_mount_data *lmd, const char *options) { printf("nid: %s\n", libcfs_nid2str(lmd->lmd_nid)); printf("mds: %s\n", lmd->lmd_mds); printf("profile: %s\n", lmd->lmd_profile); + printf("options: %s\n", options); return 0; } @@ -296,15 +297,13 @@ build_data(char *source, char *options, struct lustre_mount_data *lmd, } strcpy(lmd->lmd_profile, profile); - if (verbose) - print_options(lmd); return 0; } int main(int argc, char *const argv[]) { - char *source, *target, *options = ""; - int i, nargs = 3, opt, rc, flags; + char *source, *target, *options = "", optbuf[65536] = { '\0' }; + int i, nargs = 3, opt, rc, flags, buflen = sizeof(optbuf) - 1; struct lustre_mount_data lmd; static struct option long_opt[] = { {"fake", 0, 0, 'f'}, @@ -374,11 +373,22 @@ int main(int argc, char *const argv[]) exit(32); init_options(&lmd); - rc = build_data(source, options, &lmd, &flags); + + /* need to copy options, as parse_options->strtok() clobbers it + * and we can't use it later to put in /etc/mtab. */ + if (strlen(options) > buflen) + fprintf(stderr, "%s: options too long (%d > %d), ignore last\n", + progname, strlen(options), buflen); + strncpy(optbuf, options, buflen); + + rc = build_data(source, optbuf, &lmd, &flags); if (rc) { exit(1); } + if (verbose) + print_options(&lmd, options); + rc = access(target, F_OK); if (rc) { rc = errno;