From: arnd@arndb.de
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hch@lst.de
Subject: [RFC 7/7] cramfs: add missing inode operations
Date: Sat, 31 May 2008 17:20:20 +0200 [thread overview]
Message-ID: <20080531153511.331589811@arndb.de> (raw)
In-Reply-To: 20080531152013.031903990@arndb.de
[-- Attachment #1: 0007-cramfs-add-missing-inode-operations.patch --]
[-- Type: text/plain, Size: 2943 bytes --]
This adds support for create, link, symlink, mkdir, mknod
and rename, all of which are relatively simple to do based
on the previous patches.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/cramfs/inode.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index e7d2b47..bcdd592 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -557,6 +557,78 @@ int cramfs_rmdir(struct inode *dir, struct dentry *dentry)
}
/*
+ * File creation. Allocate an inode, and we're done..
+ */
+static int
+cramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
+{
+ struct inode * inode = get_cramfs_inode(dir->i_sb, mode, dev);
+ int error = -ENOSPC;
+
+ if (inode) {
+ if (dir->i_mode & S_ISGID) {
+ inode->i_gid = dir->i_gid;
+ if (S_ISDIR(mode))
+ inode->i_mode |= S_ISGID;
+ }
+ d_instantiate(dentry, inode);
+ dget(dentry); /* Extra count - pin the dentry in core */
+ error = 0;
+ dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+ }
+ return error;
+}
+
+static int cramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
+{
+ return cramfs_mknod(dir, dentry, mode | S_IFDIR, 0);
+}
+
+static int cramfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
+{
+ return cramfs_mknod(dir, dentry, mode | S_IFREG, 0);
+}
+
+static int cramfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
+{
+ struct inode *inode;
+ int error = -ENOSPC;
+
+ inode = get_cramfs_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
+ if (inode) {
+ int l = strlen(symname)+1;
+ error = page_symlink(inode, symname, l);
+ if (!error) {
+ if (dir->i_mode & S_ISGID)
+ inode->i_gid = dir->i_gid;
+ d_instantiate(dentry, inode);
+ dget(dentry);
+ dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+ } else
+ iput(inode);
+ }
+ return error;
+}
+
+int cramfs_rename(struct inode *old_dir, struct dentry *old_dentry,
+ struct inode *new_dir, struct dentry *new_dentry)
+{
+ struct inode *inode = old_dentry->d_inode;
+
+ if (!cramfs_empty(new_dentry))
+ return -ENOTEMPTY;
+
+ if (new_dentry->d_inode)
+ cramfs_unlink(new_dir, new_dentry);
+
+ old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
+ new_dir->i_mtime = inode->i_ctime = CURRENT_TIME;
+
+ return 0;
+}
+
+
+/*
* Lookup and fill in the inode data..
*/
static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
@@ -688,8 +760,14 @@ static const struct file_operations cramfs_directory_operations = {
};
static const struct inode_operations cramfs_dir_inode_operations = {
+ .create = cramfs_create,
+ .link = simple_link,
.unlink = cramfs_unlink,
+ .symlink = cramfs_symlink,
+ .mkdir = cramfs_mkdir,
.rmdir = cramfs_rmdir,
+ .mknod = cramfs_mknod,
+ .rename = cramfs_rename,
.lookup = cramfs_lookup,
};
--
1.5.4.3
--
prev parent reply other threads:[~2008-05-31 15:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080531152013.031903990@arndb.de>
2008-05-31 15:20 ` [RFC 1/7] cramfs: allow remount rw arnd
2008-05-31 15:20 ` [RFC 2/7] cramfs: create unique inode numbers arnd
2008-06-01 16:50 ` Jörn Engel
2008-06-01 21:24 ` Arnd Bergmann
2008-06-02 5:42 ` Jörn Engel
2008-05-31 15:20 ` [RFC 3/7] cramfs: allow unlinking of files arnd
2008-06-01 16:54 ` Jörn Engel
2008-06-01 21:28 ` Arnd Bergmann
2008-05-31 15:20 ` [RFC 4/7] cramfs: allow rmdir arnd
2008-05-31 15:20 ` [RFC 5/7] cramfs: allow writing to existing files arnd
2008-05-31 15:20 ` [RFC 6/7] cramfs: read directory entries from dcache arnd
2008-05-31 15:20 ` arnd [this message]
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=20080531153511.331589811@arndb.de \
--to=arnd@arndb.de \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox