@@ -139,7 +139,7 @@ static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi)
139139 inode -> i_mode = nwi -> nfs .mode ;
140140 }
141141
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 ;
143143
144144 inode -> i_mtime .tv_sec = ncp_date_dos2unix (nwi -> modifyTime , nwi -> modifyDate );
145145 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)
158158 inode -> i_mode = server -> m .dir_mode ;
159159 /* for directories dataStreamSize seems to be some
160160 Object ID ??? */
161- inode -> i_size = NCP_BLOCK_SIZE ;
161+ i_size_write ( inode , NCP_BLOCK_SIZE ) ;
162162 } else {
163+ u32 size ;
164+
163165 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 );
165168#ifdef CONFIG_NCPFS_EXTRAS
166169 if ((server -> m .flags & (NCP_MOUNT_EXTRAS |NCP_MOUNT_SYMLINKS ))
167170 && (nwi -> attributes & aSHARED )) {
168171 switch (nwi -> attributes & (aHIDDEN |aSYSTEM )) {
169172 case aHIDDEN :
170173 if (server -> m .flags & NCP_MOUNT_SYMLINKS ) {
171- if (/* (inode->i_size >= NCP_MIN_SYMLINK_SIZE)
172- && */ (inode -> i_size <= NCP_MAX_SYMLINK_SIZE )) {
174+ if (/* (size >= NCP_MIN_SYMLINK_SIZE)
175+ && */ (size <= NCP_MAX_SYMLINK_SIZE )) {
173176 inode -> i_mode = (inode -> i_mode & ~S_IFMT ) | S_IFLNK ;
174177 NCP_FINFO (inode )-> flags |= NCPI_KLUDGE_SYMLINK ;
175178 break ;
@@ -208,7 +211,7 @@ void ncp_update_inode2(struct inode* inode, struct ncp_entry_info *nwinfo)
208211}
209212
210213/*
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.
212215 */
213216static void ncp_set_attr (struct inode * inode , struct ncp_entry_info * nwinfo )
214217{
@@ -254,6 +257,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info)
254257 if (inode ) {
255258 atomic_set (& NCP_FINFO (inode )-> opened , info -> opened );
256259
260+ inode -> i_mapping -> backing_dev_info = sb -> s_bdi ;
257261 inode -> i_ino = info -> ino ;
258262 ncp_set_attr (inode , info );
259263 if (S_ISREG (inode -> i_mode )) {
@@ -565,10 +569,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
565569/* server->conn_status = 0; */
566570/* server->root_dentry = NULL; */
567571/* server->root_setuped = 0; */
572+ mutex_init (& server -> root_setup_lock );
568573#ifdef CONFIG_NCPFS_PACKET_SIGNING
569574/* server->sign_wanted = 0; */
570575/* server->sign_active = 0; */
571576#endif
577+ init_rwsem (& server -> auth_rwsem );
572578 server -> auth .auth_type = NCP_AUTH_NONE ;
573579/* server->auth.object_name_len = 0; */
574580/* server->auth.object_name = NULL; */
@@ -593,7 +599,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
593599 server -> nls_io = load_nls_default ();
594600#endif /* CONFIG_NCPFS_NLS */
595601
596- server -> dentry_ttl = 0 ; /* no caching */
602+ atomic_set ( & server -> dentry_ttl , 0 ) ; /* no caching */
597603
598604 INIT_LIST_HEAD (& server -> tx .requests );
599605 mutex_init (& server -> rcv .creq_mutex );
@@ -658,8 +664,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
658664 goto out_disconnect ;
659665 }
660666 }
667+ ncp_lock_server (server );
661668 if (options & 2 )
662669 server -> sign_wanted = 1 ;
670+ ncp_unlock_server (server );
663671 }
664672 else
665673#endif /* CONFIG_NCPFS_PACKET_SIGNING */
@@ -720,6 +728,9 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
720728 unload_nls (server -> nls_io );
721729 unload_nls (server -> nls_vol );
722730#endif
731+ mutex_destroy (& server -> rcv .creq_mutex );
732+ mutex_destroy (& server -> root_setup_lock );
733+ mutex_destroy (& server -> mutex );
723734out_fput2 :
724735 if (server -> info_filp )
725736 fput (server -> info_filp );
@@ -743,8 +754,6 @@ static void ncp_put_super(struct super_block *sb)
743754{
744755 struct ncp_server * server = NCP_SBP (sb );
745756
746- lock_kernel ();
747-
748757 ncp_lock_server (server );
749758 ncp_disconnect (server );
750759 ncp_unlock_server (server );
@@ -756,6 +765,9 @@ static void ncp_put_super(struct super_block *sb)
756765 unload_nls (server -> nls_vol );
757766 unload_nls (server -> nls_io );
758767#endif /* CONFIG_NCPFS_NLS */
768+ mutex_destroy (& server -> rcv .creq_mutex );
769+ mutex_destroy (& server -> root_setup_lock );
770+ mutex_destroy (& server -> mutex );
759771
760772 if (server -> info_filp )
761773 fput (server -> info_filp );
@@ -771,8 +783,6 @@ static void ncp_put_super(struct super_block *sb)
771783 vfree (server -> packet );
772784 sb -> s_fs_info = NULL ;
773785 kfree (server );
774-
775- unlock_kernel ();
776786}
777787
778788static int ncp_statfs (struct dentry * dentry , struct kstatfs * buf )
@@ -851,10 +861,8 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
851861
852862 result = - EIO ;
853863
854- lock_kernel ();
855-
856864 server = NCP_SERVER (inode );
857- if (( !server ) || ! ncp_conn_valid ( server ))
865+ if (!server ) /* How this could happen? */
858866 goto out ;
859867
860868 /* ageing the dentry to force validation */
@@ -981,8 +989,6 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
981989 result = ncp_modify_file_or_subdir_dos_info (NCP_SERVER (inode ),
982990 inode , info_mask , & info );
983991 if (result != 0 ) {
984- result = - EACCES ;
985-
986992 if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE )) {
987993 /* NetWare seems not to allow this. I
988994 do not know why. So, just tell the
@@ -1005,7 +1011,8 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
10051011 mark_inode_dirty (inode );
10061012
10071013out :
1008- unlock_kernel ();
1014+ if (result > 0 )
1015+ result = - EACCES ;
10091016 return result ;
10101017}
10111018
0 commit comments