/*
 *  linux/include/linux/xip2_fs.h, Version 1
 *
 * (C) Copyright IBM Corp. 2002,2004
 * Author(s): Carsten Otte <cotte@de.ibm.com>
 * derived from second extended filesystem (ext2)
 */

#ifndef _LINUX_XIP2_FS_H
#define _LINUX_XIP2_FS_H
#include <linux/ext2_fs.h>

/* bit operations */
#define xip2_clear_bit ext2_clear_bit
#define xip2_test_bit  ext2_test_bit
#define xip2_set_bit   ext2_set_bit
#define xip2_find_next_zero_bit ext2_find_next_zero_bit
#define xip2_find_first_zero_bit ext2_find_first_zero_bit

/* the memory area structure */
typedef struct _xip2_mem_area_t {
	char* name; 
	unsigned long start; 
	unsigned long end;
} xip2_mem_area_t;

/*
 * Debug code
 */
#undef XIP2FS_DEBUG

#ifdef XIP2FS_DEBUG
#define xip2_debug(f, a...)	{ \
				printk ("XIP2-fs DEBUG (%s, %d): %s:", \
						__FILE__, __LINE__, __FUNCTION__); \
				  	printk (f, ## a); \
					}
#else
#	define xip2_debug(f, a...)	/**/
#endif

/*
 * Useful macros
 */
#ifdef __KERNEL__
#define XIP2_SB(sb)	(&((sb)->u.xip2_sb))
#else
/* Assume that user mode programs are passing in an ext2fs superblock, not
 * a kernel struct super_block.  This will allow us to call the feature-test
 * macros from user land. */
#define XIP2_SB(sb)	(sb)
#endif


/* functions defined in fs/xip2/balloc.c */
extern int xip2_bg_has_super(struct super_block *sb, int group);
extern unsigned long xip2_bg_num_gdb(struct super_block *sb, int group);
extern unsigned long xip2_count_free_blocks (struct super_block *);
extern void xip2_check_blocks_bitmap (struct super_block *);
extern void* xip2_maread (xip2_mem_area_t* mem_area, int block, int size);

/* dir.c */
extern ino_t xip2_inode_by_name(struct inode *, struct dentry *);
extern struct ext2_dir_entry_2 * xip2_find_entry (struct inode *,struct dentry *);

/* functions defined in fs/xip2/ialloc.c */
extern unsigned long xip2_count_free_inodes (struct super_block *);

/* functions defined in fs/xip2/inode.c */
extern void xip2_read_inode (struct inode *);
extern int xip2_get_block(struct inode *inode, long iblock, 
			  unsigned long* blockno_result, int create);

/* functions defined in fs/xip2/ioctl.c */
extern int xip2_ioctl (struct inode *, struct file *, unsigned int,
		       unsigned long);

/* functions defined in fs/xip2/super.c */
extern void xip2_error (struct super_block *, const char *, const char *, ...)
	__attribute__ ((format (printf, 3, 4)));
extern NORET_TYPE void xip2_panic (struct super_block *, const char *,
				   const char *, ...)
	__attribute__ ((NORET_AND format (printf, 3, 4)));
extern void xip2_warning (struct super_block *, const char *, const char *, ...)
	__attribute__ ((format (printf, 3, 4)));
extern void xip2_update_dynamic_rev (struct super_block *sb);
extern void xip2_put_super (struct super_block *);
extern int xip2_remount (struct super_block *, int *, char *);
extern struct super_block * xip2_read_super (struct super_block *,void *,int);
extern int xip2_statfs (struct super_block *, struct statfs *);

/*
 * Inodes and files operations
 */

/* dir.c */
extern struct file_operations xip2_dir_operations;

/* file.c */
extern struct inode_operations xip2_file_inode_operations;
extern struct file_operations xip2_file_operations;
extern int xip2_file_mmap(struct file * file, struct vm_area_struct * vma);
extern struct page * xip2_nopage_in_place(struct vm_area_struct * area, 
					  unsigned long address, int unused);
extern ssize_t xip2_file_read(struct file * filp, char * buf, size_t count, 
			      loff_t *ppos);

/* inode.c */
extern struct address_space_operations xip2_aops;

/* namei.c */
extern struct inode_operations xip2_dir_inode_operations;

/* symlink.c */
extern struct inode_operations xip2_fast_symlink_inode_operations;
extern struct inode_operations xip2_symlink_inode_operations;
#endif
