Lines Matching +full:sync +full:- +full:token

1 // SPDX-License-Identifier: GPL-2.0-or-later
46 { "sync", SB_SYNCHRONOUS },
63 unsigned int token; in vfs_parse_sb_flag() local
65 token = lookup_constant(common_set_sb_flag, key, 0); in vfs_parse_sb_flag()
66 if (token) { in vfs_parse_sb_flag()
67 fc->sb_flags |= token; in vfs_parse_sb_flag()
68 fc->sb_flags_mask |= token; in vfs_parse_sb_flag()
72 token = lookup_constant(common_clear_sb_flag, key, 0); in vfs_parse_sb_flag()
73 if (token) { in vfs_parse_sb_flag()
74 fc->sb_flags &= ~token; in vfs_parse_sb_flag()
75 fc->sb_flags_mask |= token; in vfs_parse_sb_flag()
79 return -ENOPARAM; in vfs_parse_sb_flag()
83 * vfs_parse_fs_param_source - Handle setting "source" via parameter
90 * Returns 0 on success, -ENOPARAM if this is not "source" parameter, and
91 * -EINVAL otherwise. In the event of failure, supplementary error information
96 if (strcmp(param->key, "source") != 0) in vfs_parse_fs_param_source()
97 return -ENOPARAM; in vfs_parse_fs_param_source()
99 if (param->type != fs_value_is_string) in vfs_parse_fs_param_source()
100 return invalf(fc, "Non-string source"); in vfs_parse_fs_param_source()
102 if (fc->source) in vfs_parse_fs_param_source()
105 fc->source = param->string; in vfs_parse_fs_param_source()
106 param->string = NULL; in vfs_parse_fs_param_source()
112 * vfs_parse_fs_param - Add a single parameter to a superblock config
131 if (!param->key) in vfs_parse_fs_param()
134 ret = vfs_parse_sb_flag(fc, param->key); in vfs_parse_fs_param()
135 if (ret != -ENOPARAM) in vfs_parse_fs_param()
139 if (ret != -ENOPARAM) in vfs_parse_fs_param()
145 if (fc->ops->parse_param) { in vfs_parse_fs_param()
146 ret = fc->ops->parse_param(fc, param); in vfs_parse_fs_param()
147 if (ret != -ENOPARAM) in vfs_parse_fs_param()
155 if (ret != -ENOPARAM) in vfs_parse_fs_param()
159 fc->fs_type->name, param->key); in vfs_parse_fs_param()
164 * vfs_parse_fs_string - Convenience function to just parse a string.
180 return -ENOMEM; in vfs_parse_fs_string()
191 * generic_parse_monolithic - Parse key[=val][,key[=val]]* mount data
196 * called from the ->monolithic_mount_data() fs_context operation.
198 * Returns 0 on success or the error returned by the ->parse_option() fs_context
209 ret = security_sb_eat_lsm_opts(options, &fc->security); in generic_parse_monolithic()
235 * alloc_fs_context - Create a filesystem context.
255 int ret = -ENOMEM; in alloc_fs_context()
259 return ERR_PTR(-ENOMEM); in alloc_fs_context()
261 fc->purpose = purpose; in alloc_fs_context()
262 fc->sb_flags = sb_flags; in alloc_fs_context()
263 fc->sb_flags_mask = sb_flags_mask; in alloc_fs_context()
264 fc->fs_type = get_filesystem(fs_type); in alloc_fs_context()
265 fc->cred = get_current_cred(); in alloc_fs_context()
266 fc->net_ns = get_net(current->nsproxy->net_ns); in alloc_fs_context()
267 fc->log.prefix = fs_type->name; in alloc_fs_context()
269 mutex_init(&fc->uapi_mutex); in alloc_fs_context()
273 fc->user_ns = get_user_ns(fc->cred->user_ns); in alloc_fs_context()
276 fc->user_ns = get_user_ns(reference->d_sb->s_user_ns); in alloc_fs_context()
279 atomic_inc(&reference->d_sb->s_active); in alloc_fs_context()
280 fc->user_ns = get_user_ns(reference->d_sb->s_user_ns); in alloc_fs_context()
281 fc->root = dget(reference); in alloc_fs_context()
286 init_fs_context = fc->fs_type->init_fs_context; in alloc_fs_context()
293 fc->need_free = true; in alloc_fs_context()
313 return alloc_fs_context(dentry->d_sb->s_type, dentry, sb_flags, in fs_context_for_reconfigure()
327 struct super_block *sb = fc->root->d_sb; in fc_drop_locked()
328 dput(fc->root); in fc_drop_locked()
329 fc->root = NULL; in fc_drop_locked()
344 if (!src_fc->ops->dup) in vfs_dup_fs_context()
345 return ERR_PTR(-EOPNOTSUPP); in vfs_dup_fs_context()
349 return ERR_PTR(-ENOMEM); in vfs_dup_fs_context()
351 mutex_init(&fc->uapi_mutex); in vfs_dup_fs_context()
353 fc->fs_private = NULL; in vfs_dup_fs_context()
354 fc->s_fs_info = NULL; in vfs_dup_fs_context()
355 fc->source = NULL; in vfs_dup_fs_context()
356 fc->security = NULL; in vfs_dup_fs_context()
357 get_filesystem(fc->fs_type); in vfs_dup_fs_context()
358 get_net(fc->net_ns); in vfs_dup_fs_context()
359 get_user_ns(fc->user_ns); in vfs_dup_fs_context()
360 get_cred(fc->cred); in vfs_dup_fs_context()
361 if (fc->log.log) in vfs_dup_fs_context()
362 refcount_inc(&fc->log.log->usage); in vfs_dup_fs_context()
364 /* Can't call put until we've called ->dup */ in vfs_dup_fs_context()
365 ret = fc->ops->dup(fc, src_fc); in vfs_dup_fs_context()
381 * logfc - Log a message to a filesystem context
407 unsigned int logsize = ARRAY_SIZE(log->buffer); in logfc()
413 index = log->head & (logsize - 1); in logfc()
414 BUILD_BUG_ON(sizeof(log->head) != sizeof(u8) || in logfc()
415 sizeof(log->tail) != sizeof(u8)); in logfc()
416 if ((u8)(log->head - log->tail) == logsize) { in logfc()
418 if (log->need_free & (1 << index)) in logfc()
419 kfree(log->buffer[index]); in logfc()
420 log->tail++; in logfc()
423 log->buffer[index] = q ? q : "OOM: Can't store error string"; in logfc()
425 log->need_free |= 1 << index; in logfc()
427 log->need_free &= ~(1 << index); in logfc()
428 log->head++; in logfc()
439 struct fc_log *log = fc->log.log; in put_fc_log()
443 if (refcount_dec_and_test(&log->usage)) { in put_fc_log()
444 fc->log.log = NULL; in put_fc_log()
446 if (log->need_free & (1 << i)) in put_fc_log()
447 kfree(log->buffer[i]); in put_fc_log()
454 * put_fs_context - Dispose of a superblock configuration context.
461 if (fc->root) { in put_fs_context()
462 sb = fc->root->d_sb; in put_fs_context()
463 dput(fc->root); in put_fs_context()
464 fc->root = NULL; in put_fs_context()
468 if (fc->need_free && fc->ops && fc->ops->free) in put_fs_context()
469 fc->ops->free(fc); in put_fs_context()
471 security_free_mnt_opts(&fc->security); in put_fs_context()
472 put_net(fc->net_ns); in put_fs_context()
473 put_user_ns(fc->user_ns); in put_fs_context()
474 put_cred(fc->cred); in put_fs_context()
476 put_filesystem(fc->fs_type); in put_fs_context()
477 kfree(fc->source); in put_fs_context()
487 struct legacy_fs_context *ctx = fc->fs_private; in legacy_fs_context_free()
490 if (ctx->param_type == LEGACY_FS_INDIVIDUAL_PARAMS) in legacy_fs_context_free()
491 kfree(ctx->legacy_data); in legacy_fs_context_free()
502 struct legacy_fs_context *src_ctx = src_fc->fs_private; in legacy_fs_context_dup()
506 return -ENOMEM; in legacy_fs_context_dup()
508 if (ctx->param_type == LEGACY_FS_INDIVIDUAL_PARAMS) { in legacy_fs_context_dup()
509 ctx->legacy_data = kmemdup(src_ctx->legacy_data, in legacy_fs_context_dup()
510 src_ctx->data_size, GFP_KERNEL); in legacy_fs_context_dup()
511 if (!ctx->legacy_data) { in legacy_fs_context_dup()
513 return -ENOMEM; in legacy_fs_context_dup()
517 fc->fs_private = ctx; in legacy_fs_context_dup()
522 * Add a parameter to a legacy config. We build up a comma-separated list of
527 struct legacy_fs_context *ctx = fc->fs_private; in legacy_parse_param()
528 unsigned int size = ctx->data_size; in legacy_parse_param()
533 if (ret != -ENOPARAM) in legacy_parse_param()
536 if (ctx->param_type == LEGACY_FS_MONOLITHIC_PARAMS) in legacy_parse_param()
539 switch (param->type) { in legacy_parse_param()
541 len = 1 + param->size; in legacy_parse_param()
544 len += strlen(param->key); in legacy_parse_param()
548 param->key); in legacy_parse_param()
553 if (strchr(param->key, ',') || in legacy_parse_param()
554 (param->type == fs_value_is_string && in legacy_parse_param()
555 memchr(param->string, ',', param->size))) in legacy_parse_param()
557 param->key); in legacy_parse_param()
558 if (!ctx->legacy_data) { in legacy_parse_param()
559 ctx->legacy_data = kmalloc(PAGE_SIZE, GFP_KERNEL); in legacy_parse_param()
560 if (!ctx->legacy_data) in legacy_parse_param()
561 return -ENOMEM; in legacy_parse_param()
564 ctx->legacy_data[size++] = ','; in legacy_parse_param()
565 len = strlen(param->key); in legacy_parse_param()
566 memcpy(ctx->legacy_data + size, param->key, len); in legacy_parse_param()
568 if (param->type == fs_value_is_string) { in legacy_parse_param()
569 ctx->legacy_data[size++] = '='; in legacy_parse_param()
570 memcpy(ctx->legacy_data + size, param->string, param->size); in legacy_parse_param()
571 size += param->size; in legacy_parse_param()
573 ctx->legacy_data[size] = '\0'; in legacy_parse_param()
574 ctx->data_size = size; in legacy_parse_param()
575 ctx->param_type = LEGACY_FS_INDIVIDUAL_PARAMS; in legacy_parse_param()
584 struct legacy_fs_context *ctx = fc->fs_private; in legacy_parse_monolithic()
586 if (ctx->param_type != LEGACY_FS_UNSET_PARAMS) { in legacy_parse_monolithic()
588 return -EINVAL; in legacy_parse_monolithic()
591 ctx->legacy_data = data; in legacy_parse_monolithic()
592 ctx->param_type = LEGACY_FS_MONOLITHIC_PARAMS; in legacy_parse_monolithic()
593 if (!ctx->legacy_data) in legacy_parse_monolithic()
596 if (fc->fs_type->fs_flags & FS_BINARY_MOUNTDATA) in legacy_parse_monolithic()
598 return security_sb_eat_lsm_opts(ctx->legacy_data, &fc->security); in legacy_parse_monolithic()
606 struct legacy_fs_context *ctx = fc->fs_private; in legacy_get_tree()
610 root = fc->fs_type->mount(fc->fs_type, fc->sb_flags, in legacy_get_tree()
611 fc->source, ctx->legacy_data); in legacy_get_tree()
615 sb = root->d_sb; in legacy_get_tree()
618 fc->root = root; in legacy_get_tree()
627 struct legacy_fs_context *ctx = fc->fs_private; in legacy_reconfigure()
628 struct super_block *sb = fc->root->d_sb; in legacy_reconfigure()
630 if (!sb->s_op->remount_fs) in legacy_reconfigure()
633 return sb->s_op->remount_fs(sb, &fc->sb_flags, in legacy_reconfigure()
634 ctx ? ctx->legacy_data : NULL); in legacy_reconfigure()
652 fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL_ACCOUNT); in legacy_init_fs_context()
653 if (!fc->fs_private) in legacy_init_fs_context()
654 return -ENOMEM; in legacy_init_fs_context()
655 fc->ops = &legacy_fs_context_ops; in legacy_init_fs_context()
663 monolithic_mount_data = fc->ops->parse_monolithic; in parse_monolithic_mount_data()
685 if (fc->need_free && fc->ops && fc->ops->free) in vfs_clean_context()
686 fc->ops->free(fc); in vfs_clean_context()
687 fc->need_free = false; in vfs_clean_context()
688 fc->fs_private = NULL; in vfs_clean_context()
689 fc->s_fs_info = NULL; in vfs_clean_context()
690 fc->sb_flags = 0; in vfs_clean_context()
691 security_free_mnt_opts(&fc->security); in vfs_clean_context()
692 kfree(fc->source); in vfs_clean_context()
693 fc->source = NULL; in vfs_clean_context()
695 fc->purpose = FS_CONTEXT_FOR_RECONFIGURE; in vfs_clean_context()
696 fc->phase = FS_CONTEXT_AWAITING_RECONF; in vfs_clean_context()
703 if (fc->phase != FS_CONTEXT_AWAITING_RECONF) in finish_clean_context()
706 if (fc->fs_type->init_fs_context) in finish_clean_context()
707 error = fc->fs_type->init_fs_context(fc); in finish_clean_context()
711 fc->phase = FS_CONTEXT_FAILED; in finish_clean_context()
714 fc->need_free = true; in finish_clean_context()
715 fc->phase = FS_CONTEXT_RECONF_PARAMS; in finish_clean_context()