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;
+}...