Lines Matching +full:async +full:- +full:prefix

1 // SPDX-License-Identifier: GPL-2.0-or-later
51 { "async", SB_SYNCHRONOUS },
67 fc->sb_flags |= token; in vfs_parse_sb_flag()
68 fc->sb_flags_mask |= 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.
184 return -ENOMEM; in vfs_parse_fs_string()
195 * vfs_parse_monolithic_sep - Parse key[=val][,key[=val]]* mount data
203 * Returns 0 on success or the error returned by the ->parse_option() fs_context
215 ret = security_sb_eat_lsm_opts(options, &fc->security); in vfs_parse_monolithic_sep()
246 * generic_parse_monolithic - Parse key[=val][,key[=val]]* mount data
251 * called from the ->monolithic_mount_data() fs_context operation.
253 * Returns 0 on success or the error returned by the ->parse_option() fs_context
263 * alloc_fs_context - Create a filesystem context.
283 int ret = -ENOMEM; in alloc_fs_context()
287 return ERR_PTR(-ENOMEM); in alloc_fs_context()
289 fc->purpose = purpose; in alloc_fs_context()
290 fc->sb_flags = sb_flags; in alloc_fs_context()
291 fc->sb_flags_mask = sb_flags_mask; in alloc_fs_context()
292 fc->fs_type = get_filesystem(fs_type); in alloc_fs_context()
293 fc->cred = get_current_cred(); in alloc_fs_context()
294 fc->net_ns = get_net(current->nsproxy->net_ns); in alloc_fs_context()
295 fc->log.prefix = fs_type->name; in alloc_fs_context()
297 mutex_init(&fc->uapi_mutex); in alloc_fs_context()
301 fc->user_ns = get_user_ns(fc->cred->user_ns); in alloc_fs_context()
304 fc->user_ns = get_user_ns(reference->d_sb->s_user_ns); in alloc_fs_context()
307 atomic_inc(&reference->d_sb->s_active); in alloc_fs_context()
308 fc->user_ns = get_user_ns(reference->d_sb->s_user_ns); in alloc_fs_context()
309 fc->root = dget(reference); in alloc_fs_context()
314 init_fs_context = fc->fs_type->init_fs_context; in alloc_fs_context()
321 fc->need_free = true; in alloc_fs_context()
341 return alloc_fs_context(dentry->d_sb->s_type, dentry, sb_flags, in fs_context_for_reconfigure()
352 * the fc->security object is inherited from @reference (if needed).
364 ret = security_fs_context_submount(fc, reference->d_sb); in fs_context_for_submount()
376 struct super_block *sb = fc->root->d_sb; in fc_drop_locked()
377 dput(fc->root); in fc_drop_locked()
378 fc->root = NULL; in fc_drop_locked()
385 * vfs_dup_fs_context - Duplicate a filesystem context.
393 if (!src_fc->ops->dup) in vfs_dup_fs_context()
394 return ERR_PTR(-EOPNOTSUPP); in vfs_dup_fs_context()
398 return ERR_PTR(-ENOMEM); in vfs_dup_fs_context()
400 mutex_init(&fc->uapi_mutex); in vfs_dup_fs_context()
402 fc->fs_private = NULL; in vfs_dup_fs_context()
403 fc->s_fs_info = NULL; in vfs_dup_fs_context()
404 fc->source = NULL; in vfs_dup_fs_context()
405 fc->security = NULL; in vfs_dup_fs_context()
406 get_filesystem(fc->fs_type); in vfs_dup_fs_context()
407 get_net(fc->net_ns); in vfs_dup_fs_context()
408 get_user_ns(fc->user_ns); in vfs_dup_fs_context()
409 get_cred(fc->cred); in vfs_dup_fs_context()
410 if (fc->log.log) in vfs_dup_fs_context()
411 refcount_inc(&fc->log.log->usage); in vfs_dup_fs_context()
413 /* Can't call put until we've called ->dup */ in vfs_dup_fs_context()
414 ret = fc->ops->dup(fc, src_fc); in vfs_dup_fs_context()
430 * logfc - Log a message to a filesystem context
432 * @prefix: A string to prefix the output with, or NULL.
436 void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...) in logfc() argument
445 printk(KERN_WARNING "%s%s%pV\n", prefix ? prefix : "", in logfc()
446 prefix ? ": " : "", &vaf); in logfc()
449 printk(KERN_ERR "%s%s%pV\n", prefix ? prefix : "", in logfc()
450 prefix ? ": " : "", &vaf); in logfc()
453 printk(KERN_NOTICE "%s%s%pV\n", prefix ? prefix : "", in logfc()
454 prefix ? ": " : "", &vaf); in logfc()
458 unsigned int logsize = ARRAY_SIZE(log->buffer); in logfc()
461 prefix ? prefix : "", in logfc()
462 prefix ? ": " : "", &vaf); in logfc()
464 index = log->head & (logsize - 1); in logfc()
465 BUILD_BUG_ON(sizeof(log->head) != sizeof(u8) || in logfc()
466 sizeof(log->tail) != sizeof(u8)); in logfc()
467 if ((u8)(log->head - log->tail) == logsize) { in logfc()
469 if (log->need_free & (1 << index)) in logfc()
470 kfree(log->buffer[index]); in logfc()
471 log->tail++; in logfc()
474 log->buffer[index] = q ? q : "OOM: Can't store error string"; in logfc()
476 log->need_free |= 1 << index; in logfc()
478 log->need_free &= ~(1 << index); in logfc()
479 log->head++; in logfc()
490 struct fc_log *log = fc->log.log; in put_fc_log()
494 if (refcount_dec_and_test(&log->usage)) { in put_fc_log()
495 fc->log.log = NULL; in put_fc_log()
497 if (log->need_free & (1 << i)) in put_fc_log()
498 kfree(log->buffer[i]); in put_fc_log()
505 * put_fs_context - Dispose of a superblock configuration context.
512 if (fc->root) { in put_fs_context()
513 sb = fc->root->d_sb; in put_fs_context()
514 dput(fc->root); in put_fs_context()
515 fc->root = NULL; in put_fs_context()
519 if (fc->need_free && fc->ops && fc->ops->free) in put_fs_context()
520 fc->ops->free(fc); in put_fs_context()
522 security_free_mnt_opts(&fc->security); in put_fs_context()
523 put_net(fc->net_ns); in put_fs_context()
524 put_user_ns(fc->user_ns); in put_fs_context()
525 put_cred(fc->cred); in put_fs_context()
527 put_filesystem(fc->fs_type); in put_fs_context()
528 kfree(fc->source); in put_fs_context()
538 struct legacy_fs_context *ctx = fc->fs_private; in legacy_fs_context_free()
541 if (ctx->param_type == LEGACY_FS_INDIVIDUAL_PARAMS) in legacy_fs_context_free()
542 kfree(ctx->legacy_data); in legacy_fs_context_free()
553 struct legacy_fs_context *src_ctx = src_fc->fs_private; in legacy_fs_context_dup()
557 return -ENOMEM; in legacy_fs_context_dup()
559 if (ctx->param_type == LEGACY_FS_INDIVIDUAL_PARAMS) { in legacy_fs_context_dup()
560 ctx->legacy_data = kmemdup(src_ctx->legacy_data, in legacy_fs_context_dup()
561 src_ctx->data_size, GFP_KERNEL); in legacy_fs_context_dup()
562 if (!ctx->legacy_data) { in legacy_fs_context_dup()
564 return -ENOMEM; in legacy_fs_context_dup()
568 fc->fs_private = ctx; in legacy_fs_context_dup()
573 * Add a parameter to a legacy config. We build up a comma-separated list of
578 struct legacy_fs_context *ctx = fc->fs_private; in legacy_parse_param()
579 unsigned int size = ctx->data_size; in legacy_parse_param()
584 if (ret != -ENOPARAM) in legacy_parse_param()
587 if (ctx->param_type == LEGACY_FS_MONOLITHIC_PARAMS) in legacy_parse_param()
590 switch (param->type) { in legacy_parse_param()
592 len = 1 + param->size; in legacy_parse_param()
595 len += strlen(param->key); in legacy_parse_param()
599 param->key); in legacy_parse_param()
604 if (strchr(param->key, ',') || in legacy_parse_param()
605 (param->type == fs_value_is_string && in legacy_parse_param()
606 memchr(param->string, ',', param->size))) in legacy_parse_param()
608 param->key); in legacy_parse_param()
609 if (!ctx->legacy_data) { in legacy_parse_param()
610 ctx->legacy_data = kmalloc(PAGE_SIZE, GFP_KERNEL); in legacy_parse_param()
611 if (!ctx->legacy_data) in legacy_parse_param()
612 return -ENOMEM; in legacy_parse_param()
616 ctx->legacy_data[size++] = ','; in legacy_parse_param()
617 len = strlen(param->key); in legacy_parse_param()
618 memcpy(ctx->legacy_data + size, param->key, len); in legacy_parse_param()
620 if (param->type == fs_value_is_string) { in legacy_parse_param()
621 ctx->legacy_data[size++] = '='; in legacy_parse_param()
622 memcpy(ctx->legacy_data + size, param->string, param->size); in legacy_parse_param()
623 size += param->size; in legacy_parse_param()
625 ctx->legacy_data[size] = '\0'; in legacy_parse_param()
626 ctx->data_size = size; in legacy_parse_param()
627 ctx->param_type = LEGACY_FS_INDIVIDUAL_PARAMS; in legacy_parse_param()
636 struct legacy_fs_context *ctx = fc->fs_private; in legacy_parse_monolithic()
638 if (ctx->param_type != LEGACY_FS_UNSET_PARAMS) { in legacy_parse_monolithic()
640 return -EINVAL; in legacy_parse_monolithic()
643 ctx->legacy_data = data; in legacy_parse_monolithic()
644 ctx->param_type = LEGACY_FS_MONOLITHIC_PARAMS; in legacy_parse_monolithic()
645 if (!ctx->legacy_data) in legacy_parse_monolithic()
648 if (fc->fs_type->fs_flags & FS_BINARY_MOUNTDATA) in legacy_parse_monolithic()
650 return security_sb_eat_lsm_opts(ctx->legacy_data, &fc->security); in legacy_parse_monolithic()
658 struct legacy_fs_context *ctx = fc->fs_private; in legacy_get_tree()
662 root = fc->fs_type->mount(fc->fs_type, fc->sb_flags, in legacy_get_tree()
663 fc->source, ctx->legacy_data); in legacy_get_tree()
667 sb = root->d_sb; in legacy_get_tree()
670 fc->root = root; in legacy_get_tree()
679 struct legacy_fs_context *ctx = fc->fs_private; in legacy_reconfigure()
680 struct super_block *sb = fc->root->d_sb; in legacy_reconfigure()
682 if (!sb->s_op->remount_fs) in legacy_reconfigure()
685 return sb->s_op->remount_fs(sb, &fc->sb_flags, in legacy_reconfigure()
686 ctx ? ctx->legacy_data : NULL); in legacy_reconfigure()
704 fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL_ACCOUNT); in legacy_init_fs_context()
705 if (!fc->fs_private) in legacy_init_fs_context()
706 return -ENOMEM; in legacy_init_fs_context()
707 fc->ops = &legacy_fs_context_ops; in legacy_init_fs_context()
715 monolithic_mount_data = fc->ops->parse_monolithic; in parse_monolithic_mount_data()
737 if (fc->need_free && fc->ops && fc->ops->free) in vfs_clean_context()
738 fc->ops->free(fc); in vfs_clean_context()
739 fc->need_free = false; in vfs_clean_context()
740 fc->fs_private = NULL; in vfs_clean_context()
741 fc->s_fs_info = NULL; in vfs_clean_context()
742 fc->sb_flags = 0; in vfs_clean_context()
743 security_free_mnt_opts(&fc->security); in vfs_clean_context()
744 kfree(fc->source); in vfs_clean_context()
745 fc->source = NULL; in vfs_clean_context()
746 fc->exclusive = false; in vfs_clean_context()
748 fc->purpose = FS_CONTEXT_FOR_RECONFIGURE; in vfs_clean_context()
749 fc->phase = FS_CONTEXT_AWAITING_RECONF; in vfs_clean_context()
756 if (fc->phase != FS_CONTEXT_AWAITING_RECONF) in finish_clean_context()
759 if (fc->fs_type->init_fs_context) in finish_clean_context()
760 error = fc->fs_type->init_fs_context(fc); in finish_clean_context()
764 fc->phase = FS_CONTEXT_FAILED; in finish_clean_context()
767 fc->need_free = true; in finish_clean_context()
768 fc->phase = FS_CONTEXT_RECONF_PARAMS; in finish_clean_context()