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)
67 fc->sb_flags |= token;
68 fc->sb_flags_mask |= token;
74 fc->sb_flags &= ~token;
75 fc->sb_flags_mask |= token;
84 * @fc: The filesystem context to modify
94 int vfs_parse_fs_param_source(struct fs_context *fc, struct fs_parameter *param)
100 return invalf(fc, "Non-string source");
102 if (fc->source)
103 return invalf(fc, "Multiple sources");
105 fc->source = param->string;
113 * @fc: The filesystem context to modify
127 int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param)
132 return invalf(fc, "Unnamed parameter\n");
134 ret = vfs_parse_sb_flag(fc, param->key);
138 ret = security_fs_context_parse_param(fc, param);
145 if (fc->ops->parse_param) {
146 ret = fc->ops->parse_param(fc, param);
154 ret = vfs_parse_fs_param_source(fc, param);
158 return invalf(fc, "%s: Unknown parameter '%s'",
159 fc->fs_type->name, param->key);
165 * @fc: Filesystem context.
170 int vfs_parse_fs_string(struct fs_context *fc, const char *key,
188 ret = vfs_parse_fs_param(fc, &param);
196 * @fc: The superblock configuration to fill in.
206 int vfs_parse_monolithic_sep(struct fs_context *fc, void *data,
215 ret = security_sb_eat_lsm_opts(options, &fc->security);
230 ret = vfs_parse_fs_string(fc, key, value, v_len);
247 * @fc: The superblock configuration to fill in.
256 int generic_parse_monolithic(struct fs_context *fc, void *data)
258 return vfs_parse_monolithic_sep(fc, data, vfs_parse_comma_sep);
282 struct fs_context *fc;
285 fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL_ACCOUNT);
286 if (!fc)
289 fc->purpose = purpose;
290 fc->sb_flags = sb_flags;
291 fc->sb_flags_mask = sb_flags_mask;
292 fc->fs_type = get_filesystem(fs_type);
293 fc->cred = get_current_cred();
294 fc->net_ns = get_net(current->nsproxy->net_ns);
295 fc->log.prefix = fs_type->name;
297 mutex_init(&fc->uapi_mutex);
301 fc->user_ns = get_user_ns(fc->cred->user_ns);
304 fc->user_ns = get_user_ns(reference->d_sb->s_user_ns);
308 fc->user_ns = get_user_ns(reference->d_sb->s_user_ns);
309 fc->root = dget(reference);
314 init_fs_context = fc->fs_type->init_fs_context;
318 ret = init_fs_context(fc);
321 fc->need_free = true;
322 return fc;
325 put_fs_context(fc);
352 * the fc->security object is inherited from @reference (if needed).
357 struct fs_context *fc;
360 fc = alloc_fs_context(type, reference, 0, 0, FS_CONTEXT_FOR_SUBMOUNT);
361 if (IS_ERR(fc))
362 return fc;
364 ret = security_fs_context_submount(fc, reference->d_sb);
366 put_fs_context(fc);
370 return fc;
374 void fc_drop_locked(struct fs_context *fc)
376 struct super_block *sb = fc->root->d_sb;
377 dput(fc->root);
378 fc->root = NULL;
382 static void legacy_fs_context_free(struct fs_context *fc);
390 struct fs_context *fc;
396 fc = kmemdup(src_fc, sizeof(struct fs_context), GFP_KERNEL);
397 if (!fc)
400 mutex_init(&fc->uapi_mutex);
402 fc->fs_private = NULL;
403 fc->s_fs_info = NULL;
404 fc->source = NULL;
405 fc->security = NULL;
406 get_filesystem(fc->fs_type);
407 get_net(fc->net_ns);
408 get_user_ns(fc->user_ns);
409 get_cred(fc->cred);
410 if (fc->log.log)
411 refcount_inc(&fc->log.log->usage);
414 ret = fc->ops->dup(fc, src_fc);
418 ret = security_fs_context_dup(fc, src_fc);
421 return fc;
424 put_fs_context(fc);
492 static void put_fc_log(struct fs_context *fc)
494 struct fc_log *log = fc->log.log;
499 fc->log.log = NULL;
510 * @fc: The context to dispose of.
512 void put_fs_context(struct fs_context *fc)
516 if (fc->root) {
517 sb = fc->root->d_sb;
518 dput(fc->root);
519 fc->root = NULL;
523 if (fc->need_free && fc->ops && fc->ops->free)
524 fc->ops->free(fc);
526 security_free_mnt_opts(&fc->security);
527 put_net(fc->net_ns);
528 put_user_ns(fc->user_ns);
529 put_cred(fc->cred);
530 put_fc_log(fc);
531 put_filesystem(fc->fs_type);
532 kfree(fc->source);
533 kfree(fc);
540 static void legacy_fs_context_free(struct fs_context *fc)
542 struct legacy_fs_context *ctx = fc->fs_private;
554 static int legacy_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc)
572 fc->fs_private = ctx;
580 static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param)
582 struct legacy_fs_context *ctx = fc->fs_private;
587 ret = vfs_parse_fs_param_source(fc, param);
592 return invalf(fc, "VFS: Legacy: Can't mix monolithic and individual options");
602 return invalf(fc, "VFS: Legacy: Parameter type for '%s' not supported",
607 return invalf(fc, "VFS: Legacy: Cumulative options too large");
611 return invalf(fc, "VFS: Legacy: Option '%s' contained comma",
638 static int legacy_parse_monolithic(struct fs_context *fc, void *data)
640 struct legacy_fs_context *ctx = fc->fs_private;
652 if (fc->fs_type->fs_flags & FS_BINARY_MOUNTDATA)
654 return security_sb_eat_lsm_opts(ctx->legacy_data, &fc->security);
660 static int legacy_get_tree(struct fs_context *fc)
662 struct legacy_fs_context *ctx = fc->fs_private;
666 root = fc->fs_type->mount(fc->fs_type, fc->sb_flags,
667 fc->source, ctx->legacy_data);
674 fc->root = root;
681 static int legacy_reconfigure(struct fs_context *fc)
683 struct legacy_fs_context *ctx = fc->fs_private;
684 struct super_block *sb = fc->root->d_sb;
689 return sb->s_op->remount_fs(sb, &fc->sb_flags,
706 static int legacy_init_fs_context(struct fs_context *fc)
708 fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL_ACCOUNT);
709 if (!fc->fs_private)
711 fc->ops = &legacy_fs_context_ops;
715 int parse_monolithic_mount_data(struct fs_context *fc, void *data)
719 monolithic_mount_data = fc->ops->parse_monolithic;
723 return monolithic_mount_data(fc, data);
739 void vfs_clean_context(struct fs_context *fc)
741 if (fc->need_free && fc->ops && fc->ops->free)
742 fc->ops->free(fc);
743 fc->need_free = false;
744 fc->fs_private = NULL;
745 fc->s_fs_info = NULL;
746 fc->sb_flags = 0;
747 security_free_mnt_opts(&fc->security);
748 kfree(fc->source);
749 fc->source = NULL;
750 fc->exclusive = false;
752 fc->purpose = FS_CONTEXT_FOR_RECONFIGURE;
753 fc->phase = FS_CONTEXT_AWAITING_RECONF;
756 int finish_clean_context(struct fs_context *fc)
760 if (fc->phase != FS_CONTEXT_AWAITING_RECONF)
763 if (fc->fs_type->init_fs_context)
764 error = fc->fs_type->init_fs_context(fc);
766 error = legacy_init_fs_context(fc);
768 fc->phase = FS_CONTEXT_FAILED;
771 fc->need_free = true;
772 fc->phase = FS_CONTEXT_RECONF_PARAMS;