2005-04-17 00:20:36 +02:00
|
|
|
/*
|
2008-02-16 00:37:00 +01:00
|
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-17 00:20:36 +02:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/dcache.h>
|
2005-07-08 02:56:51 +02:00
|
|
|
#include <linux/file.h>
|
2008-02-16 00:37:00 +01:00
|
|
|
#include <linux/fs.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
2008-02-16 00:37:00 +01:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mount.h>
|
|
|
|
#include <linux/slab.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/statfs.h>
|
2008-02-16 00:37:00 +01:00
|
|
|
#include <linux/types.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include "os.h"
|
|
|
|
|
2008-02-23 10:53:53 +01:00
|
|
|
static struct inode *get_inode(struct super_block *, struct dentry *);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
struct hppfs_data {
|
|
|
|
struct list_head list;
|
|
|
|
char contents[PAGE_SIZE - sizeof(struct list_head)];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hppfs_private {
|
|
|
|
struct file *proc_file;
|
|
|
|
int host_fd;
|
|
|
|
loff_t len;
|
|
|
|
struct hppfs_data *contents;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hppfs_inode_info {
|
2008-05-12 23:01:49 +02:00
|
|
|
struct dentry *proc_dentry;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct inode vfs_inode;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct hppfs_inode_info *HPPFS_I(struct inode *inode)
|
|
|
|
{
|
2005-08-26 16:57:53 +02:00
|
|
|
return container_of(inode, struct hppfs_inode_info, vfs_inode);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define HPPFS_SUPER_MAGIC 0xb00000ee
|
|
|
|
|
2007-02-12 09:55:41 +01:00
|
|
|
static const struct super_operations hppfs_sbops;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
static int is_pid(struct dentry *dentry)
|
|
|
|
{
|
|
|
|
struct super_block *sb;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
sb = dentry->d_sb;
|
2008-05-12 23:01:49 +02:00
|
|
|
if (dentry->d_parent != sb->s_root)
|
2008-02-16 00:37:00 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
for (i = 0; i < dentry->d_name.len; i++) {
|
|
|
|
if (!isdigit(dentry->d_name.name[i]))
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2008-02-16 00:37:00 +01:00
|
|
|
return 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *dentry_name(struct dentry *dentry, int extra)
|
|
|
|
{
|
|
|
|
struct dentry *parent;
|
|
|
|
char *root, *name;
|
|
|
|
const char *seg_name;
|
|
|
|
int len, seg_len;
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
parent = dentry;
|
2008-02-16 00:37:00 +01:00
|
|
|
while (parent->d_parent != parent) {
|
|
|
|
if (is_pid(parent))
|
2005-04-17 00:20:36 +02:00
|
|
|
len += strlen("pid") + 1;
|
|
|
|
else len += parent->d_name.len + 1;
|
|
|
|
parent = parent->d_parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
root = "proc";
|
|
|
|
len += strlen(root);
|
|
|
|
name = kmalloc(len + extra + 1, GFP_KERNEL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (name == NULL)
|
|
|
|
return NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
name[len] = '\0';
|
|
|
|
parent = dentry;
|
2008-02-16 00:37:00 +01:00
|
|
|
while (parent->d_parent != parent) {
|
|
|
|
if (is_pid(parent)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
seg_name = "pid";
|
|
|
|
seg_len = strlen("pid");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
seg_name = parent->d_name.name;
|
|
|
|
seg_len = parent->d_name.len;
|
|
|
|
}
|
|
|
|
|
|
|
|
len -= seg_len + 1;
|
|
|
|
name[len] = '/';
|
|
|
|
strncpy(&name[len + 1], seg_name, seg_len);
|
|
|
|
parent = parent->d_parent;
|
|
|
|
}
|
|
|
|
strncpy(name, root, strlen(root));
|
2008-02-16 00:37:00 +01:00
|
|
|
return name;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int file_removed(struct dentry *dentry, const char *file)
|
|
|
|
{
|
|
|
|
char *host_file;
|
|
|
|
int extra, fd;
|
|
|
|
|
|
|
|
extra = 0;
|
2008-02-16 00:37:00 +01:00
|
|
|
if (file != NULL)
|
|
|
|
extra += strlen(file) + 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
host_file = dentry_name(dentry, extra + strlen("/remove"));
|
2008-02-16 00:37:00 +01:00
|
|
|
if (host_file == NULL) {
|
|
|
|
printk(KERN_ERR "file_removed : allocation failed\n");
|
|
|
|
return -ENOMEM;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (file != NULL) {
|
2005-04-17 00:20:36 +02:00
|
|
|
strcat(host_file, "/");
|
|
|
|
strcat(host_file, file);
|
|
|
|
}
|
|
|
|
strcat(host_file, "/remove");
|
|
|
|
|
|
|
|
fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
|
|
|
|
kfree(host_file);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (fd > 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
os_close_file(fd);
|
2008-02-16 00:37:00 +01:00
|
|
|
return 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2008-02-16 00:37:00 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
|
2008-05-12 23:01:49 +02:00
|
|
|
struct nameidata *nd)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct dentry *proc_dentry, *new, *parent;
|
|
|
|
struct inode *inode;
|
|
|
|
int err, deleted;
|
|
|
|
|
|
|
|
deleted = file_removed(dentry, NULL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (deleted < 0)
|
|
|
|
return ERR_PTR(deleted);
|
|
|
|
else if (deleted)
|
|
|
|
return ERR_PTR(-ENOENT);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
err = -ENOMEM;
|
|
|
|
parent = HPPFS_I(ino)->proc_dentry;
|
2006-01-10 00:59:24 +01:00
|
|
|
mutex_lock(&parent->d_inode->i_mutex);
|
2005-04-17 00:20:36 +02:00
|
|
|
proc_dentry = d_lookup(parent, &dentry->d_name);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (proc_dentry == NULL) {
|
2005-04-17 00:20:36 +02:00
|
|
|
proc_dentry = d_alloc(parent, &dentry->d_name);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (proc_dentry == NULL) {
|
2006-01-10 00:59:24 +01:00
|
|
|
mutex_unlock(&parent->d_inode->i_mutex);
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
new = (*parent->d_inode->i_op->lookup)(parent->d_inode,
|
|
|
|
proc_dentry, NULL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (new) {
|
2005-04-17 00:20:36 +02:00
|
|
|
dput(proc_dentry);
|
|
|
|
proc_dentry = new;
|
|
|
|
}
|
|
|
|
}
|
2006-01-10 00:59:24 +01:00
|
|
|
mutex_unlock(&parent->d_inode->i_mutex);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (IS_ERR(proc_dentry))
|
|
|
|
return proc_dentry;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-23 10:53:53 +01:00
|
|
|
err = -ENOMEM;
|
|
|
|
inode = get_inode(ino->i_sb, proc_dentry);
|
|
|
|
if (!inode)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out_dput;
|
|
|
|
|
|
|
|
d_add(dentry, inode);
|
2008-02-16 00:37:00 +01:00
|
|
|
return NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
out_dput:
|
|
|
|
dput(proc_dentry);
|
|
|
|
out:
|
2008-02-16 00:37:00 +01:00
|
|
|
return ERR_PTR(err);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2007-02-12 09:55:39 +01:00
|
|
|
static const struct inode_operations hppfs_file_iops = {
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
2006-03-31 12:30:16 +02:00
|
|
|
static ssize_t read_proc(struct file *file, char __user *buf, ssize_t count,
|
2005-04-17 00:20:36 +02:00
|
|
|
loff_t *ppos, int is_user)
|
|
|
|
{
|
2006-03-31 12:30:16 +02:00
|
|
|
ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
|
2005-04-17 00:20:36 +02:00
|
|
|
ssize_t n;
|
|
|
|
|
2006-12-08 11:37:07 +01:00
|
|
|
read = file->f_path.dentry->d_inode->i_fop->read;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (!is_user)
|
2005-04-17 00:20:36 +02:00
|
|
|
set_fs(KERNEL_DS);
|
|
|
|
|
|
|
|
n = (*read)(file, buf, count, &file->f_pos);
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (!is_user)
|
2005-04-17 00:20:36 +02:00
|
|
|
set_fs(USER_DS);
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (ppos)
|
|
|
|
*ppos = file->f_pos;
|
2005-07-14 09:33:41 +02:00
|
|
|
return n;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-03-31 12:30:16 +02:00
|
|
|
static ssize_t hppfs_read_file(int fd, char __user *buf, ssize_t count)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
ssize_t n;
|
|
|
|
int cur, err;
|
|
|
|
char *new_buf;
|
|
|
|
|
|
|
|
n = -ENOMEM;
|
|
|
|
new_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (new_buf == NULL) {
|
|
|
|
printk(KERN_ERR "hppfs_read_file : kmalloc failed\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
n = 0;
|
2008-02-16 00:37:00 +01:00
|
|
|
while (count > 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
cur = min_t(ssize_t, count, PAGE_SIZE);
|
|
|
|
err = os_read_file(fd, new_buf, cur);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (err < 0) {
|
|
|
|
printk(KERN_ERR "hppfs_read : read failed, "
|
|
|
|
"errno = %d\n", err);
|
2005-04-17 00:20:36 +02:00
|
|
|
n = err;
|
|
|
|
goto out_free;
|
2008-02-16 00:37:00 +01:00
|
|
|
} else if (err == 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (copy_to_user(buf, new_buf, err)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
n = -EFAULT;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
n += err;
|
|
|
|
count -= err;
|
|
|
|
}
|
|
|
|
out_free:
|
|
|
|
kfree(new_buf);
|
|
|
|
out:
|
2005-07-14 09:33:41 +02:00
|
|
|
return n;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-03-31 12:30:16 +02:00
|
|
|
static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count,
|
2005-04-17 00:20:36 +02:00
|
|
|
loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct hppfs_private *hppfs = file->private_data;
|
|
|
|
struct hppfs_data *data;
|
|
|
|
loff_t off;
|
|
|
|
int err;
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (hppfs->contents != NULL) {
|
2008-05-12 23:01:49 +02:00
|
|
|
int rem;
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (*ppos >= hppfs->len)
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
data = hppfs->contents;
|
|
|
|
off = *ppos;
|
2008-02-16 00:37:00 +01:00
|
|
|
while (off >= sizeof(data->contents)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
data = list_entry(data->list.next, struct hppfs_data,
|
|
|
|
list);
|
|
|
|
off -= sizeof(data->contents);
|
|
|
|
}
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (off + count > hppfs->len)
|
2005-04-17 00:20:36 +02:00
|
|
|
count = hppfs->len - off;
|
2008-05-12 23:01:49 +02:00
|
|
|
rem = copy_to_user(buf, &data->contents[off], count);
|
|
|
|
*ppos += count - rem;
|
|
|
|
if (rem > 0)
|
|
|
|
return -EFAULT;
|
2008-02-16 00:37:00 +01:00
|
|
|
} else if (hppfs->host_fd != -1) {
|
2005-04-17 00:20:36 +02:00
|
|
|
err = os_seek_file(hppfs->host_fd, *ppos);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR "hppfs_read : seek failed, "
|
|
|
|
"errno = %d\n", err);
|
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
count = hppfs_read_file(hppfs->host_fd, buf, count);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (count > 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
*ppos += count;
|
|
|
|
}
|
|
|
|
else count = read_proc(hppfs->proc_file, buf, count, ppos, 1);
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
return count;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-05-12 23:01:49 +02:00
|
|
|
static ssize_t hppfs_write(struct file *file, const char __user *buf,
|
|
|
|
size_t len, loff_t *ppos)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct hppfs_private *data = file->private_data;
|
|
|
|
struct file *proc_file = data->proc_file;
|
2006-03-31 12:30:16 +02:00
|
|
|
ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-12-08 11:37:07 +01:00
|
|
|
write = proc_file->f_path.dentry->d_inode->i_fop->write;
|
2008-05-12 23:01:49 +02:00
|
|
|
return (*write)(proc_file, buf, len, ppos);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int open_host_sock(char *host_file, int *filter_out)
|
|
|
|
{
|
|
|
|
char *end;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
end = &host_file[strlen(host_file)];
|
|
|
|
strcpy(end, "/rw");
|
|
|
|
*filter_out = 1;
|
|
|
|
fd = os_connect_socket(host_file);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (fd > 0)
|
|
|
|
return fd;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
strcpy(end, "/r");
|
|
|
|
*filter_out = 0;
|
|
|
|
fd = os_connect_socket(host_file);
|
2008-02-16 00:37:00 +01:00
|
|
|
return fd;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void free_contents(struct hppfs_data *head)
|
|
|
|
{
|
|
|
|
struct hppfs_data *data;
|
|
|
|
struct list_head *ele, *next;
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (head == NULL)
|
|
|
|
return;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
list_for_each_safe(ele, next, &head->list) {
|
2005-04-17 00:20:36 +02:00
|
|
|
data = list_entry(ele, struct hppfs_data, list);
|
|
|
|
kfree(data);
|
|
|
|
}
|
|
|
|
kfree(head);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct hppfs_data *hppfs_get_data(int fd, int filter,
|
|
|
|
struct file *proc_file,
|
|
|
|
struct file *hppfs_file,
|
|
|
|
loff_t *size_out)
|
|
|
|
{
|
|
|
|
struct hppfs_data *data, *new, *head;
|
|
|
|
int n, err;
|
|
|
|
|
|
|
|
err = -ENOMEM;
|
|
|
|
data = kmalloc(sizeof(*data), GFP_KERNEL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (data == NULL) {
|
|
|
|
printk(KERN_ERR "hppfs_get_data : head allocation failed\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&data->list);
|
|
|
|
|
|
|
|
head = data;
|
|
|
|
*size_out = 0;
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (filter) {
|
|
|
|
while ((n = read_proc(proc_file, data->contents,
|
2008-05-12 23:01:49 +02:00
|
|
|
sizeof(data->contents), NULL, 0)) > 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
os_write_file(fd, data->contents, n);
|
|
|
|
err = os_shutdown_socket(fd, 0, 1);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR "hppfs_get_data : failed to shut down "
|
2005-04-17 00:20:36 +02:00
|
|
|
"socket\n");
|
|
|
|
goto failed_free;
|
|
|
|
}
|
|
|
|
}
|
2008-02-16 00:37:00 +01:00
|
|
|
while (1) {
|
2005-04-17 00:20:36 +02:00
|
|
|
n = os_read_file(fd, data->contents, sizeof(data->contents));
|
2008-02-16 00:37:00 +01:00
|
|
|
if (n < 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
err = n;
|
2008-02-16 00:37:00 +01:00
|
|
|
printk(KERN_ERR "hppfs_get_data : read failed, "
|
|
|
|
"errno = %d\n", err);
|
2005-04-17 00:20:36 +02:00
|
|
|
goto failed_free;
|
2008-02-16 00:37:00 +01:00
|
|
|
} else if (n == 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
*size_out += n;
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (n < sizeof(data->contents))
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
new = kmalloc(sizeof(*data), GFP_KERNEL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (new == 0) {
|
|
|
|
printk(KERN_ERR "hppfs_get_data : data allocation "
|
|
|
|
"failed\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto failed_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&new->list);
|
|
|
|
list_add(&new->list, &data->list);
|
|
|
|
data = new;
|
|
|
|
}
|
2008-02-16 00:37:00 +01:00
|
|
|
return head;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
failed_free:
|
|
|
|
free_contents(head);
|
|
|
|
failed:
|
2008-02-16 00:37:00 +01:00
|
|
|
return ERR_PTR(err);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct hppfs_private *hppfs_data(void)
|
|
|
|
{
|
|
|
|
struct hppfs_private *data;
|
|
|
|
|
|
|
|
data = kmalloc(sizeof(*data), GFP_KERNEL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (data == NULL)
|
|
|
|
return data;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
*data = ((struct hppfs_private ) { .host_fd = -1,
|
|
|
|
.len = -1,
|
|
|
|
.contents = NULL } );
|
2008-02-16 00:37:00 +01:00
|
|
|
return data;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int file_mode(int fmode)
|
|
|
|
{
|
2008-02-16 00:37:00 +01:00
|
|
|
if (fmode == (FMODE_READ | FMODE_WRITE))
|
|
|
|
return O_RDWR;
|
|
|
|
if (fmode == FMODE_READ)
|
|
|
|
return O_RDONLY;
|
|
|
|
if (fmode == FMODE_WRITE)
|
|
|
|
return O_WRONLY;
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int hppfs_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2008-11-14 00:39:25 +01:00
|
|
|
const struct cred *cred = file->f_cred;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct hppfs_private *data;
|
2008-02-16 00:37:00 +01:00
|
|
|
struct vfsmount *proc_mnt;
|
2008-05-12 23:01:49 +02:00
|
|
|
struct dentry *proc_dentry;
|
2005-04-17 00:20:36 +02:00
|
|
|
char *host_file;
|
|
|
|
int err, fd, type, filter;
|
|
|
|
|
|
|
|
err = -ENOMEM;
|
|
|
|
data = hppfs_data();
|
2008-02-16 00:37:00 +01:00
|
|
|
if (data == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out;
|
|
|
|
|
2006-12-08 11:37:07 +01:00
|
|
|
host_file = dentry_name(file->f_path.dentry, strlen("/rw"));
|
2008-02-16 00:37:00 +01:00
|
|
|
if (host_file == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out_free2;
|
|
|
|
|
|
|
|
proc_dentry = HPPFS_I(inode)->proc_dentry;
|
2008-02-23 10:53:53 +01:00
|
|
|
proc_mnt = inode->i_sb->s_fs_info;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* XXX This isn't closed anywhere */
|
2008-02-16 00:37:00 +01:00
|
|
|
data->proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt),
|
2008-11-14 00:39:22 +01:00
|
|
|
file_mode(file->f_mode), cred);
|
2005-04-17 00:20:36 +02:00
|
|
|
err = PTR_ERR(data->proc_file);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (IS_ERR(data->proc_file))
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out_free1;
|
|
|
|
|
|
|
|
type = os_file_type(host_file);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (type == OS_TYPE_FILE) {
|
2005-04-17 00:20:36 +02:00
|
|
|
fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (fd >= 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
data->host_fd = fd;
|
2008-02-16 00:37:00 +01:00
|
|
|
else
|
|
|
|
printk(KERN_ERR "hppfs_open : failed to open '%s', "
|
|
|
|
"errno = %d\n", host_file, -fd);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
data->contents = NULL;
|
2008-02-16 00:37:00 +01:00
|
|
|
} else if (type == OS_TYPE_DIR) {
|
2005-04-17 00:20:36 +02:00
|
|
|
fd = open_host_sock(host_file, &filter);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (fd > 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
data->contents = hppfs_get_data(fd, filter,
|
2005-07-08 02:56:51 +02:00
|
|
|
data->proc_file,
|
2005-04-17 00:20:36 +02:00
|
|
|
file, &data->len);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (!IS_ERR(data->contents))
|
2005-04-17 00:20:36 +02:00
|
|
|
data->host_fd = fd;
|
2008-02-16 00:37:00 +01:00
|
|
|
} else
|
|
|
|
printk(KERN_ERR "hppfs_open : failed to open a socket "
|
|
|
|
"in '%s', errno = %d\n", host_file, -fd);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
kfree(host_file);
|
|
|
|
|
|
|
|
file->private_data = data;
|
2008-02-16 00:37:00 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
out_free1:
|
|
|
|
kfree(host_file);
|
|
|
|
out_free2:
|
|
|
|
free_contents(data->contents);
|
|
|
|
kfree(data);
|
|
|
|
out:
|
2008-02-16 00:37:00 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int hppfs_dir_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2008-11-14 00:39:25 +01:00
|
|
|
const struct cred *cred = file->f_cred;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct hppfs_private *data;
|
2008-02-16 00:37:00 +01:00
|
|
|
struct vfsmount *proc_mnt;
|
2008-05-12 23:01:49 +02:00
|
|
|
struct dentry *proc_dentry;
|
2005-04-17 00:20:36 +02:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = -ENOMEM;
|
|
|
|
data = hppfs_data();
|
2008-02-16 00:37:00 +01:00
|
|
|
if (data == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
proc_dentry = HPPFS_I(inode)->proc_dentry;
|
2008-02-23 10:53:53 +01:00
|
|
|
proc_mnt = inode->i_sb->s_fs_info;
|
2008-02-16 00:37:00 +01:00
|
|
|
data->proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt),
|
2008-11-14 00:39:22 +01:00
|
|
|
file_mode(file->f_mode), cred);
|
2005-04-17 00:20:36 +02:00
|
|
|
err = PTR_ERR(data->proc_file);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (IS_ERR(data->proc_file))
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
file->private_data = data;
|
2008-02-16 00:37:00 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
out_free:
|
|
|
|
kfree(data);
|
|
|
|
out:
|
2008-02-16 00:37:00 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static loff_t hppfs_llseek(struct file *file, loff_t off, int where)
|
|
|
|
{
|
|
|
|
struct hppfs_private *data = file->private_data;
|
2005-07-08 02:56:51 +02:00
|
|
|
struct file *proc_file = data->proc_file;
|
2005-04-17 00:20:36 +02:00
|
|
|
loff_t (*llseek)(struct file *, loff_t, int);
|
|
|
|
loff_t ret;
|
|
|
|
|
2006-12-08 11:37:07 +01:00
|
|
|
llseek = proc_file->f_path.dentry->d_inode->i_fop->llseek;
|
2008-02-16 00:37:00 +01:00
|
|
|
if (llseek != NULL) {
|
2005-04-17 00:20:36 +02:00
|
|
|
ret = (*llseek)(proc_file, off, where);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
return default_llseek(file, off, where);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-03-28 11:56:42 +02:00
|
|
|
static const struct file_operations hppfs_file_fops = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.owner = NULL,
|
|
|
|
.llseek = hppfs_llseek,
|
|
|
|
.read = hppfs_read,
|
|
|
|
.write = hppfs_write,
|
|
|
|
.open = hppfs_open,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hppfs_dirent {
|
|
|
|
void *vfs_dirent;
|
|
|
|
filldir_t filldir;
|
|
|
|
struct dentry *dentry;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int hppfs_filldir(void *d, const char *name, int size,
|
2006-10-09 21:26:58 +02:00
|
|
|
loff_t offset, u64 inode, unsigned int type)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct hppfs_dirent *dirent = d;
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (file_removed(dirent->dentry, name))
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
return (*dirent->filldir)(dirent->vfs_dirent, name, size, offset,
|
|
|
|
inode, type);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int hppfs_readdir(struct file *file, void *ent, filldir_t filldir)
|
|
|
|
{
|
|
|
|
struct hppfs_private *data = file->private_data;
|
2005-07-08 02:56:51 +02:00
|
|
|
struct file *proc_file = data->proc_file;
|
2005-04-17 00:20:36 +02:00
|
|
|
int (*readdir)(struct file *, void *, filldir_t);
|
|
|
|
struct hppfs_dirent dirent = ((struct hppfs_dirent)
|
|
|
|
{ .vfs_dirent = ent,
|
|
|
|
.filldir = filldir,
|
2008-02-16 00:37:00 +01:00
|
|
|
.dentry = file->f_path.dentry
|
|
|
|
});
|
2005-04-17 00:20:36 +02:00
|
|
|
int err;
|
|
|
|
|
2006-12-08 11:37:07 +01:00
|
|
|
readdir = proc_file->f_path.dentry->d_inode->i_fop->readdir;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
proc_file->f_pos = file->f_pos;
|
|
|
|
err = (*readdir)(proc_file, &dirent, hppfs_filldir);
|
|
|
|
file->f_pos = proc_file->f_pos;
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int hppfs_fsync(struct file *file, struct dentry *dentry, int datasync)
|
|
|
|
{
|
2008-02-16 00:37:00 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-03-28 11:56:42 +02:00
|
|
|
static const struct file_operations hppfs_dir_fops = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.owner = NULL,
|
|
|
|
.readdir = hppfs_readdir,
|
|
|
|
.open = hppfs_dir_open,
|
|
|
|
.fsync = hppfs_fsync,
|
|
|
|
};
|
|
|
|
|
2006-06-23 11:02:58 +02:00
|
|
|
static int hppfs_statfs(struct dentry *dentry, struct kstatfs *sf)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
sf->f_blocks = 0;
|
|
|
|
sf->f_bfree = 0;
|
|
|
|
sf->f_bavail = 0;
|
|
|
|
sf->f_files = 0;
|
|
|
|
sf->f_ffree = 0;
|
|
|
|
sf->f_type = HPPFS_SUPER_MAGIC;
|
2008-02-16 00:37:00 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct inode *hppfs_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct hppfs_inode_info *hi;
|
|
|
|
|
|
|
|
hi = kmalloc(sizeof(*hi), GFP_KERNEL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (!hi)
|
|
|
|
return NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
hi->proc_dentry = NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
inode_init_once(&hi->vfs_inode);
|
2008-02-16 00:37:00 +01:00
|
|
|
return &hi->vfs_inode;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void hppfs_delete_inode(struct inode *ino)
|
|
|
|
{
|
2008-05-12 23:01:49 +02:00
|
|
|
dput(HPPFS_I(ino)->proc_dentry);
|
|
|
|
mntput(ino->i_sb->s_fs_info);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
clear_inode(ino);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hppfs_destroy_inode(struct inode *inode)
|
|
|
|
{
|
|
|
|
kfree(HPPFS_I(inode));
|
|
|
|
}
|
|
|
|
|
2007-02-12 09:55:41 +01:00
|
|
|
static const struct super_operations hppfs_sbops = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.alloc_inode = hppfs_alloc_inode,
|
|
|
|
.destroy_inode = hppfs_destroy_inode,
|
|
|
|
.delete_inode = hppfs_delete_inode,
|
|
|
|
.statfs = hppfs_statfs,
|
|
|
|
};
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
static int hppfs_readlink(struct dentry *dentry, char __user *buffer,
|
|
|
|
int buflen)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct dentry *proc_dentry;
|
|
|
|
|
|
|
|
proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
|
2008-05-12 23:01:49 +02:00
|
|
|
return proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer,
|
|
|
|
buflen);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-05-12 23:01:49 +02:00
|
|
|
static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct dentry *proc_dentry;
|
|
|
|
|
|
|
|
proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
|
|
|
|
|
2008-05-12 23:01:49 +02:00
|
|
|
return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-02-12 09:55:39 +01:00
|
|
|
static const struct inode_operations hppfs_dir_iops = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.lookup = hppfs_lookup,
|
|
|
|
};
|
|
|
|
|
2007-02-12 09:55:39 +01:00
|
|
|
static const struct inode_operations hppfs_link_iops = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.readlink = hppfs_readlink,
|
|
|
|
.follow_link = hppfs_follow_link,
|
|
|
|
};
|
|
|
|
|
2008-02-23 10:53:53 +01:00
|
|
|
static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-02-23 10:53:53 +01:00
|
|
|
struct inode *proc_ino = dentry->d_inode;
|
|
|
|
struct inode *inode = new_inode(sb);
|
|
|
|
|
|
|
|
if (!inode)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
if (S_ISDIR(dentry->d_inode->i_mode)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
inode->i_op = &hppfs_dir_iops;
|
|
|
|
inode->i_fop = &hppfs_dir_fops;
|
2008-02-16 00:37:00 +01:00
|
|
|
} else if (S_ISLNK(dentry->d_inode->i_mode)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
inode->i_op = &hppfs_link_iops;
|
|
|
|
inode->i_fop = &hppfs_file_fops;
|
2008-02-16 00:37:00 +01:00
|
|
|
} else {
|
2005-04-17 00:20:36 +02:00
|
|
|
inode->i_op = &hppfs_file_iops;
|
|
|
|
inode->i_fop = &hppfs_file_fops;
|
|
|
|
}
|
|
|
|
|
2008-05-12 23:01:49 +02:00
|
|
|
HPPFS_I(inode)->proc_dentry = dget(dentry);
|
2008-02-23 10:53:53 +01:00
|
|
|
|
|
|
|
inode->i_uid = proc_ino->i_uid;
|
|
|
|
inode->i_gid = proc_ino->i_gid;
|
|
|
|
inode->i_atime = proc_ino->i_atime;
|
|
|
|
inode->i_mtime = proc_ino->i_mtime;
|
|
|
|
inode->i_ctime = proc_ino->i_ctime;
|
|
|
|
inode->i_ino = proc_ino->i_ino;
|
|
|
|
inode->i_mode = proc_ino->i_mode;
|
|
|
|
inode->i_nlink = proc_ino->i_nlink;
|
|
|
|
inode->i_size = proc_ino->i_size;
|
|
|
|
inode->i_blocks = proc_ino->i_blocks;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-05-12 23:01:49 +02:00
|
|
|
return inode;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
|
|
|
|
{
|
|
|
|
struct inode *root_inode;
|
2008-02-16 00:37:00 +01:00
|
|
|
struct vfsmount *proc_mnt;
|
2008-02-23 10:53:53 +01:00
|
|
|
int err = -ENOENT;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-23 10:53:53 +01:00
|
|
|
proc_mnt = do_kern_mount("proc", 0, "proc", NULL);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (IS_ERR(proc_mnt))
|
2005-04-17 00:20:36 +02:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
sb->s_blocksize = 1024;
|
|
|
|
sb->s_blocksize_bits = 10;
|
|
|
|
sb->s_magic = HPPFS_SUPER_MAGIC;
|
|
|
|
sb->s_op = &hppfs_sbops;
|
2008-02-23 10:53:53 +01:00
|
|
|
sb->s_fs_info = proc_mnt;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
err = -ENOMEM;
|
2008-02-23 10:53:53 +01:00
|
|
|
root_inode = get_inode(sb, proc_mnt->mnt_sb->s_root);
|
|
|
|
if (!root_inode)
|
|
|
|
goto out_mntput;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
sb->s_root = d_alloc_root(root_inode);
|
2008-02-16 00:37:00 +01:00
|
|
|
if (!sb->s_root)
|
|
|
|
goto out_iput;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-16 00:37:00 +01:00
|
|
|
out_iput:
|
2005-04-17 00:20:36 +02:00
|
|
|
iput(root_inode);
|
2008-02-16 00:37:00 +01:00
|
|
|
out_mntput:
|
|
|
|
mntput(proc_mnt);
|
2005-04-17 00:20:36 +02:00
|
|
|
out:
|
|
|
|
return(err);
|
|
|
|
}
|
|
|
|
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 11:02:57 +02:00
|
|
|
static int hppfs_read_super(struct file_system_type *type,
|
|
|
|
int flags, const char *dev_name,
|
|
|
|
void *data, struct vfsmount *mnt)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 11:02:57 +02:00
|
|
|
return get_sb_nodev(type, flags, data, hppfs_fill_super, mnt);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct file_system_type hppfs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "hppfs",
|
|
|
|
.get_sb = hppfs_read_super,
|
|
|
|
.kill_sb = kill_anon_super,
|
|
|
|
.fs_flags = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init init_hppfs(void)
|
|
|
|
{
|
2008-02-16 00:37:00 +01:00
|
|
|
return register_filesystem(&hppfs_type);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_hppfs(void)
|
|
|
|
{
|
|
|
|
unregister_filesystem(&hppfs_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(init_hppfs)
|
|
|
|
module_exit(exit_hppfs)
|
|
|
|
MODULE_LICENSE("GPL");
|