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);
488 static void put_fc_log(struct fs_context *fc)
490 struct fc_log *log = fc->log.log;
495 fc->log.log = NULL;
506 * @fc: The context to dispose of.
508 void put_fs_context(struct fs_context *fc)
512 if (fc->root) {
513 sb = fc->root->d_sb;
514 dput(fc->root);
515 fc->root = NULL;
519 if (fc->need_free && fc->ops && fc->ops->free)
520 fc->ops->free(fc);
522 security_free_mnt_opts(&fc->security);
523 put_net(fc->net_ns);
524 put_user_ns(fc->user_ns);
525 put_cred(fc->cred);
526 put_fc_log(fc);
527 put_filesystem(fc->fs_type);
528 kfree(fc->source);
529 kfree(fc);
536 static void legacy_fs_context_free(struct fs_context *fc)
538 struct legacy_fs_context *ctx = fc->fs_private;
550 static int legacy_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc)
568 fc->fs_private = ctx;
576 static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param)
578 struct legacy_fs_context *ctx = fc->fs_private;
583 ret = vfs_parse_fs_param_source(fc, param);
588 return invalf(fc, "VFS: Legacy: Can't mix monolithic and individual options");
598 return invalf(fc, "VFS: Legacy: Parameter type for '%s' not supported",
603 return invalf(fc, "VFS: Legacy: Cumulative options too large");
607 return invalf(fc, "VFS: Legacy: Option '%s' contained comma",
634 static int legacy_parse_monolithic(struct fs_context *fc, void *data)
636 struct legacy_fs_context *ctx = fc->fs_private;
648 if (fc->fs_type->fs_flags & FS_BINARY_MOUNTDATA)
650 return security_sb_eat_lsm_opts(ctx->legacy_data, &fc->security);
656 static int legacy_get_tree(struct fs_context *fc)
658 struct legacy_fs_context *ctx = fc->fs_private;
662 root = fc->fs_type->mount(fc->fs_type, fc->sb_flags,
663 fc->source, ctx->legacy_data);
670 fc->root = root;
677 static int legacy_reconfigure(struct fs_context *fc)
679 struct legacy_fs_context *ctx = fc->fs_private;
680 struct super_block *sb = fc->root->d_sb;
685 return sb->s_op->remount_fs(sb, &fc->sb_flags,
702 static int legacy_init_fs_context(struct fs_context *fc)
704 fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL_ACCOUNT);
705 if (!fc->fs_private)
707 fc->ops = &legacy_fs_context_ops;
711 int parse_monolithic_mount_data(struct fs_context *fc, void *data)
715 monolithic_mount_data = fc->ops->parse_monolithic;
719 return monolithic_mount_data(fc, data);
735 void vfs_clean_context(struct fs_context *fc)
737 if (fc->need_free && fc->ops && fc->ops->free)
738 fc->ops->free(fc);
739 fc->need_free = false;
740 fc->fs_private = NULL;
741 fc->s_fs_info = NULL;
742 fc->sb_flags = 0;
743 security_free_mnt_opts(&fc->security);
744 kfree(fc->source);
745 fc->source = NULL;
746 fc->exclusive = false;
748 fc->purpose = FS_CONTEXT_FOR_RECONFIGURE;
749 fc->phase = FS_CONTEXT_AWAITING_RECONF;
752 int finish_clean_context(struct fs_context *fc)
756 if (fc->phase != FS_CONTEXT_AWAITING_RECONF)
759 if (fc->fs_type->init_fs_context)
760 error = fc->fs_type->init_fs_context(fc);
762 error = legacy_init_fs_context(fc);
764 fc->phase = FS_CONTEXT_FAILED;
767 fc->need_free = true;
768 fc->phase = FS_CONTEXT_RECONF_PARAMS;