@@ -129,6 +129,17 @@ build_path_from_dentry(struct dentry *direntry)
129129 return full_path ;
130130}
131131
132+ static void setup_cifs_dentry (struct cifsTconInfo * tcon ,
133+ struct dentry * direntry ,
134+ struct inode * newinode )
135+ {
136+ if (tcon -> nocase )
137+ direntry -> d_op = & cifs_ci_dentry_ops ;
138+ else
139+ direntry -> d_op = & cifs_dentry_ops ;
140+ d_instantiate (direntry , newinode );
141+ }
142+
132143/* Inode operations in similar order to how they appear in Linux file fs.h */
133144
134145int
@@ -139,29 +150,31 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
139150 int xid ;
140151 int create_options = CREATE_NOT_DIR ;
141152 int oplock = 0 ;
153+ /* BB below access is too much for the mknod to request */
142154 int desiredAccess = GENERIC_READ | GENERIC_WRITE ;
143155 __u16 fileHandle ;
144156 struct cifs_sb_info * cifs_sb ;
145- struct cifsTconInfo * pTcon ;
157+ struct cifsTconInfo * tcon ;
146158 char * full_path = NULL ;
147159 FILE_ALL_INFO * buf = NULL ;
148160 struct inode * newinode = NULL ;
149- struct cifsFileInfo * pCifsFile = NULL ;
150161 struct cifsInodeInfo * pCifsInode ;
151162 int disposition = FILE_OVERWRITE_IF ;
152163 bool write_only = false;
153164
154165 xid = GetXid ();
155166
156167 cifs_sb = CIFS_SB (inode -> i_sb );
157- pTcon = cifs_sb -> tcon ;
168+ tcon = cifs_sb -> tcon ;
158169
159170 full_path = build_path_from_dentry (direntry );
160171 if (full_path == NULL ) {
161172 FreeXid (xid );
162173 return - ENOMEM ;
163174 }
164175
176+ mode &= ~current -> fs -> umask ;
177+
165178 if (nd && (nd -> flags & LOOKUP_OPEN )) {
166179 int oflags = nd -> intent .open .flags ;
167180
@@ -196,17 +209,15 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
196209 return - ENOMEM ;
197210 }
198211
199- mode &= ~current -> fs -> umask ;
200-
201212 /*
202213 * if we're not using unix extensions, see if we need to set
203214 * ATTR_READONLY on the create call
204215 */
205- if (!pTcon -> unix_ext && (mode & S_IWUGO ) == 0 )
216+ if (!tcon -> unix_ext && (mode & S_IWUGO ) == 0 )
206217 create_options |= CREATE_OPTION_READONLY ;
207218
208219 if (cifs_sb -> tcon -> ses -> capabilities & CAP_NT_SMBS )
209- rc = CIFSSMBOpen (xid , pTcon , full_path , disposition ,
220+ rc = CIFSSMBOpen (xid , tcon , full_path , disposition ,
210221 desiredAccess , create_options ,
211222 & fileHandle , & oplock , buf , cifs_sb -> local_nls ,
212223 cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR );
@@ -215,7 +226,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
215226
216227 if (rc == - EIO ) {
217228 /* old server, retry the open legacy style */
218- rc = SMBLegacyOpen (xid , pTcon , full_path , disposition ,
229+ rc = SMBLegacyOpen (xid , tcon , full_path , disposition ,
219230 desiredAccess , create_options ,
220231 & fileHandle , & oplock , buf , cifs_sb -> local_nls ,
221232 cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR );
@@ -225,7 +236,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
225236 } else {
226237 /* If Open reported that we actually created a file
227238 then we now have to set the mode if possible */
228- if ((pTcon -> unix_ext ) && (oplock & CIFS_CREATE_ACTION )) {
239+ if ((tcon -> unix_ext ) && (oplock & CIFS_CREATE_ACTION )) {
229240 struct cifs_unix_set_info_args args = {
230241 .mode = mode ,
231242 .ctime = NO_CHANGE_64 ,
@@ -244,20 +255,20 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
244255 args .uid = NO_CHANGE_64 ;
245256 args .gid = NO_CHANGE_64 ;
246257 }
247- CIFSSMBUnixSetInfo (xid , pTcon , full_path , & args ,
258+ CIFSSMBUnixSetInfo (xid , tcon , full_path , & args ,
248259 cifs_sb -> local_nls ,
249260 cifs_sb -> mnt_cifs_flags &
250261 CIFS_MOUNT_MAP_SPECIAL_CHR );
251262 } else {
252263 /* BB implement mode setting via Windows security
253264 descriptors e.g. */
254- /* CIFSSMBWinSetPerms(xid,pTcon ,path,mode,-1,-1,nls);*/
265+ /* CIFSSMBWinSetPerms(xid,tcon ,path,mode,-1,-1,nls);*/
255266
256267 /* Could set r/o dos attribute if mode & 0222 == 0 */
257268 }
258269
259270 /* server might mask mode so we have to query for it */
260- if (pTcon -> unix_ext )
271+ if (tcon -> unix_ext )
261272 rc = cifs_get_inode_info_unix (& newinode , full_path ,
262273 inode -> i_sb , xid );
263274 else {
@@ -283,22 +294,17 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
283294 }
284295
285296 if (rc != 0 ) {
286- cFYI (1 ,
287- ("Create worked but get_inode_info failed rc = %d" ,
288- rc ));
289- } else {
290- if (pTcon -> nocase )
291- direntry -> d_op = & cifs_ci_dentry_ops ;
292- else
293- direntry -> d_op = & cifs_dentry_ops ;
294- d_instantiate (direntry , newinode );
295- }
297+ cFYI (1 , ("Create worked, get_inode_info failed rc = %d" ,
298+ rc ));
299+ } else
300+ setup_cifs_dentry (tcon , direntry , newinode );
301+
296302 if ((nd == NULL /* nfsd case - nfs srv does not set nd */ ) ||
297303 (!(nd -> flags & LOOKUP_OPEN ))) {
298304 /* mknod case - do not leave file open */
299- CIFSSMBClose (xid , pTcon , fileHandle );
305+ CIFSSMBClose (xid , tcon , fileHandle );
300306 } else if (newinode ) {
301- pCifsFile =
307+ struct cifsFileInfo * pCifsFile =
302308 kzalloc (sizeof (struct cifsFileInfo ), GFP_KERNEL );
303309
304310 if (pCifsFile == NULL )
@@ -316,7 +322,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
316322 /* set the following in open now
317323 pCifsFile->pfile = file; */
318324 write_lock (& GlobalSMBSeslock );
319- list_add (& pCifsFile -> tlist , & pTcon -> openFileList );
325+ list_add (& pCifsFile -> tlist , & tcon -> openFileList );
320326 pCifsInode = CIFS_I (newinode );
321327 if (pCifsInode ) {
322328 /* if readable file instance put first in list*/
0 commit comments