fscrypt.h (1bdd3e05a0a3b4a97ea88bc46fef8fb265c8b94c) fscrypt.h (6e1918cfb263acacd3fc9239127732b69de64695)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * fscrypt.h: declarations for per-file encryption
4 *
5 * Filesystems that implement per-file encryption must include this header
6 * file.
7 *
8 * Copyright (C) 2015, Google, Inc.

--- 58 unchanged lines hidden (view full) ---

67};
68
69static inline bool fscrypt_has_encryption_key(const struct inode *inode)
70{
71 /* pairs with cmpxchg_release() in fscrypt_get_encryption_info() */
72 return READ_ONCE(inode->i_crypt_info) != NULL;
73}
74
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * fscrypt.h: declarations for per-file encryption
4 *
5 * Filesystems that implement per-file encryption must include this header
6 * file.
7 *
8 * Copyright (C) 2015, Google, Inc.

--- 58 unchanged lines hidden (view full) ---

67};
68
69static inline bool fscrypt_has_encryption_key(const struct inode *inode)
70{
71 /* pairs with cmpxchg_release() in fscrypt_get_encryption_info() */
72 return READ_ONCE(inode->i_crypt_info) != NULL;
73}
74
75/**
76 * fscrypt_needs_contents_encryption() - check whether an inode needs
77 * contents encryption
78 *
79 * Return: %true iff the inode is an encrypted regular file and the kernel was
80 * built with fscrypt support.
81 *
82 * If you need to know whether the encrypt bit is set even when the kernel was
83 * built without fscrypt support, you must use IS_ENCRYPTED() directly instead.
84 */
85static inline bool fscrypt_needs_contents_encryption(const struct inode *inode)
86{
87 return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode);
88}
89
75static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
76{
77 return inode->i_sb->s_cop->dummy_context &&
78 inode->i_sb->s_cop->dummy_context(inode);
79}
80
81/*
82 * When d_splice_alias() moves a directory's encrypted alias to its decrypted

--- 65 unchanged lines hidden (view full) ---

148static inline void fscrypt_free_filename(struct fscrypt_name *fname)
149{
150 kfree(fname->crypto_buf.name);
151}
152
153extern int fscrypt_fname_alloc_buffer(const struct inode *, u32,
154 struct fscrypt_str *);
155extern void fscrypt_fname_free_buffer(struct fscrypt_str *);
90static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
91{
92 return inode->i_sb->s_cop->dummy_context &&
93 inode->i_sb->s_cop->dummy_context(inode);
94}
95
96/*
97 * When d_splice_alias() moves a directory's encrypted alias to its decrypted

--- 65 unchanged lines hidden (view full) ---

163static inline void fscrypt_free_filename(struct fscrypt_name *fname)
164{
165 kfree(fname->crypto_buf.name);
166}
167
168extern int fscrypt_fname_alloc_buffer(const struct inode *, u32,
169 struct fscrypt_str *);
170extern void fscrypt_fname_free_buffer(struct fscrypt_str *);
156extern int fscrypt_fname_disk_to_usr(struct inode *, u32, u32,
157 const struct fscrypt_str *, struct fscrypt_str *);
171extern int fscrypt_fname_disk_to_usr(const struct inode *inode,
172 u32 hash, u32 minor_hash,
173 const struct fscrypt_str *iname,
174 struct fscrypt_str *oname);
158
159#define FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE 32
160
161/* Extracts the second-to-last ciphertext block; see explanation below */
162#define FSCRYPT_FNAME_DIGEST(name, len) \
163 ((name) + round_down((len) - FS_CRYPTO_BLOCK_SIZE - 1, \
164 FS_CRYPTO_BLOCK_SIZE))
165

--- 75 unchanged lines hidden (view full) ---

241 struct dentry *dentry);
242extern int __fscrypt_prepare_rename(struct inode *old_dir,
243 struct dentry *old_dentry,
244 struct inode *new_dir,
245 struct dentry *new_dentry,
246 unsigned int flags);
247extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry,
248 struct fscrypt_name *fname);
175
176#define FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE 32
177
178/* Extracts the second-to-last ciphertext block; see explanation below */
179#define FSCRYPT_FNAME_DIGEST(name, len) \
180 ((name) + round_down((len) - FS_CRYPTO_BLOCK_SIZE - 1, \
181 FS_CRYPTO_BLOCK_SIZE))
182

