2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Coda File System, Linux Kernel module
|
|
|
|
*
|
|
|
|
* Original version, adapted from cfs_mach.c, (C) Carnegie Mellon University
|
|
|
|
* Linux modifications (C) 1996, Peter J. Braam
|
|
|
|
* Rewritten for Linux 2.1 (C) 1997 Carnegie Mellon University
|
|
|
|
*
|
|
|
|
* Carnegie Mellon University encourages users of this software to
|
|
|
|
* contribute improvements to the Coda project.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_CODA_FS
|
|
|
|
#define _LINUX_CODA_FS
|
|
|
|
|
2014-06-07 01:36:19 +04:00
|
|
|
#ifdef pr_fmt
|
|
|
|
#undef pr_fmt
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/param.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/fs.h>
|
2011-01-13 00:36:09 +03:00
|
|
|
#include "coda_fs_i.h"
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* operations */
|
2007-02-12 11:55:40 +03:00
|
|
|
extern const struct inode_operations coda_dir_inode_operations;
|
|
|
|
extern const struct inode_operations coda_file_inode_operations;
|
|
|
|
extern const struct inode_operations coda_ioctl_inode_operations;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-01-13 00:25:02 +03:00
|
|
|
extern const struct dentry_operations coda_dentry_operations;
|
|
|
|
|
2006-06-28 15:26:44 +04:00
|
|
|
extern const struct address_space_operations coda_file_aops;
|
|
|
|
extern const struct address_space_operations coda_symlink_aops;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-03-28 13:56:42 +04:00
|
|
|
extern const struct file_operations coda_dir_operations;
|
|
|
|
extern const struct file_operations coda_file_operations;
|
|
|
|
extern const struct file_operations coda_ioctl_operations;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* operations shared over more than one file */
|
|
|
|
int coda_open(struct inode *i, struct file *f);
|
|
|
|
int coda_release(struct inode *i, struct file *f);
|
2011-06-21 03:28:19 +04:00
|
|
|
int coda_permission(struct inode *inode, int mask);
|
2013-10-05 02:17:02 +04:00
|
|
|
int coda_revalidate_inode(struct inode *);
|
2005-04-17 02:20:36 +04:00
|
|
|
int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
|
|
|
|
int coda_setattr(struct dentry *, struct iattr *);
|
|
|
|
|
|
|
|
/* this file: heloers */
|
|
|
|
char *coda_f2s(struct CodaFid *f);
|
|
|
|
int coda_iscontrol(const char *name, size_t length);
|
|
|
|
|
|
|
|
void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
|
|
|
|
void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
|
|
|
|
unsigned short coda_flags_to_cflags(unsigned short);
|
|
|
|
|
|
|
|
/* sysctl.h */
|
|
|
|
void coda_sysctl_init(void);
|
|
|
|
void coda_sysctl_clean(void);
|
|
|
|
|
|
|
|
#define CODA_ALLOC(ptr, cast, size) do { \
|
|
|
|
if (size < PAGE_SIZE) \
|
2011-05-28 21:36:33 +04:00
|
|
|
ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
|
2005-04-17 02:20:36 +04:00
|
|
|
else \
|
2011-05-28 21:36:33 +04:00
|
|
|
ptr = (cast)vzalloc((unsigned long) size); \
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!ptr) \
|
2014-06-07 01:36:18 +04:00
|
|
|
pr_warn("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
|
2005-04-17 02:20:36 +04:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
2016-01-23 02:11:02 +03:00
|
|
|
#define CODA_FREE(ptr, size) kvfree((ptr))
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* inode to cnode access functions */
|
|
|
|
|
|
|
|
static inline struct coda_inode_info *ITOC(struct inode *inode)
|
|
|
|
{
|
2015-03-19 14:28:04 +03:00
|
|
|
return container_of(inode, struct coda_inode_info, vfs_inode);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ struct CodaFid *coda_i2f(struct inode *inode)
|
|
|
|
{
|
|
|
|
return &(ITOC(inode)->c_fid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ char *coda_i2s(struct inode *inode)
|
|
|
|
{
|
|
|
|
return coda_f2s(&(ITOC(inode)->c_fid));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this will not zap the inode away */
|
|
|
|
static __inline__ void coda_flag_inode(struct inode *inode, int flag)
|
|
|
|
{
|
2010-10-25 10:03:44 +04:00
|
|
|
struct coda_inode_info *cii = ITOC(inode);
|
|
|
|
|
|
|
|
spin_lock(&cii->c_lock);
|
|
|
|
cii->c_flags |= flag;
|
|
|
|
spin_unlock(&cii->c_lock);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|