3 @@ -34,6 +34,9 @@ static int jffs2_mknod (struct inode *,s
4 static int jffs2_rename (struct inode *, struct dentry *,
5 struct inode *, struct dentry *);
7 +static int jffs2_whiteout (struct inode *, struct dentry *, struct dentry *);
8 +static int jffs2_fallthru (struct inode *, struct dentry *);
10 const struct file_operations jffs2_dir_operations =
12 .read = generic_read_dir,
13 @@ -55,6 +58,8 @@ const struct inode_operations jffs2_dir_
16 .rename = jffs2_rename,
17 + .fallthru = jffs2_fallthru,
18 + .whiteout = jffs2_whiteout,
19 .check_acl = jffs2_check_acl,
20 .setattr = jffs2_setattr,
21 .setxattr = jffs2_setxattr,
22 @@ -98,8 +103,21 @@ static struct dentry *jffs2_lookup(struc
29 + spin_lock(&target->d_lock);
32 + target->d_flags |= DCACHE_WHITEOUT;
35 + target->d_flags |= DCACHE_FALLTHRU;
41 + spin_unlock(&target->d_lock);
43 mutex_unlock(&dir_f->sem);
45 inode = jffs2_iget(dir_i->i_sb, ino);
46 @@ -155,7 +173,9 @@ static int jffs2_readdir(struct file *fi
47 fd->name, fd->ino, fd->type, curofs, offset));
51 + if (fd->type == DT_UNKNOWN)
52 + fd->ino = 100; /* XXX: arbitrary */
53 + else if (!fd->ino && (fd->type != DT_WHT)) {
54 D2(printk(KERN_DEBUG "Skipping deletion dirent \"%s\"\n", fd->name));
57 @@ -498,6 +518,11 @@ static int jffs2_mkdir (struct inode *di
58 return PTR_ERR(inode);
61 + if (dentry->d_flags & DCACHE_WHITEOUT) {
62 + inode->i_flags |= S_OPAQUE;
63 + ri->flags = cpu_to_je16(JFFS2_INO_FLAG_OPAQUE);
66 inode->i_op = &jffs2_dir_inode_operations;
67 inode->i_fop = &jffs2_dir_operations;
69 @@ -779,6 +804,82 @@ static int jffs2_mknod (struct inode *di
73 +static int jffs2_fallthru (struct inode *dir, struct dentry *dentry)
75 + struct jffs2_sb_info *c = JFFS2_SB_INFO(dir->i_sb);
79 + now = get_seconds();
80 + ret = jffs2_do_link(c, JFFS2_INODE_INFO(dir), 0, DT_UNKNOWN,
81 + dentry->d_name.name, dentry->d_name.len, now);
85 + d_instantiate(dentry, NULL);
86 + spin_lock(&dentry->d_lock);
87 + dentry->d_flags |= DCACHE_FALLTHRU;
88 + spin_unlock(&dentry->d_lock);
93 +static int jffs2_whiteout (struct inode *dir, struct dentry *old_dentry,
94 + struct dentry *new_dentry)
96 + struct jffs2_sb_info *c = JFFS2_SB_INFO(dir->i_sb);
97 + struct jffs2_inode_info *victim_f = NULL;
101 + /* If it's a directory, then check whether it is really empty
103 + if (new_dentry->d_inode) {
104 + victim_f = JFFS2_INODE_INFO(old_dentry->d_inode);
105 + if (S_ISDIR(old_dentry->d_inode->i_mode)) {
106 + struct jffs2_full_dirent *fd;
108 + mutex_lock(&victim_f->sem);
109 + for (fd = victim_f->dents; fd; fd = fd->next) {
111 + mutex_unlock(&victim_f->sem);
115 + mutex_unlock(&victim_f->sem);
119 + now = get_seconds();
120 + ret = jffs2_do_link(c, JFFS2_INODE_INFO(dir), 0, DT_WHT,
121 + new_dentry->d_name.name, new_dentry->d_name.len, now);
125 + spin_lock(&new_dentry->d_lock);
126 + new_dentry->d_flags &= ~DCACHE_FALLTHRU;
127 + new_dentry->d_flags |= DCACHE_WHITEOUT;
128 + spin_unlock(&new_dentry->d_lock);
129 + d_add(new_dentry, NULL);
132 + /* There was a victim. Kill it off nicely */
133 + drop_nlink(old_dentry->d_inode);
134 + /* Don't oops if the victim was a dirent pointing to an
135 + inode which didn't exist. */
136 + if (victim_f->inocache) {
137 + mutex_lock(&victim_f->sem);
138 + if (S_ISDIR(old_dentry->d_inode->i_mode))
139 + victim_f->inocache->pino_nlink = 0;
141 + victim_f->inocache->pino_nlink--;
142 + mutex_unlock(&victim_f->sem);
149 static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
150 struct inode *new_dir_i, struct dentry *new_dentry)
154 @@ -301,6 +301,10 @@ struct inode *jffs2_iget(struct super_bl
156 inode->i_op = &jffs2_dir_inode_operations;
157 inode->i_fop = &jffs2_dir_operations;
159 + if (je16_to_cpu(latest_node.flags) & JFFS2_INO_FLAG_OPAQUE)
160 + inode->i_flags |= S_OPAQUE;
165 --- a/fs/jffs2/super.c
166 +++ b/fs/jffs2/super.c
167 @@ -172,7 +172,7 @@ static int jffs2_fill_super(struct super
169 sb->s_op = &jffs2_super_operations;
170 sb->s_export_op = &jffs2_export_ops;
171 - sb->s_flags = sb->s_flags | MS_NOATIME;
172 + sb->s_flags = sb->s_flags | MS_NOATIME | MS_WHITEOUT;
173 sb->s_xattr = jffs2_xattr_handlers;
174 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
175 sb->s_flags |= MS_POSIXACL;
176 --- a/include/linux/jffs2.h
177 +++ b/include/linux/jffs2.h
179 #define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
182 +#define JFFS2_INO_FLAG_OPAQUE 4 /* Directory is opaque (for union mounts) */
185 /* These can go once we've made sure we've caught all uses without