patch-2.3.99-pre4 linux/arch/sparc/kernel/sys_sunos.c
Next file: linux/arch/sparc/lib/Makefile
Previous file: linux/arch/sparc/kernel/signal.c
Back to the patch index
Back to the overall index
- Lines: 183
- Date:
Sun Apr 2 15:53:28 2000
- Orig file:
v2.3.99-pre3/linux/arch/sparc/kernel/sys_sunos.c
- Orig date:
Sun Mar 19 18:35:30 2000
diff -u --recursive --new-file v2.3.99-pre3/linux/arch/sparc/kernel/sys_sunos.c linux/arch/sparc/kernel/sys_sunos.c
@@ -1,4 +1,4 @@
-/* $Id: sys_sunos.c,v 1.117 2000/03/15 02:43:32 davem Exp $
+/* $Id: sys_sunos.c,v 1.118 2000/03/26 11:28:56 davem Exp $
* sys_sunos.c: SunOS specific syscall compatibility support.
*
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
@@ -91,7 +91,7 @@
* of /dev/zero, transform it into an anonymous mapping.
* SunOS is so stupid some times... hmph!
*/
- if(file->f_dentry && file->f_dentry->d_inode) {
+ if (file) {
if(MAJOR(file->f_dentry->d_inode->i_rdev) == MEM_MAJOR &&
MINOR(file->f_dentry->d_inode->i_rdev) == 5) {
flags |= MAP_ANONYMOUS;
@@ -633,10 +633,9 @@
};
-extern int do_mount(struct block_device *, const char *, const char *, char *, int, void *);
extern dev_t get_unnamed_dev(void);
extern void put_unnamed_dev(dev_t);
-extern asmlinkage int sys_mount(char *, char *, char *, unsigned long, void *);
+extern asmlinkage long do_sys_mount(char *, char *, char *, int, void *);
extern asmlinkage int sys_connect(int fd, struct sockaddr *uservaddr, int addrlen);
extern asmlinkage int sys_socket(int family, int type, int protocol);
extern asmlinkage int sys_bind(int fd, struct sockaddr *umyaddr, int addrlen);
@@ -660,8 +659,6 @@
file = fget(fd);
if (!file)
goto out;
- if (!file->f_dentry || !(inode = file->f_dentry->d_inode))
- goto out_putf;
socket = &inode->u.socket_i;
local.sin_family = AF_INET;
@@ -702,12 +699,12 @@
return def_value;
}
-asmlinkage int sunos_nfs_mount(char *dir_name, int linux_flags, void *data)
+static int sunos_nfs_mount(char *dir_name, int linux_flags, void *data)
{
int server_fd;
char *the_name;
struct nfs_mount_data linux_nfs_mount;
- struct sunos_nfs_mount_args *sunos_mount = data;
+ struct sunos_nfs_mount_args sunos_mount;
/* Ok, here comes the fun part: Linux's nfs mount needs a
* socket connection to the server, but SunOS mount does not
@@ -715,33 +712,42 @@
* address to create a socket and bind it to a reserved
* port on this system
*/
+ if (copy_from_user(&sunos_mount, data, sizeof(sunos_mount))
+ return -EFAULT;
+
server_fd = sys_socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (server_fd < 0)
return -ENXIO;
- if (!sunos_nfs_get_server_fd (server_fd, sunos_mount->addr)){
+ if (copy_from_user(&linux_nfs_mount.addr,sunos_mount.addr,
+ sizeof(*sunos_mount.addr)) ||
+ copy_from_user(&linux_nfs_mount.root,sunos_mount.fh,
+ sizeof(*sunos_mount.fh))) {
+ sys_close (server_fd);
+ return -EFAULT;
+ }
+
+ if (!sunos_nfs_get_server_fd (server_fd, &linux_nfs_mount.addr)){
sys_close (server_fd);
return -ENXIO;
}
/* Now, bind it to a locally reserved port */
linux_nfs_mount.version = NFS_MOUNT_VERSION;
- linux_nfs_mount.flags = sunos_mount->flags;
- linux_nfs_mount.addr = *sunos_mount->addr;
- linux_nfs_mount.root = *sunos_mount->fh;
+ linux_nfs_mount.flags = sunos_mount.flags;
linux_nfs_mount.fd = server_fd;
- linux_nfs_mount.rsize = get_default (sunos_mount->rsize, 8192);
- linux_nfs_mount.wsize = get_default (sunos_mount->wsize, 8192);
- linux_nfs_mount.timeo = get_default (sunos_mount->timeo, 10);
- linux_nfs_mount.retrans = sunos_mount->retrans;
+ linux_nfs_mount.rsize = get_default (sunos_mount.rsize, 8192);
+ linux_nfs_mount.wsize = get_default (sunos_mount.wsize, 8192);
+ linux_nfs_mount.timeo = get_default (sunos_mount.timeo, 10);
+ linux_nfs_mount.retrans = sunos_mount.retrans;
- linux_nfs_mount.acregmin = sunos_mount->acregmin;
- linux_nfs_mount.acregmax = sunos_mount->acregmax;
- linux_nfs_mount.acdirmin = sunos_mount->acdirmin;
- linux_nfs_mount.acdirmax = sunos_mount->acdirmax;
+ linux_nfs_mount.acregmin = sunos_mount.acregmin;
+ linux_nfs_mount.acregmax = sunos_mount.acregmax;
+ linux_nfs_mount.acdirmin = sunos_mount.acdirmin;
+ linux_nfs_mount.acdirmax = sunos_mount.acdirmax;
- the_name = getname(sunos_mount->hostname);
+ the_name = getname(sunos_mount.hostname);
if(IS_ERR(the_name))
return PTR_ERR(the_name);
@@ -749,7 +755,7 @@
linux_nfs_mount.hostname [255] = 0;
putname (the_name);
- return do_mount (NULL, "", dir_name, "nfs", linux_flags, &linux_nfs_mount);
+ return do_sys_mount ("", dir_name, "nfs", linux_flags, &linux_nfs_mount);
}
asmlinkage int
@@ -758,6 +764,7 @@
int linux_flags = MS_MGC_MSK; /* new semantics */
int ret = -EINVAL;
char *dev_fname = 0;
+ char *dir_page, *type_page;
if (!capable (CAP_SYS_ADMIN))
return -EPERM;
@@ -777,24 +784,44 @@
linux_flags |= MS_RDONLY;
if(flags & SMNT_NOSUID)
linux_flags |= MS_NOSUID;
- if(strcmp(type, "ext2") == 0) {
- dev_fname = (char *) data;
- } else if(strcmp(type, "iso9660") == 0) {
- dev_fname = (char *) data;
- } else if(strcmp(type, "minix") == 0) {
- dev_fname = (char *) data;
- } else if(strcmp(type, "nfs") == 0) {
- ret = sunos_nfs_mount (dir, flags, data);
- goto out;
- } else if(strcmp(type, "ufs") == 0) {
+
+ dir_page = getname(dir);
+ ret = PTR_ERR(dir_page);
+ if (IS_ERR(dir_page))
+ goto out;
+
+ type_page = getname(type);
+ ret = PTR_ERR(type_page);
+ if (IS_ERR(type_page))
+ goto out1;
+
+ if(strcmp(type_page, "ext2") == 0) {
+ dev_fname = getname(data);
+ } else if(strcmp(type_page, "iso9660") == 0) {
+ dev_fname = getname(data);
+ } else if(strcmp(type_page, "minix") == 0) {
+ dev_fname = getname(data);
+ } else if(strcmp(type_page, "nfs") == 0) {
+ ret = sunos_nfs_mount (dir_page, flags, data);
+ goto out2
+ } else if(strcmp(type_page, "ufs") == 0) {
printk("Warning: UFS filesystem mounts unsupported.\n");
ret = -ENODEV;
- goto out;
- } else if(strcmp(type, "proc")) {
+ goto out2
+ } else if(strcmp(type_page, "proc")) {
ret = -ENODEV;
- goto out;
+ goto out2
}
- ret = sys_mount(dev_fname, dir, type, linux_flags, NULL);
+ ret = PTR_ERR(dev_fname);
+ if (IS_ERR(dev_fname))
+ goto out2;
+ ret = do_sys_mount(dev_fname, dir_page, type_page, linux_flags, NULL);
+ if (dev_fname)
+ putname(dev_fname);
+out2:
+ putname(type_page);
+out1:
+ putname(dir_page);
out:
unlock_kernel();
return ret;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)