@@ -47,27 +47,128 @@ struct fscrypt_name {
47
47
#define FSCRYPT_SET_CONTEXT_MAX_SIZE 40
48
48
49
49
#ifdef CONFIG_FS_ENCRYPTION
50
+
50
51
/*
51
- * fscrypt superblock flags
52
+ * If set, the fscrypt bounce page pool won't be allocated (unless another
53
+ * filesystem needs it). Set this if the filesystem always uses its own bounce
54
+ * pages for writes and therefore won't need the fscrypt bounce page pool.
52
55
*/
53
56
#define FS_CFLG_OWN_PAGES (1U << 1)
54
57
55
- /*
56
- * crypto operations for filesystems
57
- */
58
+ /* Crypto operations for filesystems */
58
59
struct fscrypt_operations {
60
+
61
+ /* Set of optional flags; see above for allowed flags */
59
62
unsigned int flags ;
63
+
64
+ /*
65
+ * If set, this is a filesystem-specific key description prefix that
66
+ * will be accepted for "logon" keys for v1 fscrypt policies, in
67
+ * addition to the generic prefix "fscrypt:". This functionality is
68
+ * deprecated, so new filesystems shouldn't set this field.
69
+ */
60
70
const char * key_prefix ;
71
+
72
+ /*
73
+ * Get the fscrypt context of the given inode.
74
+ *
75
+ * @inode: the inode whose context to get
76
+ * @ctx: the buffer into which to get the context
77
+ * @len: length of the @ctx buffer in bytes
78
+ *
79
+ * Return: On success, returns the length of the context in bytes; this
80
+ * may be less than @len. On failure, returns -ENODATA if the
81
+ * inode doesn't have a context, -ERANGE if the context is
82
+ * longer than @len, or another -errno code.
83
+ */
61
84
int (* get_context )(struct inode * inode , void * ctx , size_t len );
85
+
86
+ /*
87
+ * Set an fscrypt context on the given inode.
88
+ *
89
+ * @inode: the inode whose context to set. The inode won't already have
90
+ * an fscrypt context.
91
+ * @ctx: the context to set
92
+ * @len: length of @ctx in bytes (at most FSCRYPT_SET_CONTEXT_MAX_SIZE)
93
+ * @fs_data: If called from fscrypt_set_context(), this will be the
94
+ * value the filesystem passed to fscrypt_set_context().
95
+ * Otherwise (i.e. when called from
96
+ * FS_IOC_SET_ENCRYPTION_POLICY) this will be NULL.
97
+ *
98
+ * i_rwsem will be held for write.
99
+ *
100
+ * Return: 0 on success, -errno on failure.
101
+ */
62
102
int (* set_context )(struct inode * inode , const void * ctx , size_t len ,
63
103
void * fs_data );
104
+
105
+ /*
106
+ * Get the dummy fscrypt policy in use on the filesystem (if any).
107
+ *
108
+ * Filesystems only need to implement this function if they support the
109
+ * test_dummy_encryption mount option.
110
+ *
111
+ * Return: A pointer to the dummy fscrypt policy, if the filesystem is
112
+ * mounted with test_dummy_encryption; otherwise NULL.
113
+ */
64
114
const union fscrypt_policy * (* get_dummy_policy )(struct super_block * sb );
115
+
116
+ /*
117
+ * Check whether a directory is empty. i_rwsem will be held for write.
118
+ */
65
119
bool (* empty_dir )(struct inode * inode );
120
+
121
+ /* The filesystem's maximum ciphertext filename length, in bytes */
66
122
unsigned int max_namelen ;
123
+
124
+ /*
125
+ * Check whether the filesystem's inode numbers and UUID are stable,
126
+ * meaning that they will never be changed even by offline operations
127
+ * such as filesystem shrinking and therefore can be used in the
128
+ * encryption without the possibility of files becoming unreadable.
129
+ *
130
+ * Filesystems only need to implement this function if they want to
131
+ * support the FSCRYPT_POLICY_FLAG_IV_INO_LBLK_{32,64} flags. These
132
+ * flags are designed to work around the limitations of UFS and eMMC
133
+ * inline crypto hardware, and they shouldn't be used in scenarios where
134
+ * such hardware isn't being used.
135
+ *
136
+ * Leaving this NULL is equivalent to always returning false.
137
+ */
67
138
bool (* has_stable_inodes )(struct super_block * sb );
139
+
140
+ /*
141
+ * Get the number of bits that the filesystem uses to represent inode
142
+ * numbers and file logical block numbers.
143
+ *
144
+ * By default, both of these are assumed to be 64-bit. This function
145
+ * can be implemented to declare that either or both of these numbers is
146
+ * shorter, which may allow the use of the
147
+ * FSCRYPT_POLICY_FLAG_IV_INO_LBLK_{32,64} flags and/or the use of
148
+ * inline crypto hardware whose maximum DUN length is less than 64 bits
149
+ * (e.g., eMMC v5.2 spec compliant hardware). This function only needs
150
+ * to be implemented if support for one of these features is needed.
151
+ */
68
152
void (* get_ino_and_lblk_bits )(struct super_block * sb ,
69
153
int * ino_bits_ret , int * lblk_bits_ret );
154
+
155
+ /*
156
+ * Return the number of block devices to which the filesystem may write
157
+ * encrypted file contents.
158
+ *
159
+ * If the filesystem can use multiple block devices (other than block
160
+ * devices that aren't used for encrypted file contents, such as
161
+ * external journal devices), and wants to support inline encryption,
162
+ * then it must implement this function. Otherwise it's not needed.
163
+ */
70
164
int (* get_num_devices )(struct super_block * sb );
165
+
166
+ /*
167
+ * If ->get_num_devices() returns a value greater than 1, then this
168
+ * function is called to get the array of request_queues that the
169
+ * filesystem is using -- one per block device. (There may be duplicate
170
+ * entries in this array, as block devices can share a request_queue.)
171
+ */
71
172
void (* get_devices )(struct super_block * sb ,
72
173
struct request_queue * * devs );
73
174
};
0 commit comments