13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 #include <linux/kernel.h>
16 #include <linux/slab.h>
22 #include <linux/time.h>
32 static int jffs2_unlink (
struct inode *,
struct dentry *);
33 static int jffs2_symlink (
struct inode *,
struct dentry *,
const char *);
35 static int jffs2_rmdir (
struct inode *,
struct dentry *);
37 static int jffs2_rename (
struct inode *,
struct dentry *,
43 .readdir = jffs2_readdir,
52 .create = jffs2_create,
53 .lookup = jffs2_lookup,
55 .unlink = jffs2_unlink,
56 .symlink = jffs2_symlink,
60 .rename = jffs2_rename,
94 for (fd_list = dir_f->
dents; fd_list && fd_list->nhash <= target->
d_name.hash; fd_list = fd_list->next) {
95 if (fd_list->nhash == target->
d_name.hash &&
108 pr_warn(
"iget() failed for ino #%u\n", ino);
120 struct inode *inode = filp->
f_path.dentry->d_inode;
122 unsigned long offset, curofs;
124 jffs2_dbg(1,
"jffs2_readdir() for dir_i #%lu\n",
125 filp->
f_path.dentry->d_inode->i_ino);
129 offset = filp->
f_pos;
133 if (filldir(dirent,
".", 1, 0, inode->
i_ino,
DT_DIR) < 0)
139 jffs2_dbg(1,
"Dirent 1: \"..\", ino #%lu\n", pino);
140 if (filldir(dirent,
"..", 2, 1, pino,
DT_DIR) < 0)
151 if (curofs < offset) {
152 jffs2_dbg(2,
"Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n",
157 jffs2_dbg(2,
"Skipping deletion dirent \"%s\"\n",
162 jffs2_dbg(2,
"Dirent %ld: \"%s\", ino #%u, type %d\n",
177 static int jffs2_create(
struct inode *dir_i,
struct dentry *
dentry,
197 jffs2_dbg(1,
"jffs2_new_inode() failed\n");
199 return PTR_ERR(inode);
225 jffs2_dbg(1,
"%s(): Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n",
242 static int jffs2_unlink(
struct inode *dir_i,
struct dentry *dentry)
251 dentry->
d_name.len, dead_f, now);
261 static int jffs2_link (
struct dentry *old_dentry,
struct inode *dir_i,
struct dentry *dentry)
297 static int jffs2_symlink (
struct inode *dir_i,
struct dentry *dentry,
const char *target)
325 namelen = dentry->
d_name.len;
339 return PTR_ERR(inode);
346 inode->
i_size = targetlen;
370 pr_warn(
"Can't allocate %d bytes of memory\n", targetlen + 1);
377 jffs2_dbg(1,
"%s(): symlink's target '%s' cached\n",
378 __func__, (
char *)f->
target);
459 static int jffs2_mkdir (
struct inode *dir_i,
struct dentry *dentry,
umode_t mode)
483 namelen = dentry->
d_name.len;
497 return PTR_ERR(inode);
603 static int jffs2_rmdir (
struct inode *dir_i,
struct dentry *dentry)
612 for (fd = f->
dents ; fd; fd = fd->
next) {
618 dentry->
d_name.len, f, now);
627 static int jffs2_mknod (
struct inode *dir_i,
struct dentry *dentry,
umode_t mode,
dev_t rdev)
642 if (!new_valid_dev(rdev))
652 devlen = jffs2_encode_dev(&
dev, rdev);
657 namelen = dentry->
d_name.len;
671 return PTR_ERR(inode);
778 static int jffs2_rename (
struct inode *old_dir_i,
struct dentry *old_dentry,
779 struct inode *new_dir_i,
struct dentry *new_dentry)
798 for (fd = victim_f->
dents; fd; fd = fd->
next) {
821 old_dentry->
d_inode->i_ino, type,
865 pr_notice(
"%s(): Link succeeded, unlink failed (err %d). You now have a hard link\n",