mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-11 20:58:50 +03:00
These files are now a bit closer towards what I'm aiming at. Still a lot
more to do though.
This commit is contained in:
parent
ab05a11ef5
commit
a71f36113c
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* dmfs-dir.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_unlink(struct inode *dir, struct dentry *dentry)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dmfs_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_lookup(struct inode *dir, struct dentry *dentry)
|
|
||||||
{
|
|
||||||
d_add(dentry, NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dmfs_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_dir_sync(struct file *file, struct dentry *dentry, int datasync)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct dm_dir_file_operations = {
|
|
||||||
read: generic_read_dir,
|
|
||||||
readdir: dcache_readdir,
|
|
||||||
fsync: dmfs_dir_sync,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct dm_dir_inode_operations = {
|
|
||||||
create: dmfs_create_file,
|
|
||||||
lookup: dmfs_dir_lookup,
|
|
||||||
link: dmfs_dir_link,
|
|
||||||
unlink: dmfs_dir_unlink,
|
|
||||||
rename: dmfs_dir_rename,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct inode *dmfs_create_dir(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_dir_file_operations;
|
|
||||||
inode->i_op = &dmfs_dir_dir_operations;
|
|
||||||
}
|
|
||||||
|
|
||||||
return inode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* dmfs-file.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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static ssize_t dmfs_read(struct file *file, char *buf, size_t size, loff_t *pos)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t dmfs_write(struct file *file, const char *buf, size_t size, loff_t *pos)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dmfs_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_file_sync(struct file *file, struct dentry *dentry, int datasync)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct dm_file_file_operations = {
|
|
||||||
/* llseek: generic_file_llseek, */
|
|
||||||
read: dmfs_read,
|
|
||||||
write: dmfs_write,
|
|
||||||
open: dmfs_open,
|
|
||||||
fsync: dmfs_file_sync,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct dm_file_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_file_file_operations;
|
|
||||||
inode->i_op = &dmfs_file_inode_operations;
|
|
||||||
}
|
|
||||||
|
|
||||||
return inode;
|
|
||||||
}
|
|
||||||
|
|
@ -38,22 +38,31 @@ static int is_identifier(const char *str, int len)
|
|||||||
static int dmfs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
|
static int dmfs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
|
||||||
{
|
{
|
||||||
struct super_block *sb = dir->i_sb;
|
struct super_block *sb = dir->i_sb;
|
||||||
int rv;
|
struct inode *inode;
|
||||||
|
struct mapped_device *md;
|
||||||
|
|
||||||
if (!is_identifier(name, dentry->d_name.len))
|
if (!is_identifier(name, dentry->d_name.len))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
rv = dmfs_create_lv(dir, dentry, mode);
|
inode = dmfs_create_lv(dir, dentry, mode);
|
||||||
if (rv == 0) {
|
if (!IS_ERR(inode)) {
|
||||||
rv = dm_create(name, -1);
|
md = dm_create(name, -1);
|
||||||
|
if (!IS_ERR(md)) {
|
||||||
|
inode->u.generic_ip = md;
|
||||||
|
md->inode = inode;
|
||||||
|
d_instantiate(dentry, inode);
|
||||||
|
dget(dentry);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
iput(inode);
|
||||||
|
return PTR_ERR(md);
|
||||||
}
|
}
|
||||||
|
return PTR_ERR(inode);
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline positive(struct dentry *dentry)
|
static inline positive(struct dentry *dentry)
|
||||||
{
|
{
|
||||||
return dentry->d_inode && ! d_unhashed(dentry);
|
return dentry->d_inode && !d_unhashed(dentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int empty(struct dentry *dentry)
|
static int empty(struct dentry *dentry)
|
||||||
|
@ -33,18 +33,18 @@ static int dmfs_statfs(struct super_block *sb, struct statfs *buf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dmfs_delete_inode(struct inode *inode)
|
static void dmfs_delete_inode(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
|
|
||||||
switch(inode->i_mode & S_IFMT) {
|
switch(inode->i_mode & S_IFMT) {
|
||||||
case S_IFDIR:
|
case S_IFDIR:
|
||||||
if (DMFS_LVI(inode))
|
if (inode->u.generic_ip) {
|
||||||
dmfs_lv_put_inode(inode);
|
dm_remove((struct mapped_device *)inode->u.generic_ip);
|
||||||
|
inode->u.generic_ip = NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case S_IFREG:
|
case S_IFREG:
|
||||||
if (DMFS_TI(inode))
|
|
||||||
dmfs_table_put_inode(inode);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user