Commit f5f896dd authored by Petr Vandrovec's avatar Petr Vandrovec Committed by Linus Torvalds

[PATCH] 2.5.4-pre5 and ncpfs fill_super changes

* fs/ncpfs/inode.c: Return reasonable error codes instead of universal
     -EINVAL. Remove printk() as reasonable code is returned.
     Set maximum file size limit on ncpfs to 4GB-1.

* fs/ncpfs/sock.c: Return correct error code when send() fails.

	Petr Vandrovec
parent 487841ed
...@@ -315,8 +315,9 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -315,8 +315,9 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
#endif #endif
struct ncp_entry_info finfo; struct ncp_entry_info finfo;
error = -EFAULT;
if (raw_data == NULL) if (raw_data == NULL)
goto out_no_data; goto out;
switch (*(int*)raw_data) { switch (*(int*)raw_data) {
case NCP_MOUNT_VERSION: case NCP_MOUNT_VERSION:
{ {
...@@ -356,23 +357,27 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -356,23 +357,27 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
} }
break; break;
default: default:
goto out_bad_mount; error = -ECHRNG;
goto out;
} }
error = -EBADF;
ncp_filp = fget(data.ncp_fd); ncp_filp = fget(data.ncp_fd);
if (!ncp_filp) if (!ncp_filp)
goto out_bad_file; goto out;
error = -ENOTSOCK;
sock_inode = ncp_filp->f_dentry->d_inode; sock_inode = ncp_filp->f_dentry->d_inode;
if (!S_ISSOCK(sock_inode->i_mode)) if (!S_ISSOCK(sock_inode->i_mode))
goto out_bad_file2; goto out_fput;
sock = SOCKET_I(sock_inode); sock = SOCKET_I(sock_inode);
if (!sock) if (!sock)
goto out_bad_file2; goto out_fput;
if (sock->type == SOCK_STREAM) if (sock->type == SOCK_STREAM)
default_bufsize = 61440; default_bufsize = 0xF000;
else else
default_bufsize = 1024; default_bufsize = 1024;
sb->s_maxbytes = 0xFFFFFFFFU;
sb->s_blocksize = 1024; /* Eh... Is this correct? */ sb->s_blocksize = 1024; /* Eh... Is this correct? */
sb->s_blocksize_bits = 10; sb->s_blocksize_bits = 10;
sb->s_magic = NCP_SUPER_MAGIC; sb->s_magic = NCP_SUPER_MAGIC;
...@@ -408,10 +413,8 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -408,10 +413,8 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
printk(KERN_INFO "You need to recompile your ncpfs utils..\n"); printk(KERN_INFO "You need to recompile your ncpfs utils..\n");
} }
server->m.time_out = server->m.time_out * HZ / 100; server->m.time_out = server->m.time_out * HZ / 100;
server->m.file_mode = (server->m.file_mode & server->m.file_mode = (server->m.file_mode & S_IRWXUGO) | S_IFREG;
(S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG; server->m.dir_mode = (server->m.dir_mode & S_IRWXUGO) | S_IFDIR;
server->m.dir_mode = (server->m.dir_mode &
(S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFDIR;
#ifdef CONFIG_NCPFS_NLS #ifdef CONFIG_NCPFS_NLS
/* load the default NLS charsets */ /* load the default NLS charsets */
...@@ -422,19 +425,21 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -422,19 +425,21 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
server->dentry_ttl = 0; /* no caching */ server->dentry_ttl = 0; /* no caching */
#undef NCP_PACKET_SIZE #undef NCP_PACKET_SIZE
#define NCP_PACKET_SIZE 65536 #define NCP_PACKET_SIZE 131072
error = -ENOMEM;
server->packet_size = NCP_PACKET_SIZE; server->packet_size = NCP_PACKET_SIZE;
server->packet = vmalloc(NCP_PACKET_SIZE); server->packet = vmalloc(NCP_PACKET_SIZE);
if (server->packet == NULL) if (server->packet == NULL)
goto out_no_packet; goto out_nls;
ncp_lock_server(server); ncp_lock_server(server);
error = ncp_connect(server); error = ncp_connect(server);
ncp_unlock_server(server); ncp_unlock_server(server);
if (error < 0) if (error < 0)
goto out_no_connect; goto out_packet;
DPRINTK("ncp_fill_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb)); DPRINTK("ncp_fill_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb));
error = -EMSGSIZE; /* -EREMOTESIDEINCOMPATIBLE */
#ifdef CONFIG_NCPFS_PACKET_SIGNING #ifdef CONFIG_NCPFS_PACKET_SIGNING
if (ncp_negotiate_size_and_options(server, default_bufsize, if (ncp_negotiate_size_and_options(server, default_bufsize,
NCP_DEFAULT_OPTIONS, &(server->buffer_size), &options) == 0) NCP_DEFAULT_OPTIONS, &(server->buffer_size), &options) == 0)
...@@ -447,7 +452,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -447,7 +452,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
&(server->buffer_size), &options) != 0) &(server->buffer_size), &options) != 0)
{ {
goto out_no_bufsize; goto out_disconnect;
} }
} }
if (options & 2) if (options & 2)
...@@ -457,7 +462,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -457,7 +462,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
#endif /* CONFIG_NCPFS_PACKET_SIGNING */ #endif /* CONFIG_NCPFS_PACKET_SIGNING */
if (ncp_negotiate_buffersize(server, default_bufsize, if (ncp_negotiate_buffersize(server, default_bufsize,
&(server->buffer_size)) != 0) &(server->buffer_size)) != 0)
goto out_no_bufsize; goto out_disconnect;
DPRINTK("ncpfs: bufsize = %d\n", server->buffer_size); DPRINTK("ncpfs: bufsize = %d\n", server->buffer_size);
memset(&finfo, 0, sizeof(finfo)); memset(&finfo, 0, sizeof(finfo));
...@@ -482,9 +487,11 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -482,9 +487,11 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
finfo.ino = 2; /* tradition */ finfo.ino = 2; /* tradition */
server->name_space[finfo.i.volNumber] = NW_NS_DOS; server->name_space[finfo.i.volNumber] = NW_NS_DOS;
error = -ENOMEM;
root_inode = ncp_iget(sb, &finfo); root_inode = ncp_iget(sb, &finfo);
if (!root_inode) if (!root_inode)
goto out_no_root; goto out_disconnect;
DPRINTK("ncp_fill_super: root vol=%d\n", NCP_FINFO(root_inode)->volNumber); DPRINTK("ncp_fill_super: root vol=%d\n", NCP_FINFO(root_inode)->volNumber);
sb->s_root = d_alloc_root(root_inode); sb->s_root = d_alloc_root(root_inode);
if (!sb->s_root) if (!sb->s_root)
...@@ -493,49 +500,27 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -493,49 +500,27 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
return 0; return 0;
out_no_root: out_no_root:
printk(KERN_ERR "ncp_fill_super: get root inode failed\n");
iput(root_inode); iput(root_inode);
goto out_disconnect;
out_no_bufsize:
printk(KERN_ERR "ncp_fill_super: could not get bufsize\n");
out_disconnect: out_disconnect:
ncp_lock_server(server); ncp_lock_server(server);
ncp_disconnect(server); ncp_disconnect(server);
ncp_unlock_server(server); ncp_unlock_server(server);
goto out_free_packet; out_packet:
out_no_connect:
printk(KERN_ERR "ncp_fill_super: Failed connection, error=%d\n", error);
out_free_packet:
vfree(server->packet); vfree(server->packet);
goto out_free_server; out_nls:
out_no_packet:
printk(KERN_ERR "ncp_fill_super: could not alloc packet\n");
out_free_server:
#ifdef CONFIG_NCPFS_NLS #ifdef CONFIG_NCPFS_NLS
unload_nls(server->nls_io); unload_nls(server->nls_io);
unload_nls(server->nls_vol); unload_nls(server->nls_vol);
#endif #endif
out_fput:
/* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>: /* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>:
* *
* The previously used put_filp(ncp_filp); was bogous, since * The previously used put_filp(ncp_filp); was bogous, since
* it doesn't proper unlocking. * it doesn't proper unlocking.
*/ */
fput(ncp_filp); fput(ncp_filp);
goto out;
out_bad_file2:
fput(ncp_filp);
out_bad_file:
printk(KERN_ERR "ncp_fill_super: invalid ncp socket\n");
goto out;
out_bad_mount:
printk(KERN_INFO "ncp_fill_super: kernel requires mount version %d\n",
NCP_MOUNT_VERSION);
goto out;
out_no_data:
printk(KERN_ERR "ncp_fill_super: missing data argument\n");
out: out:
return -EINVAL; return error;
} }
static void ncp_put_super(struct super_block *sb) static void ncp_put_super(struct super_block *sb)
......
...@@ -132,7 +132,7 @@ static int do_ncp_rpc_call(struct ncp_server *server, int size, ...@@ -132,7 +132,7 @@ static int do_ncp_rpc_call(struct ncp_server *server, int size,
result = _send(sock, (void *) start, size); result = _send(sock, (void *) start, size);
if (result < 0) { if (result < 0) {
printk(KERN_ERR "ncp_rpc_call: send error = %d\n", result); printk(KERN_ERR "ncp_rpc_call: send error = %d\n", result);
break; return result;
} }
re_select: re_select:
poll_initwait(&wait_table); poll_initwait(&wait_table);
......
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