blob: 2ec92da182fb24446e1c43c1d72eae0e350dde9a [file] [log] [blame]
Amir Samuelov9d24c492014-05-26 14:03:44 +03001/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef PFT_H_
14#define PFT_H_
15
16#include <linux/types.h>
17#include <linux/fs.h>
Amir Samuelovacc2a3b2014-06-22 16:43:52 +030018#include <linux/bio.h>
Amir Samuelov9d24c492014-05-26 14:03:44 +030019
20#ifdef CONFIG_PFT
21
22/* dm-req-crypt API */
Amir Samuelovacc2a3b2014-06-22 16:43:52 +030023int pft_get_key_index(struct bio *bio, u32 *key_index,
Amir Samuelov9d24c492014-05-26 14:03:44 +030024 bool *is_encrypted, bool *is_inplace);
25
26/* block layer API */
27bool pft_allow_merge_bio(struct bio *bio1, struct bio *bio2);
28
29/* --- security hooks , called from selinux --- */
30int pft_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
31
32int pft_inode_post_create(struct inode *dir, struct dentry *dentry,
33 umode_t mode);
34
35int pft_file_open(struct file *filp, const struct cred *cred);
36
37int pft_file_permission(struct file *file, int mask);
38
39int pft_file_close(struct file *filp);
40
41int pft_inode_unlink(struct inode *dir, struct dentry *dentry);
42
43int pft_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
44 dev_t dev);
45
46int pft_inode_rename(struct inode *inode, struct dentry *dentry,
47 struct inode *new_inode, struct dentry *new_dentry);
48
49int pft_inode_set_xattr(struct dentry *dentry, const char *name);
50
51
52#else
53static inline int pft_get_key_index(struct inode *inode, u32 *key_index,
54 bool *is_encrypted, bool *is_inplace)
55{ return -ENODEV; }
56
57static inline bool pft_allow_merge_bio(struct bio *bio1, struct bio *bio2)
58{ return true; }
59
60static inline int pft_file_permission(struct file *file, int mask)
61{ return 0; }
62
63static inline int pft_inode_create(
64 struct inode *dir, struct dentry *dentry, umode_t mode)
65{ return 0; }
66
67static inline int pft_inode_post_create(
68 struct inode *dir, struct dentry *dentry, umode_t mode)
69{ return 0; }
70
71static inline int pft_file_open(struct file *filp, const struct cred *cred)
72{ return 0; }
73
74static inline int pft_file_close(struct file *filp)
75{ return 0; }
76
77static inline int pft_inode_unlink(struct inode *dir, struct dentry *dentry)
78{ return 0; }
79
80static inline int pft_inode_mknod(struct inode *dir, struct dentry *dentry,
81 umode_t mode, dev_t dev)
82{ return 0; }
83
84static inline int pft_inode_rename(struct inode *inode, struct dentry *dentry,
85 struct inode *new_inode, struct dentry *new_dentry)
86{ return 0; }
87
88static inline int pft_inode_set_xattr(struct dentry *dentry, const char *name)
89{ return 0; }
90
91#endif /* CONFIG_PFT */
92
93#endif /* PFT_H */