patch-2.1.45 linux/arch/sparc64/kernel/sys_sunos32.c

Next file: linux/arch/sparc64/kernel/winfixup.S
Previous file: linux/arch/sparc64/kernel/sys_sparc32.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.44/linux/arch/sparc64/kernel/sys_sunos32.c linux/arch/sparc64/kernel/sys_sunos32.c
@@ -1,4 +1,4 @@
-/* $Id: sys_sunos32.c,v 1.2 1997/07/05 07:09:16 davem Exp $
+/* $Id: sys_sunos32.c,v 1.3 1997/07/17 02:20:48 davem Exp $
  * sys_sunos32.c: SunOS binary compatability layer on sparc64.
  *
  * Copyright (C) 1995, 1996, 1997 David S. Miller (davem@caip.rutgers.edu)
@@ -80,10 +80,12 @@
 			goto out;
 		addr = (u32) attempt;
 	}
-	if(MAJOR(file->f_inode->i_rdev) == MEM_MAJOR &&
-	   MINOR(file->f_inode->i_rdev) == 5) {
-		flags |= MAP_ANONYMOUS;
-		file = 0;
+	if(file->f_dentry && file->f_dentry->d_inode) {
+		if(MAJOR(file->f_dentry->d_inode->i_rdev) == MEM_MAJOR &&
+		   MINOR(file->f_dentry->d_inode->i_rdev) == 5) {
+			flags |= MAP_ANONYMOUS;
+			file = 0;
+		}
 	}
 	if(!(flags & MAP_FIXED))
 		addr = 0;
@@ -377,17 +379,33 @@
 asmlinkage int sunos_getdents(unsigned int fd, u32 u_dirent, int cnt)
 {
 	struct file * file;
+	struct dentry * dentry;
+	struct inode * inode;
 	struct sunos_dirent * lastdirent;
 	struct sunos_dirent_callback buf;
 	int error = -EBADF;
 	void *dirent = (void *)A(u_dirent);
 
 	lock_kernel();
-	if (fd >= SUNOS_NR_OPEN || !(file = current->files->fd[fd]))
+	if(fd >= SUNOS_NR_OPEN)
 		goto out;
+
+	file = current->files->fd[fd];
+	if(!file)
+		goto out;
+
+	dentry = file->f_dentry;
+	if(!dentry)
+		goto out;
+
+	inode = dentry->d_inode;
+	if(!inode)
+		goto out;
+
 	error = -ENOTDIR;
 	if (!file->f_op || !file->f_op->readdir)
 		goto out;
+
 	error = -EINVAL;
 	if(cnt < (sizeof(struct sunos_dirent) + 255))
 		goto out;
@@ -396,13 +414,13 @@
 	buf.previous = NULL;
 	buf.count = cnt;
 	buf.error = 0;
-	error = file->f_op->readdir(file->f_inode, file, &buf, sunos_filldir);
+
+	error = file->f_op->readdir(inode, file, &buf, sunos_filldir);
 	if (error < 0)
 		goto out;
 	lastdirent = buf.previous;
-	if (!lastdirent) {
-		error = buf.error;
-	} else {
+	error = buf.error;
+	if (lastdirent) {
 		put_user(file->f_pos, &lastdirent->d_off);
 		error = cnt - buf.count;
 	}
@@ -454,6 +472,8 @@
 				   int cnt, u32 u_basep)
 {
 	struct file * file;
+	struct dentry * dentry;
+	struct inode * inode;
 	struct sunos_direntry * lastdirent;
 	struct sunos_direntry_callback buf;
 	int error = -EBADF;
@@ -461,11 +481,25 @@
 	unsigned int *basep = (unsigned int *)A(u_basep);
 
 	lock_kernel();
-	if (fd >= SUNOS_NR_OPEN || !(file = current->files->fd[fd]))
+	if(fd >= SUNOS_NR_OPEN)
+		goto out;
+
+	file = current->files->fd[fd];
+	if(!file)
 		goto out;
+
+	dentry = file->f_dentry;
+	if(!dentry)
+		goto out;
+
+	inode = dentry->d_inode;
+	if(!inode)
+		goto out;
+
 	error = -ENOTDIR;
 	if (!file->f_op || !file->f_op->readdir)
 		goto out;
+
 	error = -EINVAL;
 	if(cnt < (sizeof(struct sunos_direntry) + 255))
 		goto out;
@@ -474,13 +508,13 @@
 	buf.previous = NULL;
 	buf.count = cnt;
 	buf.error = 0;
-	error = file->f_op->readdir(file->f_inode, file, &buf, sunos_filldirentry);
+
+	error = file->f_op->readdir(inode, file, &buf, sunos_filldirentry);
 	if (error < 0)
 		goto out;
 	lastdirent = buf.previous;
-	if (!lastdirent) {
-		error = buf.error;
-	} else {
+	error = buf.error;
+	if (lastdirent) {
 		put_user(file->f_pos, basep);
 		error = cnt - buf.count;
 	}
@@ -684,12 +718,20 @@
 	int    try_port;
 	int    ret;
 	struct socket *socket;
+	struct dentry *dentry;
 	struct inode  *inode;
 	struct file   *file;
 
 	file = current->files->fd [fd];
-	inode = file->f_inode;
-	if (!inode || !inode->i_sock)
+	if(!file)
+		return 0;
+
+	dentry = file->f_dentry;
+	if(!dentry)
+		return 0;
+
+	inode = dentry->d_inode;
+	if(!inode)
 		return 0;
 
 	socket = &inode->u.socket_i;
@@ -770,7 +812,8 @@
 	linux_nfs_mount.acdirmin = sunos_mount->acdirmin;
 	linux_nfs_mount.acdirmax = sunos_mount->acdirmax;
 
-	if (getname (sunos_mount->hostname, &the_name))
+	the_name = getname(sunos_mount->hostname);
+	if(IS_ERR(the_name))
 		return -EFAULT;
 
 	strncpy (linux_nfs_mount.hostname, the_name, 254);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov