aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ncpfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ncpfs/inode.c')
-rw-r--r--fs/ncpfs/inode.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index b4de38cf49f5..985fabb26aca 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -139,7 +139,7 @@ static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi)
139 inode->i_mode = nwi->nfs.mode; 139 inode->i_mode = nwi->nfs.mode;
140 } 140 }
141 141
142 inode->i_blocks = (inode->i_size + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT; 142 inode->i_blocks = (i_size_read(inode) + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT;
143 143
144 inode->i_mtime.tv_sec = ncp_date_dos2unix(nwi->modifyTime, nwi->modifyDate); 144 inode->i_mtime.tv_sec = ncp_date_dos2unix(nwi->modifyTime, nwi->modifyDate);
145 inode->i_ctime.tv_sec = ncp_date_dos2unix(nwi->creationTime, nwi->creationDate); 145 inode->i_ctime.tv_sec = ncp_date_dos2unix(nwi->creationTime, nwi->creationDate);
@@ -158,18 +158,21 @@ static void ncp_update_attrs(struct inode *inode, struct ncp_entry_info *nwinfo)
158 inode->i_mode = server->m.dir_mode; 158 inode->i_mode = server->m.dir_mode;
159 /* for directories dataStreamSize seems to be some 159 /* for directories dataStreamSize seems to be some
160 Object ID ??? */ 160 Object ID ??? */
161 inode->i_size = NCP_BLOCK_SIZE; 161 i_size_write(inode, NCP_BLOCK_SIZE);
162 } else { 162 } else {
163 u32 size;
164
163 inode->i_mode = server->m.file_mode; 165 inode->i_mode = server->m.file_mode;
164 inode->i_size = le32_to_cpu(nwi->dataStreamSize); 166 size = le32_to_cpu(nwi->dataStreamSize);
167 i_size_write(inode, size);
165#ifdef CONFIG_NCPFS_EXTRAS 168#ifdef CONFIG_NCPFS_EXTRAS
166 if ((server->m.flags & (NCP_MOUNT_EXTRAS|NCP_MOUNT_SYMLINKS)) 169 if ((server->m.flags & (NCP_MOUNT_EXTRAS|NCP_MOUNT_SYMLINKS))
167 && (nwi->attributes & aSHARED)) { 170 && (nwi->attributes & aSHARED)) {
168 switch (nwi->attributes & (aHIDDEN|aSYSTEM)) { 171 switch (nwi->attributes & (aHIDDEN|aSYSTEM)) {
169 case aHIDDEN: 172 case aHIDDEN:
170 if (server->m.flags & NCP_MOUNT_SYMLINKS) { 173 if (server->m.flags & NCP_MOUNT_SYMLINKS) {
171 if (/* (inode->i_size >= NCP_MIN_SYMLINK_SIZE) 174 if (/* (size >= NCP_MIN_SYMLINK_SIZE)
172 && */ (inode->i_size <= NCP_MAX_SYMLINK_SIZE)) { 175 && */ (size <= NCP_MAX_SYMLINK_SIZE)) {
173 inode->i_mode = (inode->i_mode & ~S_IFMT) | S_IFLNK; 176 inode->i_mode = (inode->i_mode & ~S_IFMT) | S_IFLNK;
174 NCP_FINFO(inode)->flags |= NCPI_KLUDGE_SYMLINK; 177 NCP_FINFO(inode)->flags |= NCPI_KLUDGE_SYMLINK;
175 break; 178 break;
@@ -208,7 +211,7 @@ void ncp_update_inode2(struct inode* inode, struct ncp_entry_info *nwinfo)
208} 211}
209 212
210/* 213/*
211 * Fill in the inode based on the ncp_entry_info structure. 214 * Fill in the inode based on the ncp_entry_info structure. Used only for brand new inodes.
212 */ 215 */
213static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo) 216static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
214{ 217{
@@ -254,6 +257,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info)
254 if (inode) { 257 if (inode) {
255 atomic_set(&NCP_FINFO(inode)->opened, info->opened); 258 atomic_set(&NCP_FINFO(inode)->opened, info->opened);
256 259
260 inode->i_mapping->backing_dev_info = sb->s_bdi;
257 inode->i_ino = info->ino; 261 inode->i_ino = info->ino;
258 ncp_set_attr(inode, info); 262 ncp_set_attr(inode, info);
259 if (S_ISREG(inode->i_mode)) { 263 if (S_ISREG(inode->i_mode)) {
@@ -299,10 +303,12 @@ ncp_evict_inode(struct inode *inode)
299 303
300static void ncp_stop_tasks(struct ncp_server *server) { 304static void ncp_stop_tasks(struct ncp_server *server) {
301 struct sock* sk = server->ncp_sock->sk; 305 struct sock* sk = server->ncp_sock->sk;
302 306
307 lock_sock(sk);
303 sk->sk_error_report = server->error_report; 308 sk->sk_error_report = server->error_report;
304 sk->sk_data_ready = server->data_ready; 309 sk->sk_data_ready = server->data_ready;
305 sk->sk_write_space = server->write_space; 310 sk->sk_write_space = server->write_space;
311 release_sock(sk);
306 del_timer_sync(&server->timeout_tm); 312 del_timer_sync(&server->timeout_tm);
307 flush_scheduled_work(); 313 flush_scheduled_work();
308} 314}
@@ -565,10 +571,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
565/* server->conn_status = 0; */ 571/* server->conn_status = 0; */
566/* server->root_dentry = NULL; */ 572/* server->root_dentry = NULL; */
567/* server->root_setuped = 0; */ 573/* server->root_setuped = 0; */
574 mutex_init(&server->root_setup_lock);
568#ifdef CONFIG_NCPFS_PACKET_SIGNING 575#ifdef CONFIG_NCPFS_PACKET_SIGNING
569/* server->sign_wanted = 0; */ 576/* server->sign_wanted = 0; */
570/* server->sign_active = 0; */ 577/* server->sign_active = 0; */
571#endif 578#endif
579 init_rwsem(&server->auth_rwsem);
572 server->auth.auth_type = NCP_AUTH_NONE; 580 server->auth.auth_type = NCP_AUTH_NONE;
573/* server->auth.object_name_len = 0; */ 581/* server->auth.object_name_len = 0; */
574/* server->auth.object_name = NULL; */ 582/* server->auth.object_name = NULL; */
@@ -593,16 +601,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
593 server->nls_io = load_nls_default(); 601 server->nls_io = load_nls_default();
594#endif /* CONFIG_NCPFS_NLS */ 602#endif /* CONFIG_NCPFS_NLS */
595 603
596 server->dentry_ttl = 0; /* no caching */ 604 atomic_set(&server->dentry_ttl, 0); /* no caching */
597 605
598 INIT_LIST_HEAD(&server->tx.requests); 606 INIT_LIST_HEAD(&server->tx.requests);
599 mutex_init(&server->rcv.creq_mutex); 607 mutex_init(&server->rcv.creq_mutex);
600 server->tx.creq = NULL; 608 server->tx.creq = NULL;
601 server->rcv.creq = NULL; 609 server->rcv.creq = NULL;
602 server->data_ready = sock->sk->sk_data_ready;
603 server->write_space = sock->sk->sk_write_space;
604 server->error_report = sock->sk->sk_error_report;
605 sock->sk->sk_user_data = server;
606 610
607 init_timer(&server->timeout_tm); 611 init_timer(&server->timeout_tm);
608#undef NCP_PACKET_SIZE 612#undef NCP_PACKET_SIZE
@@ -619,6 +623,11 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
619 if (server->rxbuf == NULL) 623 if (server->rxbuf == NULL)
620 goto out_txbuf; 624 goto out_txbuf;
621 625
626 lock_sock(sock->sk);
627 server->data_ready = sock->sk->sk_data_ready;
628 server->write_space = sock->sk->sk_write_space;
629 server->error_report = sock->sk->sk_error_report;
630 sock->sk->sk_user_data = server;
622 sock->sk->sk_data_ready = ncp_tcp_data_ready; 631 sock->sk->sk_data_ready = ncp_tcp_data_ready;
623 sock->sk->sk_error_report = ncp_tcp_error_report; 632 sock->sk->sk_error_report = ncp_tcp_error_report;
624 if (sock->type == SOCK_STREAM) { 633 if (sock->type == SOCK_STREAM) {
@@ -634,6 +643,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
634 server->timeout_tm.data = (unsigned long)server; 643 server->timeout_tm.data = (unsigned long)server;
635 server->timeout_tm.function = ncpdgram_timeout_call; 644 server->timeout_tm.function = ncpdgram_timeout_call;
636 } 645 }
646 release_sock(sock->sk);
637 647
638 ncp_lock_server(server); 648 ncp_lock_server(server);
639 error = ncp_connect(server); 649 error = ncp_connect(server);
@@ -658,8 +668,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
658 goto out_disconnect; 668 goto out_disconnect;
659 } 669 }
660 } 670 }
671 ncp_lock_server(server);
661 if (options & 2) 672 if (options & 2)
662 server->sign_wanted = 1; 673 server->sign_wanted = 1;
674 ncp_unlock_server(server);
663 } 675 }
664 else 676 else
665#endif /* CONFIG_NCPFS_PACKET_SIGNING */ 677#endif /* CONFIG_NCPFS_PACKET_SIGNING */
@@ -720,6 +732,9 @@ out_nls:
720 unload_nls(server->nls_io); 732 unload_nls(server->nls_io);
721 unload_nls(server->nls_vol); 733 unload_nls(server->nls_vol);
722#endif 734#endif
735 mutex_destroy(&server->rcv.creq_mutex);
736 mutex_destroy(&server->root_setup_lock);
737 mutex_destroy(&server->mutex);
723out_fput2: 738out_fput2:
724 if (server->info_filp) 739 if (server->info_filp)
725 fput(server->info_filp); 740 fput(server->info_filp);
@@ -743,8 +758,6 @@ static void ncp_put_super(struct super_block *sb)
743{ 758{
744 struct ncp_server *server = NCP_SBP(sb); 759 struct ncp_server *server = NCP_SBP(sb);
745 760
746 lock_kernel();
747
748 ncp_lock_server(server); 761 ncp_lock_server(server);
749 ncp_disconnect(server); 762 ncp_disconnect(server);
750 ncp_unlock_server(server); 763 ncp_unlock_server(server);
@@ -756,6 +769,9 @@ static void ncp_put_super(struct super_block *sb)
756 unload_nls(server->nls_vol); 769 unload_nls(server->nls_vol);
757 unload_nls(server->nls_io); 770 unload_nls(server->nls_io);
758#endif /* CONFIG_NCPFS_NLS */ 771#endif /* CONFIG_NCPFS_NLS */
772 mutex_destroy(&server->rcv.creq_mutex);
773 mutex_destroy(&server->root_setup_lock);
774 mutex_destroy(&server->mutex);
759 775
760 if (server->info_filp) 776 if (server->info_filp)
761 fput(server->info_filp); 777 fput(server->info_filp);
@@ -771,8 +787,6 @@ static void ncp_put_super(struct super_block *sb)
771 vfree(server->packet); 787 vfree(server->packet);
772 sb->s_fs_info = NULL; 788 sb->s_fs_info = NULL;
773 kfree(server); 789 kfree(server);
774
775 unlock_kernel();
776} 790}
777 791
778static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf) 792static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf)
@@ -851,10 +865,8 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
851 865
852 result = -EIO; 866 result = -EIO;
853 867
854 lock_kernel();
855
856 server = NCP_SERVER(inode); 868 server = NCP_SERVER(inode);
857 if ((!server) || !ncp_conn_valid(server)) 869 if (!server) /* How this could happen? */
858 goto out; 870 goto out;
859 871
860 /* ageing the dentry to force validation */ 872 /* ageing the dentry to force validation */
@@ -981,8 +993,6 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
981 result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode), 993 result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode),
982 inode, info_mask, &info); 994 inode, info_mask, &info);
983 if (result != 0) { 995 if (result != 0) {
984 result = -EACCES;
985
986 if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE)) { 996 if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE)) {
987 /* NetWare seems not to allow this. I 997 /* NetWare seems not to allow this. I
988 do not know why. So, just tell the 998 do not know why. So, just tell the
@@ -1005,7 +1015,8 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
1005 mark_inode_dirty(inode); 1015 mark_inode_dirty(inode);
1006 1016
1007out: 1017out:
1008 unlock_kernel(); 1018 if (result > 0)
1019 result = -EACCES;
1009 return result; 1020 return result;
1010} 1021}
1011 1022