Loading mm/shmem.c +79 −69 Original line number Diff line number Diff line Loading @@ -3363,40 +3363,13 @@ static const struct export_operations shmem_export_ops = { .fh_to_dentry = shmem_fh_to_dentry, }; static int shmem_parse_options(char *options, struct shmem_options *ctx) static int shmem_parse_one(struct shmem_options *ctx, char *opt, char *value) { char *this_char, *value, *rest; char *rest; uid_t uid; gid_t gid; while (options != NULL) { this_char = options; for (;;) { /* * NUL-terminate this option: unfortunately, * mount options form a comma-separated list, * but mpol's nodelist may also contain commas. */ options = strchr(options, ','); if (options == NULL) break; options++; if (!isdigit(*options)) { options[-1] = '\0'; break; } } if (!*this_char) continue; if ((value = strchr(this_char,'=')) != NULL) { *value++ = 0; } else { pr_err("tmpfs: No value for mount option '%s'\n", this_char); goto error; } if (!strcmp(this_char,"size")) { if (!strcmp(opt, "size")) { unsigned long long size; size = memparse(value,&rest); if (*rest == '%') { Loading @@ -3409,28 +3382,28 @@ static int shmem_parse_options(char *options, struct shmem_options *ctx) goto bad_val; ctx->blocks = DIV_ROUND_UP(size, PAGE_SIZE); ctx->seen |= SHMEM_SEEN_BLOCKS; } else if (!strcmp(this_char,"nr_blocks")) { } else if (!strcmp(opt, "nr_blocks")) { ctx->blocks = memparse(value, &rest); if (*rest) goto bad_val; ctx->seen |= SHMEM_SEEN_BLOCKS; } else if (!strcmp(this_char,"nr_inodes")) { } else if (!strcmp(opt, "nr_inodes")) { ctx->inodes = memparse(value, &rest); if (*rest) goto bad_val; ctx->seen |= SHMEM_SEEN_INODES; } else if (!strcmp(this_char,"mode")) { } else if (!strcmp(opt, "mode")) { ctx->mode = simple_strtoul(value, &rest, 8) & 07777; if (*rest) goto bad_val; } else if (!strcmp(this_char,"uid")) { } else if (!strcmp(opt, "uid")) { uid = simple_strtoul(value, &rest, 0); if (*rest) goto bad_val; ctx->uid = make_kuid(current_user_ns(), uid); if (!uid_valid(ctx->uid)) goto bad_val; } else if (!strcmp(this_char,"gid")) { } else if (!strcmp(opt, "gid")) { gid = simple_strtoul(value, &rest, 0); if (*rest) goto bad_val; Loading @@ -3438,7 +3411,7 @@ static int shmem_parse_options(char *options, struct shmem_options *ctx) if (!gid_valid(ctx->gid)) goto bad_val; #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE } else if (!strcmp(this_char, "huge")) { } else if (!strcmp(opt, "huge")) { int huge; huge = shmem_parse_huge(value); if (huge < 0) Loading @@ -3450,22 +3423,59 @@ static int shmem_parse_options(char *options, struct shmem_options *ctx) ctx->seen |= SHMEM_SEEN_HUGE; #endif #ifdef CONFIG_NUMA } else if (!strcmp(this_char,"mpol")) { } else if (!strcmp(opt, "mpol")) { mpol_put(ctx->mpol); ctx->mpol = NULL; if (mpol_parse_str(value, &ctx->mpol)) goto bad_val; #endif } else { pr_err("tmpfs: Bad mount option %s\n", this_char); goto error; } pr_err("tmpfs: Bad mount option %s\n", opt); return -EINVAL; } return 0; bad_val: pr_err("tmpfs: Bad value '%s' for mount option '%s'\n", value, this_char); value, opt); return -EINVAL; } static int shmem_parse_options(char *options, struct shmem_options *ctx) { char *this_char, *value; while (options != NULL) { this_char = options; for (;;) { /* * NUL-terminate this option: unfortunately, * mount options form a comma-separated list, * but mpol's nodelist may also contain commas. */ options = strchr(options, ','); if (options == NULL) break; options++; if (!isdigit(*options)) { options[-1] = '\0'; break; } } if (!*this_char) continue; if ((value = strchr(this_char,'=')) != NULL) { *value++ = 0; } else { pr_err("tmpfs: No value for mount option '%s'\n", this_char); goto error; } if (shmem_parse_one(ctx, this_char, value) < 0) goto error; } return 0; error: mpol_put(ctx->mpol); ctx->mpol = NULL; Loading Loading
mm/shmem.c +79 −69 Original line number Diff line number Diff line Loading @@ -3363,40 +3363,13 @@ static const struct export_operations shmem_export_ops = { .fh_to_dentry = shmem_fh_to_dentry, }; static int shmem_parse_options(char *options, struct shmem_options *ctx) static int shmem_parse_one(struct shmem_options *ctx, char *opt, char *value) { char *this_char, *value, *rest; char *rest; uid_t uid; gid_t gid; while (options != NULL) { this_char = options; for (;;) { /* * NUL-terminate this option: unfortunately, * mount options form a comma-separated list, * but mpol's nodelist may also contain commas. */ options = strchr(options, ','); if (options == NULL) break; options++; if (!isdigit(*options)) { options[-1] = '\0'; break; } } if (!*this_char) continue; if ((value = strchr(this_char,'=')) != NULL) { *value++ = 0; } else { pr_err("tmpfs: No value for mount option '%s'\n", this_char); goto error; } if (!strcmp(this_char,"size")) { if (!strcmp(opt, "size")) { unsigned long long size; size = memparse(value,&rest); if (*rest == '%') { Loading @@ -3409,28 +3382,28 @@ static int shmem_parse_options(char *options, struct shmem_options *ctx) goto bad_val; ctx->blocks = DIV_ROUND_UP(size, PAGE_SIZE); ctx->seen |= SHMEM_SEEN_BLOCKS; } else if (!strcmp(this_char,"nr_blocks")) { } else if (!strcmp(opt, "nr_blocks")) { ctx->blocks = memparse(value, &rest); if (*rest) goto bad_val; ctx->seen |= SHMEM_SEEN_BLOCKS; } else if (!strcmp(this_char,"nr_inodes")) { } else if (!strcmp(opt, "nr_inodes")) { ctx->inodes = memparse(value, &rest); if (*rest) goto bad_val; ctx->seen |= SHMEM_SEEN_INODES; } else if (!strcmp(this_char,"mode")) { } else if (!strcmp(opt, "mode")) { ctx->mode = simple_strtoul(value, &rest, 8) & 07777; if (*rest) goto bad_val; } else if (!strcmp(this_char,"uid")) { } else if (!strcmp(opt, "uid")) { uid = simple_strtoul(value, &rest, 0); if (*rest) goto bad_val; ctx->uid = make_kuid(current_user_ns(), uid); if (!uid_valid(ctx->uid)) goto bad_val; } else if (!strcmp(this_char,"gid")) { } else if (!strcmp(opt, "gid")) { gid = simple_strtoul(value, &rest, 0); if (*rest) goto bad_val; Loading @@ -3438,7 +3411,7 @@ static int shmem_parse_options(char *options, struct shmem_options *ctx) if (!gid_valid(ctx->gid)) goto bad_val; #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE } else if (!strcmp(this_char, "huge")) { } else if (!strcmp(opt, "huge")) { int huge; huge = shmem_parse_huge(value); if (huge < 0) Loading @@ -3450,22 +3423,59 @@ static int shmem_parse_options(char *options, struct shmem_options *ctx) ctx->seen |= SHMEM_SEEN_HUGE; #endif #ifdef CONFIG_NUMA } else if (!strcmp(this_char,"mpol")) { } else if (!strcmp(opt, "mpol")) { mpol_put(ctx->mpol); ctx->mpol = NULL; if (mpol_parse_str(value, &ctx->mpol)) goto bad_val; #endif } else { pr_err("tmpfs: Bad mount option %s\n", this_char); goto error; } pr_err("tmpfs: Bad mount option %s\n", opt); return -EINVAL; } return 0; bad_val: pr_err("tmpfs: Bad value '%s' for mount option '%s'\n", value, this_char); value, opt); return -EINVAL; } static int shmem_parse_options(char *options, struct shmem_options *ctx) { char *this_char, *value; while (options != NULL) { this_char = options; for (;;) { /* * NUL-terminate this option: unfortunately, * mount options form a comma-separated list, * but mpol's nodelist may also contain commas. */ options = strchr(options, ','); if (options == NULL) break; options++; if (!isdigit(*options)) { options[-1] = '\0'; break; } } if (!*this_char) continue; if ((value = strchr(this_char,'=')) != NULL) { *value++ = 0; } else { pr_err("tmpfs: No value for mount option '%s'\n", this_char); goto error; } if (shmem_parse_one(ctx, this_char, value) < 0) goto error; } return 0; error: mpol_put(ctx->mpol); ctx->mpol = NULL; Loading