Lines Matching full:fc
39 static int legacy_init_fs_context(struct fs_context *fc);
61 static int vfs_parse_sb_flag(struct fs_context *fc, const char *key) in vfs_parse_sb_flag() argument
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()
84 * @fc: The filesystem context to modify
94 int vfs_parse_fs_param_source(struct fs_context *fc, struct fs_parameter *param) in vfs_parse_fs_param_source() argument
100 return invalf(fc, "Non-string source"); in vfs_parse_fs_param_source()
102 if (fc->source) in vfs_parse_fs_param_source()
103 return invalf(fc, "Multiple sources"); in vfs_parse_fs_param_source()
105 fc->source = param->string; in vfs_parse_fs_param_source()
113 * @fc: The filesystem context to modify
127 int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param) in vfs_parse_fs_param() argument
132 return invalf(fc, "Unnamed parameter\n"); in vfs_parse_fs_param()
134 ret = vfs_parse_sb_flag(fc, param->key); in vfs_parse_fs_param()
138 ret = security_fs_context_parse_param(fc, param); 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()
154 ret = vfs_parse_fs_param_source(fc, param); in vfs_parse_fs_param()
158 return invalf(fc, "%s: Unknown parameter '%s'", in vfs_parse_fs_param()
159 fc->fs_type->name, param->key); in vfs_parse_fs_param()
165 * @fc: Filesystem context.
170 int vfs_parse_fs_string(struct fs_context *fc, const char *key, in vfs_parse_fs_string() argument
188 ret = vfs_parse_fs_param(fc, ¶m); in vfs_parse_fs_string()
196 * @fc: The superblock configuration to fill in.
206 int vfs_parse_monolithic_sep(struct fs_context *fc, void *data, in vfs_parse_monolithic_sep() argument
215 ret = security_sb_eat_lsm_opts(options, &fc->security); in vfs_parse_monolithic_sep()
230 ret = vfs_parse_fs_string(fc, key, value, v_len); in vfs_parse_monolithic_sep()
247 * @fc: The superblock configuration to fill in.
256 int generic_parse_monolithic(struct fs_context *fc, void *data) in generic_parse_monolithic() argument
258 return vfs_parse_monolithic_sep(fc, data, vfs_parse_comma_sep); in generic_parse_monolithic()
282 struct fs_context *fc; in alloc_fs_context() local
285 fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL_ACCOUNT); in alloc_fs_context()
286 if (!fc) 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()
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()
318 ret = init_fs_context(fc); in alloc_fs_context()
321 fc->need_free = true; in alloc_fs_context()
322 return fc; in alloc_fs_context()
325 put_fs_context(fc); in alloc_fs_context()
352 * the fc->security object is inherited from @reference (if needed).
357 struct fs_context *fc; in fs_context_for_submount() local
360 fc = alloc_fs_context(type, reference, 0, 0, FS_CONTEXT_FOR_SUBMOUNT); in fs_context_for_submount()
361 if (IS_ERR(fc)) in fs_context_for_submount()
362 return fc; in fs_context_for_submount()
364 ret = security_fs_context_submount(fc, reference->d_sb); in fs_context_for_submount()
366 put_fs_context(fc); in fs_context_for_submount()
370 return fc; in fs_context_for_submount()
374 void fc_drop_locked(struct fs_context *fc) in fc_drop_locked() argument
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()
382 static void legacy_fs_context_free(struct fs_context *fc);
390 struct fs_context *fc; in vfs_dup_fs_context() local
396 fc = kmemdup(src_fc, sizeof(struct fs_context), GFP_KERNEL); in vfs_dup_fs_context()
397 if (!fc) 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()
414 ret = fc->ops->dup(fc, src_fc); in vfs_dup_fs_context()
418 ret = security_fs_context_dup(fc, src_fc); in vfs_dup_fs_context()
421 return fc; in vfs_dup_fs_context()
424 put_fs_context(fc); in vfs_dup_fs_context()
488 static void put_fc_log(struct fs_context *fc) in put_fc_log() argument
490 struct fc_log *log = fc->log.log; in put_fc_log()
495 fc->log.log = NULL; in put_fc_log()
506 * @fc: The context to dispose of.
508 void put_fs_context(struct fs_context *fc) in put_fs_context() argument
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()
526 put_fc_log(fc); in put_fs_context()
527 put_filesystem(fc->fs_type); in put_fs_context()
528 kfree(fc->source); in put_fs_context()
529 kfree(fc); in put_fs_context()
536 static void legacy_fs_context_free(struct fs_context *fc) in legacy_fs_context_free() argument
538 struct legacy_fs_context *ctx = fc->fs_private; in legacy_fs_context_free()
550 static int legacy_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc) in legacy_fs_context_dup() argument
568 fc->fs_private = ctx; in legacy_fs_context_dup()
576 static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param) in legacy_parse_param() argument
578 struct legacy_fs_context *ctx = fc->fs_private; in legacy_parse_param()
583 ret = vfs_parse_fs_param_source(fc, param); in legacy_parse_param()
588 return invalf(fc, "VFS: Legacy: Can't mix monolithic and individual options"); in legacy_parse_param()
598 return invalf(fc, "VFS: Legacy: Parameter type for '%s' not supported", in legacy_parse_param()
603 return invalf(fc, "VFS: Legacy: Cumulative options too large"); in legacy_parse_param()
607 return invalf(fc, "VFS: Legacy: Option '%s' contained comma", in legacy_parse_param()
634 static int legacy_parse_monolithic(struct fs_context *fc, void *data) in legacy_parse_monolithic() argument
636 struct legacy_fs_context *ctx = fc->fs_private; 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()
656 static int legacy_get_tree(struct fs_context *fc) in legacy_get_tree() argument
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()
670 fc->root = root; in legacy_get_tree()
677 static int legacy_reconfigure(struct fs_context *fc) in legacy_reconfigure() argument
679 struct legacy_fs_context *ctx = fc->fs_private; in legacy_reconfigure()
680 struct super_block *sb = fc->root->d_sb; in legacy_reconfigure()
685 return sb->s_op->remount_fs(sb, &fc->sb_flags, in legacy_reconfigure()
702 static int legacy_init_fs_context(struct fs_context *fc) in legacy_init_fs_context() argument
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()
707 fc->ops = &legacy_fs_context_ops; in legacy_init_fs_context()
711 int parse_monolithic_mount_data(struct fs_context *fc, void *data) in parse_monolithic_mount_data() argument
715 monolithic_mount_data = fc->ops->parse_monolithic; in parse_monolithic_mount_data()
719 return monolithic_mount_data(fc, data); in parse_monolithic_mount_data()
735 void vfs_clean_context(struct fs_context *fc) in vfs_clean_context() argument
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()
752 int finish_clean_context(struct fs_context *fc) in finish_clean_context() argument
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()
762 error = legacy_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()