From: Christoph Hellwig <hch@infradead.org>
To: Tom Zanussi <zanussi@us.ibm.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Greg KH <greg@kroah.com>, Andrew Morton <akpm@osdl.org>,
Andi Kleen <ak@muc.de>, Roman Zippel <zippel@linux-m68k.org>,
Robert Wisniewski <bob@watson.ibm.com>,
Tim Bird <tim.bird@AM.SONY.COM>,
karim@opersys.com
Subject: Re: [PATCH] relayfs redux, part 3
Date: Fri, 4 Feb 2005 21:39:09 +0000 [thread overview]
Message-ID: <20050204213909.GA26241@infradead.org> (raw)
In-Reply-To: <16899.55393.651042.627079@tut.ibm.com>
in the filesystem path especially relayfs_create_entry and the functions
called by it seem overly complex, probably because copying from ramfs
which allows namespace operations from userland. See the totally untested
code below for how it could be done more cleanly.
What I really dislike is the code for automatically creating complex
hiearchies. What kinds of hierachies does LTT use? It shouldn't be
more than subsystem/{stream1, stream2, ..., streamN}, right? In that
case I think we could leave it to the user to take of that himself.
static struct inode *relayfs_get_inode(struct super_block *sb, int mode)
{
struct inode * inode = new_inode(sb);
if (!inode)
return NULL;
inode->i_mode = mode;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_blocks = 0;
inode->i_mapping->backing_dev_info = &relayfs_backing_dev_info;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch (mode & S_IFMT) {
case S_IFREG:
inode->i_fop = &relayfs_file_operations;
break;
case S_IFDIR:
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
/*
* directory inodes start off with i_nlink == 2 (for "." entry)
*/
inode->i_nlink++;
break;
default:
break;
}
return inode;
}
/**
* relayfs_create_entry - create a relayfs directory or file
* @name: the name of the file to create
* @parent: parent directory
* @dentry: result dentry
* @mode: mode
* @data: data to associate with the file
*
* Creates a file or directory with the specifed permissions.
*/
static int relayfs_create_entry(const char *name, struct dentry *parent,
struct dentry **dentry, int mode, void *data)
{
struct qstr qname;
struct dentry *d;
struct inode *inode;
int error = 0;
BUG_ON(!S_ISREG(mode) || !S_ISDIR(mode));
error = simple_pin_fs("relayfs", &relayfs_mount, &relayfs_mount_count);
if (error) {
printk(KERN_ERR "Couldn't mount relayfs: errcode %d\n", error);
return error;
}
qname.name = name;
qname.len = strlen(name);
qname.hash = full_name_hash(name, qname.len);
if (parent == NULL)
if (relayfs_mount && relayfs_mount->mnt_sb)
parent = relayfs_mount->mnt_sb->s_root;
if (parent == NULL) {
simple_release_fs(&relayfs_mount, &relayfs_mount_count);
return -EINVAL;
}
parent = dget(parent);
down(&parent->d_inode->i_sem);
d = lookup_hash(&qname, parent);
if (IS_ERR(d)) {
error = PTR_ERR(d);
goto release_mount;
}
if (d->d_inode) {
error = -EEXIST;
goto release_mount;
}
inode = relayfs_get_inode(parent->d_inode->i_sb, mode);
if (!inode) {
error = -ENOSPC;
goto release_mount;
}
d_instantiate(d, inode);
dget(d); /* Extra count - pin the dentry in core */
if (mode & S_IFREG)
d->d_inode->u.generic_ip = data;
else
parent->d_inode->i_nlink++;
error = 0;
goto exit;
release_mount:
simple_release_fs(&relayfs_mount, &relayfs_mount_count);
exit:
*dentry = d;
up(&parent->d_inode->i_sem);
dput(parent);
return error;
}
next prev parent reply other threads:[~2005-02-04 22:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-04 20:17 [PATCH] relayfs redux, part 3 Tom Zanussi
2005-02-04 21:10 ` Christoph Hellwig
2005-02-04 22:00 ` Tom Zanussi
2005-02-04 21:39 ` Christoph Hellwig [this message]
2005-02-04 22:06 ` Tom Zanussi
2005-02-04 22:12 ` Andi Kleen
2005-02-04 22:22 ` Tom Zanussi
2005-02-05 6:57 ` Andi Kleen
2005-02-05 9:54 ` [PATCH] relayfs redux, part 3 II - another comment Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050204213909.GA26241@infradead.org \
--to=hch@infradead.org \
--cc=ak@muc.de \
--cc=akpm@osdl.org \
--cc=bob@watson.ibm.com \
--cc=greg@kroah.com \
--cc=karim@opersys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tim.bird@AM.SONY.COM \
--cc=zanussi@us.ibm.com \
--cc=zippel@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.