2
0
Fork 0

Change namei/dput to user_path_walk/path_release for

compatibility with 2.3.99 and later.
This commit is contained in:
jaggy 2001-08-28 11:34:07 +00:00
parent c2c8ee5553
commit 7a5f0bea03
8 changed files with 102 additions and 88 deletions

View file

@ -1,5 +1,9 @@
Tue Aug 28 10:29:06 BST 2001
* Change namei/dput to user_path_walk/path_release for
compatibility with 2.3.99 and later.
-- Mike
* Minor fixes to support up 2.2.19 kernels.
-- Mike

View file

@ -3,7 +3,7 @@
*
* Copyright (C) 1994 Mike Jagdis
*
* $Id: bsd.c,v 1.18 1998/08/15 22:52:41 jaggy Exp $
* $Id: bsd.c,v 1.19 2001/08/28 11:34:07 jaggy Exp $
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/iBCSemul/bsd.c,v $
*/
@ -248,7 +248,7 @@ copy_statfs(struct bsd_statfs *buf, struct statfs *st)
int
bsd_statfs(const char *path, struct bsd_statfs *buf)
{
struct dentry *dentry;
struct nameidata nd;
struct statfs st;
int error;
mm_segment_t old_fs;
@ -258,10 +258,9 @@ bsd_statfs(const char *path, struct bsd_statfs *buf)
return error;
lock_kernel();
dentry = namei(path);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
struct inode *inode = dentry->d_inode;
error = user_path_walk(path, &nd);
if (!error) {
struct inode *inode = nd.dentry->d_inode;
error = -ENOSYS;
if (inode->i_sb->s_op->statfs) {
old_fs = get_fs();
@ -273,7 +272,7 @@ bsd_statfs(const char *path, struct bsd_statfs *buf)
copy_statfs(buf, &st);
}
dput(dentry);
path_release(&nd);
}
unlock_kernel();
return error;

View file

@ -3,7 +3,7 @@
*
* Copyright (C) 1994 Mike Jagdis
*
* $Id: bsdstat.c,v 1.9 1998/06/24 20:34:15 jaggy Exp $
* $Id: bsdstat.c,v 1.10 2001/08/28 11:34:07 jaggy Exp $
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/iBCSemul/bsdstat.c,v $
*/
@ -55,19 +55,16 @@ cp_bsd_stat(struct inode *inode, struct bsd_stat *st)
int
bsd_stat(char *filename, struct bsd_stat *st)
{
struct dentry * dentry;
struct nameidata nd;
int error;
lock_kernel();
dentry = namei(filename);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = do_revalidate(dentry);
error = user_path_walk(filename, &nd);
if (!error) {
error = do_revalidate(nd.dentry);
if (!error)
error = cp_bsd_stat(dentry->d_inode, st);
dput(dentry);
error = cp_bsd_stat(nd.dentry->d_inode, st);
path_release(&nd);
}
unlock_kernel();
return error;
@ -76,19 +73,16 @@ bsd_stat(char *filename, struct bsd_stat *st)
int
bsd_lstat(char *filename, struct bsd_stat *st)
{
struct dentry * dentry;
struct nameidata nd;
int error;
lock_kernel();
dentry = lnamei(filename);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = do_revalidate(dentry);
error = user_path_walk_link(filename, &nd);
if (!error) {
error = do_revalidate(nd.dentry);
if (!error)
error = cp_bsd_stat(dentry->d_inode, st);
dput(dentry);
error = cp_bsd_stat(nd.dentry->d_inode, st);
path_release(&nd);
}
unlock_kernel();
return error;

View file

@ -4,7 +4,7 @@
* Copyright (C) 1993 Joe Portman (baron@hebron.connected.com)
* Copyright (C) 1993, 1994 Drew Sullivan (re-worked for iBCS2)
*
* $Id: open.c,v 1.42 1999/09/01 19:30:07 jaggy Exp $
* $Id: open.c,v 1.43 2001/08/28 11:34:07 jaggy Exp $
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/iBCSemul/open.c,v $
*/
@ -86,16 +86,15 @@ int ibcs_statfs(const char * path, struct ibcs_statfs * buf, int len, int fstype
return -EINVAL;
if (!fstype) {
struct dentry *dentry;
struct nameidata nd;
struct statfs lxstat;
int error;
mm_segment_t old_fs;
lock_kernel();
dentry = namei(path);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
struct inode *inode = dentry->d_inode;
error = user_path_walk(path, &nd);
if (!error) {
struct inode *inode = nd.dentry->d_inode;
error = -ENOSYS;
if (inode->i_sb->s_op->statfs) {
@ -120,7 +119,7 @@ int ibcs_statfs(const char * path, struct ibcs_statfs * buf, int len, int fstype
error = -EFAULT;
}
}
dput(dentry);
path_release(&nd);
}
unlock_kernel();
return error;

View file

@ -3,7 +3,7 @@
*
* Copyright 1994-1996 Mike Jagdis (jaggy@purplet.demon.co.uk)
*
* $Id: socksys.c,v 1.68 1999/07/11 22:32:02 jaggy Exp $
* $Id: socksys.c,v 1.69 2001/08/28 11:34:07 jaggy Exp $
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/iBCSemul/socksys.c,v $
*/
@ -832,7 +832,7 @@ ibcs_ioctl_socksys(int fd, unsigned int cmd, void *arg)
case NIOCOLDGETFH:
case NIOCGETFH: {
struct getfh_args gf;
struct dentry *dentry;
struct nameidata nd;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@ -845,17 +845,16 @@ ibcs_ioctl_socksys(int fd, unsigned int cmd, void *arg)
lock_kernel();
error = verify_area(VERIFY_WRITE, (char *)gf.fhp, sizeof(fhandle_t));
if (!error) {
dentry = namei(gf.fname);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
struct inode *ino = dentry->d_inode;
error = user_path_walk(gf.fname, &nd);
if (!error) {
struct inode *ino = nd.dentry->d_inode;
__put_user(ino->i_dev, &gf.fhp->fh.fsid);
__put_user(ino->i_ino, &gf.fhp->fh.fno);
__put_user(0L, &gf.fhp->fh.fgen);
__put_user(ino->i_dev, &gf.fhp->fh.ex_fsid);
__put_user(ino->i_ino, &gf.fhp->fh.ex_fno);
__put_user(0L, &gf.fhp->fh.ex_fgen);
dput(dentry);
path_release(&nd);
error = 0;
}
}

View file

@ -6,7 +6,7 @@
* Hacked by Eric Youngdale for iBCS.
* Added to by Drew Sullivan.
*
* $Id: stat.c,v 1.15 1998/08/16 16:34:09 jaggy Exp $
* $Id: stat.c,v 1.16 2001/08/28 11:34:07 jaggy Exp $
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/iBCSemul/stat.c,v $
*/
#define __KERNEL__ 1
@ -95,19 +95,16 @@ extern "C"
#endif
int ibcs_stat(char * filename, struct ibcs_stat * statbuf)
{
struct dentry * dentry;
struct nameidata nd;
int error;
lock_kernel();
dentry = namei(filename);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = do_revalidate(dentry);
error = user_path_walk(filename, &nd);
if (!error) {
error = do_revalidate(nd.dentry);
if (!error)
error = cp_ibcs_stat(dentry->d_inode, statbuf);
dput(dentry);
error = cp_ibcs_stat(nd.dentry->d_inode, statbuf);
path_release(&nd);
}
unlock_kernel();
return error;
@ -118,19 +115,16 @@ extern "C"
#endif
int ibcs_lstat(char * filename, struct ibcs_stat * statbuf)
{
struct dentry * dentry;
struct nameidata nd;
int error;
lock_kernel();
dentry = lnamei(filename);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = do_revalidate(dentry);
error = user_path_walk_link(filename, &nd);
if (!error) {
error = do_revalidate(nd.dentry);
if (!error)
error = cp_ibcs_stat(dentry->d_inode, statbuf);
dput(dentry);
error = cp_ibcs_stat(nd.dentry->d_inode, statbuf);
path_release(&nd);
}
unlock_kernel();
return error;

View file

@ -6,7 +6,7 @@
* Hacked by Eric Youngdale for iBCS (1993, 1994).
* Added to by Drew Sullivan, modified by EY for xstat (used by SVr4).
*
* $Id: xstat.c,v 1.20 1998/10/15 21:20:47 jaggy Exp $
* $Id: xstat.c,v 1.21 2001/08/28 11:34:07 jaggy Exp $
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/iBCSemul/xstat.c,v $
*/
@ -179,25 +179,23 @@ cp_svr4_xstat(struct inode * inode, struct svr4_xstat * statbuf)
int
ibcs_xstat(int vers, char *filename, void *buf)
{
struct dentry * dentry;
struct nameidata nd;
int error;
if (vers == R3_STAT_VERSION)
return ibcs_stat(filename, (struct ibcs_stat *)buf);
lock_kernel();
dentry = namei(filename);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = do_revalidate(dentry);
error = user_path_walk(filename, &nd);
if (!error) {
error = do_revalidate(nd.dentry);
if (!error) switch (vers) {
case R4_STAT_VERSION:
error = cp_svr4_xstat(dentry->d_inode, buf);
error = cp_svr4_xstat(nd.dentry->d_inode, buf);
break;
case SCO_STAT_VERSION:
error = cp_sco_xstat(dentry->d_inode, buf);
error = cp_sco_xstat(nd.dentry->d_inode, buf);
break;
default:
@ -211,7 +209,7 @@ ibcs_xstat(int vers, char *filename, void *buf)
break;
}
dput(dentry);
path_release(&nd);
}
unlock_kernel();
return error;
@ -221,25 +219,23 @@ ibcs_xstat(int vers, char *filename, void *buf)
int
ibcs_lxstat(int vers, char *filename, void *buf)
{
struct dentry * dentry;
struct nameidata nd;
int error;
if (vers == R3_STAT_VERSION)
return ibcs_lstat(filename, (struct ibcs_stat *)buf);
lock_kernel();
dentry = lnamei(filename);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = do_revalidate(dentry);
error = user_path_walk_link(filename, &nd);
if (!error) {
error = do_revalidate(nd.dentry);
if (!error) switch(vers) {
case R4_STAT_VERSION:
error = cp_svr4_xstat(dentry->d_inode, buf);
error = cp_svr4_xstat(nd.dentry->d_inode, buf);
break;
case SCO_STAT_VERSION:
error = cp_sco_xstat(dentry->d_inode, buf);
error = cp_sco_xstat(nd.dentry->d_inode, buf);
break;
default:
@ -252,7 +248,7 @@ ibcs_lxstat(int vers, char *filename, void *buf)
error = -EINVAL;
}
dput(dentry);
path_release(&nd);
}
unlock_kernel();
return error;
@ -409,14 +405,12 @@ abi_statvfs(char *filename, void *stat)
int error;
struct statfs st;
mm_segment_t old_fs;
struct dentry *dentry;
struct nameidata nd;
lock_kernel();
dentry = namei(filename);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = do_revalidate(dentry);
error = user_path_walk(filename, &nd);
if (!error) {
error = do_revalidate(nd.dentry);
old_fs = get_fs();
set_fs(get_ds());
@ -425,12 +419,12 @@ abi_statvfs(char *filename, void *stat)
if (!error) {
if (personality(PER_SCOSVR3))
error = cp_sco_statvfs(dentry, &st, stat);
error = cp_sco_statvfs(nd.dentry, &st, stat);
else
error = cp_abi_statvfs(dentry, &st, stat);
error = cp_abi_statvfs(nd.dentry, &st, stat);
}
dput(dentry);
path_release(&nd);
}
unlock_kernel();
return error;

View file

@ -1,7 +1,7 @@
/*
* Function prototypes used by the iBCS2 emulator
*
* $Id: ibcs.h,v 1.61 2000/01/04 11:54:27 mike Exp $
* $Id: ibcs.h,v 1.62 2001/08/28 11:34:07 jaggy Exp $
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/include/ibcs/ibcs.h,v $
*/
#include <linux/ptrace.h> /* for pt_regs */
@ -48,6 +48,37 @@ do_revalidate(struct dentry *dentry)
return 0;
}
#ifndef user_path_walk
struct nameidata {
struct dentry *dentry;
};
static __inline__ int
user_path_walk(const char *filename, struct nameidata *nd)
{
int error;
nd->dentry = namei(filename);
error = PTR_ERR(nd->dentry);
if (!IS_ERR(nd->dentry))
error = 0;
return error;
}
static __inline__ int
user_path_walk_link(const char *filename, struct nameidata *nd)
{
int error;
nd->dentry = lnamei(filename);
error = PTR_ERR(nd->dentry);
if (!IS_ERR(nd->dentry))
error = 0;
return error;
}
static __inline__ void
path_release(struct nameidata *nd)
{
dput(nd->dentry);
}
#endif
typedef int (*sysfun_p)();