Commit 5e689743 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] fs/libfs.c

	Linus, I've taken a bunch of common methods into fs/libfs.c and
killed the (duplicated) instances in filesystems.  There will be more -
ideally I'd like to get a library that would make writing small filesystems
trivial.
parent 4ce937cb
......@@ -76,7 +76,6 @@ struct hotplug_slot_core {
};
static struct super_operations pcihpfs_ops;
static struct file_operations pcihpfs_dir_operations;
static struct file_operations default_file_operations;
static struct inode_operations pcihpfs_dir_inode_operations;
static struct vfsmount *pcihpfs_mount; /* one of the mounts of our fs for reference counting */
......@@ -95,13 +94,6 @@ static int pcihpfs_statfs (struct super_block *sb, struct statfs *buf)
return 0;
}
/* SMP-safe */
static struct dentry *pcihpfs_lookup (struct inode *dir, struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
static struct inode *pcihpfs_get_inode (struct super_block *sb, int mode, int dev)
{
struct inode *inode = new_inode(sb);
......@@ -123,7 +115,7 @@ static struct inode *pcihpfs_get_inode (struct super_block *sb, int mode, int de
break;
case S_IFDIR:
inode->i_op = &pcihpfs_dir_inode_operations;
inode->i_fop = &pcihpfs_dir_operations;
inode->i_fop = &simple_dir_operations;
break;
}
}
......@@ -241,11 +233,6 @@ static int default_open (struct inode *inode, struct file *filp)
return 0;
}
static struct file_operations pcihpfs_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
};
static struct file_operations default_file_operations = {
read: default_read_file,
write: default_write_file,
......@@ -302,7 +289,7 @@ static struct file_operations test_file_operations = {
static struct inode_operations pcihpfs_dir_inode_operations = {
create: pcihpfs_create,
lookup: pcihpfs_lookup,
lookup: simple_lookup,
unlink: pcihpfs_unlink,
mkdir: pcihpfs_mkdir,
rmdir: pcihpfs_rmdir,
......@@ -310,7 +297,7 @@ static struct inode_operations pcihpfs_dir_inode_operations = {
};
static struct super_operations pcihpfs_ops = {
statfs: pcihpfs_statfs,
statfs: simple_statfs,
put_inode: force_delete,
};
......
......@@ -40,7 +40,6 @@
#include <asm/byteorder.h>
static struct super_operations usbfs_ops;
static struct file_operations usbfs_dir_operations;
static struct file_operations default_file_operations;
static struct inode_operations usbfs_dir_inode_operations;
static struct vfsmount *usbfs_mount;
......@@ -141,21 +140,6 @@ static int parse_options(struct super_block *s, char *data)
/* --------------------------------------------------------------------- */
/* SMP-safe */
static struct dentry *usbfs_lookup (struct inode *dir, struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
static int usbfs_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = USBDEVICE_SUPER_MAGIC;
buf->f_bsize = PAGE_CACHE_SIZE;
buf->f_namelen = NAME_MAX;
return 0;
}
static struct inode *usbfs_get_inode (struct super_block *sb, int mode, int dev)
{
struct inode *inode = new_inode(sb);
......@@ -177,7 +161,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, int dev)
break;
case S_IFDIR:
inode->i_op = &usbfs_dir_inode_operations;
inode->i_fop = &usbfs_dir_operations;
inode->i_fop = &simple_dir_operations;
break;
}
}
......@@ -296,11 +280,6 @@ static int default_open (struct inode *inode, struct file *filp)
return 0;
}
static struct file_operations usbfs_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
};
static struct file_operations default_file_operations = {
read: default_read_file,
write: default_write_file,
......@@ -310,14 +289,14 @@ static struct file_operations default_file_operations = {
static struct inode_operations usbfs_dir_inode_operations = {
create: usbfs_create,
lookup: usbfs_lookup,
lookup: simple_lookup,
unlink: usbfs_unlink,
mkdir: usbfs_mkdir,
rmdir: usbfs_rmdir,
};
static struct super_operations usbfs_ops = {
statfs: usbfs_statfs,
statfs: simple_statfs,
put_inode: force_delete,
};
......
......@@ -14,7 +14,7 @@ obj-y := open.o read_write.o devices.o file_table.o buffer.o \
bio.o super.o block_dev.o char_dev.o stat.o exec.o pipe.o \
namei.o fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \
dcache.o inode.o attr.o bad_inode.o file.o iobuf.o dnotify.o \
filesystems.o namespace.o seq_file.o xattr.o
filesystems.o namespace.o seq_file.o xattr.o libfs.o
ifeq ($(CONFIG_QUOTA),y)
obj-y += dquot.o
......
......@@ -6,7 +6,7 @@
O_TARGET := autofs.o
obj-y := dir.o dirhash.o init.o inode.o root.o symlink.o waitq.o
obj-y := dirhash.o init.o inode.o root.o symlink.o waitq.o
obj-m := $(O_TARGET)
include $(TOPDIR)/Rules.make
......@@ -139,9 +139,7 @@ struct autofs_dir_ent *autofs_expire(struct super_block *,struct autofs_sb_info
extern struct inode_operations autofs_root_inode_operations;
extern struct inode_operations autofs_symlink_inode_operations;
extern struct inode_operations autofs_dir_inode_operations;
extern struct file_operations autofs_root_operations;
extern struct file_operations autofs_dir_operations;
/* Initializing function */
......
/* -*- linux-c -*- --------------------------------------------------------- *
*
* linux/fs/autofs/dir.c
*
* Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
*
* This file is part of the Linux kernel and is made available under
* the terms of the GNU General Public License, version 2, or at your
* option, any later version, incorporated herein by reference.
*
* ------------------------------------------------------------------------- */
#include "autofs_i.h"
/*
* No entries except for "." and "..", both of which are handled by the VFS
* layer. So all children are negative and dcache-based versions of operations
* are OK.
*/
/* SMP-safe */
static struct dentry *autofs_dir_lookup(struct inode *dir,struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
struct file_operations autofs_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
};
struct inode_operations autofs_dir_inode_operations = {
lookup: autofs_dir_lookup,
};
......@@ -39,13 +39,12 @@ static void autofs_put_super(struct super_block *sb)
DPRINTK(("autofs: shutting down\n"));
}
static int autofs_statfs(struct super_block *sb, struct statfs *buf);
static void autofs_read_inode(struct inode *inode);
static struct super_operations autofs_sops = {
read_inode: autofs_read_inode,
put_super: autofs_put_super,
statfs: autofs_statfs,
statfs: simple_statfs,
};
static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid, pid_t *pgrp, int *minproto, int *maxproto)
......@@ -191,14 +190,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
return -EINVAL;
}
static int autofs_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = AUTOFS_SUPER_MAGIC;
buf->f_bsize = 1024;
buf->f_namelen = NAME_MAX;
return 0;
}
static void autofs_read_inode(struct inode *inode)
{
ino_t ino = inode->i_ino;
......@@ -207,8 +198,8 @@ static void autofs_read_inode(struct inode *inode)
/* Initialize to the default case (stub directory) */
inode->i_op = &autofs_dir_inode_operations;
inode->i_fop = &autofs_dir_operations;
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
inode->i_nlink = 2;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
......
......@@ -139,7 +139,6 @@ int autofs4_expire_multi(struct super_block *, struct vfsmount *,
extern struct inode_operations autofs4_symlink_inode_operations;
extern struct inode_operations autofs4_dir_inode_operations;
extern struct inode_operations autofs4_root_inode_operations;
extern struct file_operations autofs4_dir_operations;
extern struct file_operations autofs4_root_operations;
/* Initializing function */
......
......@@ -90,11 +90,9 @@ static void autofs4_put_super(struct super_block *sb)
DPRINTK(("autofs: shutting down\n"));
}
static int autofs4_statfs(struct super_block *sb, struct statfs *buf);
static struct super_operations autofs4_sops = {
put_super: autofs4_put_super,
statfs: autofs4_statfs,
statfs: simple_statfs,
};
static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
......@@ -280,14 +278,6 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
return -EINVAL;
}
static int autofs4_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = AUTOFS_SUPER_MAGIC;
buf->f_bsize = 1024;
buf->f_namelen = NAME_MAX;
return 0;
}
struct inode *autofs4_get_inode(struct super_block *sb,
struct autofs_info *inf)
{
......@@ -313,7 +303,7 @@ struct inode *autofs4_get_inode(struct super_block *sb,
if (S_ISDIR(inf->mode)) {
inode->i_nlink = 2;
inode->i_op = &autofs4_dir_inode_operations;
inode->i_fop = &autofs4_dir_operations;
inode->i_fop = &simple_dir_operations;
} else if (S_ISLNK(inf->mode)) {
inode->i_size = inf->size;
inode->i_op = &autofs4_symlink_inode_operations;
......
......@@ -32,11 +32,6 @@ struct file_operations autofs4_root_operations = {
ioctl: autofs4_root_ioctl,
};
struct file_operations autofs4_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
};
struct inode_operations autofs4_root_inode_operations = {
lookup: autofs4_root_lookup,
unlink: autofs4_dir_unlink,
......
......@@ -616,36 +616,10 @@ static struct file_operations bm_status_operations = {
write: bm_status_write,
};
/* / */
/* SMP-safe */
static struct dentry * bm_lookup(struct inode *dir, struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
static struct file_operations bm_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
};
static struct inode_operations bm_dir_inode_operations = {
lookup: bm_lookup,
};
/* Superblock handling */
static int bm_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = sb->s_magic;
buf->f_bsize = PAGE_CACHE_SIZE;
buf->f_namelen = 255;
return 0;
}
static struct super_operations s_ops = {
statfs: bm_statfs,
statfs: simple_statfs,
put_inode: force_delete,
clear_inode: bm_clear_inode,
};
......@@ -670,8 +644,8 @@ static int bm_fill_super(struct super_block * sb, void * data, int silent)
inode = bm_get_inode(sb, S_IFDIR | 0755);
if (!inode)
return -ENOMEM;
inode->i_op = &bm_dir_inode_operations;
inode->i_fop = &bm_dir_operations;
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
dentry[0] = d_alloc_root(inode);
if (!dentry[0]) {
iput(inode);
......
......@@ -2541,17 +2541,6 @@ static int devfs_notify_change (struct dentry *dentry, struct iattr *iattr)
return 0;
} /* End Function devfs_notify_change */
static int devfs_statfs (struct super_block *sb, struct statfs *buf)
{
buf->f_type = DEVFS_SUPER_MAGIC;
buf->f_bsize = FAKE_BLOCK_SIZE;
buf->f_bfree = 0;
buf->f_bavail = 0;
buf->f_ffree = 0;
buf->f_namelen = NAME_MAX;
return 0;
} /* End Function devfs_statfs */
static void devfs_clear_inode (struct inode *inode)
{
if ( S_ISBLK (inode->i_mode) ) bdput (inode->i_bdev);
......@@ -2561,7 +2550,7 @@ static struct super_operations devfs_sops =
{
put_inode: force_delete,
clear_inode: devfs_clear_inode,
statfs: devfs_statfs,
statfs: simple_statfs,
};
......
......@@ -48,12 +48,11 @@ static void devpts_put_super(struct super_block *sb)
kfree(sbi);
}
static int devpts_statfs(struct super_block *sb, struct statfs *buf);
static int devpts_remount (struct super_block * sb, int * flags, char * data);
static struct super_operations devpts_sops = {
put_super: devpts_put_super,
statfs: devpts_statfs,
statfs: simple_statfs,
remount_fs: devpts_remount,
};
......@@ -171,14 +170,6 @@ static int devpts_fill_super(struct super_block *s, void *data, int silent)
return error;
}
static int devpts_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = DEVPTS_SUPER_MAGIC;
buf->f_bsize = 1024;
buf->f_namelen = NAME_MAX;
return 0;
}
static struct super_block *devpts_get_sb(struct file_system_type *fs_type,
int flags, char *dev_name, void *data)
{
......
......@@ -48,7 +48,6 @@
#define DRIVERFS_MAGIC 0x42454552
static struct super_operations driverfs_ops;
static struct file_operations driverfs_dir_operations;
static struct file_operations driverfs_file_operations;
static struct inode_operations driverfs_dir_inode_operations;
static struct dentry_operations driverfs_dentry_dir_ops;
......@@ -58,21 +57,6 @@ static struct vfsmount *driverfs_mount;
static spinlock_t mount_lock = SPIN_LOCK_UNLOCKED;
static int mount_count = 0;
static int driverfs_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = DRIVERFS_MAGIC;
buf->f_bsize = PAGE_CACHE_SIZE;
buf->f_namelen = 255;
return 0;
}
/* SMP-safe */
static struct dentry *driverfs_lookup(struct inode *dir, struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
struct inode *driverfs_get_inode(struct super_block *sb, int mode, int dev)
{
struct inode *inode = new_inode(sb);
......@@ -94,7 +78,7 @@ struct inode *driverfs_get_inode(struct super_block *sb, int mode, int dev)
break;
case S_IFDIR:
inode->i_op = &driverfs_dir_inode_operations;
inode->i_fop = &driverfs_dir_operations;
inode->i_fop = &simple_dir_operations;
break;
}
}
......@@ -375,14 +359,9 @@ static struct file_operations driverfs_file_operations = {
release: driverfs_release,
};
static struct file_operations driverfs_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
};
static struct inode_operations driverfs_dir_inode_operations = {
create: driverfs_create,
lookup: driverfs_lookup,
lookup: simple_lookup,
unlink: driverfs_unlink,
mkdir: driverfs_mkdir,
rmdir: driverfs_rmdir,
......@@ -393,7 +372,7 @@ static struct dentry_operations driverfs_dentry_file_ops = {
};
static struct super_operations driverfs_ops = {
statfs: driverfs_statfs,
statfs: simple_statfs,
put_inode: force_delete,
};
......
/*
* fs/libfs.c
* Library for filesystems writers.
*/
#include <linux/pagemap.h>
int simple_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = sb->s_magic;
buf->f_bsize = PAGE_CACHE_SIZE;
buf->f_namelen = NAME_MAX;
return 0;
}
/*
* Lookup the data. This is trivial - if the dentry didn't already
* exist, we know it is negative.
*/
struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
int simple_sync_file(struct file * file, struct dentry *dentry, int datasync)
{
return 0;
}
/*
* Directory is locked and all positive dentries in it are safe, since
* for ramfs-type trees they can't go away without unlink() or rmdir(),
* both impossible due to the lock on directory.
*/
int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
{
int i;
struct dentry *dentry = filp->f_dentry;
i = filp->f_pos;
switch (i) {
case 0:
if (filldir(dirent, ".", 1, i, dentry->d_inode->i_ino, DT_DIR) < 0)
break;
i++;
filp->f_pos++;
/* fallthrough */
case 1:
if (filldir(dirent, "..", 2, i, parent_ino(dentry), DT_DIR) < 0)
break;
i++;
filp->f_pos++;
/* fallthrough */
default: {
struct list_head *list;
int j = i-2;
spin_lock(&dcache_lock);
list = dentry->d_subdirs.next;
for (;;) {
if (list == &dentry->d_subdirs) {
spin_unlock(&dcache_lock);
return 0;
}
if (!j)
break;
j--;
list = list->next;
}
while(1) {
struct dentry *de = list_entry(list, struct dentry, d_child);
/*
* See comment on top of function on why we
* can just drop the lock here..
*/
if (!list_empty(&de->d_hash) && de->d_inode) {
spin_unlock(&dcache_lock);
if (filldir(dirent, de->d_name.name, de->d_name.len, filp->f_pos, de->d_inode->i_ino, DT_UNKNOWN) < 0)
break;
spin_lock(&dcache_lock);
}
filp->f_pos++;
list = list->next;
if (list != &dentry->d_subdirs)
continue;
spin_unlock(&dcache_lock);
break;
}
}
}
return 0;
}
ssize_t generic_read_dir(struct file *filp, char *buf, size_t siz, loff_t *ppos)
{
return -EISDIR;
}
struct file_operations simple_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
};
struct inode_operations simple_dir_inode_operations = {
lookup: simple_lookup,
};
......@@ -995,20 +995,9 @@ static void openprom_read_inode(struct inode * inode)
}
}
static int openprom_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = OPENPROM_SUPER_MAGIC;
buf->f_bsize = PAGE_SIZE/sizeof(long); /* ??? */
buf->f_bfree = 0;
buf->f_bavail = 0;
buf->f_ffree = 0;
buf->f_namelen = NAME_MAX;
return 0;
}
static struct super_operations openprom_sops = {
read_inode: openprom_read_inode,
statfs: openprom_statfs,
statfs: simple_statfs,
};
static int openprom_fill_super(struct super_block *s, void *data, int silent)
......
......@@ -589,16 +589,9 @@ int do_pipe(int *fd)
* any operations on the root directory. However, we need a non-trivial
* d_name - pipe: will go nicely and kill the special-casing in procfs.
*/
static int pipefs_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = PIPEFS_MAGIC;
buf->f_bsize = 1024;
buf->f_namelen = 255;
return 0;
}
static struct super_operations pipefs_ops = {
statfs: pipefs_statfs,
statfs: simple_statfs,
};
static int pipefs_fill_super(struct super_block *sb, void *data, int silent)
......
......@@ -82,17 +82,6 @@ static void proc_read_inode(struct inode * inode)
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
}
static int proc_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = PROC_SUPER_MAGIC;
buf->f_bsize = PAGE_SIZE/sizeof(long);
buf->f_bfree = 0;
buf->f_bavail = 0;
buf->f_ffree = 0;
buf->f_namelen = NAME_MAX;
return 0;
}
static kmem_cache_t * proc_inode_cachep;
static struct inode *proc_alloc_inode(struct super_block *sb)
......@@ -135,7 +124,7 @@ static struct super_operations proc_sops = {
read_inode: proc_read_inode,
put_inode: force_delete,
delete_inode: proc_delete_inode,
statfs: proc_statfs,
statfs: simple_statfs,
};
static int parse_options(char *options,uid_t *uid,gid_t *gid)
......
......@@ -38,29 +38,9 @@
static struct super_operations ramfs_ops;
static struct address_space_operations ramfs_aops;
static struct file_operations ramfs_dir_operations;
static struct file_operations ramfs_file_operations;
static struct inode_operations ramfs_dir_inode_operations;
static int ramfs_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = RAMFS_MAGIC;
buf->f_bsize = PAGE_CACHE_SIZE;
buf->f_namelen = 255;
return 0;
}
/*
* Lookup the data. This is trivial - if the dentry didn't already
* exist, we know it is negative.
*/
/* SMP-safe */
static struct dentry * ramfs_lookup(struct inode *dir, struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
/*
* Read a page. Again trivial. If it didn't already exist
* in the page cache, it is zero-filled.
......@@ -122,7 +102,7 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, int dev)
break;
case S_IFDIR:
inode->i_op = &ramfs_dir_inode_operations;
inode->i_fop = &ramfs_dir_operations;
inode->i_fop = &simple_dir_operations;
break;
case S_IFLNK:
inode->i_op = &page_symlink_inode_operations;
......@@ -284,15 +264,9 @@ static struct file_operations ramfs_file_operations = {
fsync: ramfs_sync_file,
};
static struct file_operations ramfs_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
fsync: ramfs_sync_file,
};
static struct inode_operations ramfs_dir_inode_operations = {
create: ramfs_create,
lookup: ramfs_lookup,
lookup: simple_lookup,
link: ramfs_link,
unlink: ramfs_unlink,
symlink: ramfs_symlink,
......@@ -303,7 +277,7 @@ static struct inode_operations ramfs_dir_inode_operations = {
};
static struct super_operations ramfs_ops = {
statfs: ramfs_statfs,
statfs: simple_statfs,
put_inode: force_delete,
};
......
......@@ -20,11 +20,6 @@ struct file_operations generic_ro_fops = {
mmap: generic_file_mmap,
};
ssize_t generic_read_dir(struct file *filp, char *buf, size_t siz, loff_t *ppos)
{
return -EISDIR;
}
loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
{
long long retval;
......
......@@ -32,74 +32,6 @@ int vfs_readdir(struct file *file, filldir_t filler, void *buf)
return res;
}
/*
* Directory is locked and all positive dentries in it are safe, since
* for ramfs-type trees they can't go away without unlink() or rmdir(),
* both impossible due to the lock on directory.
*/
int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
{
int i;
struct dentry *dentry = filp->f_dentry;
i = filp->f_pos;
switch (i) {
case 0:
if (filldir(dirent, ".", 1, i, dentry->d_inode->i_ino, DT_DIR) < 0)
break;
i++;
filp->f_pos++;
/* fallthrough */
case 1:
if (filldir(dirent, "..", 2, i, parent_ino(dentry), DT_DIR) < 0)
break;
i++;
filp->f_pos++;
/* fallthrough */
default: {
struct list_head *list;
int j = i-2;
spin_lock(&dcache_lock);
list = dentry->d_subdirs.next;
for (;;) {
if (list == &dentry->d_subdirs) {
spin_unlock(&dcache_lock);
return 0;
}
if (!j)
break;
j--;
list = list->next;
}
while(1) {
struct dentry *de = list_entry(list, struct dentry, d_child);
/*
* See comment on top of function on why we
* can just drop the lock here..
*/
if (!list_empty(&de->d_hash) && de->d_inode) {
spin_unlock(&dcache_lock);
if (filldir(dirent, de->d_name.name, de->d_name.len, filp->f_pos, de->d_inode->i_ino, DT_UNKNOWN) < 0)
break;
spin_lock(&dcache_lock);
}
filp->f_pos++;
list = list->next;
if (list != &dentry->d_subdirs)
continue;
spin_unlock(&dcache_lock);
break;
}
}
}
return 0;
}
/*
* Traditional linux readdir() handling..
*
......
......@@ -1456,7 +1456,6 @@ extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, r
extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
extern loff_t remote_llseek(struct file *file, loff_t offset, int origin);
extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
extern int generic_file_open(struct inode * inode, struct file * filp);
extern struct file_operations generic_ro_fops;
......@@ -1468,7 +1467,6 @@ extern int page_follow_link(struct dentry *, struct nameidata *);
extern struct inode_operations page_symlink_inode_operations;
extern int vfs_readdir(struct file *, filldir_t, void *);
extern int dcache_readdir(struct file *, void *, filldir_t);
extern int vfs_stat(char *, struct kstat *);
extern int vfs_lstat(char *, struct kstat *);
......@@ -1480,6 +1478,12 @@ extern void drop_super(struct super_block *sb);
extern kdev_t ROOT_DEV;
extern char root_device_name[];
extern int dcache_readdir(struct file *, void *, filldir_t);
extern int simple_statfs(struct super_block *, struct statfs *);
extern struct dentry *simple_lookup(struct inode *, struct dentry *);
extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
extern struct file_operations simple_dir_operations;
extern struct inode_operations simple_dir_inode_operations;
extern void show_buffers(void);
......
......@@ -283,6 +283,10 @@ EXPORT_SYMBOL(lease_get_mtime);
EXPORT_SYMBOL(lock_may_read);
EXPORT_SYMBOL(lock_may_write);
EXPORT_SYMBOL(dcache_readdir);
EXPORT_SYMBOL(simple_statfs);
EXPORT_SYMBOL(simple_lookup);
EXPORT_SYMBOL(simple_dir_operations);
EXPORT_SYMBOL(simple_dir_inode_operations);
EXPORT_SYMBOL(fd_install);
EXPORT_SYMBOL(put_unused_fd);
EXPORT_SYMBOL(get_sb_bdev);
......
......@@ -42,7 +42,6 @@ static struct super_operations shmem_ops;
static struct address_space_operations shmem_aops;
static struct file_operations shmem_file_operations;
static struct inode_operations shmem_inode_operations;
static struct file_operations shmem_dir_operations;
static struct inode_operations shmem_dir_inode_operations;
static struct vm_operations_struct shmem_vm_ops;
......@@ -708,7 +707,7 @@ struct inode *shmem_get_inode(struct super_block *sb, int mode, int dev)
case S_IFDIR:
inode->i_nlink++;
inode->i_op = &shmem_dir_inode_operations;
inode->i_fop = &shmem_dir_operations;
inode->i_fop = &simple_dir_operations;
break;
case S_IFLNK:
break;
......@@ -970,17 +969,6 @@ static int shmem_statfs(struct super_block *sb, struct statfs *buf)
return 0;
}
/*
* Lookup the data. This is trivial - if the dentry didn't already
* exist, we know it is negative.
*/
/* SMP-safe */
static struct dentry * shmem_lookup(struct inode *dir, struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
/*
* File creation. Allocate an inode, and we're done..
*/
......@@ -1376,18 +1364,10 @@ static struct inode_operations shmem_inode_operations = {
truncate: shmem_truncate,
};
static struct file_operations shmem_dir_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
#ifdef CONFIG_TMPFS
fsync: shmem_sync_file,
#endif
};
static struct inode_operations shmem_dir_inode_operations = {
#ifdef CONFIG_TMPFS
create: shmem_create,
lookup: shmem_lookup,
lookup: simple_lookup,
link: shmem_link,
unlink: shmem_unlink,
symlink: shmem_symlink,
......
......@@ -263,13 +263,6 @@ int move_addr_to_user(void *kaddr, int klen, void *uaddr, int *ulen)
}
#define SOCKFS_MAGIC 0x534F434B
static int sockfs_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = SOCKFS_MAGIC;
buf->f_bsize = 1024;
buf->f_namelen = 255;
return 0;
}
static kmem_cache_t * sock_inode_cachep;
......@@ -321,7 +314,7 @@ static int init_inodecache(void)
static struct super_operations sockfs_ops = {
alloc_inode: sock_alloc_inode,
destroy_inode: sock_destroy_inode,
statfs: sockfs_statfs,
statfs: simple_statfs,
};
static int sockfs_fill_super(struct super_block *sb, void *data, int silent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment