aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-05-15 03:34:44 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-15 03:34:44 -0400
commit63fe46da9c380b3f2bbdf3765044649517cc717c (patch)
tree9478c1aca1d692b408955aea20c9cd9a37e589c0 /fs/cifs
parent99dd1a2b8347ac2ae802300b7862f6f7bcf17139 (diff)
parent066b2118976e6e7cc50eed39e2747c75343a23c4 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts: drivers/net/wireless/iwlwifi/iwl-4965-rs.c drivers/net/wireless/rt2x00/rt61pci.c
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/CHANGES3
-rw-r--r--fs/cifs/asn1.c10
-rw-r--r--fs/cifs/cifs_dfs_ref.c25
-rw-r--r--fs/cifs/cifsacl.c16
-rw-r--r--fs/cifs/cifsfs.c72
-rw-r--r--fs/cifs/cifsfs.h10
-rw-r--r--fs/cifs/cifsglob.h44
-rw-r--r--fs/cifs/cifspdu.h3
-rw-r--r--fs/cifs/cifsproto.h15
-rw-r--r--fs/cifs/cifssmb.c54
-rw-r--r--fs/cifs/connect.c232
-rw-r--r--fs/cifs/dir.c34
-rw-r--r--fs/cifs/dns_resolve.c62
-rw-r--r--fs/cifs/fcntl.c2
-rw-r--r--fs/cifs/file.c80
-rw-r--r--fs/cifs/inode.c81
-rw-r--r--fs/cifs/link.c2
-rw-r--r--fs/cifs/misc.c33
-rw-r--r--fs/cifs/netmisc.c32
-rw-r--r--fs/cifs/readdir.c12
-rw-r--r--fs/cifs/smbencrypt.c8
-rw-r--r--fs/cifs/xattr.c2
22 files changed, 421 insertions, 411 deletions
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 05c9da6181c3..8355e918fddf 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,3 +1,6 @@
1Version 1.53
2------------
3
1Version 1.52 4Version 1.52
2------------ 5------------
3Fix oops on second mount to server when null auth is used. 6Fix oops on second mount to server when null auth is used.
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
index bcda2c6b6a04..cb52cbbe45ff 100644
--- a/fs/cifs/asn1.c
+++ b/fs/cifs/asn1.c
@@ -460,8 +460,8 @@ decode_negTokenInit(unsigned char *security_blob, int length,
460 unsigned char *sequence_end; 460 unsigned char *sequence_end;
461 unsigned long *oid = NULL; 461 unsigned long *oid = NULL;
462 unsigned int cls, con, tag, oidlen, rc; 462 unsigned int cls, con, tag, oidlen, rc;
463 int use_ntlmssp = FALSE; 463 bool use_ntlmssp = false;
464 int use_kerberos = FALSE; 464 bool use_kerberos = false;
465 465
466 *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/ 466 *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/
467 467
@@ -561,15 +561,15 @@ decode_negTokenInit(unsigned char *security_blob, int length,
561 if (compare_oid(oid, oidlen, 561 if (compare_oid(oid, oidlen,
562 MSKRB5_OID, 562 MSKRB5_OID,
563 MSKRB5_OID_LEN)) 563 MSKRB5_OID_LEN))
564 use_kerberos = TRUE; 564 use_kerberos = true;
565 else if (compare_oid(oid, oidlen, 565 else if (compare_oid(oid, oidlen,
566 KRB5_OID, 566 KRB5_OID,
567 KRB5_OID_LEN)) 567 KRB5_OID_LEN))
568 use_kerberos = TRUE; 568 use_kerberos = true;
569 else if (compare_oid(oid, oidlen, 569 else if (compare_oid(oid, oidlen,
570 NTLMSSP_OID, 570 NTLMSSP_OID,
571 NTLMSSP_OID_LEN)) 571 NTLMSSP_OID_LEN))
572 use_ntlmssp = TRUE; 572 use_ntlmssp = true;
573 573
574 kfree(oid); 574 kfree(oid);
575 } 575 }
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index 95024c066d89..f6fdecf6598c 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -93,15 +93,11 @@ static char *cifs_get_share_name(const char *node_name)
93 /* find sharename end */ 93 /* find sharename end */
94 pSep++; 94 pSep++;
95 pSep = memchr(UNC+(pSep-UNC), '\\', len-(pSep-UNC)); 95 pSep = memchr(UNC+(pSep-UNC), '\\', len-(pSep-UNC));
96 if (!pSep) { 96 if (pSep) {
97 cERROR(1, ("%s:2 cant find share name in node name: %s", 97 /* trim path up to sharename end
98 __func__, node_name)); 98 * now we have share name in UNC */
99 kfree(UNC); 99 *pSep = 0;
100 return NULL;
101 } 100 }
102 /* trim path up to sharename end
103 * * now we have share name in UNC */
104 *pSep = 0;
105 101
106 return UNC; 102 return UNC;
107} 103}
@@ -188,7 +184,7 @@ static char *compose_mount_options(const char *sb_mountdata,
188 tkn_e = strchr(tkn_e+1, '\\'); 184 tkn_e = strchr(tkn_e+1, '\\');
189 if (tkn_e) { 185 if (tkn_e) {
190 strcat(mountdata, ",prefixpath="); 186 strcat(mountdata, ",prefixpath=");
191 strcat(mountdata, tkn_e); 187 strcat(mountdata, tkn_e+1);
192 } 188 }
193 } 189 }
194 190
@@ -244,7 +240,8 @@ static char *build_full_dfs_path_from_dentry(struct dentry *dentry)
244 return NULL; 240 return NULL;
245 241
246 if (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS) { 242 if (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS) {
247 /* we should use full path name to correct working with DFS */ 243 int i;
244 /* we should use full path name for correct working with DFS */
248 l_max_len = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE+1) + 245 l_max_len = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE+1) +
249 strnlen(search_path, MAX_PATHCONF) + 1; 246 strnlen(search_path, MAX_PATHCONF) + 1;
250 tmp_path = kmalloc(l_max_len, GFP_KERNEL); 247 tmp_path = kmalloc(l_max_len, GFP_KERNEL);
@@ -253,8 +250,14 @@ static char *build_full_dfs_path_from_dentry(struct dentry *dentry)
253 return NULL; 250 return NULL;
254 } 251 }
255 strncpy(tmp_path, cifs_sb->tcon->treeName, l_max_len); 252 strncpy(tmp_path, cifs_sb->tcon->treeName, l_max_len);
256 strcat(tmp_path, search_path);
257 tmp_path[l_max_len-1] = 0; 253 tmp_path[l_max_len-1] = 0;
254 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
255 for (i = 0; i < l_max_len; i++) {
256 if (tmp_path[i] == '\\')
257 tmp_path[i] = '/';
258 }
259 strncat(tmp_path, search_path, l_max_len - strlen(tmp_path));
260
258 full_path = tmp_path; 261 full_path = tmp_path;
259 kfree(search_path); 262 kfree(search_path);
260 } else { 263 } else {
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index e99d4faf5f02..34902cff5400 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -559,7 +559,7 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode,
559 const char *path, const __u16 *pfid) 559 const char *path, const __u16 *pfid)
560{ 560{
561 struct cifsFileInfo *open_file = NULL; 561 struct cifsFileInfo *open_file = NULL;
562 int unlock_file = FALSE; 562 bool unlock_file = false;
563 int xid; 563 int xid;
564 int rc = -EIO; 564 int rc = -EIO;
565 __u16 fid; 565 __u16 fid;
@@ -586,10 +586,10 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode,
586 cifs_sb = CIFS_SB(sb); 586 cifs_sb = CIFS_SB(sb);
587 587
588 if (open_file) { 588 if (open_file) {
589 unlock_file = TRUE; 589 unlock_file = true;
590 fid = open_file->netfid; 590 fid = open_file->netfid;
591 } else if (pfid == NULL) { 591 } else if (pfid == NULL) {
592 int oplock = FALSE; 592 int oplock = 0;
593 /* open file */ 593 /* open file */
594 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, 594 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
595 READ_CONTROL, 0, &fid, &oplock, NULL, 595 READ_CONTROL, 0, &fid, &oplock, NULL,
@@ -604,7 +604,7 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode,
604 604
605 rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen); 605 rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen);
606 cFYI(1, ("GetCIFSACL rc = %d ACL len %d", rc, *pacllen)); 606 cFYI(1, ("GetCIFSACL rc = %d ACL len %d", rc, *pacllen));
607 if (unlock_file == TRUE) /* find_readable_file increments ref count */ 607 if (unlock_file == true) /* find_readable_file increments ref count */
608 atomic_dec(&open_file->wrtPending); 608 atomic_dec(&open_file->wrtPending);
609 else if (pfid == NULL) /* if opened above we have to close the handle */ 609 else if (pfid == NULL) /* if opened above we have to close the handle */
610 CIFSSMBClose(xid, cifs_sb->tcon, fid); 610 CIFSSMBClose(xid, cifs_sb->tcon, fid);
@@ -619,7 +619,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
619 struct inode *inode, const char *path) 619 struct inode *inode, const char *path)
620{ 620{
621 struct cifsFileInfo *open_file; 621 struct cifsFileInfo *open_file;
622 int unlock_file = FALSE; 622 bool unlock_file = false;
623 int xid; 623 int xid;
624 int rc = -EIO; 624 int rc = -EIO;
625 __u16 fid; 625 __u16 fid;
@@ -640,10 +640,10 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
640 640
641 open_file = find_readable_file(CIFS_I(inode)); 641 open_file = find_readable_file(CIFS_I(inode));
642 if (open_file) { 642 if (open_file) {
643 unlock_file = TRUE; 643 unlock_file = true;
644 fid = open_file->netfid; 644 fid = open_file->netfid;
645 } else { 645 } else {
646 int oplock = FALSE; 646 int oplock = 0;
647 /* open file */ 647 /* open file */
648 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, 648 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
649 WRITE_DAC, 0, &fid, &oplock, NULL, 649 WRITE_DAC, 0, &fid, &oplock, NULL,
@@ -658,7 +658,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
658 658
659 rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); 659 rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
660 cFYI(DBG2, ("SetCIFSACL rc = %d", rc)); 660 cFYI(DBG2, ("SetCIFSACL rc = %d", rc));
661 if (unlock_file == TRUE) 661 if (unlock_file)
662 atomic_dec(&open_file->wrtPending); 662 atomic_dec(&open_file->wrtPending);
663 else 663 else
664 CIFSSMBClose(xid, cifs_sb->tcon, fid); 664 CIFSSMBClose(xid, cifs_sb->tcon, fid);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 39c2cbdface7..427a7c695896 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -222,50 +222,50 @@ static int
222cifs_statfs(struct dentry *dentry, struct kstatfs *buf) 222cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
223{ 223{
224 struct super_block *sb = dentry->d_sb; 224 struct super_block *sb = dentry->d_sb;
225 int xid; 225 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
226 struct cifsTconInfo *tcon = cifs_sb->tcon;
226 int rc = -EOPNOTSUPP; 227 int rc = -EOPNOTSUPP;
227 struct cifs_sb_info *cifs_sb; 228 int xid;
228 struct cifsTconInfo *pTcon;
229 229
230 xid = GetXid(); 230 xid = GetXid();
231 231
232 cifs_sb = CIFS_SB(sb);
233 pTcon = cifs_sb->tcon;
234
235 buf->f_type = CIFS_MAGIC_NUMBER; 232 buf->f_type = CIFS_MAGIC_NUMBER;
236 233
237 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */ 234 /*
238 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would 235 * PATH_MAX may be too long - it would presumably be total path,
239 presumably be total path, but note 236 * but note that some servers (includinng Samba 3) have a shorter
240 that some servers (includinng Samba 3) 237 * maximum path.
241 have a shorter maximum path */ 238 *
239 * Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO.
240 */
241 buf->f_namelen = PATH_MAX;
242 buf->f_files = 0; /* undefined */ 242 buf->f_files = 0; /* undefined */
243 buf->f_ffree = 0; /* unlimited */ 243 buf->f_ffree = 0; /* unlimited */
244 244
245/* BB we could add a second check for a QFS Unix capability bit */ 245 /*
246/* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */ 246 * We could add a second check for a QFS Unix capability bit
247 if ((pTcon->ses->capabilities & CAP_UNIX) && (CIFS_POSIX_EXTENSIONS & 247 */
248 le64_to_cpu(pTcon->fsUnixInfo.Capability))) 248 if ((tcon->ses->capabilities & CAP_UNIX) &&
249 rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf); 249 (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability)))
250 250 rc = CIFSSMBQFSPosixInfo(xid, tcon, buf);
251 /* Only need to call the old QFSInfo if failed 251
252 on newer one */ 252 /*
253 if (rc) 253 * Only need to call the old QFSInfo if failed on newer one,
254 if (pTcon->ses->capabilities & CAP_NT_SMBS) 254 * e.g. by OS/2.
255 rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */ 255 **/
256 256 if (rc && (tcon->ses->capabilities & CAP_NT_SMBS))
257 /* Some old Windows servers also do not support level 103, retry with 257 rc = CIFSSMBQFSInfo(xid, tcon, buf);
258 older level one if old server failed the previous call or we 258
259 bypassed it because we detected that this was an older LANMAN sess */ 259 /*
260 * Some old Windows servers also do not support level 103, retry with
261 * older level one if old server failed the previous call or we
262 * bypassed it because we detected that this was an older LANMAN sess
263 */
260 if (rc) 264 if (rc)
261 rc = SMBOldQFSInfo(xid, pTcon, buf); 265 rc = SMBOldQFSInfo(xid, tcon, buf);
262 /* int f_type; 266
263 __fsid_t f_fsid;
264 int f_namelen; */
265 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */
266 FreeXid(xid); 267 FreeXid(xid);
267 return 0; /* always return success? what if volume is no 268 return 0;
268 longer available? */
269} 269}
270 270
271static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd) 271static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd)
@@ -306,8 +306,8 @@ cifs_alloc_inode(struct super_block *sb)
306 /* Until the file is open and we have gotten oplock 306 /* Until the file is open and we have gotten oplock
307 info back from the server, can not assume caching of 307 info back from the server, can not assume caching of
308 file data or metadata */ 308 file data or metadata */
309 cifs_inode->clientCanCacheRead = FALSE; 309 cifs_inode->clientCanCacheRead = false;
310 cifs_inode->clientCanCacheAll = FALSE; 310 cifs_inode->clientCanCacheAll = false;
311 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ 311 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
312 312
313 /* Can not set i_flags here - they get immediately overwritten 313 /* Can not set i_flags here - they get immediately overwritten
@@ -940,7 +940,7 @@ static int cifs_oplock_thread(void *dummyarg)
940 rc = CIFSSMBLock(0, pTcon, netfid, 940 rc = CIFSSMBLock(0, pTcon, netfid,
941 0 /* len */ , 0 /* offset */, 0, 941 0 /* len */ , 0 /* offset */, 0,
942 0, LOCKING_ANDX_OPLOCK_RELEASE, 942 0, LOCKING_ANDX_OPLOCK_RELEASE,
943 0 /* wait flag */); 943 false /* wait flag */);
944 cFYI(1, ("Oplock release rc = %d", rc)); 944 cFYI(1, ("Oplock release rc = %d", rc));
945 } 945 }
946 } else 946 } else
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index e1dd9f32e1d7..cd1301a09b3b 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -24,14 +24,6 @@
24 24
25#define ROOT_I 2 25#define ROOT_I 2
26 26
27#ifndef FALSE
28#define FALSE 0
29#endif
30
31#ifndef TRUE
32#define TRUE 1
33#endif
34
35extern struct file_system_type cifs_fs_type; 27extern struct file_system_type cifs_fs_type;
36extern const struct address_space_operations cifs_addr_ops; 28extern const struct address_space_operations cifs_addr_ops;
37extern const struct address_space_operations cifs_addr_ops_smallbuf; 29extern const struct address_space_operations cifs_addr_ops_smallbuf;
@@ -110,5 +102,5 @@ extern int cifs_ioctl(struct inode *inode, struct file *filep,
110extern const struct export_operations cifs_export_ops; 102extern const struct export_operations cifs_export_ops;
111#endif /* EXPERIMENTAL */ 103#endif /* EXPERIMENTAL */
112 104
113#define CIFS_VERSION "1.52" 105#define CIFS_VERSION "1.53"
114#endif /* _CIFSFS_H */ 106#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 69a2e1942542..b7d9f698e63e 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -57,14 +57,6 @@
57 57
58#include "cifspdu.h" 58#include "cifspdu.h"
59 59
60#ifndef FALSE
61#define FALSE 0
62#endif
63
64#ifndef TRUE
65#define TRUE 1
66#endif
67
68#ifndef XATTR_DOS_ATTRIB 60#ifndef XATTR_DOS_ATTRIB
69#define XATTR_DOS_ATTRIB "user.DOSATTRIB" 61#define XATTR_DOS_ATTRIB "user.DOSATTRIB"
70#endif 62#endif
@@ -147,7 +139,7 @@ struct TCP_Server_Info {
147 enum protocolEnum protocolType; 139 enum protocolEnum protocolType;
148 char versionMajor; 140 char versionMajor;
149 char versionMinor; 141 char versionMinor;
150 unsigned svlocal:1; /* local server or remote */ 142 bool svlocal:1; /* local server or remote */
151 atomic_t socketUseCount; /* number of open cifs sessions on socket */ 143 atomic_t socketUseCount; /* number of open cifs sessions on socket */
152 atomic_t inFlight; /* number of requests on the wire to server */ 144 atomic_t inFlight; /* number of requests on the wire to server */
153#ifdef CONFIG_CIFS_STATS2 145#ifdef CONFIG_CIFS_STATS2
@@ -286,10 +278,10 @@ struct cifsTconInfo {
286 FILE_SYSTEM_DEVICE_INFO fsDevInfo; 278 FILE_SYSTEM_DEVICE_INFO fsDevInfo;
287 FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */ 279 FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
288 FILE_SYSTEM_UNIX_INFO fsUnixInfo; 280 FILE_SYSTEM_UNIX_INFO fsUnixInfo;
289 unsigned ipc:1; /* set if connection to IPC$ eg for RPC/PIPES */ 281 bool ipc:1; /* set if connection to IPC$ eg for RPC/PIPES */
290 unsigned retry:1; 282 bool retry:1;
291 unsigned nocase:1; 283 bool nocase:1;
292 unsigned unix_ext:1; /* if off disable Linux extensions to CIFS protocol 284 bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
293 for this mount even if server would support */ 285 for this mount even if server would support */
294 /* BB add field for back pointer to sb struct(s)? */ 286 /* BB add field for back pointer to sb struct(s)? */
295}; 287};
@@ -317,10 +309,10 @@ struct cifs_search_info {
317 char *srch_entries_start; 309 char *srch_entries_start;
318 char *presume_name; 310 char *presume_name;
319 unsigned int resume_name_len; 311 unsigned int resume_name_len;
320 unsigned endOfSearch:1; 312 bool endOfSearch:1;
321 unsigned emptyDir:1; 313 bool emptyDir:1;
322 unsigned unicode:1; 314 bool unicode:1;
323 unsigned smallBuf:1; /* so we know which buf_release function to call */ 315 bool smallBuf:1; /* so we know which buf_release function to call */
324}; 316};
325 317
326struct cifsFileInfo { 318struct cifsFileInfo {
@@ -335,9 +327,9 @@ struct cifsFileInfo {
335 struct inode *pInode; /* needed for oplock break */ 327 struct inode *pInode; /* needed for oplock break */
336 struct mutex lock_mutex; 328 struct mutex lock_mutex;
337 struct list_head llist; /* list of byte range locks we have. */ 329 struct list_head llist; /* list of byte range locks we have. */
338 unsigned closePend:1; /* file is marked to close */ 330 bool closePend:1; /* file is marked to close */
339 unsigned invalidHandle:1; /* file closed via session abend */ 331 bool invalidHandle:1; /* file closed via session abend */
340 unsigned messageMode:1; /* for pipes: message vs byte mode */ 332 bool messageMode:1; /* for pipes: message vs byte mode */
341 atomic_t wrtPending; /* handle in use - defer close */ 333 atomic_t wrtPending; /* handle in use - defer close */
342 struct semaphore fh_sem; /* prevents reopen race after dead ses*/ 334 struct semaphore fh_sem; /* prevents reopen race after dead ses*/
343 char *search_resume_name; /* BB removeme BB */ 335 char *search_resume_name; /* BB removeme BB */
@@ -356,9 +348,9 @@ struct cifsInodeInfo {
356 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ 348 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
357 atomic_t inUse; /* num concurrent users (local openers cifs) of file*/ 349 atomic_t inUse; /* num concurrent users (local openers cifs) of file*/
358 unsigned long time; /* jiffies of last update/check of inode */ 350 unsigned long time; /* jiffies of last update/check of inode */
359 unsigned clientCanCacheRead:1; /* read oplock */ 351 bool clientCanCacheRead:1; /* read oplock */
360 unsigned clientCanCacheAll:1; /* read and writebehind oplock */ 352 bool clientCanCacheAll:1; /* read and writebehind oplock */
361 unsigned oplockPending:1; 353 bool oplockPending:1;
362 struct inode vfs_inode; 354 struct inode vfs_inode;
363}; 355};
364 356
@@ -426,9 +418,9 @@ struct mid_q_entry {
426 struct smb_hdr *resp_buf; /* response buffer */ 418 struct smb_hdr *resp_buf; /* response buffer */
427 int midState; /* wish this were enum but can not pass to wait_event */ 419 int midState; /* wish this were enum but can not pass to wait_event */
428 __u8 command; /* smb command code */ 420 __u8 command; /* smb command code */
429 unsigned largeBuf:1; /* if valid response, is pointer to large buf */ 421 bool largeBuf:1; /* if valid response, is pointer to large buf */
430 unsigned multiRsp:1; /* multiple trans2 responses for one request */ 422 bool multiRsp:1; /* multiple trans2 responses for one request */
431 unsigned multiEnd:1; /* both received */ 423 bool multiEnd:1; /* both received */
432}; 424};
433 425
434struct oplock_q_entry { 426struct oplock_q_entry {
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index 9f49c2f3582c..c43bf4b7a556 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -340,6 +340,7 @@
340#define OPEN_NO_RECALL 0x00400000 340#define OPEN_NO_RECALL 0x00400000
341#define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */ 341#define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */
342#define CREATE_OPTIONS_MASK 0x007FFFFF 342#define CREATE_OPTIONS_MASK 0x007FFFFF
343#define CREATE_OPTION_READONLY 0x10000000
343#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */ 344#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
344 345
345/* ImpersonationLevel flags */ 346/* ImpersonationLevel flags */
@@ -2050,7 +2051,7 @@ typedef struct {
2050 to 0xFFFF00 */ 2051 to 0xFFFF00 */
2051#define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080 2052#define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
2052#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */ 2053#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */
2053#define CIFS_UNIX_TRANPSORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */ 2054#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */
2054#define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and 2055#define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and
2055 QFS PROXY call */ 2056 QFS PROXY call */
2056#ifdef CONFIG_CIFS_POSIX 2057#ifdef CONFIG_CIFS_POSIX
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 50f9fdae19b3..d481f6c5a2be 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -59,8 +59,9 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
59 struct smb_hdr *out_buf, 59 struct smb_hdr *out_buf,
60 int *bytes_returned); 60 int *bytes_returned);
61extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length); 61extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length);
62extern int is_valid_oplock_break(struct smb_hdr *smb, struct TCP_Server_Info *); 62extern bool is_valid_oplock_break(struct smb_hdr *smb,
63extern int is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof); 63 struct TCP_Server_Info *);
64extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof);
64extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *); 65extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *);
65#ifdef CONFIG_CIFS_EXPERIMENTAL 66#ifdef CONFIG_CIFS_EXPERIMENTAL
66extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *); 67extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *);
@@ -69,7 +70,7 @@ extern unsigned int smbCalcSize(struct smb_hdr *ptr);
69extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr); 70extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr);
70extern int decode_negTokenInit(unsigned char *security_blob, int length, 71extern int decode_negTokenInit(unsigned char *security_blob, int length,
71 enum securityEnum *secType); 72 enum securityEnum *secType);
72extern int cifs_inet_pton(int, char *source, void *dst); 73extern int cifs_inet_pton(const int, const char *source, void *dst);
73extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr); 74extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr);
74extern void header_assemble(struct smb_hdr *, char /* command */ , 75extern void header_assemble(struct smb_hdr *, char /* command */ ,
75 const struct cifsTconInfo *, int /* length of 76 const struct cifsTconInfo *, int /* length of
@@ -187,12 +188,12 @@ extern int CIFSSMBSetAttrLegacy(int xid, struct cifsTconInfo *tcon,
187#endif /* possibly unneeded function */ 188#endif /* possibly unneeded function */
188extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, 189extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon,
189 const char *fileName, __u64 size, 190 const char *fileName, __u64 size,
190 int setAllocationSizeFlag, 191 bool setAllocationSizeFlag,
191 const struct nls_table *nls_codepage, 192 const struct nls_table *nls_codepage,
192 int remap_special_chars); 193 int remap_special_chars);
193extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, 194extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon,
194 __u64 size, __u16 fileHandle, __u32 opener_pid, 195 __u64 size, __u16 fileHandle, __u32 opener_pid,
195 int AllocSizeFlag); 196 bool AllocSizeFlag);
196extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon, 197extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon,
197 char *full_path, __u64 mode, __u64 uid, 198 char *full_path, __u64 mode, __u64 uid,
198 __u64 gid, dev_t dev, 199 __u64 gid, dev_t dev,
@@ -291,11 +292,11 @@ extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
291 const __u16 netfid, const __u64 len, 292 const __u16 netfid, const __u64 len,
292 const __u64 offset, const __u32 numUnlock, 293 const __u64 offset, const __u32 numUnlock,
293 const __u32 numLock, const __u8 lockType, 294 const __u32 numLock, const __u8 lockType,
294 const int waitFlag); 295 const bool waitFlag);
295extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, 296extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
296 const __u16 smb_file_id, const int get_flag, 297 const __u16 smb_file_id, const int get_flag,
297 const __u64 len, struct file_lock *, 298 const __u64 len, struct file_lock *,
298 const __u16 lock_type, const int waitFlag); 299 const __u16 lock_type, const bool waitFlag);
299extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon); 300extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon);
300extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses); 301extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses);
301 302
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 4728fa982a4e..95fbba4ea7d4 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -95,7 +95,7 @@ static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
95 list_for_each_safe(tmp, tmp1, &pTcon->openFileList) { 95 list_for_each_safe(tmp, tmp1, &pTcon->openFileList) {
96 open_file = list_entry(tmp, struct cifsFileInfo, tlist); 96 open_file = list_entry(tmp, struct cifsFileInfo, tlist);
97 if (open_file) 97 if (open_file)
98 open_file->invalidHandle = TRUE; 98 open_file->invalidHandle = true;
99 } 99 }
100 write_unlock(&GlobalSMBSeslock); 100 write_unlock(&GlobalSMBSeslock);
101 /* BB Add call to invalidate_inodes(sb) for all superblocks mounted 101 /* BB Add call to invalidate_inodes(sb) for all superblocks mounted
@@ -141,7 +141,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
141 if (tcon->ses->server->tcpStatus == 141 if (tcon->ses->server->tcpStatus ==
142 CifsNeedReconnect) { 142 CifsNeedReconnect) {
143 /* on "soft" mounts we wait once */ 143 /* on "soft" mounts we wait once */
144 if ((tcon->retry == FALSE) || 144 if (!tcon->retry ||
145 (tcon->ses->status == CifsExiting)) { 145 (tcon->ses->status == CifsExiting)) {
146 cFYI(1, ("gave up waiting on " 146 cFYI(1, ("gave up waiting on "
147 "reconnect in smb_init")); 147 "reconnect in smb_init"));
@@ -289,7 +289,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
289 if (tcon->ses->server->tcpStatus == 289 if (tcon->ses->server->tcpStatus ==
290 CifsNeedReconnect) { 290 CifsNeedReconnect) {
291 /* on "soft" mounts we wait once */ 291 /* on "soft" mounts we wait once */
292 if ((tcon->retry == FALSE) || 292 if (!tcon->retry ||
293 (tcon->ses->status == CifsExiting)) { 293 (tcon->ses->status == CifsExiting)) {
294 cFYI(1, ("gave up waiting on " 294 cFYI(1, ("gave up waiting on "
295 "reconnect in smb_init")); 295 "reconnect in smb_init"));
@@ -1224,11 +1224,8 @@ OldOpenRetry:
1224 else /* BB FIXME BB */ 1224 else /* BB FIXME BB */
1225 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); 1225 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/);
1226 1226
1227 /* if ((omode & S_IWUGO) == 0) 1227 if (create_options & CREATE_OPTION_READONLY)
1228 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/ 1228 pSMB->FileAttributes |= cpu_to_le16(ATTR_READONLY);
1229 /* Above line causes problems due to vfs splitting create into two
1230 pieces - need to set mode after file created not while it is
1231 being created */
1232 1229
1233 /* BB FIXME BB */ 1230 /* BB FIXME BB */
1234/* pSMB->CreateOptions = cpu_to_le32(create_options & 1231/* pSMB->CreateOptions = cpu_to_le32(create_options &
@@ -1331,17 +1328,16 @@ openRetry:
1331 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM); 1328 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM);
1332 else 1329 else
1333 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL); 1330 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL);
1331
1334 /* XP does not handle ATTR_POSIX_SEMANTICS */ 1332 /* XP does not handle ATTR_POSIX_SEMANTICS */
1335 /* but it helps speed up case sensitive checks for other 1333 /* but it helps speed up case sensitive checks for other
1336 servers such as Samba */ 1334 servers such as Samba */
1337 if (tcon->ses->capabilities & CAP_UNIX) 1335 if (tcon->ses->capabilities & CAP_UNIX)
1338 pSMB->FileAttributes |= cpu_to_le32(ATTR_POSIX_SEMANTICS); 1336 pSMB->FileAttributes |= cpu_to_le32(ATTR_POSIX_SEMANTICS);
1339 1337
1340 /* if ((omode & S_IWUGO) == 0) 1338 if (create_options & CREATE_OPTION_READONLY)
1341 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/ 1339 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);
1342 /* Above line causes problems due to vfs splitting create into two 1340
1343 pieces - need to set mode after file created not while it is
1344 being created */
1345 pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL); 1341 pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
1346 pSMB->CreateDisposition = cpu_to_le32(openDisposition); 1342 pSMB->CreateDisposition = cpu_to_le32(openDisposition);
1347 pSMB->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK); 1343 pSMB->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK);
@@ -1686,7 +1682,7 @@ int
1686CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, 1682CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1687 const __u16 smb_file_id, const __u64 len, 1683 const __u16 smb_file_id, const __u64 len,
1688 const __u64 offset, const __u32 numUnlock, 1684 const __u64 offset, const __u32 numUnlock,
1689 const __u32 numLock, const __u8 lockType, const int waitFlag) 1685 const __u32 numLock, const __u8 lockType, const bool waitFlag)
1690{ 1686{
1691 int rc = 0; 1687 int rc = 0;
1692 LOCK_REQ *pSMB = NULL; 1688 LOCK_REQ *pSMB = NULL;
@@ -1695,7 +1691,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1695 int timeout = 0; 1691 int timeout = 0;
1696 __u16 count; 1692 __u16 count;
1697 1693
1698 cFYI(1, ("CIFSSMBLock timeout %d numLock %d", waitFlag, numLock)); 1694 cFYI(1, ("CIFSSMBLock timeout %d numLock %d", (int)waitFlag, numLock));
1699 rc = small_smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB); 1695 rc = small_smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB);
1700 1696
1701 if (rc) 1697 if (rc)
@@ -1706,7 +1702,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1706 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) { 1702 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
1707 timeout = CIFS_ASYNC_OP; /* no response expected */ 1703 timeout = CIFS_ASYNC_OP; /* no response expected */
1708 pSMB->Timeout = 0; 1704 pSMB->Timeout = 0;
1709 } else if (waitFlag == TRUE) { 1705 } else if (waitFlag) {
1710 timeout = CIFS_BLOCKING_OP; /* blocking operation, no timeout */ 1706 timeout = CIFS_BLOCKING_OP; /* blocking operation, no timeout */
1711 pSMB->Timeout = cpu_to_le32(-1);/* blocking - do not time out */ 1707 pSMB->Timeout = cpu_to_le32(-1);/* blocking - do not time out */
1712 } else { 1708 } else {
@@ -1756,7 +1752,7 @@ int
1756CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, 1752CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1757 const __u16 smb_file_id, const int get_flag, const __u64 len, 1753 const __u16 smb_file_id, const int get_flag, const __u64 len,
1758 struct file_lock *pLockData, const __u16 lock_type, 1754 struct file_lock *pLockData, const __u16 lock_type,
1759 const int waitFlag) 1755 const bool waitFlag)
1760{ 1756{
1761 struct smb_com_transaction2_sfi_req *pSMB = NULL; 1757 struct smb_com_transaction2_sfi_req *pSMB = NULL;
1762 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; 1758 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
@@ -3581,9 +3577,9 @@ findFirstRetry:
3581 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3577 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
3582 if (rc == 0) { 3578 if (rc == 0) {
3583 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3579 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3584 psrch_inf->unicode = TRUE; 3580 psrch_inf->unicode = true;
3585 else 3581 else
3586 psrch_inf->unicode = FALSE; 3582 psrch_inf->unicode = false;
3587 3583
3588 psrch_inf->ntwrk_buf_start = (char *)pSMBr; 3584 psrch_inf->ntwrk_buf_start = (char *)pSMBr;
3589 psrch_inf->smallBuf = 0; 3585 psrch_inf->smallBuf = 0;
@@ -3594,9 +3590,9 @@ findFirstRetry:
3594 le16_to_cpu(pSMBr->t2.ParameterOffset)); 3590 le16_to_cpu(pSMBr->t2.ParameterOffset));
3595 3591
3596 if (parms->EndofSearch) 3592 if (parms->EndofSearch)
3597 psrch_inf->endOfSearch = TRUE; 3593 psrch_inf->endOfSearch = true;
3598 else 3594 else
3599 psrch_inf->endOfSearch = FALSE; 3595 psrch_inf->endOfSearch = false;
3600 3596
3601 psrch_inf->entries_in_buffer = 3597 psrch_inf->entries_in_buffer =
3602 le16_to_cpu(parms->SearchCount); 3598 le16_to_cpu(parms->SearchCount);
@@ -3624,7 +3620,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3624 3620
3625 cFYI(1, ("In FindNext")); 3621 cFYI(1, ("In FindNext"));
3626 3622
3627 if (psrch_inf->endOfSearch == TRUE) 3623 if (psrch_inf->endOfSearch)
3628 return -ENOENT; 3624 return -ENOENT;
3629 3625
3630 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 3626 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
@@ -3682,7 +3678,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3682 cifs_stats_inc(&tcon->num_fnext); 3678 cifs_stats_inc(&tcon->num_fnext);
3683 if (rc) { 3679 if (rc) {
3684 if (rc == -EBADF) { 3680 if (rc == -EBADF) {
3685 psrch_inf->endOfSearch = TRUE; 3681 psrch_inf->endOfSearch = true;
3686 rc = 0; /* search probably was closed at end of search*/ 3682 rc = 0; /* search probably was closed at end of search*/
3687 } else 3683 } else
3688 cFYI(1, ("FindNext returned = %d", rc)); 3684 cFYI(1, ("FindNext returned = %d", rc));
@@ -3692,9 +3688,9 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3692 if (rc == 0) { 3688 if (rc == 0) {
3693 /* BB fixme add lock for file (srch_info) struct here */ 3689 /* BB fixme add lock for file (srch_info) struct here */
3694 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3690 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3695 psrch_inf->unicode = TRUE; 3691 psrch_inf->unicode = true;
3696 else 3692 else
3697 psrch_inf->unicode = FALSE; 3693 psrch_inf->unicode = false;
3698 response_data = (char *) &pSMBr->hdr.Protocol + 3694 response_data = (char *) &pSMBr->hdr.Protocol +
3699 le16_to_cpu(pSMBr->t2.ParameterOffset); 3695 le16_to_cpu(pSMBr->t2.ParameterOffset);
3700 parms = (T2_FNEXT_RSP_PARMS *)response_data; 3696 parms = (T2_FNEXT_RSP_PARMS *)response_data;
@@ -3709,9 +3705,9 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3709 psrch_inf->ntwrk_buf_start = (char *)pSMB; 3705 psrch_inf->ntwrk_buf_start = (char *)pSMB;
3710 psrch_inf->smallBuf = 0; 3706 psrch_inf->smallBuf = 0;
3711 if (parms->EndofSearch) 3707 if (parms->EndofSearch)
3712 psrch_inf->endOfSearch = TRUE; 3708 psrch_inf->endOfSearch = true;
3713 else 3709 else
3714 psrch_inf->endOfSearch = FALSE; 3710 psrch_inf->endOfSearch = false;
3715 psrch_inf->entries_in_buffer = 3711 psrch_inf->entries_in_buffer =
3716 le16_to_cpu(parms->SearchCount); 3712 le16_to_cpu(parms->SearchCount);
3717 psrch_inf->index_of_last_entry += 3713 psrch_inf->index_of_last_entry +=
@@ -4586,7 +4582,7 @@ QFSPosixRetry:
4586 4582
4587int 4583int
4588CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName, 4584CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName,
4589 __u64 size, int SetAllocation, 4585 __u64 size, bool SetAllocation,
4590 const struct nls_table *nls_codepage, int remap) 4586 const struct nls_table *nls_codepage, int remap)
4591{ 4587{
4592 struct smb_com_transaction2_spi_req *pSMB = NULL; 4588 struct smb_com_transaction2_spi_req *pSMB = NULL;
@@ -4675,7 +4671,7 @@ SetEOFRetry:
4675 4671
4676int 4672int
4677CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, 4673CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
4678 __u16 fid, __u32 pid_of_opener, int SetAllocation) 4674 __u16 fid, __u32 pid_of_opener, bool SetAllocation)
4679{ 4675{
4680 struct smb_com_transaction2_sfi_req *pSMB = NULL; 4676 struct smb_com_transaction2_sfi_req *pSMB = NULL;
4681 char *data_offset; 4677 char *data_offset;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index e17106730168..f428bf3bf1a9 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -49,8 +49,6 @@
49#define CIFS_PORT 445 49#define CIFS_PORT 445
50#define RFC1001_PORT 139 50#define RFC1001_PORT 139
51 51
52static DECLARE_COMPLETION(cifsd_complete);
53
54extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, 52extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
55 unsigned char *p24); 53 unsigned char *p24);
56 54
@@ -71,23 +69,23 @@ struct smb_vol {
71 mode_t file_mode; 69 mode_t file_mode;
72 mode_t dir_mode; 70 mode_t dir_mode;
73 unsigned secFlg; 71 unsigned secFlg;
74 unsigned rw:1; 72 bool rw:1;
75 unsigned retry:1; 73 bool retry:1;
76 unsigned intr:1; 74 bool intr:1;
77 unsigned setuids:1; 75 bool setuids:1;
78 unsigned override_uid:1; 76 bool override_uid:1;
79 unsigned override_gid:1; 77 bool override_gid:1;
80 unsigned noperm:1; 78 bool noperm:1;
81 unsigned no_psx_acl:1; /* set if posix acl support should be disabled */ 79 bool no_psx_acl:1; /* set if posix acl support should be disabled */
82 unsigned cifs_acl:1; 80 bool cifs_acl:1;
83 unsigned no_xattr:1; /* set if xattr (EA) support should be disabled*/ 81 bool no_xattr:1; /* set if xattr (EA) support should be disabled*/
84 unsigned server_ino:1; /* use inode numbers from server ie UniqueId */ 82 bool server_ino:1; /* use inode numbers from server ie UniqueId */
85 unsigned direct_io:1; 83 bool direct_io:1;
86 unsigned remap:1; /* set to remap seven reserved chars in filenames */ 84 bool remap:1; /* set to remap seven reserved chars in filenames */
87 unsigned posix_paths:1; /* unset to not ask for posix pathnames. */ 85 bool posix_paths:1; /* unset to not ask for posix pathnames. */
88 unsigned no_linux_ext:1; 86 bool no_linux_ext:1;
89 unsigned sfu_emul:1; 87 bool sfu_emul:1;
90 unsigned nullauth:1; /* attempt to authenticate with null user */ 88 bool nullauth:1; /* attempt to authenticate with null user */
91 unsigned nocase; /* request case insensitive filenames */ 89 unsigned nocase; /* request case insensitive filenames */
92 unsigned nobrl; /* disable sending byte range locks to srv */ 90 unsigned nobrl; /* disable sending byte range locks to srv */
93 unsigned int rsize; 91 unsigned int rsize;
@@ -345,18 +343,16 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
345 struct task_struct *task_to_wake = NULL; 343 struct task_struct *task_to_wake = NULL;
346 struct mid_q_entry *mid_entry; 344 struct mid_q_entry *mid_entry;
347 char temp; 345 char temp;
348 int isLargeBuf = FALSE; 346 bool isLargeBuf = false;
349 int isMultiRsp; 347 bool isMultiRsp;
350 int reconnect; 348 int reconnect;
351 349
352 current->flags |= PF_MEMALLOC; 350 current->flags |= PF_MEMALLOC;
353 server->tsk = current; /* save process info to wake at shutdown */
354 cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current))); 351 cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));
355 write_lock(&GlobalSMBSeslock); 352 write_lock(&GlobalSMBSeslock);
356 atomic_inc(&tcpSesAllocCount); 353 atomic_inc(&tcpSesAllocCount);
357 length = tcpSesAllocCount.counter; 354 length = tcpSesAllocCount.counter;
358 write_unlock(&GlobalSMBSeslock); 355 write_unlock(&GlobalSMBSeslock);
359 complete(&cifsd_complete);
360 if (length > 1) 356 if (length > 1)
361 mempool_resize(cifs_req_poolp, length + cifs_min_rcv, 357 mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
362 GFP_KERNEL); 358 GFP_KERNEL);
@@ -390,8 +386,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
390 } else /* if existing small buf clear beginning */ 386 } else /* if existing small buf clear beginning */
391 memset(smallbuf, 0, sizeof(struct smb_hdr)); 387 memset(smallbuf, 0, sizeof(struct smb_hdr));
392 388
393 isLargeBuf = FALSE; 389 isLargeBuf = false;
394 isMultiRsp = FALSE; 390 isMultiRsp = false;
395 smb_buffer = smallbuf; 391 smb_buffer = smallbuf;
396 iov.iov_base = smb_buffer; 392 iov.iov_base = smb_buffer;
397 iov.iov_len = 4; 393 iov.iov_len = 4;
@@ -517,7 +513,7 @@ incomplete_rcv:
517 reconnect = 0; 513 reconnect = 0;
518 514
519 if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { 515 if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) {
520 isLargeBuf = TRUE; 516 isLargeBuf = true;
521 memcpy(bigbuf, smallbuf, 4); 517 memcpy(bigbuf, smallbuf, 4);
522 smb_buffer = bigbuf; 518 smb_buffer = bigbuf;
523 } 519 }
@@ -582,16 +578,18 @@ incomplete_rcv:
582 (mid_entry->command == smb_buffer->Command)) { 578 (mid_entry->command == smb_buffer->Command)) {
583 if (check2ndT2(smb_buffer,server->maxBuf) > 0) { 579 if (check2ndT2(smb_buffer,server->maxBuf) > 0) {
584 /* We have a multipart transact2 resp */ 580 /* We have a multipart transact2 resp */
585 isMultiRsp = TRUE; 581 isMultiRsp = true;
586 if (mid_entry->resp_buf) { 582 if (mid_entry->resp_buf) {
587 /* merge response - fix up 1st*/ 583 /* merge response - fix up 1st*/
588 if (coalesce_t2(smb_buffer, 584 if (coalesce_t2(smb_buffer,
589 mid_entry->resp_buf)) { 585 mid_entry->resp_buf)) {
590 mid_entry->multiRsp = 1; 586 mid_entry->multiRsp =
587 true;
591 break; 588 break;
592 } else { 589 } else {
593 /* all parts received */ 590 /* all parts received */
594 mid_entry->multiEnd = 1; 591 mid_entry->multiEnd =
592 true;
595 goto multi_t2_fnd; 593 goto multi_t2_fnd;
596 } 594 }
597 } else { 595 } else {
@@ -603,17 +601,15 @@ incomplete_rcv:
603 /* Have first buffer */ 601 /* Have first buffer */
604 mid_entry->resp_buf = 602 mid_entry->resp_buf =
605 smb_buffer; 603 smb_buffer;
606 mid_entry->largeBuf = 1; 604 mid_entry->largeBuf =
605 true;
607 bigbuf = NULL; 606 bigbuf = NULL;
608 } 607 }
609 } 608 }
610 break; 609 break;
611 } 610 }
612 mid_entry->resp_buf = smb_buffer; 611 mid_entry->resp_buf = smb_buffer;
613 if (isLargeBuf) 612 mid_entry->largeBuf = isLargeBuf;
614 mid_entry->largeBuf = 1;
615 else
616 mid_entry->largeBuf = 0;
617multi_t2_fnd: 613multi_t2_fnd:
618 task_to_wake = mid_entry->tsk; 614 task_to_wake = mid_entry->tsk;
619 mid_entry->midState = MID_RESPONSE_RECEIVED; 615 mid_entry->midState = MID_RESPONSE_RECEIVED;
@@ -638,8 +634,8 @@ multi_t2_fnd:
638 smallbuf = NULL; 634 smallbuf = NULL;
639 } 635 }
640 wake_up_process(task_to_wake); 636 wake_up_process(task_to_wake);
641 } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE) 637 } else if (!is_valid_oplock_break(smb_buffer, server) &&
642 && (isMultiRsp == FALSE)) { 638 !isMultiRsp) {
643 cERROR(1, ("No task to wake, unknown frame received! " 639 cERROR(1, ("No task to wake, unknown frame received! "
644 "NumMids %d", midCount.counter)); 640 "NumMids %d", midCount.counter));
645 cifs_dump_mem("Received Data is: ", (char *)smb_buffer, 641 cifs_dump_mem("Received Data is: ", (char *)smb_buffer,
@@ -654,10 +650,20 @@ multi_t2_fnd:
654 650
655 spin_lock(&GlobalMid_Lock); 651 spin_lock(&GlobalMid_Lock);
656 server->tcpStatus = CifsExiting; 652 server->tcpStatus = CifsExiting;
657 server->tsk = NULL; 653 spin_unlock(&GlobalMid_Lock);
654
655 /* don't exit until kthread_stop is called */
656 set_current_state(TASK_UNINTERRUPTIBLE);
657 while (!kthread_should_stop()) {
658 schedule();
659 set_current_state(TASK_UNINTERRUPTIBLE);
660 }
661 set_current_state(TASK_RUNNING);
662
658 /* check if we have blocked requests that need to free */ 663 /* check if we have blocked requests that need to free */
659 /* Note that cifs_max_pending is normally 50, but 664 /* Note that cifs_max_pending is normally 50, but
660 can be set at module install time to as little as two */ 665 can be set at module install time to as little as two */
666 spin_lock(&GlobalMid_Lock);
661 if (atomic_read(&server->inFlight) >= cifs_max_pending) 667 if (atomic_read(&server->inFlight) >= cifs_max_pending)
662 atomic_set(&server->inFlight, cifs_max_pending - 1); 668 atomic_set(&server->inFlight, cifs_max_pending - 1);
663 /* We do not want to set the max_pending too low or we 669 /* We do not want to set the max_pending too low or we
@@ -825,7 +831,7 @@ cifs_parse_mount_options(char *options, const char *devname,
825 vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP); 831 vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP);
826 832
827 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */ 833 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */
828 vol->rw = TRUE; 834 vol->rw = true;
829 /* default is always to request posix paths. */ 835 /* default is always to request posix paths. */
830 vol->posix_paths = 1; 836 vol->posix_paths = 1;
831 837
@@ -1181,7 +1187,7 @@ cifs_parse_mount_options(char *options, const char *devname,
1181 } else if (strnicmp(data, "guest", 5) == 0) { 1187 } else if (strnicmp(data, "guest", 5) == 0) {
1182 /* ignore */ 1188 /* ignore */
1183 } else if (strnicmp(data, "rw", 2) == 0) { 1189 } else if (strnicmp(data, "rw", 2) == 0) {
1184 vol->rw = TRUE; 1190 vol->rw = true;
1185 } else if ((strnicmp(data, "suid", 4) == 0) || 1191 } else if ((strnicmp(data, "suid", 4) == 0) ||
1186 (strnicmp(data, "nosuid", 6) == 0) || 1192 (strnicmp(data, "nosuid", 6) == 0) ||
1187 (strnicmp(data, "exec", 4) == 0) || 1193 (strnicmp(data, "exec", 4) == 0) ||
@@ -1197,7 +1203,7 @@ cifs_parse_mount_options(char *options, const char *devname,
1197 is ok to just ignore them */ 1203 is ok to just ignore them */
1198 continue; 1204 continue;
1199 } else if (strnicmp(data, "ro", 2) == 0) { 1205 } else if (strnicmp(data, "ro", 2) == 0) {
1200 vol->rw = FALSE; 1206 vol->rw = false;
1201 } else if (strnicmp(data, "hard", 4) == 0) { 1207 } else if (strnicmp(data, "hard", 4) == 0) {
1202 vol->retry = 1; 1208 vol->retry = 1;
1203 } else if (strnicmp(data, "soft", 4) == 0) { 1209 } else if (strnicmp(data, "soft", 4) == 0) {
@@ -1305,6 +1311,9 @@ cifs_parse_mount_options(char *options, const char *devname,
1305 "begin with // or \\\\ \n"); 1311 "begin with // or \\\\ \n");
1306 return 1; 1312 return 1;
1307 } 1313 }
1314 value = strpbrk(vol->UNC+2, "/\\");
1315 if (value)
1316 *value = '\\';
1308 } else { 1317 } else {
1309 printk(KERN_WARNING "CIFS: UNC name too long\n"); 1318 printk(KERN_WARNING "CIFS: UNC name too long\n");
1310 return 1; 1319 return 1;
@@ -1318,42 +1327,43 @@ cifs_parse_mount_options(char *options, const char *devname,
1318 1327
1319static struct cifsSesInfo * 1328static struct cifsSesInfo *
1320cifs_find_tcp_session(struct in_addr *target_ip_addr, 1329cifs_find_tcp_session(struct in_addr *target_ip_addr,
1321 struct in6_addr *target_ip6_addr, 1330 struct in6_addr *target_ip6_addr,
1322 char *userName, struct TCP_Server_Info **psrvTcp) 1331 char *userName, struct TCP_Server_Info **psrvTcp)
1323{ 1332{
1324 struct list_head *tmp; 1333 struct list_head *tmp;
1325 struct cifsSesInfo *ses; 1334 struct cifsSesInfo *ses;
1335
1326 *psrvTcp = NULL; 1336 *psrvTcp = NULL;
1327 read_lock(&GlobalSMBSeslock);
1328 1337
1338 read_lock(&GlobalSMBSeslock);
1329 list_for_each(tmp, &GlobalSMBSessionList) { 1339 list_for_each(tmp, &GlobalSMBSessionList) {
1330 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 1340 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
1331 if (ses->server) { 1341 if (!ses->server)
1332 if ((target_ip_addr && 1342 continue;
1333 (ses->server->addr.sockAddr.sin_addr.s_addr 1343
1334 == target_ip_addr->s_addr)) || (target_ip6_addr 1344 if (target_ip_addr &&
1335 && memcmp(&ses->server->addr.sockAddr6.sin6_addr, 1345 ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr)
1336 target_ip6_addr, sizeof(*target_ip6_addr)))) { 1346 continue;
1337 /* BB lock server and tcp session and increment 1347 else if (target_ip6_addr &&
1338 use count here?? */ 1348 memcmp(&ses->server->addr.sockAddr6.sin6_addr,
1339 1349 target_ip6_addr, sizeof(*target_ip6_addr)))
1340 /* found a match on the TCP session */ 1350 continue;
1341 *psrvTcp = ses->server; 1351 /* BB lock server and tcp session; increment use count here?? */
1342 1352
1343 /* BB check if reconnection needed */ 1353 /* found a match on the TCP session */
1344 if (strncmp 1354 *psrvTcp = ses->server;
1345 (ses->userName, userName, 1355
1346 MAX_USERNAME_SIZE) == 0){ 1356 /* BB check if reconnection needed */
1347 read_unlock(&GlobalSMBSeslock); 1357 if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) {
1348 /* Found exact match on both TCP and 1358 read_unlock(&GlobalSMBSeslock);
1349 SMB sessions */ 1359 /* Found exact match on both TCP and
1350 return ses; 1360 SMB sessions */
1351 } 1361 return ses;
1352 }
1353 } 1362 }
1354 /* else tcp and smb sessions need reconnection */ 1363 /* else tcp and smb sessions need reconnection */
1355 } 1364 }
1356 read_unlock(&GlobalSMBSeslock); 1365 read_unlock(&GlobalSMBSeslock);
1366
1357 return NULL; 1367 return NULL;
1358} 1368}
1359 1369
@@ -1362,45 +1372,43 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName)
1362{ 1372{
1363 struct list_head *tmp; 1373 struct list_head *tmp;
1364 struct cifsTconInfo *tcon; 1374 struct cifsTconInfo *tcon;
1375 __be32 old_ip;
1365 1376
1366 read_lock(&GlobalSMBSeslock); 1377 read_lock(&GlobalSMBSeslock);
1378
1367 list_for_each(tmp, &GlobalTreeConnectionList) { 1379 list_for_each(tmp, &GlobalTreeConnectionList) {
1368 cFYI(1, ("Next tcon")); 1380 cFYI(1, ("Next tcon"));
1369 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 1381 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
1370 if (tcon->ses) { 1382 if (!tcon->ses || !tcon->ses->server)
1371 if (tcon->ses->server) { 1383 continue;
1372 cFYI(1, 1384
1373 ("old ip addr: %x == new ip %x ?", 1385 old_ip = tcon->ses->server->addr.sockAddr.sin_addr.s_addr;
1374 tcon->ses->server->addr.sockAddr.sin_addr. 1386 cFYI(1, ("old ip addr: %x == new ip %x ?",
1375 s_addr, new_target_ip_addr)); 1387 old_ip, new_target_ip_addr));
1376 if (tcon->ses->server->addr.sockAddr.sin_addr. 1388
1377 s_addr == new_target_ip_addr) { 1389 if (old_ip != new_target_ip_addr)
1378 /* BB lock tcon, server and tcp session and increment use count here? */ 1390 continue;
1379 /* found a match on the TCP session */ 1391
1380 /* BB check if reconnection needed */ 1392 /* BB lock tcon, server, tcp session and increment use count? */
1381 cFYI(1, 1393 /* found a match on the TCP session */
1382 ("IP match, old UNC: %s new: %s", 1394 /* BB check if reconnection needed */
1383 tcon->treeName, uncName)); 1395 cFYI(1, ("IP match, old UNC: %s new: %s",
1384 if (strncmp 1396 tcon->treeName, uncName));
1385 (tcon->treeName, uncName, 1397
1386 MAX_TREE_SIZE) == 0) { 1398 if (strncmp(tcon->treeName, uncName, MAX_TREE_SIZE))
1387 cFYI(1, 1399 continue;
1388 ("and old usr: %s new: %s", 1400
1389 tcon->treeName, uncName)); 1401 cFYI(1, ("and old usr: %s new: %s",
1390 if (strncmp 1402 tcon->treeName, uncName));
1391 (tcon->ses->userName, 1403
1392 userName, 1404 if (strncmp(tcon->ses->userName, userName, MAX_USERNAME_SIZE))
1393 MAX_USERNAME_SIZE) == 0) { 1405 continue;
1394 read_unlock(&GlobalSMBSeslock); 1406
1395 /* matched smb session 1407 /* matched smb session (user name) */
1396 (user name */ 1408 read_unlock(&GlobalSMBSeslock);
1397 return tcon; 1409 return tcon;
1398 }
1399 }
1400 }
1401 }
1402 }
1403 } 1410 }
1411
1404 read_unlock(&GlobalSMBSeslock); 1412 read_unlock(&GlobalSMBSeslock);
1405 return NULL; 1413 return NULL;
1406} 1414}
@@ -1982,7 +1990,6 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1982 kfree(srvTcp->hostname); 1990 kfree(srvTcp->hostname);
1983 goto out; 1991 goto out;
1984 } 1992 }
1985 wait_for_completion(&cifsd_complete);
1986 rc = 0; 1993 rc = 0;
1987 memcpy(srvTcp->workstation_RFC1001_name, 1994 memcpy(srvTcp->workstation_RFC1001_name,
1988 volume_info.source_rfc1001_name, 16); 1995 volume_info.source_rfc1001_name, 16);
@@ -2189,15 +2196,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2189 srvTcp->tcpStatus = CifsExiting; 2196 srvTcp->tcpStatus = CifsExiting;
2190 spin_unlock(&GlobalMid_Lock); 2197 spin_unlock(&GlobalMid_Lock);
2191 if (srvTcp->tsk) { 2198 if (srvTcp->tsk) {
2192 struct task_struct *tsk;
2193 /* If we could verify that kthread_stop would 2199 /* If we could verify that kthread_stop would
2194 always wake up processes blocked in 2200 always wake up processes blocked in
2195 tcp in recv_mesg then we could remove the 2201 tcp in recv_mesg then we could remove the
2196 send_sig call */ 2202 send_sig call */
2197 force_sig(SIGKILL, srvTcp->tsk); 2203 force_sig(SIGKILL, srvTcp->tsk);
2198 tsk = srvTcp->tsk; 2204 kthread_stop(srvTcp->tsk);
2199 if (tsk)
2200 kthread_stop(tsk);
2201 } 2205 }
2202 } 2206 }
2203 /* If find_unc succeeded then rc == 0 so we can not end */ 2207 /* If find_unc succeeded then rc == 0 so we can not end */
@@ -2213,23 +2217,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2213 if ((temp_rc == -ESHUTDOWN) && 2217 if ((temp_rc == -ESHUTDOWN) &&
2214 (pSesInfo->server) && 2218 (pSesInfo->server) &&
2215 (pSesInfo->server->tsk)) { 2219 (pSesInfo->server->tsk)) {
2216 struct task_struct *tsk;
2217 force_sig(SIGKILL, 2220 force_sig(SIGKILL,
2218 pSesInfo->server->tsk); 2221 pSesInfo->server->tsk);
2219 tsk = pSesInfo->server->tsk; 2222 kthread_stop(pSesInfo->server->tsk);
2220 if (tsk)
2221 kthread_stop(tsk);
2222 } 2223 }
2223 } else { 2224 } else {
2224 cFYI(1, ("No session or bad tcon")); 2225 cFYI(1, ("No session or bad tcon"));
2225 if ((pSesInfo->server) && 2226 if ((pSesInfo->server) &&
2226 (pSesInfo->server->tsk)) { 2227 (pSesInfo->server->tsk)) {
2227 struct task_struct *tsk;
2228 force_sig(SIGKILL, 2228 force_sig(SIGKILL,
2229 pSesInfo->server->tsk); 2229 pSesInfo->server->tsk);
2230 tsk = pSesInfo->server->tsk; 2230 kthread_stop(pSesInfo->server->tsk);
2231 if (tsk)
2232 kthread_stop(tsk);
2233 } 2231 }
2234 } 2232 }
2235 sesInfoFree(pSesInfo); 2233 sesInfoFree(pSesInfo);
@@ -2602,7 +2600,7 @@ sesssetup_nomem: /* do not return an error on nomem for the info strings,
2602 2600
2603static int 2601static int
2604CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, 2602CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2605 struct cifsSesInfo *ses, int *pNTLMv2_flag, 2603 struct cifsSesInfo *ses, bool *pNTLMv2_flag,
2606 const struct nls_table *nls_codepage) 2604 const struct nls_table *nls_codepage)
2607{ 2605{
2608 struct smb_hdr *smb_buffer; 2606 struct smb_hdr *smb_buffer;
@@ -2625,7 +2623,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2625 if (ses == NULL) 2623 if (ses == NULL)
2626 return -EINVAL; 2624 return -EINVAL;
2627 domain = ses->domainName; 2625 domain = ses->domainName;
2628 *pNTLMv2_flag = FALSE; 2626 *pNTLMv2_flag = false;
2629 smb_buffer = cifs_buf_get(); 2627 smb_buffer = cifs_buf_get();
2630 if (smb_buffer == NULL) { 2628 if (smb_buffer == NULL) {
2631 return -ENOMEM; 2629 return -ENOMEM;
@@ -2778,7 +2776,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2778 CIFS_CRYPTO_KEY_SIZE); 2776 CIFS_CRYPTO_KEY_SIZE);
2779 if (SecurityBlob2->NegotiateFlags & 2777 if (SecurityBlob2->NegotiateFlags &
2780 cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) 2778 cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2))
2781 *pNTLMv2_flag = TRUE; 2779 *pNTLMv2_flag = true;
2782 2780
2783 if ((SecurityBlob2->NegotiateFlags & 2781 if ((SecurityBlob2->NegotiateFlags &
2784 cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) 2782 cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN))
@@ -2939,7 +2937,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2939} 2937}
2940static int 2938static int
2941CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, 2939CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2942 char *ntlm_session_key, int ntlmv2_flag, 2940 char *ntlm_session_key, bool ntlmv2_flag,
2943 const struct nls_table *nls_codepage) 2941 const struct nls_table *nls_codepage)
2944{ 2942{
2945 struct smb_hdr *smb_buffer; 2943 struct smb_hdr *smb_buffer;
@@ -3556,8 +3554,6 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
3556 cifs_sb->prepath = NULL; 3554 cifs_sb->prepath = NULL;
3557 kfree(tmp); 3555 kfree(tmp);
3558 if (ses) 3556 if (ses)
3559 schedule_timeout_interruptible(msecs_to_jiffies(500));
3560 if (ses)
3561 sesInfoFree(ses); 3557 sesInfoFree(ses);
3562 3558
3563 FreeXid(xid); 3559 FreeXid(xid);
@@ -3569,7 +3565,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3569{ 3565{
3570 int rc = 0; 3566 int rc = 0;
3571 char ntlm_session_key[CIFS_SESS_KEY_SIZE]; 3567 char ntlm_session_key[CIFS_SESS_KEY_SIZE];
3572 int ntlmv2_flag = FALSE; 3568 bool ntlmv2_flag = false;
3573 int first_time = 0; 3569 int first_time = 0;
3574 3570
3575 /* what if server changes its buffer size after dropping the session? */ 3571 /* what if server changes its buffer size after dropping the session? */
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 0f5c62ba4038..e4e0078a0526 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -119,6 +119,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
119{ 119{
120 int rc = -ENOENT; 120 int rc = -ENOENT;
121 int xid; 121 int xid;
122 int create_options = CREATE_NOT_DIR;
122 int oplock = 0; 123 int oplock = 0;
123 int desiredAccess = GENERIC_READ | GENERIC_WRITE; 124 int desiredAccess = GENERIC_READ | GENERIC_WRITE;
124 __u16 fileHandle; 125 __u16 fileHandle;
@@ -130,7 +131,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
130 struct cifsFileInfo *pCifsFile = NULL; 131 struct cifsFileInfo *pCifsFile = NULL;
131 struct cifsInodeInfo *pCifsInode; 132 struct cifsInodeInfo *pCifsInode;
132 int disposition = FILE_OVERWRITE_IF; 133 int disposition = FILE_OVERWRITE_IF;
133 int write_only = FALSE; 134 bool write_only = false;
134 135
135 xid = GetXid(); 136 xid = GetXid();
136 137
@@ -152,7 +153,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
152 if (oflags & FMODE_WRITE) { 153 if (oflags & FMODE_WRITE) {
153 desiredAccess |= GENERIC_WRITE; 154 desiredAccess |= GENERIC_WRITE;
154 if (!(oflags & FMODE_READ)) 155 if (!(oflags & FMODE_READ))
155 write_only = TRUE; 156 write_only = true;
156 } 157 }
157 158
158 if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) 159 if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
@@ -176,9 +177,19 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
176 FreeXid(xid); 177 FreeXid(xid);
177 return -ENOMEM; 178 return -ENOMEM;
178 } 179 }
180
181 mode &= ~current->fs->umask;
182
183 /*
184 * if we're not using unix extensions, see if we need to set
185 * ATTR_READONLY on the create call
186 */
187 if (!pTcon->unix_ext && (mode & S_IWUGO) == 0)
188 create_options |= CREATE_OPTION_READONLY;
189
179 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) 190 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
180 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, 191 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
181 desiredAccess, CREATE_NOT_DIR, 192 desiredAccess, create_options,
182 &fileHandle, &oplock, buf, cifs_sb->local_nls, 193 &fileHandle, &oplock, buf, cifs_sb->local_nls,
183 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 194 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
184 else 195 else
@@ -187,7 +198,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
187 if (rc == -EIO) { 198 if (rc == -EIO) {
188 /* old server, retry the open legacy style */ 199 /* old server, retry the open legacy style */
189 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, 200 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,
190 desiredAccess, CREATE_NOT_DIR, 201 desiredAccess, create_options,
191 &fileHandle, &oplock, buf, cifs_sb->local_nls, 202 &fileHandle, &oplock, buf, cifs_sb->local_nls,
192 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 203 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
193 } 204 }
@@ -197,7 +208,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
197 /* If Open reported that we actually created a file 208 /* If Open reported that we actually created a file
198 then we now have to set the mode if possible */ 209 then we now have to set the mode if possible */
199 if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) { 210 if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
200 mode &= ~current->fs->umask;
201 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 211 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
202 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 212 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
203 (__u64)current->fsuid, 213 (__u64)current->fsuid,
@@ -254,7 +264,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
254 d_instantiate(direntry, newinode); 264 d_instantiate(direntry, newinode);
255 } 265 }
256 if ((nd == NULL /* nfsd case - nfs srv does not set nd */) || 266 if ((nd == NULL /* nfsd case - nfs srv does not set nd */) ||
257 ((nd->flags & LOOKUP_OPEN) == FALSE)) { 267 (!(nd->flags & LOOKUP_OPEN))) {
258 /* mknod case - do not leave file open */ 268 /* mknod case - do not leave file open */
259 CIFSSMBClose(xid, pTcon, fileHandle); 269 CIFSSMBClose(xid, pTcon, fileHandle);
260 } else if (newinode) { 270 } else if (newinode) {
@@ -266,8 +276,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
266 pCifsFile->netfid = fileHandle; 276 pCifsFile->netfid = fileHandle;
267 pCifsFile->pid = current->tgid; 277 pCifsFile->pid = current->tgid;
268 pCifsFile->pInode = newinode; 278 pCifsFile->pInode = newinode;
269 pCifsFile->invalidHandle = FALSE; 279 pCifsFile->invalidHandle = false;
270 pCifsFile->closePend = FALSE; 280 pCifsFile->closePend = false;
271 init_MUTEX(&pCifsFile->fh_sem); 281 init_MUTEX(&pCifsFile->fh_sem);
272 mutex_init(&pCifsFile->lock_mutex); 282 mutex_init(&pCifsFile->lock_mutex);
273 INIT_LIST_HEAD(&pCifsFile->llist); 283 INIT_LIST_HEAD(&pCifsFile->llist);
@@ -280,7 +290,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
280 pCifsInode = CIFS_I(newinode); 290 pCifsInode = CIFS_I(newinode);
281 if (pCifsInode) { 291 if (pCifsInode) {
282 /* if readable file instance put first in list*/ 292 /* if readable file instance put first in list*/
283 if (write_only == TRUE) { 293 if (write_only) {
284 list_add_tail(&pCifsFile->flist, 294 list_add_tail(&pCifsFile->flist,
285 &pCifsInode->openFileList); 295 &pCifsInode->openFileList);
286 } else { 296 } else {
@@ -288,12 +298,12 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
288 &pCifsInode->openFileList); 298 &pCifsInode->openFileList);
289 } 299 }
290 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { 300 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
291 pCifsInode->clientCanCacheAll = TRUE; 301 pCifsInode->clientCanCacheAll = true;
292 pCifsInode->clientCanCacheRead = TRUE; 302 pCifsInode->clientCanCacheRead = true;
293 cFYI(1, ("Exclusive Oplock inode %p", 303 cFYI(1, ("Exclusive Oplock inode %p",
294 newinode)); 304 newinode));
295 } else if ((oplock & 0xF) == OPLOCK_READ) 305 } else if ((oplock & 0xF) == OPLOCK_READ)
296 pCifsInode->clientCanCacheRead = TRUE; 306 pCifsInode->clientCanCacheRead = true;
297 } 307 }
298 write_unlock(&GlobalSMBSeslock); 308 write_unlock(&GlobalSMBSeslock);
299 } 309 }
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c
index 7cc86c418182..939e256f8497 100644
--- a/fs/cifs/dns_resolve.c
+++ b/fs/cifs/dns_resolve.c
@@ -55,6 +55,32 @@ struct key_type key_type_dns_resolver = {
55 .match = user_match, 55 .match = user_match,
56}; 56};
57 57
58/* Checks if supplied name is IP address
59 * returns:
60 * 1 - name is IP
61 * 0 - name is not IP
62 */
63static int is_ip(const char *name)
64{
65 int rc;
66 struct sockaddr_in sin_server;
67 struct sockaddr_in6 sin_server6;
68
69 rc = cifs_inet_pton(AF_INET, name,
70 &sin_server.sin_addr.s_addr);
71
72 if (rc <= 0) {
73 /* not ipv4 address, try ipv6 */
74 rc = cifs_inet_pton(AF_INET6, name,
75 &sin_server6.sin6_addr.in6_u);
76 if (rc > 0)
77 return 1;
78 } else {
79 return 1;
80 }
81 /* we failed translating address */
82 return 0;
83}
58 84
59/* Resolves server name to ip address. 85/* Resolves server name to ip address.
60 * input: 86 * input:
@@ -67,8 +93,9 @@ int
67dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) 93dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
68{ 94{
69 int rc = -EAGAIN; 95 int rc = -EAGAIN;
70 struct key *rkey; 96 struct key *rkey = ERR_PTR(-EAGAIN);
71 char *name; 97 char *name;
98 char *data = NULL;
72 int len; 99 int len;
73 100
74 if (!ip_addr || !unc) 101 if (!ip_addr || !unc)
@@ -97,26 +124,41 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
97 memcpy(name, unc+2, len); 124 memcpy(name, unc+2, len);
98 name[len] = 0; 125 name[len] = 0;
99 126
127 if (is_ip(name)) {
128 cFYI(1, ("%s: it is IP, skipping dns upcall: %s",
129 __func__, name));
130 data = name;
131 goto skip_upcall;
132 }
133
100 rkey = request_key(&key_type_dns_resolver, name, ""); 134 rkey = request_key(&key_type_dns_resolver, name, "");
101 if (!IS_ERR(rkey)) { 135 if (!IS_ERR(rkey)) {
102 len = strlen(rkey->payload.data); 136 data = rkey->payload.data;
103 *ip_addr = kmalloc(len+1, GFP_KERNEL); 137 cFYI(1, ("%s: resolved: %s to %s", __func__,
104 if (*ip_addr) {
105 memcpy(*ip_addr, rkey->payload.data, len);
106 (*ip_addr)[len] = '\0';
107 cFYI(1, ("%s: resolved: %s to %s", __func__,
108 rkey->description, 138 rkey->description,
109 *ip_addr 139 *ip_addr
110 )); 140 ));
141 } else {
142 cERROR(1, ("%s: unable to resolve: %s", __func__, name));
143 goto out;
144 }
145
146skip_upcall:
147 if (data) {
148 len = strlen(data);
149 *ip_addr = kmalloc(len+1, GFP_KERNEL);
150 if (*ip_addr) {
151 memcpy(*ip_addr, data, len);
152 (*ip_addr)[len] = '\0';
111 rc = 0; 153 rc = 0;
112 } else { 154 } else {
113 rc = -ENOMEM; 155 rc = -ENOMEM;
114 } 156 }
115 key_put(rkey); 157 if (!IS_ERR(rkey))
116 } else { 158 key_put(rkey);
117 cERROR(1, ("%s: unable to resolve: %s", __func__, name));
118 } 159 }
119 160
161out:
120 kfree(name); 162 kfree(name);
121 return rc; 163 return rc;
122} 164}
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index 7d1d5aa4c430..5a57581eb4b2 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -68,7 +68,7 @@ int cifs_dir_notify(struct file *file, unsigned long arg)
68{ 68{
69 int xid; 69 int xid;
70 int rc = -EINVAL; 70 int rc = -EINVAL;
71 int oplock = FALSE; 71 int oplock = 0;
72 struct cifs_sb_info *cifs_sb; 72 struct cifs_sb_info *cifs_sb;
73 struct cifsTconInfo *pTcon; 73 struct cifsTconInfo *pTcon;
74 char *full_path = NULL; 74 char *full_path = NULL;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 40b690073fc1..31a0a33b9d95 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -51,8 +51,8 @@ static inline struct cifsFileInfo *cifs_init_private(
51 INIT_LIST_HEAD(&private_data->llist); 51 INIT_LIST_HEAD(&private_data->llist);
52 private_data->pfile = file; /* needed for writepage */ 52 private_data->pfile = file; /* needed for writepage */
53 private_data->pInode = inode; 53 private_data->pInode = inode;
54 private_data->invalidHandle = FALSE; 54 private_data->invalidHandle = false;
55 private_data->closePend = FALSE; 55 private_data->closePend = false;
56 /* we have to track num writers to the inode, since writepages 56 /* we have to track num writers to the inode, since writepages
57 does not tell us which handle the write is for so there can 57 does not tell us which handle the write is for so there can
58 be a close (overlapping with write) of the filehandle that 58 be a close (overlapping with write) of the filehandle that
@@ -148,12 +148,12 @@ client_can_cache:
148 full_path, buf, inode->i_sb, xid, NULL); 148 full_path, buf, inode->i_sb, xid, NULL);
149 149
150 if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) { 150 if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) {
151 pCifsInode->clientCanCacheAll = TRUE; 151 pCifsInode->clientCanCacheAll = true;
152 pCifsInode->clientCanCacheRead = TRUE; 152 pCifsInode->clientCanCacheRead = true;
153 cFYI(1, ("Exclusive Oplock granted on inode %p", 153 cFYI(1, ("Exclusive Oplock granted on inode %p",
154 file->f_path.dentry->d_inode)); 154 file->f_path.dentry->d_inode));
155 } else if ((*oplock & 0xF) == OPLOCK_READ) 155 } else if ((*oplock & 0xF) == OPLOCK_READ)
156 pCifsInode->clientCanCacheRead = TRUE; 156 pCifsInode->clientCanCacheRead = true;
157 157
158 return rc; 158 return rc;
159} 159}
@@ -247,7 +247,7 @@ int cifs_open(struct inode *inode, struct file *file)
247 if (oplockEnabled) 247 if (oplockEnabled)
248 oplock = REQ_OPLOCK; 248 oplock = REQ_OPLOCK;
249 else 249 else
250 oplock = FALSE; 250 oplock = 0;
251 251
252 /* BB pass O_SYNC flag through on file attributes .. BB */ 252 /* BB pass O_SYNC flag through on file attributes .. BB */
253 253
@@ -339,7 +339,7 @@ static int cifs_relock_file(struct cifsFileInfo *cifsFile)
339 return rc; 339 return rc;
340} 340}
341 341
342static int cifs_reopen_file(struct file *file, int can_flush) 342static int cifs_reopen_file(struct file *file, bool can_flush)
343{ 343{
344 int rc = -EACCES; 344 int rc = -EACCES;
345 int xid, oplock; 345 int xid, oplock;
@@ -360,7 +360,7 @@ static int cifs_reopen_file(struct file *file, int can_flush)
360 360
361 xid = GetXid(); 361 xid = GetXid();
362 down(&pCifsFile->fh_sem); 362 down(&pCifsFile->fh_sem);
363 if (pCifsFile->invalidHandle == FALSE) { 363 if (!pCifsFile->invalidHandle) {
364 up(&pCifsFile->fh_sem); 364 up(&pCifsFile->fh_sem);
365 FreeXid(xid); 365 FreeXid(xid);
366 return 0; 366 return 0;
@@ -404,7 +404,7 @@ reopen_error_exit:
404 if (oplockEnabled) 404 if (oplockEnabled)
405 oplock = REQ_OPLOCK; 405 oplock = REQ_OPLOCK;
406 else 406 else
407 oplock = FALSE; 407 oplock = 0;
408 408
409 /* Can not refresh inode by passing in file_info buf to be returned 409 /* Can not refresh inode by passing in file_info buf to be returned
410 by SMBOpen and then calling get_inode_info with returned buf 410 by SMBOpen and then calling get_inode_info with returned buf
@@ -422,7 +422,7 @@ reopen_error_exit:
422 cFYI(1, ("oplock: %d", oplock)); 422 cFYI(1, ("oplock: %d", oplock));
423 } else { 423 } else {
424 pCifsFile->netfid = netfid; 424 pCifsFile->netfid = netfid;
425 pCifsFile->invalidHandle = FALSE; 425 pCifsFile->invalidHandle = false;
426 up(&pCifsFile->fh_sem); 426 up(&pCifsFile->fh_sem);
427 pCifsInode = CIFS_I(inode); 427 pCifsInode = CIFS_I(inode);
428 if (pCifsInode) { 428 if (pCifsInode) {
@@ -432,8 +432,8 @@ reopen_error_exit:
432 CIFS_I(inode)->write_behind_rc = rc; 432 CIFS_I(inode)->write_behind_rc = rc;
433 /* temporarily disable caching while we 433 /* temporarily disable caching while we
434 go to server to get inode info */ 434 go to server to get inode info */
435 pCifsInode->clientCanCacheAll = FALSE; 435 pCifsInode->clientCanCacheAll = false;
436 pCifsInode->clientCanCacheRead = FALSE; 436 pCifsInode->clientCanCacheRead = false;
437 if (pTcon->unix_ext) 437 if (pTcon->unix_ext)
438 rc = cifs_get_inode_info_unix(&inode, 438 rc = cifs_get_inode_info_unix(&inode,
439 full_path, inode->i_sb, xid); 439 full_path, inode->i_sb, xid);
@@ -448,16 +448,16 @@ reopen_error_exit:
448 we can not go to the server to get the new inod 448 we can not go to the server to get the new inod
449 info */ 449 info */
450 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { 450 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
451 pCifsInode->clientCanCacheAll = TRUE; 451 pCifsInode->clientCanCacheAll = true;
452 pCifsInode->clientCanCacheRead = TRUE; 452 pCifsInode->clientCanCacheRead = true;
453 cFYI(1, ("Exclusive Oplock granted on inode %p", 453 cFYI(1, ("Exclusive Oplock granted on inode %p",
454 file->f_path.dentry->d_inode)); 454 file->f_path.dentry->d_inode));
455 } else if ((oplock & 0xF) == OPLOCK_READ) { 455 } else if ((oplock & 0xF) == OPLOCK_READ) {
456 pCifsInode->clientCanCacheRead = TRUE; 456 pCifsInode->clientCanCacheRead = true;
457 pCifsInode->clientCanCacheAll = FALSE; 457 pCifsInode->clientCanCacheAll = false;
458 } else { 458 } else {
459 pCifsInode->clientCanCacheRead = FALSE; 459 pCifsInode->clientCanCacheRead = false;
460 pCifsInode->clientCanCacheAll = FALSE; 460 pCifsInode->clientCanCacheAll = false;
461 } 461 }
462 cifs_relock_file(pCifsFile); 462 cifs_relock_file(pCifsFile);
463 } 463 }
@@ -484,7 +484,7 @@ int cifs_close(struct inode *inode, struct file *file)
484 if (pSMBFile) { 484 if (pSMBFile) {
485 struct cifsLockInfo *li, *tmp; 485 struct cifsLockInfo *li, *tmp;
486 486
487 pSMBFile->closePend = TRUE; 487 pSMBFile->closePend = true;
488 if (pTcon) { 488 if (pTcon) {
489 /* no sense reconnecting to close a file that is 489 /* no sense reconnecting to close a file that is
490 already closed */ 490 already closed */
@@ -553,8 +553,8 @@ int cifs_close(struct inode *inode, struct file *file)
553 cFYI(1, ("closing last open instance for inode %p", inode)); 553 cFYI(1, ("closing last open instance for inode %p", inode));
554 /* if the file is not open we do not know if we can cache info 554 /* if the file is not open we do not know if we can cache info
555 on this inode, much less write behind and read ahead */ 555 on this inode, much less write behind and read ahead */
556 CIFS_I(inode)->clientCanCacheRead = FALSE; 556 CIFS_I(inode)->clientCanCacheRead = false;
557 CIFS_I(inode)->clientCanCacheAll = FALSE; 557 CIFS_I(inode)->clientCanCacheAll = false;
558 } 558 }
559 read_unlock(&GlobalSMBSeslock); 559 read_unlock(&GlobalSMBSeslock);
560 if ((rc == 0) && CIFS_I(inode)->write_behind_rc) 560 if ((rc == 0) && CIFS_I(inode)->write_behind_rc)
@@ -583,9 +583,9 @@ int cifs_closedir(struct inode *inode, struct file *file)
583 pTcon = cifs_sb->tcon; 583 pTcon = cifs_sb->tcon;
584 584
585 cFYI(1, ("Freeing private data in close dir")); 585 cFYI(1, ("Freeing private data in close dir"));
586 if ((pCFileStruct->srch_inf.endOfSearch == FALSE) && 586 if (!pCFileStruct->srch_inf.endOfSearch &&
587 (pCFileStruct->invalidHandle == FALSE)) { 587 !pCFileStruct->invalidHandle) {
588 pCFileStruct->invalidHandle = TRUE; 588 pCFileStruct->invalidHandle = true;
589 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid); 589 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid);
590 cFYI(1, ("Closing uncompleted readdir with rc %d", 590 cFYI(1, ("Closing uncompleted readdir with rc %d",
591 rc)); 591 rc));
@@ -637,12 +637,12 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
637 __u32 numLock = 0; 637 __u32 numLock = 0;
638 __u32 numUnlock = 0; 638 __u32 numUnlock = 0;
639 __u64 length; 639 __u64 length;
640 int wait_flag = FALSE; 640 bool wait_flag = false;
641 struct cifs_sb_info *cifs_sb; 641 struct cifs_sb_info *cifs_sb;
642 struct cifsTconInfo *pTcon; 642 struct cifsTconInfo *pTcon;
643 __u16 netfid; 643 __u16 netfid;
644 __u8 lockType = LOCKING_ANDX_LARGE_FILES; 644 __u8 lockType = LOCKING_ANDX_LARGE_FILES;
645 int posix_locking; 645 bool posix_locking;
646 646
647 length = 1 + pfLock->fl_end - pfLock->fl_start; 647 length = 1 + pfLock->fl_end - pfLock->fl_start;
648 rc = -EACCES; 648 rc = -EACCES;
@@ -659,7 +659,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
659 cFYI(1, ("Flock")); 659 cFYI(1, ("Flock"));
660 if (pfLock->fl_flags & FL_SLEEP) { 660 if (pfLock->fl_flags & FL_SLEEP) {
661 cFYI(1, ("Blocking lock")); 661 cFYI(1, ("Blocking lock"));
662 wait_flag = TRUE; 662 wait_flag = true;
663 } 663 }
664 if (pfLock->fl_flags & FL_ACCESS) 664 if (pfLock->fl_flags & FL_ACCESS)
665 cFYI(1, ("Process suspended by mandatory locking - " 665 cFYI(1, ("Process suspended by mandatory locking - "
@@ -794,7 +794,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
794 stored_rc = CIFSSMBLock(xid, pTcon, 794 stored_rc = CIFSSMBLock(xid, pTcon,
795 netfid, 795 netfid,
796 li->length, li->offset, 796 li->length, li->offset,
797 1, 0, li->type, FALSE); 797 1, 0, li->type, false);
798 if (stored_rc) 798 if (stored_rc)
799 rc = stored_rc; 799 rc = stored_rc;
800 800
@@ -866,7 +866,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
866 filemap_fdatawait from here so tell 866 filemap_fdatawait from here so tell
867 reopen_file not to flush data to server 867 reopen_file not to flush data to server
868 now */ 868 now */
869 rc = cifs_reopen_file(file, FALSE); 869 rc = cifs_reopen_file(file, false);
870 if (rc != 0) 870 if (rc != 0)
871 break; 871 break;
872 } 872 }
@@ -966,7 +966,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
966 filemap_fdatawait from here so tell 966 filemap_fdatawait from here so tell
967 reopen_file not to flush data to 967 reopen_file not to flush data to
968 server now */ 968 server now */
969 rc = cifs_reopen_file(file, FALSE); 969 rc = cifs_reopen_file(file, false);
970 if (rc != 0) 970 if (rc != 0)
971 break; 971 break;
972 } 972 }
@@ -1093,7 +1093,7 @@ refind_writable:
1093 1093
1094 read_unlock(&GlobalSMBSeslock); 1094 read_unlock(&GlobalSMBSeslock);
1095 /* Had to unlock since following call can block */ 1095 /* Had to unlock since following call can block */
1096 rc = cifs_reopen_file(open_file->pfile, FALSE); 1096 rc = cifs_reopen_file(open_file->pfile, false);
1097 if (!rc) { 1097 if (!rc) {
1098 if (!open_file->closePend) 1098 if (!open_file->closePend)
1099 return open_file; 1099 return open_file;
@@ -1608,7 +1608,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1608 int buf_type = CIFS_NO_BUFFER; 1608 int buf_type = CIFS_NO_BUFFER;
1609 if ((open_file->invalidHandle) && 1609 if ((open_file->invalidHandle) &&
1610 (!open_file->closePend)) { 1610 (!open_file->closePend)) {
1611 rc = cifs_reopen_file(file, TRUE); 1611 rc = cifs_reopen_file(file, true);
1612 if (rc != 0) 1612 if (rc != 0)
1613 break; 1613 break;
1614 } 1614 }
@@ -1693,7 +1693,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1693 while (rc == -EAGAIN) { 1693 while (rc == -EAGAIN) {
1694 if ((open_file->invalidHandle) && 1694 if ((open_file->invalidHandle) &&
1695 (!open_file->closePend)) { 1695 (!open_file->closePend)) {
1696 rc = cifs_reopen_file(file, TRUE); 1696 rc = cifs_reopen_file(file, true);
1697 if (rc != 0) 1697 if (rc != 0)
1698 break; 1698 break;
1699 } 1699 }
@@ -1850,7 +1850,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1850 while (rc == -EAGAIN) { 1850 while (rc == -EAGAIN) {
1851 if ((open_file->invalidHandle) && 1851 if ((open_file->invalidHandle) &&
1852 (!open_file->closePend)) { 1852 (!open_file->closePend)) {
1853 rc = cifs_reopen_file(file, TRUE); 1853 rc = cifs_reopen_file(file, true);
1854 if (rc != 0) 1854 if (rc != 0)
1855 break; 1855 break;
1856 } 1856 }
@@ -2009,10 +2009,10 @@ static int is_inode_writable(struct cifsInodeInfo *cifs_inode)
2009 refreshing the inode only on increases in the file size 2009 refreshing the inode only on increases in the file size
2010 but this is tricky to do without racing with writebehind 2010 but this is tricky to do without racing with writebehind
2011 page caching in the current Linux kernel design */ 2011 page caching in the current Linux kernel design */
2012int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) 2012bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
2013{ 2013{
2014 if (!cifsInode) 2014 if (!cifsInode)
2015 return 1; 2015 return true;
2016 2016
2017 if (is_inode_writable(cifsInode)) { 2017 if (is_inode_writable(cifsInode)) {
2018 /* This inode is open for write at least once */ 2018 /* This inode is open for write at least once */
@@ -2022,15 +2022,15 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
2022 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { 2022 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
2023 /* since no page cache to corrupt on directio 2023 /* since no page cache to corrupt on directio
2024 we can change size safely */ 2024 we can change size safely */
2025 return 1; 2025 return true;
2026 } 2026 }
2027 2027
2028 if (i_size_read(&cifsInode->vfs_inode) < end_of_file) 2028 if (i_size_read(&cifsInode->vfs_inode) < end_of_file)
2029 return 1; 2029 return true;
2030 2030
2031 return 0; 2031 return false;
2032 } else 2032 } else
2033 return 1; 2033 return true;
2034} 2034}
2035 2035
2036static int cifs_prepare_write(struct file *file, struct page *page, 2036static int cifs_prepare_write(struct file *file, struct page *page,
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index e1031b9e2c55..fcbdbb6ad7bf 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -281,7 +281,7 @@ static int decode_sfu_inode(struct inode *inode, __u64 size,
281 struct cifs_sb_info *cifs_sb, int xid) 281 struct cifs_sb_info *cifs_sb, int xid)
282{ 282{
283 int rc; 283 int rc;
284 int oplock = FALSE; 284 int oplock = 0;
285 __u16 netfid; 285 __u16 netfid;
286 struct cifsTconInfo *pTcon = cifs_sb->tcon; 286 struct cifsTconInfo *pTcon = cifs_sb->tcon;
287 char buf[24]; 287 char buf[24];
@@ -389,7 +389,7 @@ int cifs_get_inode_info(struct inode **pinode,
389 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 389 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
390 const unsigned char *full_path = NULL; 390 const unsigned char *full_path = NULL;
391 char *buf = NULL; 391 char *buf = NULL;
392 int adjustTZ = FALSE; 392 bool adjustTZ = false;
393 bool is_dfs_referral = false; 393 bool is_dfs_referral = false;
394 394
395 pTcon = cifs_sb->tcon; 395 pTcon = cifs_sb->tcon;
@@ -425,7 +425,7 @@ try_again_CIFSSMBQPathInfo:
425 pfindData, cifs_sb->local_nls, 425 pfindData, cifs_sb->local_nls,
426 cifs_sb->mnt_cifs_flags & 426 cifs_sb->mnt_cifs_flags &
427 CIFS_MOUNT_MAP_SPECIAL_CHR); 427 CIFS_MOUNT_MAP_SPECIAL_CHR);
428 adjustTZ = TRUE; 428 adjustTZ = true;
429 } 429 }
430 } 430 }
431 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */ 431 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */
@@ -703,7 +703,7 @@ psx_del_no_retry:
703 } else if (rc == -ENOENT) { 703 } else if (rc == -ENOENT) {
704 d_drop(direntry); 704 d_drop(direntry);
705 } else if (rc == -ETXTBSY) { 705 } else if (rc == -ETXTBSY) {
706 int oplock = FALSE; 706 int oplock = 0;
707 __u16 netfid; 707 __u16 netfid;
708 708
709 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, 709 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE,
@@ -736,7 +736,7 @@ psx_del_no_retry:
736 rc = -EOPNOTSUPP; 736 rc = -EOPNOTSUPP;
737 737
738 if (rc == -EOPNOTSUPP) { 738 if (rc == -EOPNOTSUPP) {
739 int oplock = FALSE; 739 int oplock = 0;
740 __u16 netfid; 740 __u16 netfid;
741 /* rc = CIFSSMBSetAttrLegacy(xid, pTcon, 741 /* rc = CIFSSMBSetAttrLegacy(xid, pTcon,
742 full_path, 742 full_path,
@@ -774,7 +774,7 @@ psx_del_no_retry:
774 if (direntry->d_inode) 774 if (direntry->d_inode)
775 drop_nlink(direntry->d_inode); 775 drop_nlink(direntry->d_inode);
776 } else if (rc == -ETXTBSY) { 776 } else if (rc == -ETXTBSY) {
777 int oplock = FALSE; 777 int oplock = 0;
778 __u16 netfid; 778 __u16 netfid;
779 779
780 rc = CIFSSMBOpen(xid, pTcon, full_path, 780 rc = CIFSSMBOpen(xid, pTcon, full_path,
@@ -974,8 +974,8 @@ mkdir_get_info:
974 * failed to get it from the server or was set bogus */ 974 * failed to get it from the server or was set bogus */
975 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) 975 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
976 direntry->d_inode->i_nlink = 2; 976 direntry->d_inode->i_nlink = 2;
977 mode &= ~current->fs->umask;
977 if (pTcon->unix_ext) { 978 if (pTcon->unix_ext) {
978 mode &= ~current->fs->umask;
979 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 979 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
980 CIFSSMBUnixSetPerms(xid, pTcon, full_path, 980 CIFSSMBUnixSetPerms(xid, pTcon, full_path,
981 mode, 981 mode,
@@ -994,9 +994,16 @@ mkdir_get_info:
994 CIFS_MOUNT_MAP_SPECIAL_CHR); 994 CIFS_MOUNT_MAP_SPECIAL_CHR);
995 } 995 }
996 } else { 996 } else {
997 /* BB to be implemented via Windows secrty descriptors 997 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
998 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, 998 (mode & S_IWUGO) == 0) {
999 -1, -1, local_nls); */ 999 FILE_BASIC_INFO pInfo;
1000 memset(&pInfo, 0, sizeof(pInfo));
1001 pInfo.Attributes = cpu_to_le32(ATTR_READONLY);
1002 CIFSSMBSetTimes(xid, pTcon, full_path,
1003 &pInfo, cifs_sb->local_nls,
1004 cifs_sb->mnt_cifs_flags &
1005 CIFS_MOUNT_MAP_SPECIAL_CHR);
1006 }
1000 if (direntry->d_inode) { 1007 if (direntry->d_inode) {
1001 direntry->d_inode->i_mode = mode; 1008 direntry->d_inode->i_mode = mode;
1002 direntry->d_inode->i_mode |= S_IFDIR; 1009 direntry->d_inode->i_mode |= S_IFDIR;
@@ -1149,7 +1156,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
1149 cFYI(1, ("rename rc %d", rc)); 1156 cFYI(1, ("rename rc %d", rc));
1150 1157
1151 if ((rc == -EIO) || (rc == -EEXIST)) { 1158 if ((rc == -EIO) || (rc == -EEXIST)) {
1152 int oplock = FALSE; 1159 int oplock = 0;
1153 __u16 netfid; 1160 __u16 netfid;
1154 1161
1155 /* BB FIXME Is Generic Read correct for rename? */ 1162 /* BB FIXME Is Generic Read correct for rename? */
@@ -1186,7 +1193,7 @@ int cifs_revalidate(struct dentry *direntry)
1186 struct cifsInodeInfo *cifsInode; 1193 struct cifsInodeInfo *cifsInode;
1187 loff_t local_size; 1194 loff_t local_size;
1188 struct timespec local_mtime; 1195 struct timespec local_mtime;
1189 int invalidate_inode = FALSE; 1196 bool invalidate_inode = false;
1190 1197
1191 if (direntry->d_inode == NULL) 1198 if (direntry->d_inode == NULL)
1192 return -ENOENT; 1199 return -ENOENT;
@@ -1268,7 +1275,7 @@ int cifs_revalidate(struct dentry *direntry)
1268 only ones who could have modified the file and the 1275 only ones who could have modified the file and the
1269 server copy is staler than ours */ 1276 server copy is staler than ours */
1270 } else { 1277 } else {
1271 invalidate_inode = TRUE; 1278 invalidate_inode = true;
1272 } 1279 }
1273 } 1280 }
1274 1281
@@ -1402,24 +1409,25 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1402 int rc = -EACCES; 1409 int rc = -EACCES;
1403 struct cifsFileInfo *open_file = NULL; 1410 struct cifsFileInfo *open_file = NULL;
1404 FILE_BASIC_INFO time_buf; 1411 FILE_BASIC_INFO time_buf;
1405 int set_time = FALSE; 1412 bool set_time = false;
1406 int set_dosattr = FALSE; 1413 bool set_dosattr = false;
1407 __u64 mode = 0xFFFFFFFFFFFFFFFFULL; 1414 __u64 mode = 0xFFFFFFFFFFFFFFFFULL;
1408 __u64 uid = 0xFFFFFFFFFFFFFFFFULL; 1415 __u64 uid = 0xFFFFFFFFFFFFFFFFULL;
1409 __u64 gid = 0xFFFFFFFFFFFFFFFFULL; 1416 __u64 gid = 0xFFFFFFFFFFFFFFFFULL;
1410 struct cifsInodeInfo *cifsInode; 1417 struct cifsInodeInfo *cifsInode;
1418 struct inode *inode = direntry->d_inode;
1411 1419
1412 xid = GetXid(); 1420 xid = GetXid();
1413 1421
1414 cFYI(1, ("setattr on file %s attrs->iavalid 0x%x", 1422 cFYI(1, ("setattr on file %s attrs->iavalid 0x%x",
1415 direntry->d_name.name, attrs->ia_valid)); 1423 direntry->d_name.name, attrs->ia_valid));
1416 1424
1417 cifs_sb = CIFS_SB(direntry->d_inode->i_sb); 1425 cifs_sb = CIFS_SB(inode->i_sb);
1418 pTcon = cifs_sb->tcon; 1426 pTcon = cifs_sb->tcon;
1419 1427
1420 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) { 1428 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) {
1421 /* check if we have permission to change attrs */ 1429 /* check if we have permission to change attrs */
1422 rc = inode_change_ok(direntry->d_inode, attrs); 1430 rc = inode_change_ok(inode, attrs);
1423 if (rc < 0) { 1431 if (rc < 0) {
1424 FreeXid(xid); 1432 FreeXid(xid);
1425 return rc; 1433 return rc;
@@ -1432,7 +1440,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1432 FreeXid(xid); 1440 FreeXid(xid);
1433 return -ENOMEM; 1441 return -ENOMEM;
1434 } 1442 }
1435 cifsInode = CIFS_I(direntry->d_inode); 1443 cifsInode = CIFS_I(inode);
1436 1444
1437 if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) { 1445 if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) {
1438 /* 1446 /*
@@ -1443,9 +1451,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1443 will be truncated anyway? Also, should we error out here if 1451 will be truncated anyway? Also, should we error out here if
1444 the flush returns error? 1452 the flush returns error?
1445 */ 1453 */
1446 rc = filemap_write_and_wait(direntry->d_inode->i_mapping); 1454 rc = filemap_write_and_wait(inode->i_mapping);
1447 if (rc != 0) { 1455 if (rc != 0) {
1448 CIFS_I(direntry->d_inode)->write_behind_rc = rc; 1456 cifsInode->write_behind_rc = rc;
1449 rc = 0; 1457 rc = 0;
1450 } 1458 }
1451 } 1459 }
@@ -1464,7 +1472,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1464 __u16 nfid = open_file->netfid; 1472 __u16 nfid = open_file->netfid;
1465 __u32 npid = open_file->pid; 1473 __u32 npid = open_file->pid;
1466 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, 1474 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size,
1467 nfid, npid, FALSE); 1475 nfid, npid, false);
1468 atomic_dec(&open_file->wrtPending); 1476 atomic_dec(&open_file->wrtPending);
1469 cFYI(1, ("SetFSize for attrs rc = %d", rc)); 1477 cFYI(1, ("SetFSize for attrs rc = %d", rc));
1470 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { 1478 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
@@ -1484,14 +1492,14 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1484 it was found or because there was an error setting 1492 it was found or because there was an error setting
1485 it by handle */ 1493 it by handle */
1486 rc = CIFSSMBSetEOF(xid, pTcon, full_path, 1494 rc = CIFSSMBSetEOF(xid, pTcon, full_path,
1487 attrs->ia_size, FALSE, 1495 attrs->ia_size, false,
1488 cifs_sb->local_nls, 1496 cifs_sb->local_nls,
1489 cifs_sb->mnt_cifs_flags & 1497 cifs_sb->mnt_cifs_flags &
1490 CIFS_MOUNT_MAP_SPECIAL_CHR); 1498 CIFS_MOUNT_MAP_SPECIAL_CHR);
1491 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); 1499 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
1492 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { 1500 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1493 __u16 netfid; 1501 __u16 netfid;
1494 int oplock = FALSE; 1502 int oplock = 0;
1495 1503
1496 rc = SMBLegacyOpen(xid, pTcon, full_path, 1504 rc = SMBLegacyOpen(xid, pTcon, full_path,
1497 FILE_OPEN, 1505 FILE_OPEN,
@@ -1516,14 +1524,13 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1516 1524
1517 /* Server is ok setting allocation size implicitly - no need 1525 /* Server is ok setting allocation size implicitly - no need
1518 to call: 1526 to call:
1519 CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, TRUE, 1527 CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, true,
1520 cifs_sb->local_nls); 1528 cifs_sb->local_nls);
1521 */ 1529 */
1522 1530
1523 if (rc == 0) { 1531 if (rc == 0) {
1524 rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size); 1532 rc = cifs_vmtruncate(inode, attrs->ia_size);
1525 cifs_truncate_page(direntry->d_inode->i_mapping, 1533 cifs_truncate_page(inode->i_mapping, inode->i_size);
1526 direntry->d_inode->i_size);
1527 } else 1534 } else
1528 goto cifs_setattr_exit; 1535 goto cifs_setattr_exit;
1529 } 1536 }
@@ -1557,14 +1564,14 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1557 rc = 0; 1564 rc = 0;
1558#ifdef CONFIG_CIFS_EXPERIMENTAL 1565#ifdef CONFIG_CIFS_EXPERIMENTAL
1559 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) 1566 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
1560 rc = mode_to_acl(direntry->d_inode, full_path, mode); 1567 rc = mode_to_acl(inode, full_path, mode);
1561 else if ((mode & S_IWUGO) == 0) { 1568 else if ((mode & S_IWUGO) == 0) {
1562#else 1569#else
1563 if ((mode & S_IWUGO) == 0) { 1570 if ((mode & S_IWUGO) == 0) {
1564#endif 1571#endif
1565 /* not writeable */ 1572 /* not writeable */
1566 if ((cifsInode->cifsAttrs & ATTR_READONLY) == 0) { 1573 if ((cifsInode->cifsAttrs & ATTR_READONLY) == 0) {
1567 set_dosattr = TRUE; 1574 set_dosattr = true;
1568 time_buf.Attributes = 1575 time_buf.Attributes =
1569 cpu_to_le32(cifsInode->cifsAttrs | 1576 cpu_to_le32(cifsInode->cifsAttrs |
1570 ATTR_READONLY); 1577 ATTR_READONLY);
@@ -1574,28 +1581,24 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1574 not be able to write to it - so if any write 1581 not be able to write to it - so if any write
1575 bit is enabled for user or group or other we 1582 bit is enabled for user or group or other we
1576 need to at least try to remove r/o dos attr */ 1583 need to at least try to remove r/o dos attr */
1577 set_dosattr = TRUE; 1584 set_dosattr = true;
1578 time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs & 1585 time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs &
1579 (~ATTR_READONLY)); 1586 (~ATTR_READONLY));
1580 /* Windows ignores set to zero */ 1587 /* Windows ignores set to zero */
1581 if (time_buf.Attributes == 0) 1588 if (time_buf.Attributes == 0)
1582 time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL); 1589 time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL);
1583 } 1590 }
1584#ifdef CONFIG_CIFS_EXPERIMENTAL
1585 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
1586 mode_to_acl(direntry->d_inode, full_path, mode);
1587#endif
1588 } 1591 }
1589 1592
1590 if (attrs->ia_valid & ATTR_ATIME) { 1593 if (attrs->ia_valid & ATTR_ATIME) {
1591 set_time = TRUE; 1594 set_time = true;
1592 time_buf.LastAccessTime = 1595 time_buf.LastAccessTime =
1593 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime)); 1596 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime));
1594 } else 1597 } else
1595 time_buf.LastAccessTime = 0; 1598 time_buf.LastAccessTime = 0;
1596 1599
1597 if (attrs->ia_valid & ATTR_MTIME) { 1600 if (attrs->ia_valid & ATTR_MTIME) {
1598 set_time = TRUE; 1601 set_time = true;
1599 time_buf.LastWriteTime = 1602 time_buf.LastWriteTime =
1600 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime)); 1603 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime));
1601 } else 1604 } else
@@ -1606,7 +1609,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1606 server times */ 1609 server times */
1607 1610
1608 if (set_time && (attrs->ia_valid & ATTR_CTIME)) { 1611 if (set_time && (attrs->ia_valid & ATTR_CTIME)) {
1609 set_time = TRUE; 1612 set_time = true;
1610 /* Although Samba throws this field away 1613 /* Although Samba throws this field away
1611 it may be useful to Windows - but we do 1614 it may be useful to Windows - but we do
1612 not want to set ctime unless some other 1615 not want to set ctime unless some other
@@ -1630,7 +1633,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1630 rc = -EOPNOTSUPP; 1633 rc = -EOPNOTSUPP;
1631 1634
1632 if (rc == -EOPNOTSUPP) { 1635 if (rc == -EOPNOTSUPP) {
1633 int oplock = FALSE; 1636 int oplock = 0;
1634 __u16 netfid; 1637 __u16 netfid;
1635 1638
1636 cFYI(1, ("calling SetFileInfo since SetPathInfo for " 1639 cFYI(1, ("calling SetFileInfo since SetPathInfo for "
@@ -1669,7 +1672,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1669 /* do not need local check to inode_check_ok since the server does 1672 /* do not need local check to inode_check_ok since the server does
1670 that */ 1673 that */
1671 if (!rc) 1674 if (!rc)
1672 rc = inode_setattr(direntry->d_inode, attrs); 1675 rc = inode_setattr(inode, attrs);
1673cifs_setattr_exit: 1676cifs_setattr_exit:
1674 kfree(full_path); 1677 kfree(full_path);
1675 FreeXid(xid); 1678 FreeXid(xid);
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index d4e7ec93285f..1c2c3ce5020b 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -230,7 +230,7 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
230 struct inode *inode = direntry->d_inode; 230 struct inode *inode = direntry->d_inode;
231 int rc = -EACCES; 231 int rc = -EACCES;
232 int xid; 232 int xid;
233 int oplock = FALSE; 233 int oplock = 0;
234 struct cifs_sb_info *cifs_sb; 234 struct cifs_sb_info *cifs_sb;
235 struct cifsTconInfo *pTcon; 235 struct cifsTconInfo *pTcon;
236 char *full_path = NULL; 236 char *full_path = NULL;
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 2a42d9fedbb2..1d69b8014e0b 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -496,7 +496,8 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
496 } 496 }
497 return 0; 497 return 0;
498} 498}
499int 499
500bool
500is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) 501is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
501{ 502{
502 struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; 503 struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf;
@@ -522,17 +523,17 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
522 pnotify->Action)); /* BB removeme BB */ 523 pnotify->Action)); /* BB removeme BB */
523 /* cifs_dump_mem("Rcvd notify Data: ",buf, 524 /* cifs_dump_mem("Rcvd notify Data: ",buf,
524 sizeof(struct smb_hdr)+60); */ 525 sizeof(struct smb_hdr)+60); */
525 return TRUE; 526 return true;
526 } 527 }
527 if (pSMBr->hdr.Status.CifsError) { 528 if (pSMBr->hdr.Status.CifsError) {
528 cFYI(1, ("notify err 0x%d", 529 cFYI(1, ("notify err 0x%d",
529 pSMBr->hdr.Status.CifsError)); 530 pSMBr->hdr.Status.CifsError));
530 return TRUE; 531 return true;
531 } 532 }
532 return FALSE; 533 return false;
533 } 534 }
534 if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) 535 if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
535 return FALSE; 536 return false;
536 if (pSMB->hdr.Flags & SMBFLG_RESPONSE) { 537 if (pSMB->hdr.Flags & SMBFLG_RESPONSE) {
537 /* no sense logging error on invalid handle on oplock 538 /* no sense logging error on invalid handle on oplock
538 break - harmless race between close request and oplock 539 break - harmless race between close request and oplock
@@ -541,21 +542,21 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
541 if ((NT_STATUS_INVALID_HANDLE) == 542 if ((NT_STATUS_INVALID_HANDLE) ==
542 le32_to_cpu(pSMB->hdr.Status.CifsError)) { 543 le32_to_cpu(pSMB->hdr.Status.CifsError)) {
543 cFYI(1, ("invalid handle on oplock break")); 544 cFYI(1, ("invalid handle on oplock break"));
544 return TRUE; 545 return true;
545 } else if (ERRbadfid == 546 } else if (ERRbadfid ==
546 le16_to_cpu(pSMB->hdr.Status.DosError.Error)) { 547 le16_to_cpu(pSMB->hdr.Status.DosError.Error)) {
547 return TRUE; 548 return true;
548 } else { 549 } else {
549 return FALSE; /* on valid oplock brk we get "request" */ 550 return false; /* on valid oplock brk we get "request" */
550 } 551 }
551 } 552 }
552 if (pSMB->hdr.WordCount != 8) 553 if (pSMB->hdr.WordCount != 8)
553 return FALSE; 554 return false;
554 555
555 cFYI(1, ("oplock type 0x%d level 0x%d", 556 cFYI(1, ("oplock type 0x%d level 0x%d",
556 pSMB->LockType, pSMB->OplockLevel)); 557 pSMB->LockType, pSMB->OplockLevel));
557 if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) 558 if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE))
558 return FALSE; 559 return false;
559 560
560 /* look up tcon based on tid & uid */ 561 /* look up tcon based on tid & uid */
561 read_lock(&GlobalSMBSeslock); 562 read_lock(&GlobalSMBSeslock);
@@ -573,11 +574,11 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
573 ("file id match, oplock break")); 574 ("file id match, oplock break"));
574 pCifsInode = 575 pCifsInode =
575 CIFS_I(netfile->pInode); 576 CIFS_I(netfile->pInode);
576 pCifsInode->clientCanCacheAll = FALSE; 577 pCifsInode->clientCanCacheAll = false;
577 if (pSMB->OplockLevel == 0) 578 if (pSMB->OplockLevel == 0)
578 pCifsInode->clientCanCacheRead 579 pCifsInode->clientCanCacheRead
579 = FALSE; 580 = false;
580 pCifsInode->oplockPending = TRUE; 581 pCifsInode->oplockPending = true;
581 AllocOplockQEntry(netfile->pInode, 582 AllocOplockQEntry(netfile->pInode,
582 netfile->netfid, 583 netfile->netfid,
583 tcon); 584 tcon);
@@ -585,17 +586,17 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
585 ("about to wake up oplock thread")); 586 ("about to wake up oplock thread"));
586 if (oplockThread) 587 if (oplockThread)
587 wake_up_process(oplockThread); 588 wake_up_process(oplockThread);
588 return TRUE; 589 return true;
589 } 590 }
590 } 591 }
591 read_unlock(&GlobalSMBSeslock); 592 read_unlock(&GlobalSMBSeslock);
592 cFYI(1, ("No matching file for oplock break")); 593 cFYI(1, ("No matching file for oplock break"));
593 return TRUE; 594 return true;
594 } 595 }
595 } 596 }
596 read_unlock(&GlobalSMBSeslock); 597 read_unlock(&GlobalSMBSeslock);
597 cFYI(1, ("Can not process oplock break for non-existent connection")); 598 cFYI(1, ("Can not process oplock break for non-existent connection"));
598 return TRUE; 599 return true;
599} 600}
600 601
601void 602void
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index 3b5a5ce882b6..00f4cff400b3 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -132,47 +132,17 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
132 {0, 0} 132 {0, 0}
133}; 133};
134 134
135
136/* if the mount helper is missing we need to reverse the 1st slash
137 from '/' to backslash in order to format the UNC properly for
138 ip address parsing and for tree connect (unless the user
139 remembered to put the UNC name in properly). Fortunately we do
140 not have to call this twice (we check for IPv4 addresses
141 first, so it is already converted by the time we
142 try IPv6 addresses */
143static int canonicalize_unc(char *cp)
144{
145 int i;
146
147 for (i = 0; i <= 46 /* INET6_ADDRSTRLEN */ ; i++) {
148 if (cp[i] == 0)
149 break;
150 if (cp[i] == '\\')
151 break;
152 if (cp[i] == '/') {
153 cFYI(DBG2, ("change slash to \\ in malformed UNC"));
154 cp[i] = '\\';
155 return 1;
156 }
157 }
158 return 0;
159}
160
161/* Convert string containing dotted ip address to binary form */ 135/* Convert string containing dotted ip address to binary form */
162/* returns 0 if invalid address */ 136/* returns 0 if invalid address */
163 137
164int 138int
165cifs_inet_pton(int address_family, char *cp, void *dst) 139cifs_inet_pton(const int address_family, const char *cp, void *dst)
166{ 140{
167 int ret = 0; 141 int ret = 0;
168 142
169 /* calculate length by finding first slash or NULL */ 143 /* calculate length by finding first slash or NULL */
170 if (address_family == AF_INET) { 144 if (address_family == AF_INET) {
171 ret = in4_pton(cp, -1 /* len */, dst, '\\', NULL); 145 ret = in4_pton(cp, -1 /* len */, dst, '\\', NULL);
172 if (ret == 0) {
173 if (canonicalize_unc(cp))
174 ret = in4_pton(cp, -1, dst, '\\', NULL);
175 }
176 } else if (address_family == AF_INET6) { 146 } else if (address_family == AF_INET6) {
177 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); 147 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
178 } 148 }
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 32b445edc882..34ec32100c72 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -447,8 +447,8 @@ static int initiate_cifs_search(const int xid, struct file *file)
447 if (file->private_data == NULL) 447 if (file->private_data == NULL)
448 return -ENOMEM; 448 return -ENOMEM;
449 cifsFile = file->private_data; 449 cifsFile = file->private_data;
450 cifsFile->invalidHandle = TRUE; 450 cifsFile->invalidHandle = true;
451 cifsFile->srch_inf.endOfSearch = FALSE; 451 cifsFile->srch_inf.endOfSearch = false;
452 452
453 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 453 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
454 if (cifs_sb == NULL) 454 if (cifs_sb == NULL)
@@ -485,7 +485,7 @@ ffirst_retry:
485 cifs_sb->mnt_cifs_flags & 485 cifs_sb->mnt_cifs_flags &
486 CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); 486 CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
487 if (rc == 0) 487 if (rc == 0)
488 cifsFile->invalidHandle = FALSE; 488 cifsFile->invalidHandle = false;
489 if ((rc == -EOPNOTSUPP) && 489 if ((rc == -EOPNOTSUPP) &&
490 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { 490 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
491 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; 491 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
@@ -670,7 +670,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
670 (index_to_find < first_entry_in_buffer)) { 670 (index_to_find < first_entry_in_buffer)) {
671 /* close and restart search */ 671 /* close and restart search */
672 cFYI(1, ("search backing up - close and restart search")); 672 cFYI(1, ("search backing up - close and restart search"));
673 cifsFile->invalidHandle = TRUE; 673 cifsFile->invalidHandle = true;
674 CIFSFindClose(xid, pTcon, cifsFile->netfid); 674 CIFSFindClose(xid, pTcon, cifsFile->netfid);
675 kfree(cifsFile->search_resume_name); 675 kfree(cifsFile->search_resume_name);
676 cifsFile->search_resume_name = NULL; 676 cifsFile->search_resume_name = NULL;
@@ -692,7 +692,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
692 } 692 }
693 693
694 while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) && 694 while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
695 (rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)) { 695 (rc == 0) && !cifsFile->srch_inf.endOfSearch) {
696 cFYI(1, ("calling findnext2")); 696 cFYI(1, ("calling findnext2"));
697 rc = CIFSFindNext(xid, pTcon, cifsFile->netfid, 697 rc = CIFSFindNext(xid, pTcon, cifsFile->netfid,
698 &cifsFile->srch_inf); 698 &cifsFile->srch_inf);
@@ -1038,7 +1038,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1038 break; 1038 break;
1039 } 1039 }
1040 } /* else { 1040 } /* else {
1041 cifsFile->invalidHandle = TRUE; 1041 cifsFile->invalidHandle = true;
1042 CIFSFindClose(xid, pTcon, cifsFile->netfid); 1042 CIFSFindClose(xid, pTcon, cifsFile->netfid);
1043 } 1043 }
1044 kfree(cifsFile->search_resume_name); 1044 kfree(cifsFile->search_resume_name);
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c
index 58bbfd992cc0..ff3232fa1015 100644
--- a/fs/cifs/smbencrypt.c
+++ b/fs/cifs/smbencrypt.c
@@ -35,11 +35,11 @@
35#include "cifs_debug.h" 35#include "cifs_debug.h"
36#include "cifsencrypt.h" 36#include "cifsencrypt.h"
37 37
38#ifndef FALSE 38#ifndef false
39#define FALSE 0 39#define false 0
40#endif 40#endif
41#ifndef TRUE 41#ifndef true
42#define TRUE 1 42#define true 1
43#endif 43#endif
44 44
45/* following came from the other byteorder.h to avoid include conflicts */ 45/* following came from the other byteorder.h to avoid include conflicts */
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index 8cd6a445b017..e9527eedc639 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -264,7 +264,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
264#ifdef CONFIG_CIFS_EXPERIMENTAL 264#ifdef CONFIG_CIFS_EXPERIMENTAL
265 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { 265 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
266 __u16 fid; 266 __u16 fid;
267 int oplock = FALSE; 267 int oplock = 0;
268 struct cifs_ntsd *pacl = NULL; 268 struct cifs_ntsd *pacl = NULL;
269 __u32 buflen = 0; 269 __u32 buflen = 0;
270 if (experimEnabled) 270 if (experimEnabled)