Lines Matching refs: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()
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()
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()
169 int vfs_parse_fs_qstr(struct fs_context *fc, const char *key, in vfs_parse_fs_qstr() argument
187 ret = vfs_parse_fs_param(fc, ¶m); in vfs_parse_fs_qstr()
205 int vfs_parse_monolithic_sep(struct fs_context *fc, void *data, in vfs_parse_monolithic_sep() argument
214 ret = security_sb_eat_lsm_opts(options, &fc->security); in vfs_parse_monolithic_sep()
227 ret = vfs_parse_fs_string(fc, key, value); in vfs_parse_monolithic_sep()
253 int generic_parse_monolithic(struct fs_context *fc, void *data) in generic_parse_monolithic() argument
255 return vfs_parse_monolithic_sep(fc, data, vfs_parse_comma_sep); in generic_parse_monolithic()
279 struct fs_context *fc; in alloc_fs_context() local
282 fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL_ACCOUNT); in alloc_fs_context()
283 if (!fc) in alloc_fs_context()
286 fc->purpose = purpose; in alloc_fs_context()
287 fc->sb_flags = sb_flags; in alloc_fs_context()
288 fc->sb_flags_mask = sb_flags_mask; in alloc_fs_context()
289 fc->fs_type = get_filesystem(fs_type); in alloc_fs_context()
290 fc->cred = get_current_cred(); in alloc_fs_context()
291 fc->net_ns = get_net(current->nsproxy->net_ns); in alloc_fs_context()
292 fc->log.prefix = fs_type->name; in alloc_fs_context()
294 mutex_init(&fc->uapi_mutex); in alloc_fs_context()
298 fc->user_ns = get_user_ns(fc->cred->user_ns); in alloc_fs_context()
301 fc->user_ns = get_user_ns(reference->d_sb->s_user_ns); in alloc_fs_context()
305 fc->user_ns = get_user_ns(reference->d_sb->s_user_ns); in alloc_fs_context()
306 fc->root = dget(reference); in alloc_fs_context()
311 init_fs_context = fc->fs_type->init_fs_context; in alloc_fs_context()
315 ret = init_fs_context(fc); in alloc_fs_context()
318 fc->need_free = true; in alloc_fs_context()
319 return fc; in alloc_fs_context()
322 put_fs_context(fc); in alloc_fs_context()
354 struct fs_context *fc; in fs_context_for_submount() local
357 fc = alloc_fs_context(type, reference, 0, 0, FS_CONTEXT_FOR_SUBMOUNT); in fs_context_for_submount()
358 if (IS_ERR(fc)) in fs_context_for_submount()
359 return fc; in fs_context_for_submount()
361 ret = security_fs_context_submount(fc, reference->d_sb); in fs_context_for_submount()
363 put_fs_context(fc); in fs_context_for_submount()
367 return fc; in fs_context_for_submount()
371 void fc_drop_locked(struct fs_context *fc) in fc_drop_locked() argument
373 struct super_block *sb = fc->root->d_sb; in fc_drop_locked()
374 dput(fc->root); in fc_drop_locked()
375 fc->root = NULL; in fc_drop_locked()
379 static void legacy_fs_context_free(struct fs_context *fc);
387 struct fs_context *fc; in vfs_dup_fs_context() local
393 fc = kmemdup(src_fc, sizeof(struct fs_context), GFP_KERNEL); in vfs_dup_fs_context()
394 if (!fc) in vfs_dup_fs_context()
397 mutex_init(&fc->uapi_mutex); in vfs_dup_fs_context()
399 fc->fs_private = NULL; in vfs_dup_fs_context()
400 fc->s_fs_info = NULL; in vfs_dup_fs_context()
401 fc->source = NULL; in vfs_dup_fs_context()
402 fc->security = NULL; in vfs_dup_fs_context()
403 get_filesystem(fc->fs_type); in vfs_dup_fs_context()
404 get_net(fc->net_ns); in vfs_dup_fs_context()
405 get_user_ns(fc->user_ns); in vfs_dup_fs_context()
406 get_cred(fc->cred); in vfs_dup_fs_context()
407 if (fc->log.log) in vfs_dup_fs_context()
408 refcount_inc(&fc->log.log->usage); in vfs_dup_fs_context()
411 ret = fc->ops->dup(fc, src_fc); in vfs_dup_fs_context()
415 ret = security_fs_context_dup(fc, src_fc); in vfs_dup_fs_context()
418 return fc; in vfs_dup_fs_context()
421 put_fs_context(fc); in vfs_dup_fs_context()
489 static void put_fc_log(struct fs_context *fc) in put_fc_log() argument
491 struct fc_log *log = fc->log.log; in put_fc_log()
496 fc->log.log = NULL; in put_fc_log()
509 void put_fs_context(struct fs_context *fc) in put_fs_context() argument
513 if (fc->root) { in put_fs_context()
514 sb = fc->root->d_sb; in put_fs_context()
515 dput(fc->root); in put_fs_context()
516 fc->root = NULL; in put_fs_context()
520 if (fc->need_free && fc->ops && fc->ops->free) in put_fs_context()
521 fc->ops->free(fc); in put_fs_context()
523 security_free_mnt_opts(&fc->security); in put_fs_context()
524 put_net(fc->net_ns); in put_fs_context()
525 put_user_ns(fc->user_ns); in put_fs_context()
526 put_cred(fc->cred); in put_fs_context()
527 put_fc_log(fc); in put_fs_context()
528 put_filesystem(fc->fs_type); in put_fs_context()
529 kfree(fc->source); in put_fs_context()
530 kfree(fc); in put_fs_context()
537 static void legacy_fs_context_free(struct fs_context *fc) in legacy_fs_context_free() argument
539 struct legacy_fs_context *ctx = fc->fs_private; in legacy_fs_context_free()
551 static int legacy_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc) in legacy_fs_context_dup() argument
569 fc->fs_private = ctx; in legacy_fs_context_dup()
577 static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param) in legacy_parse_param() argument
579 struct legacy_fs_context *ctx = fc->fs_private; in legacy_parse_param()
584 ret = vfs_parse_fs_param_source(fc, param); in legacy_parse_param()
589 return invalf(fc, "VFS: Legacy: Can't mix monolithic and individual options"); in legacy_parse_param()
599 return invalf(fc, "VFS: Legacy: Parameter type for '%s' not supported", in legacy_parse_param()
604 return invalf(fc, "VFS: Legacy: Cumulative options too large"); in legacy_parse_param()
608 return invalf(fc, "VFS: Legacy: Option '%s' contained comma", in legacy_parse_param()
635 static int legacy_parse_monolithic(struct fs_context *fc, void *data) in legacy_parse_monolithic() argument
637 struct legacy_fs_context *ctx = fc->fs_private; in legacy_parse_monolithic()
649 if (fc->fs_type->fs_flags & FS_BINARY_MOUNTDATA) in legacy_parse_monolithic()
651 return security_sb_eat_lsm_opts(ctx->legacy_data, &fc->security); in legacy_parse_monolithic()
657 static int legacy_get_tree(struct fs_context *fc) in legacy_get_tree() argument
659 struct legacy_fs_context *ctx = fc->fs_private; in legacy_get_tree()
663 root = fc->fs_type->mount(fc->fs_type, fc->sb_flags, in legacy_get_tree()
664 fc->source, ctx->legacy_data); in legacy_get_tree()
671 fc->root = root; in legacy_get_tree()
678 static int legacy_reconfigure(struct fs_context *fc) in legacy_reconfigure() argument
680 struct legacy_fs_context *ctx = fc->fs_private; in legacy_reconfigure()
681 struct super_block *sb = fc->root->d_sb; in legacy_reconfigure()
686 return sb->s_op->remount_fs(sb, &fc->sb_flags, in legacy_reconfigure()
703 static int legacy_init_fs_context(struct fs_context *fc) in legacy_init_fs_context() argument
705 fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL_ACCOUNT); in legacy_init_fs_context()
706 if (!fc->fs_private) in legacy_init_fs_context()
708 fc->ops = &legacy_fs_context_ops; in legacy_init_fs_context()
712 int parse_monolithic_mount_data(struct fs_context *fc, void *data) in parse_monolithic_mount_data() argument
716 monolithic_mount_data = fc->ops->parse_monolithic; in parse_monolithic_mount_data()
720 return monolithic_mount_data(fc, data); in parse_monolithic_mount_data()
736 void vfs_clean_context(struct fs_context *fc) in vfs_clean_context() argument
738 if (fc->need_free && fc->ops && fc->ops->free) in vfs_clean_context()
739 fc->ops->free(fc); in vfs_clean_context()
740 fc->need_free = false; in vfs_clean_context()
741 fc->fs_private = NULL; in vfs_clean_context()
742 fc->s_fs_info = NULL; in vfs_clean_context()
743 fc->sb_flags = 0; in vfs_clean_context()
744 security_free_mnt_opts(&fc->security); in vfs_clean_context()
745 kfree(fc->source); in vfs_clean_context()
746 fc->source = NULL; in vfs_clean_context()
747 fc->exclusive = false; in vfs_clean_context()
749 fc->purpose = FS_CONTEXT_FOR_RECONFIGURE; in vfs_clean_context()
750 fc->phase = FS_CONTEXT_AWAITING_RECONF; in vfs_clean_context()
753 int finish_clean_context(struct fs_context *fc) in finish_clean_context() argument
757 if (fc->phase != FS_CONTEXT_AWAITING_RECONF) in finish_clean_context()
760 if (fc->fs_type->init_fs_context) in finish_clean_context()
761 error = fc->fs_type->init_fs_context(fc); in finish_clean_context()
763 error = legacy_init_fs_context(fc); in finish_clean_context()
765 fc->phase = FS_CONTEXT_FAILED; in finish_clean_context()
768 fc->need_free = true; in finish_clean_context()
769 fc->phase = FS_CONTEXT_RECONF_PARAMS; in finish_clean_context()