Commit 9e87dd22 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (2/4) 2.5.5-pre1 fixes

helper for safe access to parent's inumber
parent e3a17d17
...@@ -79,7 +79,7 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -79,7 +79,7 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir)
stored++; stored++;
} }
if (f_pos == 1) { if (f_pos == 1) {
if (filldir(dirent, "..", 2, f_pos, filp->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) if (filldir(dirent, "..", 2, f_pos, parent_ino(filp->f_dentry), DT_DIR) < 0)
return stored; return stored;
filp->f_pos = f_pos = 2; filp->f_pos = f_pos = 2;
stored++; stored++;
......
...@@ -2678,7 +2678,7 @@ static int devfs_readdir (struct file *file, void *dirent, filldir_t filldir) ...@@ -2678,7 +2678,7 @@ static int devfs_readdir (struct file *file, void *dirent, filldir_t filldir)
case 0: case 0:
scan_dir_for_removable (parent); scan_dir_for_removable (parent);
err = (*filldir) (dirent, "..", 2, file->f_pos, err = (*filldir) (dirent, "..", 2, file->f_pos,
file->f_dentry->d_parent->d_inode->i_ino, DT_DIR); parent_ino(file->f_dentry), DT_DIR);
if (err == -EINVAL) break; if (err == -EINVAL) break;
if (err < 0) return err; if (err < 0) return err;
file->f_pos++; file->f_pos++;
......
...@@ -531,7 +531,7 @@ static int fat_readdirx(struct inode *inode, struct file *filp, void *dirent, ...@@ -531,7 +531,7 @@ static int fat_readdirx(struct inode *inode, struct file *filp, void *dirent,
if (!memcmp(de->name,MSDOS_DOT,11)) if (!memcmp(de->name,MSDOS_DOT,11))
inum = inode->i_ino; inum = inode->i_ino;
else if (!memcmp(de->name,MSDOS_DOTDOT,11)) { else if (!memcmp(de->name,MSDOS_DOTDOT,11)) {
inum = filp->f_dentry->d_parent->d_inode->i_ino; inum = parent_ino(filp->f_dentry);
} else { } else {
struct inode *tmp = fat_iget(sb, ino); struct inode *tmp = fat_iget(sb, ino);
if (tmp) { if (tmp) {
......
...@@ -185,7 +185,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, ...@@ -185,7 +185,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
/* Handle the case of the '..' directory */ /* Handle the case of the '..' directory */
if (de->name_len[0] == 1 && de->name[0] == 1) { if (de->name_len[0] == 1 && de->name[0] == 1) {
inode_number = filp->f_dentry->d_parent->d_inode->i_ino; inode_number = parent_ino(filp->f_dentry);
if (filldir(dirent, "..", 2, filp->f_pos, inode_number, DT_DIR) < 0) if (filldir(dirent, "..", 2, filp->f_pos, inode_number, DT_DIR) < 0)
break; break;
filp->f_pos += de_len; filp->f_pos += de_len;
......
...@@ -157,8 +157,8 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -157,8 +157,8 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir)
offset++; offset++;
} }
if (offset == 1) { if (offset == 1) {
D1(printk(KERN_DEBUG "Dirent 1: \"..\", ino #%lu\n", filp->f_dentry->d_parent->d_inode->i_ino)); D1(printk(KERN_DEBUG "Dirent 1: \"..\", ino #%lu\n", parent_ino(filp->f_dentry)));
if (filldir(dirent, "..", 2, 1, filp->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) if (filldir(dirent, "..", 2, 1, parent_ino(filp->f_dentry), DT_DIR) < 0)
goto out; goto out;
offset++; offset++;
} }
......
...@@ -411,8 +411,7 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -411,8 +411,7 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
filp->f_pos = 1; filp->f_pos = 1;
} }
if (filp->f_pos == 1) { if (filp->f_pos == 1) {
if (filldir(dirent, "..", 2, 1, if (filldir(dirent, "..", 2, 1, parent_ino(dentry), DT_DIR))
dentry->d_parent->d_inode->i_ino, DT_DIR))
goto out; goto out;
filp->f_pos = 2; filp->f_pos = 2;
} }
......
...@@ -754,7 +754,7 @@ inline int _fh_update(struct dentry *dentry, struct svc_export *exp, ...@@ -754,7 +754,7 @@ inline int _fh_update(struct dentry *dentry, struct svc_export *exp,
*maxsize = 2; *maxsize = 2;
return 1; return 1;
} }
*datap++ = ino_t_to_u32(dentry->d_parent->d_inode->i_ino); *datap++ = ino_t_to_u32(parent_ino(dentry));
*maxsize = 3; *maxsize = 3;
return 2; return 2;
} }
...@@ -814,7 +814,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, st ...@@ -814,7 +814,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, st
fhp->fh_handle.ofh_dev = htonl((major(exp->ex_dev)<<16)| minor(exp->ex_dev)); fhp->fh_handle.ofh_dev = htonl((major(exp->ex_dev)<<16)| minor(exp->ex_dev));
fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev; fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev;
fhp->fh_handle.ofh_xino = ino_t_to_u32(exp->ex_ino); fhp->fh_handle.ofh_xino = ino_t_to_u32(exp->ex_ino);
fhp->fh_handle.ofh_dirino = ino_t_to_u32(dentry->d_parent->d_inode->i_ino); fhp->fh_handle.ofh_dirino = ino_t_to_u32(parent_ino(dentry));
if (inode) if (inode)
_fh_update_old(dentry, exp, &fhp->fh_handle); _fh_update_old(dentry, exp, &fhp->fh_handle);
} else { } else {
......
...@@ -276,10 +276,9 @@ static int ntfs_readdir(struct file* filp, void *dirent, filldir_t filldir) ...@@ -276,10 +276,9 @@ static int ntfs_readdir(struct file* filp, void *dirent, filldir_t filldir)
ntfs_debug(DEBUG_OTHER, __FUNCTION__ "(): Calling " ntfs_debug(DEBUG_OTHER, __FUNCTION__ "(): Calling "
"filldir for .. with len 2, f_pos 0x%Lx, " "filldir for .. with len 2, f_pos 0x%Lx, "
"inode %lu, DT_DIR.\n", filp->f_pos, "inode %lu, DT_DIR.\n", filp->f_pos,
filp->f_dentry->d_parent->d_inode->i_ino); parent_ino(filp->f_dentry));
cb.ret_code = filldir(dirent, "..", 2, filp->f_pos, cb.ret_code = filldir(dirent, "..", 2, filp->f_pos,
filp->f_dentry->d_parent->d_inode->i_ino, parent_ino(filp->f_dentry), DT_DIR);
DT_DIR);
if (cb.ret_code) if (cb.ret_code)
goto done; goto done;
cb.pl++; cb.pl++;
......
...@@ -319,7 +319,7 @@ int proc_readdir(struct file * filp, ...@@ -319,7 +319,7 @@ int proc_readdir(struct file * filp,
/* fall through */ /* fall through */
case 1: case 1:
if (filldir(dirent, "..", 2, i, if (filldir(dirent, "..", 2, i,
filp->f_dentry->d_parent->d_inode->i_ino, parent_ino(filp->f_dentry),
DT_DIR) < 0) DT_DIR) < 0)
return 0; return 0;
i++; i++;
......
...@@ -52,7 +52,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir) ...@@ -52,7 +52,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
filp->f_pos++; filp->f_pos++;
/* fallthrough */ /* fallthrough */
case 1: case 1:
if (filldir(dirent, "..", 2, i, dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) if (filldir(dirent, "..", 2, i, parent_ino(dentry), DT_DIR) < 0)
break; break;
i++; i++;
filp->f_pos++; filp->f_pos++;
......
...@@ -82,8 +82,7 @@ smb_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -82,8 +82,7 @@ smb_readdir(struct file *filp, void *dirent, filldir_t filldir)
filp->f_pos = 1; filp->f_pos = 1;
/* fallthrough */ /* fallthrough */
case 1: case 1:
if (filldir(dirent, "..", 2, 1, if (filldir(dirent, "..", 2, 1, parent_ino(dentry), DT_DIR) < 0)
dentry->d_parent->d_inode->i_ino, DT_DIR) < 0)
goto out; goto out;
filp->f_pos = 2; filp->f_pos = 2;
} }
......
...@@ -1508,6 +1508,15 @@ extern int generic_osync_inode(struct inode *, int); ...@@ -1508,6 +1508,15 @@ extern int generic_osync_inode(struct inode *, int);
extern int inode_change_ok(struct inode *, struct iattr *); extern int inode_change_ok(struct inode *, struct iattr *);
extern int inode_setattr(struct inode *, struct iattr *); extern int inode_setattr(struct inode *, struct iattr *);
static inline ino_t parent_ino(struct dentry *dentry)
{
ino_t res;
spin_lock(&dcache_lock);
res = dentry->d_parent->d_inode->i_ino;
spin_unlock(&dcache_lock);
return res;
}
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _LINUX_FS_H */ #endif /* _LINUX_FS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment