Amir Samuelov | 9d24c49 | 2014-05-26 14:03:44 +0300 | [diff] [blame] | 1 | /* 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 Samuelov | acc2a3b | 2014-06-22 16:43:52 +0300 | [diff] [blame] | 18 | #include <linux/bio.h> |
Amir Samuelov | 9d24c49 | 2014-05-26 14:03:44 +0300 | [diff] [blame] | 19 | |
| 20 | #ifdef CONFIG_PFT |
| 21 | |
| 22 | /* dm-req-crypt API */ |
Amir Samuelov | acc2a3b | 2014-06-22 16:43:52 +0300 | [diff] [blame] | 23 | int pft_get_key_index(struct bio *bio, u32 *key_index, |
Amir Samuelov | 9d24c49 | 2014-05-26 14:03:44 +0300 | [diff] [blame] | 24 | bool *is_encrypted, bool *is_inplace); |
| 25 | |
| 26 | /* block layer API */ |
| 27 | bool pft_allow_merge_bio(struct bio *bio1, struct bio *bio2); |
| 28 | |
| 29 | /* --- security hooks , called from selinux --- */ |
| 30 | int pft_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode); |
| 31 | |
| 32 | int pft_inode_post_create(struct inode *dir, struct dentry *dentry, |
| 33 | umode_t mode); |
| 34 | |
| 35 | int pft_file_open(struct file *filp, const struct cred *cred); |
| 36 | |
| 37 | int pft_file_permission(struct file *file, int mask); |
| 38 | |
| 39 | int pft_file_close(struct file *filp); |
| 40 | |
| 41 | int pft_inode_unlink(struct inode *dir, struct dentry *dentry); |
| 42 | |
| 43 | int pft_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, |
| 44 | dev_t dev); |
| 45 | |
| 46 | int pft_inode_rename(struct inode *inode, struct dentry *dentry, |
| 47 | struct inode *new_inode, struct dentry *new_dentry); |
| 48 | |
| 49 | int pft_inode_set_xattr(struct dentry *dentry, const char *name); |
| 50 | |
| 51 | |
| 52 | #else |
| 53 | static inline int pft_get_key_index(struct inode *inode, u32 *key_index, |
| 54 | bool *is_encrypted, bool *is_inplace) |
| 55 | { return -ENODEV; } |
| 56 | |
| 57 | static inline bool pft_allow_merge_bio(struct bio *bio1, struct bio *bio2) |
| 58 | { return true; } |
| 59 | |
| 60 | static inline int pft_file_permission(struct file *file, int mask) |
| 61 | { return 0; } |
| 62 | |
| 63 | static inline int pft_inode_create( |
| 64 | struct inode *dir, struct dentry *dentry, umode_t mode) |
| 65 | { return 0; } |
| 66 | |
| 67 | static inline int pft_inode_post_create( |
| 68 | struct inode *dir, struct dentry *dentry, umode_t mode) |
| 69 | { return 0; } |
| 70 | |
| 71 | static inline int pft_file_open(struct file *filp, const struct cred *cred) |
| 72 | { return 0; } |
| 73 | |
| 74 | static inline int pft_file_close(struct file *filp) |
| 75 | { return 0; } |
| 76 | |
| 77 | static inline int pft_inode_unlink(struct inode *dir, struct dentry *dentry) |
| 78 | { return 0; } |
| 79 | |
| 80 | static inline int pft_inode_mknod(struct inode *dir, struct dentry *dentry, |
| 81 | umode_t mode, dev_t dev) |
| 82 | { return 0; } |
| 83 | |
| 84 | static inline int pft_inode_rename(struct inode *inode, struct dentry *dentry, |
| 85 | struct inode *new_inode, struct dentry *new_dentry) |
| 86 | { return 0; } |
| 87 | |
| 88 | static 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 */ |