/*
 * (C) Copyright Fuji Xerox Co., Ltd. All rights are reserved.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * 2017/12/15	nobuo.iwata@fujixerox.co.jp
 */

#ifndef __FXLSM_LSM_H
#define __FXLSM_LSM_H

#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/version.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
#define FXLSM_LSM_NEW
#else
#define FXLSM_LSM_OLD
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0)
#define FXLSM_PATH_CONST const
#else
#define FXLSM_PATH_CONST
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
#define FXLSM_HAVE_LSM_NAMES
#define FXLSM_HAVE_SECURITY_HOOK_LIST_LSM
#endif

#if defined(FXLSM_LSM_OLD) && defined(FXLSM_LOADABLE)
extern int (*fxlsm_org_file_open)
		(struct file *file, const struct cred *cred);
extern int (*fxlsm_org_path_unlink)
		(struct path *dir, struct dentry *dentry);
extern int (*fxlsm_org_path_mkdir)
		(struct path *dir, struct dentry *dentry, umode_t mode);
extern int (*fxlsm_org_path_rmdir)
		(struct path *dir, struct dentry *dentry);
extern int (*fxlsm_org_path_mknod)
		(struct path *dir, struct dentry *dentry, umode_t mode,
			unsigned int dev);
extern int (*fxlsm_org_path_symlink)
		(struct path *dir, struct dentry *dentry,
			const char *old_name);
extern int (*fxlsm_org_path_link)
		(struct dentry *old_dentry, struct path *new_dir,
			struct dentry *new_dentry);
extern int (*fxlsm_org_path_rename)
		(struct path *old_dir, struct dentry *old_dentry,
			struct path *new_dir, struct dentry *new_dentry);
extern int (*fxlsm_org_path_chmod)
		(struct path *path, umode_t mode);
extern int (*fxlsm_org_path_chown)
		(struct path *path, kuid_t uid, kgid_t gid);
extern int (*fxlsm_org_path_chroot)
		(struct path *path);
extern int (*fxlsm_org_path_truncate)
		(struct path *path);
#endif

#endif /* !__FXLSM_LSM_H */