--- 75 unchanged lines hidden (view full) ---

258 struct dentry *dentry);
259extern int __fscrypt_prepare_rename(struct inode *old_dir,
260 struct dentry *old_dentry,
261 struct inode *new_dir,
262 struct dentry *new_dentry,
263 unsigned int flags);
264extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry,
265 struct fscrypt_name *fname);
266extern int fscrypt_prepare_setflags(struct inode *inode,
267 unsigned int oldflags, unsigned int flags);
249extern int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len,
250 unsigned int max_len,
251 struct fscrypt_str *disk_link);
252extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
253 unsigned int len,
254 struct fscrypt_str *disk_link);
255extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
256 unsigned int max_size,

--- 5 unchanged lines hidden (view full) ---

262}
263#else /* !CONFIG_FS_ENCRYPTION */
264
265static inline bool fscrypt_has_encryption_key(const struct inode *inode)
266{
267 return false;
268}
269
268extern int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len,
269 unsigned int max_len,
270 struct fscrypt_str *disk_link);
271extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
272 unsigned int len,
273 struct fscrypt_str *disk_link);
274extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
275 unsigned int max_size,

--- 5 unchanged lines hidden (view full) ---

281}
282#else /* !CONFIG_FS_ENCRYPTION */
283
284static inline bool fscrypt_has_encryption_key(const struct inode *inode)
285{
286 return false;
287}
288
289static inline bool fscrypt_needs_contents_encryption(const struct inode *inode)
290{
291 return false;
292}
293
270static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
271{
272 return false;
273}
274
275static inline void fscrypt_handle_d_move(struct dentry *dentry)
276{
277}

--- 155 unchanged lines hidden (view full) ---

433 return -EOPNOTSUPP;
434}
435
436static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
437{
438 return;
439}
440
294static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
295{
296 return false;
297}
298
299static inline void fscrypt_handle_d_move(struct dentry *dentry)
300{
301}

--- 155 unchanged lines hidden (view full) ---

457 return -EOPNOTSUPP;
458}
459
460static inline void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
461{
462 return;
463}
464
441static inline int fscrypt_fname_disk_to_usr(struct inode *inode,
465static inline int fscrypt_fname_disk_to_usr(const struct inode *inode,
442 u32 hash, u32 minor_hash,
443 const struct fscrypt_str *iname,
444 struct fscrypt_str *oname)
445{
446 return -EOPNOTSUPP;
447}
448
449static inline bool fscrypt_match_name(const struct fscrypt_name *fname,

--- 42 unchanged lines hidden (view full) ---

492
493static inline int __fscrypt_prepare_lookup(struct inode *dir,
494 struct dentry *dentry,
495 struct fscrypt_name *fname)
496{
497 return -EOPNOTSUPP;
498}
499
466 u32 hash, u32 minor_hash,
467 const struct fscrypt_str *iname,
468 struct fscrypt_str *oname)
469{
470 return -EOPNOTSUPP;
471}
472
473static inline bool fscrypt_match_name(const struct fscrypt_name *fname,

--- 42 unchanged lines hidden (view full) ---

516
517static inline int __fscrypt_prepare_lookup(struct inode *dir,
518 struct dentry *dentry,
519 struct fscrypt_name *fname)
520{
521 return -EOPNOTSUPP;
522}
523
524static inline int fscrypt_prepare_setflags(struct inode *inode,
525 unsigned int oldflags,
526 unsigned int flags)
527{
528 return 0;
529}
530
500static inline int __fscrypt_prepare_symlink(struct inode *dir,
501 unsigned int len,
502 unsigned int max_len,
503 struct fscrypt_str *disk_link)
504{
505 return -EOPNOTSUPP;
506}
507

--- 244 unchanged lines hidden ---
531static inline int __fscrypt_prepare_symlink(struct inode *dir,
532 unsigned int len,
533 unsigned int max_len,
534 struct fscrypt_str *disk_link)
535{
536 return -EOPNOTSUPP;
537}
538

--- 244 unchanged lines hidden ---