diff options
Diffstat (limited to 'fs/ncpfs/inode.c')
-rw-r--r-- | fs/ncpfs/inode.c | 82 |
1 files changed, 28 insertions, 54 deletions
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index 647d86d2db39..e31e589369a4 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
13 | 15 | ||
14 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
@@ -133,7 +135,7 @@ void ncp_update_inode(struct inode *inode, struct ncp_entry_info *nwinfo) | |||
133 | NCP_FINFO(inode)->access = nwinfo->access; | 135 | NCP_FINFO(inode)->access = nwinfo->access; |
134 | memcpy(NCP_FINFO(inode)->file_handle, nwinfo->file_handle, | 136 | memcpy(NCP_FINFO(inode)->file_handle, nwinfo->file_handle, |
135 | sizeof(nwinfo->file_handle)); | 137 | sizeof(nwinfo->file_handle)); |
136 | DPRINTK("ncp_update_inode: updated %s, volnum=%d, dirent=%u\n", | 138 | ncp_dbg(1, "updated %s, volnum=%d, dirent=%u\n", |
137 | nwinfo->i.entryName, NCP_FINFO(inode)->volNumber, | 139 | nwinfo->i.entryName, NCP_FINFO(inode)->volNumber, |
138 | NCP_FINFO(inode)->dirEntNum); | 140 | NCP_FINFO(inode)->dirEntNum); |
139 | } | 141 | } |
@@ -141,8 +143,7 @@ void ncp_update_inode(struct inode *inode, struct ncp_entry_info *nwinfo) | |||
141 | static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi) | 143 | static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi) |
142 | { | 144 | { |
143 | /* NFS namespace mode overrides others if it's set. */ | 145 | /* NFS namespace mode overrides others if it's set. */ |
144 | DPRINTK(KERN_DEBUG "ncp_update_dates_and_mode: (%s) nfs.mode=0%o\n", | 146 | ncp_dbg(1, "(%s) nfs.mode=0%o\n", nwi->entryName, nwi->nfs.mode); |
145 | nwi->entryName, nwi->nfs.mode); | ||
146 | if (nwi->nfs.mode) { | 147 | if (nwi->nfs.mode) { |
147 | /* XXX Security? */ | 148 | /* XXX Security? */ |
148 | inode->i_mode = nwi->nfs.mode; | 149 | inode->i_mode = nwi->nfs.mode; |
@@ -230,7 +231,7 @@ static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo) | |||
230 | 231 | ||
231 | ncp_update_attrs(inode, nwinfo); | 232 | ncp_update_attrs(inode, nwinfo); |
232 | 233 | ||
233 | DDPRINTK("ncp_read_inode: inode->i_mode = %u\n", inode->i_mode); | 234 | ncp_dbg(2, "inode->i_mode = %u\n", inode->i_mode); |
234 | 235 | ||
235 | set_nlink(inode, 1); | 236 | set_nlink(inode, 1); |
236 | inode->i_uid = server->m.uid; | 237 | inode->i_uid = server->m.uid; |
@@ -258,7 +259,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info) | |||
258 | struct inode *inode; | 259 | struct inode *inode; |
259 | 260 | ||
260 | if (info == NULL) { | 261 | if (info == NULL) { |
261 | printk(KERN_ERR "ncp_iget: info is NULL\n"); | 262 | pr_err("%s: info is NULL\n", __func__); |
262 | return NULL; | 263 | return NULL; |
263 | } | 264 | } |
264 | 265 | ||
@@ -290,7 +291,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info) | |||
290 | } | 291 | } |
291 | insert_inode_hash(inode); | 292 | insert_inode_hash(inode); |
292 | } else | 293 | } else |
293 | printk(KERN_ERR "ncp_iget: iget failed!\n"); | 294 | pr_err("%s: iget failed!\n", __func__); |
294 | return inode; | 295 | return inode; |
295 | } | 296 | } |
296 | 297 | ||
@@ -301,12 +302,12 @@ ncp_evict_inode(struct inode *inode) | |||
301 | clear_inode(inode); | 302 | clear_inode(inode); |
302 | 303 | ||
303 | if (S_ISDIR(inode->i_mode)) { | 304 | if (S_ISDIR(inode->i_mode)) { |
304 | DDPRINTK("ncp_evict_inode: put directory %ld\n", inode->i_ino); | 305 | ncp_dbg(2, "put directory %ld\n", inode->i_ino); |
305 | } | 306 | } |
306 | 307 | ||
307 | if (ncp_make_closed(inode) != 0) { | 308 | if (ncp_make_closed(inode) != 0) { |
308 | /* We can't do anything but complain. */ | 309 | /* We can't do anything but complain. */ |
309 | printk(KERN_ERR "ncp_evict_inode: could not close\n"); | 310 | pr_err("%s: could not close\n", __func__); |
310 | } | 311 | } |
311 | } | 312 | } |
312 | 313 | ||
@@ -469,9 +470,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
469 | { | 470 | { |
470 | struct ncp_mount_data_kernel data; | 471 | struct ncp_mount_data_kernel data; |
471 | struct ncp_server *server; | 472 | struct ncp_server *server; |
472 | struct file *ncp_filp; | ||
473 | struct inode *root_inode; | 473 | struct inode *root_inode; |
474 | struct inode *sock_inode; | ||
475 | struct socket *sock; | 474 | struct socket *sock; |
476 | int error; | 475 | int error; |
477 | int default_bufsize; | 476 | int default_bufsize; |
@@ -540,18 +539,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
540 | if (!uid_valid(data.mounted_uid) || !uid_valid(data.uid) || | 539 | if (!uid_valid(data.mounted_uid) || !uid_valid(data.uid) || |
541 | !gid_valid(data.gid)) | 540 | !gid_valid(data.gid)) |
542 | goto out; | 541 | goto out; |
543 | error = -EBADF; | 542 | sock = sockfd_lookup(data.ncp_fd, &error); |
544 | ncp_filp = fget(data.ncp_fd); | ||
545 | if (!ncp_filp) | ||
546 | goto out; | ||
547 | error = -ENOTSOCK; | ||
548 | sock_inode = file_inode(ncp_filp); | ||
549 | if (!S_ISSOCK(sock_inode->i_mode)) | ||
550 | goto out_fput; | ||
551 | sock = SOCKET_I(sock_inode); | ||
552 | if (!sock) | 543 | if (!sock) |
553 | goto out_fput; | 544 | goto out; |
554 | 545 | ||
555 | if (sock->type == SOCK_STREAM) | 546 | if (sock->type == SOCK_STREAM) |
556 | default_bufsize = 0xF000; | 547 | default_bufsize = 0xF000; |
557 | else | 548 | else |
@@ -573,27 +564,16 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
573 | if (error) | 564 | if (error) |
574 | goto out_fput; | 565 | goto out_fput; |
575 | 566 | ||
576 | server->ncp_filp = ncp_filp; | ||
577 | server->ncp_sock = sock; | 567 | server->ncp_sock = sock; |
578 | 568 | ||
579 | if (data.info_fd != -1) { | 569 | if (data.info_fd != -1) { |
580 | struct socket *info_sock; | 570 | struct socket *info_sock = sockfd_lookup(data.info_fd, &error); |
581 | |||
582 | error = -EBADF; | ||
583 | server->info_filp = fget(data.info_fd); | ||
584 | if (!server->info_filp) | ||
585 | goto out_bdi; | ||
586 | error = -ENOTSOCK; | ||
587 | sock_inode = file_inode(server->info_filp); | ||
588 | if (!S_ISSOCK(sock_inode->i_mode)) | ||
589 | goto out_fput2; | ||
590 | info_sock = SOCKET_I(sock_inode); | ||
591 | if (!info_sock) | 571 | if (!info_sock) |
592 | goto out_fput2; | 572 | goto out_bdi; |
573 | server->info_sock = info_sock; | ||
593 | error = -EBADFD; | 574 | error = -EBADFD; |
594 | if (info_sock->type != SOCK_STREAM) | 575 | if (info_sock->type != SOCK_STREAM) |
595 | goto out_fput2; | 576 | goto out_fput2; |
596 | server->info_sock = info_sock; | ||
597 | } | 577 | } |
598 | 578 | ||
599 | /* server->lock = 0; */ | 579 | /* server->lock = 0; */ |
@@ -621,7 +601,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
621 | now because of PATH_MAX changes.. */ | 601 | now because of PATH_MAX changes.. */ |
622 | if (server->m.time_out < 1) { | 602 | if (server->m.time_out < 1) { |
623 | server->m.time_out = 10; | 603 | server->m.time_out = 10; |
624 | printk(KERN_INFO "You need to recompile your ncpfs utils..\n"); | 604 | pr_info("You need to recompile your ncpfs utils..\n"); |
625 | } | 605 | } |
626 | server->m.time_out = server->m.time_out * HZ / 100; | 606 | server->m.time_out = server->m.time_out * HZ / 100; |
627 | server->m.file_mode = (server->m.file_mode & S_IRWXUGO) | S_IFREG; | 607 | server->m.file_mode = (server->m.file_mode & S_IRWXUGO) | S_IFREG; |
@@ -682,7 +662,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
682 | ncp_unlock_server(server); | 662 | ncp_unlock_server(server); |
683 | if (error < 0) | 663 | if (error < 0) |
684 | goto out_rxbuf; | 664 | goto out_rxbuf; |
685 | DPRINTK("ncp_fill_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb)); | 665 | ncp_dbg(1, "NCP_SBP(sb) = %p\n", NCP_SBP(sb)); |
686 | 666 | ||
687 | error = -EMSGSIZE; /* -EREMOTESIDEINCOMPATIBLE */ | 667 | error = -EMSGSIZE; /* -EREMOTESIDEINCOMPATIBLE */ |
688 | #ifdef CONFIG_NCPFS_PACKET_SIGNING | 668 | #ifdef CONFIG_NCPFS_PACKET_SIGNING |
@@ -710,7 +690,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
710 | if (ncp_negotiate_buffersize(server, default_bufsize, | 690 | if (ncp_negotiate_buffersize(server, default_bufsize, |
711 | &(server->buffer_size)) != 0) | 691 | &(server->buffer_size)) != 0) |
712 | goto out_disconnect; | 692 | goto out_disconnect; |
713 | DPRINTK("ncpfs: bufsize = %d\n", server->buffer_size); | 693 | ncp_dbg(1, "bufsize = %d\n", server->buffer_size); |
714 | 694 | ||
715 | memset(&finfo, 0, sizeof(finfo)); | 695 | memset(&finfo, 0, sizeof(finfo)); |
716 | finfo.i.attributes = aDIR; | 696 | finfo.i.attributes = aDIR; |
@@ -739,7 +719,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
739 | root_inode = ncp_iget(sb, &finfo); | 719 | root_inode = ncp_iget(sb, &finfo); |
740 | if (!root_inode) | 720 | if (!root_inode) |
741 | goto out_disconnect; | 721 | goto out_disconnect; |
742 | DPRINTK("ncp_fill_super: root vol=%d\n", NCP_FINFO(root_inode)->volNumber); | 722 | ncp_dbg(1, "root vol=%d\n", NCP_FINFO(root_inode)->volNumber); |
743 | sb->s_root = d_make_root(root_inode); | 723 | sb->s_root = d_make_root(root_inode); |
744 | if (!sb->s_root) | 724 | if (!sb->s_root) |
745 | goto out_disconnect; | 725 | goto out_disconnect; |
@@ -765,17 +745,12 @@ out_nls: | |||
765 | mutex_destroy(&server->root_setup_lock); | 745 | mutex_destroy(&server->root_setup_lock); |
766 | mutex_destroy(&server->mutex); | 746 | mutex_destroy(&server->mutex); |
767 | out_fput2: | 747 | out_fput2: |
768 | if (server->info_filp) | 748 | if (server->info_sock) |
769 | fput(server->info_filp); | 749 | sockfd_put(server->info_sock); |
770 | out_bdi: | 750 | out_bdi: |
771 | bdi_destroy(&server->bdi); | 751 | bdi_destroy(&server->bdi); |
772 | out_fput: | 752 | out_fput: |
773 | /* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>: | 753 | sockfd_put(sock); |
774 | * | ||
775 | * The previously used put_filp(ncp_filp); was bogus, since | ||
776 | * it doesn't perform proper unlocking. | ||
777 | */ | ||
778 | fput(ncp_filp); | ||
779 | out: | 754 | out: |
780 | put_pid(data.wdog_pid); | 755 | put_pid(data.wdog_pid); |
781 | sb->s_fs_info = NULL; | 756 | sb->s_fs_info = NULL; |
@@ -808,9 +783,9 @@ static void ncp_put_super(struct super_block *sb) | |||
808 | mutex_destroy(&server->root_setup_lock); | 783 | mutex_destroy(&server->root_setup_lock); |
809 | mutex_destroy(&server->mutex); | 784 | mutex_destroy(&server->mutex); |
810 | 785 | ||
811 | if (server->info_filp) | 786 | if (server->info_sock) |
812 | fput(server->info_filp); | 787 | sockfd_put(server->info_sock); |
813 | fput(server->ncp_filp); | 788 | sockfd_put(server->ncp_sock); |
814 | kill_pid(server->m.wdog_pid, SIGTERM, 1); | 789 | kill_pid(server->m.wdog_pid, SIGTERM, 1); |
815 | put_pid(server->m.wdog_pid); | 790 | put_pid(server->m.wdog_pid); |
816 | 791 | ||
@@ -985,8 +960,7 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr) | |||
985 | if ((attr->ia_valid & ATTR_SIZE) != 0) { | 960 | if ((attr->ia_valid & ATTR_SIZE) != 0) { |
986 | int written; | 961 | int written; |
987 | 962 | ||
988 | DPRINTK("ncpfs: trying to change size to %ld\n", | 963 | ncp_dbg(1, "trying to change size to %llu\n", attr->ia_size); |
989 | attr->ia_size); | ||
990 | 964 | ||
991 | if ((result = ncp_make_open(inode, O_WRONLY)) < 0) { | 965 | if ((result = ncp_make_open(inode, O_WRONLY)) < 0) { |
992 | result = -EACCES; | 966 | result = -EACCES; |
@@ -1072,7 +1046,7 @@ MODULE_ALIAS_FS("ncpfs"); | |||
1072 | static int __init init_ncp_fs(void) | 1046 | static int __init init_ncp_fs(void) |
1073 | { | 1047 | { |
1074 | int err; | 1048 | int err; |
1075 | DPRINTK("ncpfs: init_ncp_fs called\n"); | 1049 | ncp_dbg(1, "called\n"); |
1076 | 1050 | ||
1077 | err = init_inodecache(); | 1051 | err = init_inodecache(); |
1078 | if (err) | 1052 | if (err) |
@@ -1089,7 +1063,7 @@ out1: | |||
1089 | 1063 | ||
1090 | static void __exit exit_ncp_fs(void) | 1064 | static void __exit exit_ncp_fs(void) |
1091 | { | 1065 | { |
1092 | DPRINTK("ncpfs: exit_ncp_fs called\n"); | 1066 | ncp_dbg(1, "called\n"); |
1093 | unregister_filesystem(&ncp_fs_type); | 1067 | unregister_filesystem(&ncp_fs_type); |
1094 | destroy_inodecache(); | 1068 | destroy_inodecache(); |
1095 | } | 1069 | } |