diff options
author | Steve French <sfrench@us.ibm.com> | 2007-10-18 17:45:27 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2007-10-18 17:45:27 -0400 |
commit | a761ac579b89bc1f00212a42401398108deba65c (patch) | |
tree | 5345eaf8fa239af7f8f28989bea7942b0ab8ea13 /fs/cifs | |
parent | abb63d6c3d3d0e4d93b63589135962091154be9b (diff) |
[CIFS] log better errors on failed mounts
Also returns more accurate errors to mount for the cases of
account expired and password expired
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsproto.h | 5 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 10 | ||||
-rw-r--r-- | fs/cifs/netmisc.c | 28 | ||||
-rw-r--r-- | fs/cifs/sess.c | 3 | ||||
-rw-r--r-- | fs/cifs/smberr.h | 5 | ||||
-rw-r--r-- | fs/cifs/transport.c | 10 |
6 files changed, 35 insertions, 26 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 001f0dc7e60d..1a883663b22d 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -50,7 +50,8 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *, | |||
50 | int * /* bytes returned */ , const int long_op); | 50 | int * /* bytes returned */ , const int long_op); |
51 | extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *, | 51 | extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *, |
52 | struct kvec *, int /* nvec to send */, | 52 | struct kvec *, int /* nvec to send */, |
53 | int * /* type of buf returned */ , const int long_op); | 53 | int * /* type of buf returned */ , const int long_op, |
54 | const int logError /* whether to log status code*/ ); | ||
54 | extern int SendReceiveBlockingLock(const unsigned int /* xid */ , | 55 | extern int SendReceiveBlockingLock(const unsigned int /* xid */ , |
55 | struct cifsTconInfo *, | 56 | struct cifsTconInfo *, |
56 | struct smb_hdr * /* input */ , | 57 | struct smb_hdr * /* input */ , |
@@ -65,7 +66,7 @@ extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr); | |||
65 | extern int decode_negTokenInit(unsigned char *security_blob, int length, | 66 | extern int decode_negTokenInit(unsigned char *security_blob, int length, |
66 | enum securityEnum *secType); | 67 | enum securityEnum *secType); |
67 | extern int cifs_inet_pton(int, char *source, void *dst); | 68 | extern int cifs_inet_pton(int, char *source, void *dst); |
68 | extern int map_smb_to_linux_error(struct smb_hdr *smb); | 69 | extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr); |
69 | extern void header_assemble(struct smb_hdr *, char /* command */ , | 70 | extern void header_assemble(struct smb_hdr *, char /* command */ , |
70 | const struct cifsTconInfo *, int /* length of | 71 | const struct cifsTconInfo *, int /* length of |
71 | fixed section (word count) in two byte units */); | 72 | fixed section (word count) in two byte units */); |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 2b2d4fec3656..f0d9a485d095 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -1446,9 +1446,8 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid, | |||
1446 | 1446 | ||
1447 | iov[0].iov_base = (char *)pSMB; | 1447 | iov[0].iov_base = (char *)pSMB; |
1448 | iov[0].iov_len = pSMB->hdr.smb_buf_length + 4; | 1448 | iov[0].iov_len = pSMB->hdr.smb_buf_length + 4; |
1449 | rc = SendReceive2(xid, tcon->ses, iov, | 1449 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovecs */, |
1450 | 1 /* num iovecs */, | 1450 | &resp_buf_type, 0 /* not long op */, 1 /* log err */ ); |
1451 | &resp_buf_type, 0); | ||
1452 | cifs_stats_inc(&tcon->num_reads); | 1451 | cifs_stats_inc(&tcon->num_reads); |
1453 | pSMBr = (READ_RSP *)iov[0].iov_base; | 1452 | pSMBr = (READ_RSP *)iov[0].iov_base; |
1454 | if (rc) { | 1453 | if (rc) { |
@@ -1667,7 +1666,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, | |||
1667 | 1666 | ||
1668 | 1667 | ||
1669 | rc = SendReceive2(xid, tcon->ses, iov, n_vec + 1, &resp_buf_type, | 1668 | rc = SendReceive2(xid, tcon->ses, iov, n_vec + 1, &resp_buf_type, |
1670 | long_op); | 1669 | long_op, 0 /* do not log STATUS code */ ); |
1671 | cifs_stats_inc(&tcon->num_writes); | 1670 | cifs_stats_inc(&tcon->num_writes); |
1672 | if (rc) { | 1671 | if (rc) { |
1673 | cFYI(1, ("Send error Write2 = %d", rc)); | 1672 | cFYI(1, ("Send error Write2 = %d", rc)); |
@@ -3094,7 +3093,8 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid, | |||
3094 | iov[0].iov_base = (char *)pSMB; | 3093 | iov[0].iov_base = (char *)pSMB; |
3095 | iov[0].iov_len = pSMB->hdr.smb_buf_length + 4; | 3094 | iov[0].iov_len = pSMB->hdr.smb_buf_length + 4; |
3096 | 3095 | ||
3097 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovec */, &buf_type, 0); | 3096 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovec */, &buf_type, |
3097 | 0 /* not long op */, 0 /* do not log STATUS codes */ ); | ||
3098 | cifs_stats_inc(&tcon->num_acl_get); | 3098 | cifs_stats_inc(&tcon->num_acl_get); |
3099 | if (rc) { | 3099 | if (rc) { |
3100 | cFYI(1, ("Send error in QuerySecDesc = %d", rc)); | 3100 | cFYI(1, ("Send error in QuerySecDesc = %d", rc)); |
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index 9ae4941cd61d..f06359cb22ee 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
@@ -114,10 +114,16 @@ static const struct smb_to_posix_error mapping_table_ERRSRV[] = { | |||
114 | {ERRusempx, -EIO}, | 114 | {ERRusempx, -EIO}, |
115 | {ERRusestd, -EIO}, | 115 | {ERRusestd, -EIO}, |
116 | {ERR_NOTIFY_ENUM_DIR, -ENOBUFS}, | 116 | {ERR_NOTIFY_ENUM_DIR, -ENOBUFS}, |
117 | {ERRaccountexpired, -EACCES}, | 117 | {ERRnoSuchUser, -EACCES}, |
118 | /* {ERRaccountexpired, -EACCES}, | ||
118 | {ERRbadclient, -EACCES}, | 119 | {ERRbadclient, -EACCES}, |
119 | {ERRbadLogonTime, -EACCES}, | 120 | {ERRbadLogonTime, -EACCES}, |
120 | {ERRpasswordExpired, -EACCES}, | 121 | {ERRpasswordExpired, -EACCES},*/ |
122 | {ERRaccountexpired, -EKEYEXPIRED}, | ||
123 | {ERRbadclient, -EACCES}, | ||
124 | {ERRbadLogonTime, -EACCES}, | ||
125 | {ERRpasswordExpired, -EKEYEXPIRED}, | ||
126 | |||
121 | {ERRnosupport, -EINVAL}, | 127 | {ERRnosupport, -EINVAL}, |
122 | {0, 0} | 128 | {0, 0} |
123 | }; | 129 | }; |
@@ -270,7 +276,7 @@ static const struct { | |||
270 | from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE | 276 | from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE |
271 | during the session setup } */ | 277 | during the session setup } */ |
272 | { | 278 | { |
273 | ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, { | 279 | ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, { /* could map to 2238 */ |
274 | ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, { | 280 | ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, { |
275 | ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, { | 281 | ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, { |
276 | ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, { | 282 | ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, { |
@@ -285,10 +291,10 @@ static const struct { | |||
285 | ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, { | 291 | ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, { |
286 | ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, { | 292 | ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, { |
287 | ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, { | 293 | ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, { |
288 | ERRSRV, 2241, NT_STATUS_INVALID_LOGON_HOURS}, { | 294 | ERRSRV, ERRbadLogonTime, NT_STATUS_INVALID_LOGON_HOURS}, { |
289 | ERRSRV, 2240, NT_STATUS_INVALID_WORKSTATION}, { | 295 | ERRSRV, ERRbadclient, NT_STATUS_INVALID_WORKSTATION}, { |
290 | ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_EXPIRED}, { | 296 | ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_EXPIRED}, { |
291 | ERRSRV, 2239, NT_STATUS_ACCOUNT_DISABLED}, { | 297 | ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_DISABLED}, { |
292 | ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, { | 298 | ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, { |
293 | ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, { | 299 | ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, { |
294 | ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, { | 300 | ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, { |
@@ -585,7 +591,7 @@ static const struct { | |||
585 | ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, { | 591 | ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, { |
586 | ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, { | 592 | ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, { |
587 | ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, { | 593 | ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, { |
588 | ERRSRV, 2239, NT_STATUS_ACCOUNT_EXPIRED}, { | 594 | ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_EXPIRED}, { |
589 | ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, { | 595 | ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, { |
590 | ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, { | 596 | ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, { |
591 | ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, { | 597 | ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, { |
@@ -754,7 +760,7 @@ ntstatus_to_dos(__u32 ntstatus, __u8 * eclass, __u16 * ecode) | |||
754 | } | 760 | } |
755 | 761 | ||
756 | int | 762 | int |
757 | map_smb_to_linux_error(struct smb_hdr *smb) | 763 | map_smb_to_linux_error(struct smb_hdr *smb, int logErr) |
758 | { | 764 | { |
759 | unsigned int i; | 765 | unsigned int i; |
760 | int rc = -EIO; /* if transport error smb error may not be set */ | 766 | int rc = -EIO; /* if transport error smb error may not be set */ |
@@ -771,7 +777,9 @@ map_smb_to_linux_error(struct smb_hdr *smb) | |||
771 | /* translate the newer STATUS codes to old style SMB errors | 777 | /* translate the newer STATUS codes to old style SMB errors |
772 | * and then to POSIX errors */ | 778 | * and then to POSIX errors */ |
773 | __u32 err = le32_to_cpu(smb->Status.CifsError); | 779 | __u32 err = le32_to_cpu(smb->Status.CifsError); |
774 | if (cifsFYI & CIFS_RC) | 780 | if (logErr && (err != (NT_STATUS_MORE_PROCESSING_REQUIRED))) |
781 | cifs_print_status(err); | ||
782 | else if (cifsFYI & CIFS_RC) | ||
775 | cifs_print_status(err); | 783 | cifs_print_status(err); |
776 | ntstatus_to_dos(err, &smberrclass, &smberrcode); | 784 | ntstatus_to_dos(err, &smberrclass, &smberrcode); |
777 | } else { | 785 | } else { |
@@ -813,7 +821,7 @@ map_smb_to_linux_error(struct smb_hdr *smb) | |||
813 | } | 821 | } |
814 | /* else ERRHRD class errors or junk - return EIO */ | 822 | /* else ERRHRD class errors or junk - return EIO */ |
815 | 823 | ||
816 | cFYI(1, (" !!Mapping smb error code %d to POSIX err %d !!", | 824 | cFYI(1, ("Mapping smb error code %d to POSIX err %d", |
817 | smberrcode, rc)); | 825 | smberrcode, rc)); |
818 | 826 | ||
819 | /* generic corrective action e.g. reconnect SMB session on | 827 | /* generic corrective action e.g. reconnect SMB session on |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index c74a064e7825..899dc6078d9a 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -513,7 +513,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
513 | 513 | ||
514 | iov[1].iov_base = str_area; | 514 | iov[1].iov_base = str_area; |
515 | iov[1].iov_len = count; | 515 | iov[1].iov_len = count; |
516 | rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, 0); | 516 | rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, |
517 | 0 /* not long op */, 1 /* log NT STATUS if any */ ); | ||
517 | /* SMB request buf freed in SendReceive2 */ | 518 | /* SMB request buf freed in SendReceive2 */ |
518 | 519 | ||
519 | cFYI(1, ("ssetup rc from sendrecv2 is %d", rc)); | 520 | cFYI(1, ("ssetup rc from sendrecv2 is %d", rc)); |
diff --git a/fs/cifs/smberr.h b/fs/cifs/smberr.h index 2ef0be288820..7f50e8577c1c 100644 --- a/fs/cifs/smberr.h +++ b/fs/cifs/smberr.h | |||
@@ -173,9 +173,10 @@ | |||
173 | #define ERRusestd 251 /* temporarily unable to use either raw | 173 | #define ERRusestd 251 /* temporarily unable to use either raw |
174 | or mpx */ | 174 | or mpx */ |
175 | #define ERR_NOTIFY_ENUM_DIR 1024 | 175 | #define ERR_NOTIFY_ENUM_DIR 1024 |
176 | #define ERRnoSuchUser 2238 /* user account does not exist */ | ||
176 | #define ERRaccountexpired 2239 | 177 | #define ERRaccountexpired 2239 |
177 | #define ERRbadclient 2240 | 178 | #define ERRbadclient 2240 /* can not logon from this client */ |
178 | #define ERRbadLogonTime 2241 | 179 | #define ERRbadLogonTime 2241 /* logon hours do not allow this */ |
179 | #define ERRpasswordExpired 2242 | 180 | #define ERRpasswordExpired 2242 |
180 | #define ERRnetlogonNotStarted 2455 | 181 | #define ERRnetlogonNotStarted 2455 |
181 | #define ERRnosupport 0xFFFF | 182 | #define ERRnosupport 0xFFFF |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 6684926bf3d2..7ed32b3cb781 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -418,7 +418,7 @@ static int wait_for_response(struct cifsSesInfo *ses, | |||
418 | int | 418 | int |
419 | SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, | 419 | SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, |
420 | struct kvec *iov, int n_vec, int *pRespBufType /* ret */, | 420 | struct kvec *iov, int n_vec, int *pRespBufType /* ret */, |
421 | const int long_op) | 421 | const int long_op, const int logError) |
422 | { | 422 | { |
423 | int rc = 0; | 423 | int rc = 0; |
424 | unsigned int receive_len; | 424 | unsigned int receive_len; |
@@ -464,7 +464,6 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, | |||
464 | wake_up(&ses->server->request_q); | 464 | wake_up(&ses->server->request_q); |
465 | return rc; | 465 | return rc; |
466 | } | 466 | } |
467 | |||
468 | rc = cifs_sign_smb2(iov, n_vec, ses->server, &midQ->sequence_number); | 467 | rc = cifs_sign_smb2(iov, n_vec, ses->server, &midQ->sequence_number); |
469 | 468 | ||
470 | midQ->midState = MID_REQUEST_SUBMITTED; | 469 | midQ->midState = MID_REQUEST_SUBMITTED; |
@@ -567,8 +566,7 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, | |||
567 | } | 566 | } |
568 | 567 | ||
569 | /* BB special case reconnect tid and uid here? */ | 568 | /* BB special case reconnect tid and uid here? */ |
570 | /* BB special case Errbadpassword and pwdexpired here */ | 569 | rc = map_smb_to_linux_error(midQ->resp_buf, logError); |
571 | rc = map_smb_to_linux_error(midQ->resp_buf); | ||
572 | 570 | ||
573 | /* convert ByteCount if necessary */ | 571 | /* convert ByteCount if necessary */ |
574 | if (receive_len >= sizeof(struct smb_hdr) - 4 | 572 | if (receive_len >= sizeof(struct smb_hdr) - 4 |
@@ -747,7 +745,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, | |||
747 | *pbytes_returned = out_buf->smb_buf_length; | 745 | *pbytes_returned = out_buf->smb_buf_length; |
748 | 746 | ||
749 | /* BB special case reconnect tid and uid here? */ | 747 | /* BB special case reconnect tid and uid here? */ |
750 | rc = map_smb_to_linux_error(out_buf); | 748 | rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); |
751 | 749 | ||
752 | /* convert ByteCount if necessary */ | 750 | /* convert ByteCount if necessary */ |
753 | if (receive_len >= sizeof(struct smb_hdr) - 4 | 751 | if (receive_len >= sizeof(struct smb_hdr) - 4 |
@@ -990,7 +988,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, | |||
990 | *pbytes_returned = out_buf->smb_buf_length; | 988 | *pbytes_returned = out_buf->smb_buf_length; |
991 | 989 | ||
992 | /* BB special case reconnect tid and uid here? */ | 990 | /* BB special case reconnect tid and uid here? */ |
993 | rc = map_smb_to_linux_error(out_buf); | 991 | rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); |
994 | 992 | ||
995 | /* convert ByteCount if necessary */ | 993 | /* convert ByteCount if necessary */ |
996 | if (receive_len >= sizeof(struct smb_hdr) - 4 | 994 | if (receive_len >= sizeof(struct smb_hdr) - 4 |