Update of /cvsroot/linuxconsole/ruby/linux/fs/inputfs
In directory usw-pr-cvs1:/tmp/cvs-serv23749
Added Files:
Makefile dir.c file.c inode.c super.c
Log Message:
Skeleton to new input filesystem.
--- NEW FILE: Makefile ---
#
# Makefile for the Linux input filesystem routines.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (not a .c file).
#
# Note 2! The CFLAGS definitions are now in the main makefile.
O_TARGET := inputfs.o
obj-y := super.o inode.o file.o dir.o
obj-m := $(O_TARGET)
include $(TOPDIR)/Rules.make
--- NEW FILE: dir.c ---
/*
* fs/inputfs/dir.c
*
* inputfs directory operations
*
* Copyright (C) 2001 James Simmons <jsi...@tr...>
*
* Released under the terms of the GNU GPL v2.0.
*
*/
#include <linux/inputfs_fs.h>
#include <linux/dcache.h>
/* FIXME: Keep things happy for now, add our own later */
struct file_operations inputfs_dir_ops = {
read: generic_read_dir,
readdir: dcache_readdir,
};
/* Ditto */
struct inode_operations inputfs_dir_inode_ops = {
/* Empty for now */
};
--- NEW FILE: file.c ---
/*
* fs/inputfs/file.c
*
* inputfs file operations
*
* Copyright (C) 2001 James Simmons <jsi...@tr...>
*
* Released under the terms of the GNU GPL v2.0.
*
*/
#include <linux/inputfs_fs.h>
/*
* FIXME: Use generic routines for now, add our own later.
*/
struct file_operations inputfs_file_ops = {
mmap: generic_file_mmap,
llseek: generic_file_llseek,
};
--- NEW FILE: inode.c ---
/*
* fs/inputfs/inode.c
*
* inputfs inode operations
*
* Copyright (C) 2001 James Simmons <jsi...@tr...>
*
* Released under the terms of the GNU GPL v2.0.
*
*/
#include <linux/locks.h>
#include <linux/inputfs_fs.h>
#include <asm/uaccess.h>
void inputfs_read_inode(struct inode *inode)
{
inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME;
}
struct inode *inputfs_get_inode(struct super_block *sb, int mode, int dev)
{
struct inode *inode = new_inode(sb);
if (!inode) {
printk(KERN_WARNING "inputfs: Unable to get new inode\n");
return NULL;
}
inode->i_mode = mode;
inode->i_uid = current->fsuid;
inode->i_gid = current->fsgid;
inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_blocks = 0;
inode->i_rdev = NODEV;
inputfs_read_inode(inode);
switch (mode & S_IFMT) {
case S_IFREG:
inode->i_fop = &inputfs_file_ops;
break;
case S_IFDIR:
inode->i_op = &inputfs_dir_inode_ops;
inode->i_fop = &inputfs_dir_ops;
break;
default:
init_special_inode(inode, mode, dev);
break;
}
return inode;
}
--- NEW FILE: super.c ---
/*
* fs/inputfs/super.c
*
* inputfs superblock operations
*
* Copyright (C) 2001 James Simmons <jsi...@tr...>
*
* Released under the terms of the GNU GPL v2.0.
*
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/inputfs_fs.h>
#include <linux/pagemap.h>
#include <linux/dcache.h>
static struct vfsmount *inputfs_mnt;
static int inputfs_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = INPUTFS_SUPER_MAGIC;
buf->f_bsize = PAGE_CACHE_SIZE;
buf->f_namelen = NAME_MAX;
return 0;
}
static struct super_operations inputfs_super_ops = {
statfs: inputfs_statfs,
};
static struct super_block *inputfs_read_super(struct super_block *sb,
void *data, int silent)
{
struct inode *root_inode;
sb->s_blocksize = PAGE_CACHE_SIZE;
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
sb->s_magic = INPUTFS_SUPER_MAGIC;
sb->s_op = &inputfs_super_ops;
root_inode = inputfs_get_inode(sb, S_IFDIR | 0755, 0);
if (!root_inode) {
printk(KERN_WARNING "inputfs: Unable to get root inode\n");
return NULL;
}
sb->s_root = d_alloc_root(root_inode);
if (!sb->s_root) {
printk(KERN_WARNING "inputfs: Unable to get root dentry\n");
iput(root_inode);
return NULL;
}
return sb;
}
static DECLARE_FSTYPE(inputfs_fs_type, "inputfs", inputfs_read_super, FS_SINGLE);
static int __init init_inputfs_fs(void)
{
int ret = register_filesystem(&inputfs_fs_type);
if (!ret) {
inputfs_mnt = kern_mount(&inputfs_fs_type);
ret = PTR_ERR(inputfs_mnt);
if (!IS_ERR(inputfs_mnt)) {
ret = 0;
}
}
return ret;
}
static void __exit exit_inputfs_fs(void)
{
kern_umount(inputfs_mnt);
unregister_filesystem(&inputfs_fs_type);
}
EXPORT_NO_SYMBOLS;
MODULE_AUTHOR("James Simmons <jsi...@tr...>");
MODULE_DESCRIPTION("input file system");
MODULE_LICENSE("GPL");
module_init(init_inputfs_fs);
module_exit(exit_inputfs_fs);
|