blob: 98772f882a3e76cad517af5bc173469e2f43b14f [file] [log] [blame]
David Howells9bc61ab2018-11-04 03:19:03 -05001/* Filesystem superblock creation and reconfiguration context.
2 *
3 * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _LINUX_FS_CONTEXT_H
13#define _LINUX_FS_CONTEXT_H
14
15#include <linux/kernel.h>
16#include <linux/errno.h>
17#include <linux/security.h>
18
19struct cred;
20struct dentry;
21struct file_operations;
22struct file_system_type;
23struct net;
24struct user_namespace;
25
26enum fs_context_purpose {
27 FS_CONTEXT_FOR_MOUNT, /* New superblock for explicit mount */
David Howells8d0347f2018-11-04 09:28:36 -050028 FS_CONTEXT_FOR_RECONFIGURE, /* Superblock reconfiguration (remount) */
David Howells9bc61ab2018-11-04 03:19:03 -050029};
30
31/*
32 * Filesystem context for holding the parameters used in the creation or
33 * reconfiguration of a superblock.
34 *
35 * Superblock creation fills in ->root whereas reconfiguration begins with this
36 * already set.
37 *
38 * See Documentation/filesystems/mounting.txt
39 */
40struct fs_context {
41 struct file_system_type *fs_type;
42 void *fs_private; /* The filesystem's context */
43 struct dentry *root; /* The root and superblock */
44 struct user_namespace *user_ns; /* The user namespace for this mount */
45 struct net *net_ns; /* The network namespace for this mount */
46 const struct cred *cred; /* The mounter's credentials */
47 const char *source; /* The source name (eg. dev path) */
48 const char *subtype; /* The subtype to set on the superblock */
49 void *security; /* Linux S&M options */
50 unsigned int sb_flags; /* Proposed superblock flags (SB_*) */
51 unsigned int sb_flags_mask; /* Superblock flags that were changed */
52 enum fs_context_purpose purpose:8;
53 bool need_free:1; /* Need to call ops->free() */
54};
55
56/*
57 * fs_context manipulation functions.
58 */
59extern struct fs_context *fs_context_for_mount(struct file_system_type *fs_type,
60 unsigned int sb_flags);
David Howells8d0347f2018-11-04 09:28:36 -050061extern struct fs_context *fs_context_for_reconfigure(struct dentry *dentry,
62 unsigned int sb_flags,
63 unsigned int sb_flags_mask);
David Howells9bc61ab2018-11-04 03:19:03 -050064
65extern int vfs_get_tree(struct fs_context *fc);
66extern void put_fs_context(struct fs_context *fc);
67
68#endif /* _LINUX_FS_CONTEXT_H */