1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

o New file dmfs-super.c

o dmfs-dir.c becomes dmfs-lv.c
 o dmfs-file.c becomes dmfs-table.c
 o A few tweeks and updates

The main reason for the slow progress on these files (which are not yet used
by the device mapper) is that we are working out what this interface should
look like as we go along.

Once this has evolved a bit further and in a state where it can be used we'll
announce it on the lists for further comment.
This commit is contained in:
Steven Whitehouse 2001-09-18 15:38:54 +00:00
parent 7c913930fe
commit 710bb6996d
4 changed files with 265 additions and 2 deletions

View File

@ -0,0 +1,98 @@
/*
* dmfs-lv.c
*
* Copyright (C) 2001 Sistina Software
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2, or (at
* your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* Heavily based upon ramfs */
static int dmfs_lv_unlink(struct inode *dir, struct dentry *dentry)
{
}
static int dmfs_lv_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
{
struct inode *inode = old_dentry->d_inode;
if (!S_ISREG(inode->i_mode))
return -EPERM;
if (dentry->d_parent != old_dentry->d_parent)
return -EPERM;
inode->i_ctime = CURRENT_TIME;
return 0;
}
static struct dentry *dmfs_lv_lookup(struct inode *dir, struct dentry *dentry)
{
d_add(dentry, NULL);
return NULL;
}
static int dmfs_lv_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry)
{
if (old_dir != new_dir)
return -EPERM;
return 0;
}
static int dmfs_lv_sync(struct file *file, struct dentry *dentry, int datasync)
{
return 0;
}
static struct dmfs_lv_file_operations = {
read: generic_read_dir,
readdir: dcache_readdir,
fsync: dmfs_lv_sync,
};
static struct dmfs_lv_inode_operations = {
create: dmfs_create_file,
lookup: dmfs_lv_lookup,
link: dmfs_lv_link,
unlink: dmfs_lv_unlink,
rename: dmfs_lv_rename,
};
struct inode *dmfs_create_lv(struct inode *dir, struct dentry *dentry, int mode)
{
struct inode *inode = new_inode(sb);
if (inode) {
inode->i_mode = mode | S_IFDIR;
inode->i_uid = current->fsuid;
inode->i_gid = current->fsgid;
inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_blocks = 0;
inode->i_rdev = NODEV;
inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME;
inode->i_fop = &dmfs_lv_file_operations;
inode->i_op = &dmfs_lv_dir_operations;
}
return inode;
}

View File

@ -21,6 +21,10 @@
/* Heavily based upon ramfs */
#include <linux/config.h>
#include <linux/ctype.h>
#include <linux/fs.h>
static int is_identifier(const char *str, int len)
{
while(len--) {
@ -39,7 +43,7 @@ static int dmfs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (!is_identifier(name, dentry->d_name.len))
return -EPERM;
rv = dmfs_create_dir(dir, dentry, mode);
rv = dmfs_create_lv(dir, dentry, mode);
if (rv == 0) {
rv = dm_create(name, -1);
}
@ -100,7 +104,7 @@ static int dmfs_root_rename(struct inode *old_dir, struct dentry *old_dentry,
if (old_dir != new_dir)
return -EPERM;
return -EINVAL; /* FIXME: so a change of LV name here */
return -EINVAL; /* FIXME: a change of LV name here */
}
static int dmfs_root_sync(struct file *file, struct dentry *dentry, int datasync)

View File

@ -0,0 +1,84 @@
/*
* dmfs-super.c
*
* Copyright (C) 2001 Sistina Software
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2, or (at
* your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <linux/config.h>
#include <linux/fs.h>
#define DMFS_MAGIC 0x444D4653
static int dmfs_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = sb->s_magic;
buf->f_bsize = sb->s_blocksize;
buf->f_namelen = DM_NAME_LEN - 1;
return 0;
}
static int dmfs_delete_inode(struct inode *inode)
{
struct super_block *sb = inode->i_sb;
switch(inode->i_mode & S_IFMT) {
case S_IFDIR:
if (DMFS_LVI(inode))
dmfs_lv_put_inode(inode);
break;
case S_IFREG:
if (DMFS_TI(inode))
dmfs_table_put_inode(inode);
break;
}
clear_inode(inode);
}
static struct super_operations dmfs_super_operations = {
statfs: dmfs_statfs,
put_inode: force_delete,
delete_inode: dmfs_delete_inode,
};
struct super_block *dmfs_read_super(struct super_block *sb, void *data, int silent)
{
struct inode *inode;
struct dentry *root;
sb->s_blocksize = PAGE_CACHE_SIZE;
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
sb->s_magic = DMFS_MAGIC;
sb->s_ops = &dmfs_super_operations;
sb->s_maxbytes = MAX_NON_LFS;
inode = dmfs_create_root(sb, 0755);
if (IS_ERR(inode))
return NULL;
root = d_alloc_root(inode);
if (!root) {
iput(inode);
return NULL;
}
sb->s_root = root;
return sb;
}

View File

@ -0,0 +1,77 @@
/*
* dmfs-table.c
*
* Copyright (C) 2001 Sistina Software
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2, or (at
* your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <linux/config.h>
#include <linux/fs.h>
static ssize_t dmfs_table_read(struct file *file, char *buf, size_t size, loff_t *pos)
{
}
static ssize_t dmfs_table_write(struct file *file, const char *buf, size_t size, loff_t *pos)
{
}
static int dmfs_table_open(struct inode *inode, struct file *file)
{
struct dentry *dentry = file->f_dentry;
if (dentry->name.len == 6 && memcmp("ACTIVE", dentry->name.name, 6) == 0)
return -EPERM;
return 0;
}
static int dmfs_table_sync(struct file *file, struct dentry *dentry, int datasync)
{
return 0;
}
static struct dm_table_file_operations = {
/* llseek: generic_file_llseek, */
read: dmfs_read,
write: dmfs_write,
open: dmfs_open,
fsync: dmfs_table_sync,
};
static struct dmfs_table_inode_operations = {
};
int dmfs_create_file(struct inode *dir, struct dentry *dentry, int mode)
{
struct inode *inode = new_inode(dir->i_sb);
if (inode) {
inode->i_mode = mode | S_IFREG;
inode->i_uid = current->fsuid;
inode->i_gid = current->fsgid;
inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_blocks = 0;
inode->i_rdev = NODEV;
inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME;
inode->i_fop = &dmfs_table_file_operations;
inode->i_op = &dmfs_table_inode_operations;
}
return inode;
}