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()
166 int vfs_parse_fs_string(struct fs_context *fc, const char *key, in vfs_parse_fs_string() argument
184 ret = vfs_parse_fs_param(fc, ¶m); in vfs_parse_fs_string()
201 int generic_parse_monolithic(struct fs_context *fc, void *data) in generic_parse_monolithic() argument
209 ret = security_sb_eat_lsm_opts(options, &fc->security); in generic_parse_monolithic()
224 ret = vfs_parse_fs_string(fc, key, value, v_len); in generic_parse_monolithic()
254 struct fs_context *fc; in alloc_fs_context() local
257 fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL_ACCOUNT); in alloc_fs_context()
258 if (!fc) 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()
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()
290 ret = init_fs_context(fc); in alloc_fs_context()
293 fc->need_free = true; in alloc_fs_context()
294 return fc; in alloc_fs_context()
297 put_fs_context(fc); in alloc_fs_context()
325 void fc_drop_locked(struct fs_context *fc) in fc_drop_locked() argument
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()
333 static void legacy_fs_context_free(struct fs_context *fc);
341 struct fs_context *fc; in vfs_dup_fs_context() local
347 fc = kmemdup(src_fc, sizeof(struct fs_context), GFP_KERNEL); in vfs_dup_fs_context()
348 if (!fc) 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()
365 ret = fc->ops->dup(fc, src_fc); in vfs_dup_fs_context()
369 ret = security_fs_context_dup(fc, src_fc); in vfs_dup_fs_context()
372 return fc; in vfs_dup_fs_context()
375 put_fs_context(fc); in vfs_dup_fs_context()
437 static void put_fc_log(struct fs_context *fc) in put_fc_log() argument
439 struct fc_log *log = fc->log.log; in put_fc_log()
444 fc->log.log = NULL; in put_fc_log()
457 void put_fs_context(struct fs_context *fc) in put_fs_context() argument
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()
475 put_fc_log(fc); in put_fs_context()
476 put_filesystem(fc->fs_type); in put_fs_context()
477 kfree(fc->source); in put_fs_context()
478 kfree(fc); in put_fs_context()
485 static void legacy_fs_context_free(struct fs_context *fc) in legacy_fs_context_free() argument
487 struct legacy_fs_context *ctx = fc->fs_private; in legacy_fs_context_free()
499 static int legacy_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc) in legacy_fs_context_dup() argument
517 fc->fs_private = ctx; in legacy_fs_context_dup()
525 static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param) in legacy_parse_param() argument
527 struct legacy_fs_context *ctx = fc->fs_private; in legacy_parse_param()
532 ret = vfs_parse_fs_param_source(fc, param); in legacy_parse_param()
537 return invalf(fc, "VFS: Legacy: Can't mix monolithic and individual options"); in legacy_parse_param()
547 return invalf(fc, "VFS: Legacy: Parameter type for '%s' not supported", in legacy_parse_param()
552 return invalf(fc, "VFS: Legacy: Cumulative options too large"); in legacy_parse_param()
556 return invalf(fc, "VFS: Legacy: Option '%s' contained comma", in legacy_parse_param()
582 static int legacy_parse_monolithic(struct fs_context *fc, void *data) in legacy_parse_monolithic() argument
584 struct legacy_fs_context *ctx = fc->fs_private; 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()
604 static int legacy_get_tree(struct fs_context *fc) in legacy_get_tree() argument
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()
618 fc->root = root; in legacy_get_tree()
625 static int legacy_reconfigure(struct fs_context *fc) in legacy_reconfigure() argument
627 struct legacy_fs_context *ctx = fc->fs_private; in legacy_reconfigure()
628 struct super_block *sb = fc->root->d_sb; in legacy_reconfigure()
633 return sb->s_op->remount_fs(sb, &fc->sb_flags, in legacy_reconfigure()
650 static int legacy_init_fs_context(struct fs_context *fc) in legacy_init_fs_context() argument
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()
655 fc->ops = &legacy_fs_context_ops; in legacy_init_fs_context()
659 int parse_monolithic_mount_data(struct fs_context *fc, void *data) in parse_monolithic_mount_data() argument
663 monolithic_mount_data = fc->ops->parse_monolithic; in parse_monolithic_mount_data()
667 return monolithic_mount_data(fc, data); in parse_monolithic_mount_data()
683 void vfs_clean_context(struct fs_context *fc) in vfs_clean_context() argument
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()
699 int finish_clean_context(struct fs_context *fc) in finish_clean_context() argument
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()
709 error = legacy_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()