Commit fb8c4b14 authored by Steve French's avatar Steve French

[CIFS] whitespace cleanup

More than halfway there
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent b609f06a
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software * along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/net.h> #include <linux/net.h>
...@@ -93,20 +93,20 @@ struct smb_vol { ...@@ -93,20 +93,20 @@ struct smb_vol {
unsigned int wsize; unsigned int wsize;
unsigned int sockopt; unsigned int sockopt;
unsigned short int port; unsigned short int port;
char * prepath; char *prepath;
}; };
static int ipv4_connect(struct sockaddr_in *psin_server, static int ipv4_connect(struct sockaddr_in *psin_server,
struct socket **csocket, struct socket **csocket,
char * netb_name, char *netb_name,
char * server_netb_name); char *server_netb_name);
static int ipv6_connect(struct sockaddr_in6 *psin_server, static int ipv6_connect(struct sockaddr_in6 *psin_server,
struct socket **csocket); struct socket **csocket);
/* /*
* cifs tcp session reconnection * cifs tcp session reconnection
* *
* mark tcp session as reconnecting so temporarily locked * mark tcp session as reconnecting so temporarily locked
* mark all smb sessions as reconnecting for tcp session * mark all smb sessions as reconnecting for tcp session
* reconnect tcp session * reconnect tcp session
...@@ -120,11 +120,11 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -120,11 +120,11 @@ cifs_reconnect(struct TCP_Server_Info *server)
struct list_head *tmp; struct list_head *tmp;
struct cifsSesInfo *ses; struct cifsSesInfo *ses;
struct cifsTconInfo *tcon; struct cifsTconInfo *tcon;
struct mid_q_entry * mid_entry; struct mid_q_entry *mid_entry;
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if( kthread_should_stop() ) { if ( kthread_should_stop() ) {
/* the demux thread will exit normally /* the demux thread will exit normally
next time through the loop */ next time through the loop */
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
return rc; return rc;
...@@ -150,18 +150,18 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -150,18 +150,18 @@ cifs_reconnect(struct TCP_Server_Info *server)
} }
list_for_each(tmp, &GlobalTreeConnectionList) { list_for_each(tmp, &GlobalTreeConnectionList) {
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
if((tcon) && (tcon->ses) && (tcon->ses->server == server)) { if ((tcon) && (tcon->ses) && (tcon->ses->server == server)) {
tcon->tidStatus = CifsNeedReconnect; tcon->tidStatus = CifsNeedReconnect;
} }
} }
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
/* do not want to be sending data on a socket we are freeing */ /* do not want to be sending data on a socket we are freeing */
down(&server->tcpSem); down(&server->tcpSem);
if(server->ssocket) { if (server->ssocket) {
cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state, cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state,
server->ssocket->flags)); server->ssocket->flags));
server->ssocket->ops->shutdown(server->ssocket,SEND_SHUTDOWN); server->ssocket->ops->shutdown(server->ssocket, SEND_SHUTDOWN);
cFYI(1, ("Post shutdown state: 0x%x Flags: 0x%lx", cFYI(1, ("Post shutdown state: 0x%x Flags: 0x%lx",
server->ssocket->state, server->ssocket->state,
server->ssocket->flags)); server->ssocket->flags));
sock_release(server->ssocket); sock_release(server->ssocket);
...@@ -173,8 +173,8 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -173,8 +173,8 @@ cifs_reconnect(struct TCP_Server_Info *server)
mid_entry = list_entry(tmp, struct mid_entry = list_entry(tmp, struct
mid_q_entry, mid_q_entry,
qhead); qhead);
if(mid_entry) { if (mid_entry) {
if(mid_entry->midState == MID_REQUEST_SUBMITTED) { if (mid_entry->midState == MID_REQUEST_SUBMITTED) {
/* Mark other intransit requests as needing /* Mark other intransit requests as needing
retry so we do not immediately mark the retry so we do not immediately mark the
session bad again (ie after we reconnect session bad again (ie after we reconnect
...@@ -184,29 +184,29 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -184,29 +184,29 @@ cifs_reconnect(struct TCP_Server_Info *server)
} }
} }
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
up(&server->tcpSem); up(&server->tcpSem);
while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) {
{
try_to_freeze(); try_to_freeze();
if(server->protocolType == IPV6) { if (server->protocolType == IPV6) {
rc = ipv6_connect(&server->addr.sockAddr6,&server->ssocket); rc = ipv6_connect(&server->addr.sockAddr6,
&server->ssocket);
} else { } else {
rc = ipv4_connect(&server->addr.sockAddr, rc = ipv4_connect(&server->addr.sockAddr,
&server->ssocket, &server->ssocket,
server->workstation_RFC1001_name, server->workstation_RFC1001_name,
server->server_RFC1001_name); server->server_RFC1001_name);
} }
if(rc) { if (rc) {
cFYI(1, ("reconnect error %d",rc)); cFYI(1, ("reconnect error %d", rc));
msleep(3000); msleep(3000);
} else { } else {
atomic_inc(&tcpSesReconnectCount); atomic_inc(&tcpSesReconnectCount);
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if( !kthread_should_stop() ) if ( !kthread_should_stop() )
server->tcpStatus = CifsGood; server->tcpStatus = CifsGood;
server->sequence_number = 0; server->sequence_number = 0;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
/* atomic_set(&server->inFlight,0);*/ /* atomic_set(&server->inFlight,0);*/
wake_up(&server->response_q); wake_up(&server->response_q);
} }
...@@ -214,26 +214,26 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -214,26 +214,26 @@ cifs_reconnect(struct TCP_Server_Info *server)
return rc; return rc;
} }
/* /*
return codes: return codes:
0 not a transact2, or all data present 0 not a transact2, or all data present
>0 transact2 with that much data missing >0 transact2 with that much data missing
-EINVAL = invalid transact2 -EINVAL = invalid transact2
*/ */
static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize) static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize)
{ {
struct smb_t2_rsp * pSMBt; struct smb_t2_rsp *pSMBt;
int total_data_size; int total_data_size;
int data_in_this_rsp; int data_in_this_rsp;
int remaining; int remaining;
if(pSMB->Command != SMB_COM_TRANSACTION2) if (pSMB->Command != SMB_COM_TRANSACTION2)
return 0; return 0;
/* check for plausible wct, bcc and t2 data and parm sizes */ /* check for plausible wct, bcc and t2 data and parm sizes */
/* check for parm and data offset going beyond end of smb */ /* check for parm and data offset going beyond end of smb */
if(pSMB->WordCount != 10) { /* coalesce_t2 depends on this */ if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
cFYI(1, ("invalid transact2 word count")); cFYI(1, ("invalid transact2 word count"));
return -EINVAL; return -EINVAL;
} }
...@@ -245,25 +245,25 @@ static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize) ...@@ -245,25 +245,25 @@ static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize)
remaining = total_data_size - data_in_this_rsp; remaining = total_data_size - data_in_this_rsp;
if(remaining == 0) if (remaining == 0)
return 0; return 0;
else if(remaining < 0) { else if (remaining < 0) {
cFYI(1, ("total data %d smaller than data in frame %d", cFYI(1, ("total data %d smaller than data in frame %d",
total_data_size, data_in_this_rsp)); total_data_size, data_in_this_rsp));
return -EINVAL; return -EINVAL;
} else { } else {
cFYI(1, ("missing %d bytes from transact2, check next response", cFYI(1, ("missing %d bytes from transact2, check next response",
remaining)); remaining));
if(total_data_size > maxBufSize) { if (total_data_size > maxBufSize) {
cERROR(1,("TotalDataSize %d is over maximum buffer %d", cERROR(1, ("TotalDataSize %d is over maximum buffer %d",
total_data_size,maxBufSize)); total_data_size, maxBufSize));
return -EINVAL; return -EINVAL;
} }
return remaining; return remaining;
} }
} }
static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
{ {
struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond;
struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB;
...@@ -271,43 +271,43 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) ...@@ -271,43 +271,43 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB)
int total_in_buf; int total_in_buf;
int remaining; int remaining;
int total_in_buf2; int total_in_buf2;
char * data_area_of_target; char *data_area_of_target;
char * data_area_of_buf2; char *data_area_of_buf2;
__u16 byte_count; __u16 byte_count;
total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount);
if(total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { if (total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) {
cFYI(1,("total data sizes of primary and secondary t2 differ")); cFYI(1, ("total data sizes of primary and secondary t2 differ"));
} }
total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount);
remaining = total_data_size - total_in_buf; remaining = total_data_size - total_in_buf;
if(remaining < 0) if (remaining < 0)
return -EINVAL; return -EINVAL;
if(remaining == 0) /* nothing to do, ignore */ if (remaining == 0) /* nothing to do, ignore */
return 0; return 0;
total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount);
if(remaining < total_in_buf2) { if (remaining < total_in_buf2) {
cFYI(1, ("transact2 2nd response contains too much data")); cFYI(1, ("transact2 2nd response contains too much data"));
} }
/* find end of first SMB data area */ /* find end of first SMB data area */
data_area_of_target = (char *)&pSMBt->hdr.Protocol + data_area_of_target = (char *)&pSMBt->hdr.Protocol +
le16_to_cpu(pSMBt->t2_rsp.DataOffset); le16_to_cpu(pSMBt->t2_rsp.DataOffset);
/* validate target area */ /* validate target area */
data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol +
le16_to_cpu(pSMB2->t2_rsp.DataOffset); le16_to_cpu(pSMB2->t2_rsp.DataOffset);
data_area_of_target += total_in_buf; data_area_of_target += total_in_buf;
/* copy second buffer into end of first buffer */ /* copy second buffer into end of first buffer */
memcpy(data_area_of_target,data_area_of_buf2,total_in_buf2); memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2);
total_in_buf += total_in_buf2; total_in_buf += total_in_buf2;
pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf);
byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); byte_count = le16_to_cpu(BCC_LE(pTargetSMB));
...@@ -321,7 +321,7 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) ...@@ -321,7 +321,7 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB)
pTargetSMB->smb_buf_length = byte_count; pTargetSMB->smb_buf_length = byte_count;
if(remaining == total_in_buf2) { if (remaining == total_in_buf2) {
cFYI(1, ("found the last secondary response")); cFYI(1, ("found the last secondary response"));
return 0; /* we are done */ return 0; /* we are done */
} else /* more responses to go */ } else /* more responses to go */
...@@ -352,12 +352,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -352,12 +352,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
current->flags |= PF_MEMALLOC; current->flags |= PF_MEMALLOC;
server->tsk = current; /* save process info to wake at shutdown */ server->tsk = current; /* save process info to wake at shutdown */
cFYI(1, ("Demultiplex PID: %d", current->pid)); cFYI(1, ("Demultiplex PID: %d", current->pid));
write_lock(&GlobalSMBSeslock); write_lock(&GlobalSMBSeslock);
atomic_inc(&tcpSesAllocCount); atomic_inc(&tcpSesAllocCount);
length = tcpSesAllocCount.counter; length = tcpSesAllocCount.counter;
write_unlock(&GlobalSMBSeslock); write_unlock(&GlobalSMBSeslock);
complete(&cifsd_complete); complete(&cifsd_complete);
if(length > 1) { if (length > 1) {
mempool_resize(cifs_req_poolp, mempool_resize(cifs_req_poolp,
length + cifs_min_rcv, length + cifs_min_rcv,
GFP_KERNEL); GFP_KERNEL);
...@@ -452,7 +452,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -452,7 +452,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
with the most common, zero, as regular data */ with the most common, zero, as regular data */
temp = *((char *) smb_buffer); temp = *((char *) smb_buffer);
/* Note that FC 1001 length is big endian on the wire, /* Note that FC 1001 length is big endian on the wire,
but we convert it here so it is always manipulated but we convert it here so it is always manipulated
as host byte order */ as host byte order */
pdu_length = ntohl(smb_buffer->smb_buf_length); pdu_length = ntohl(smb_buffer->smb_buf_length);
...@@ -461,17 +461,17 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -461,17 +461,17 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); cFYI(1, ("rfc1002 length 0x%x", pdu_length+4));
if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) { if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) {
continue; continue;
} else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) { } else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) {
cFYI(1, ("Good RFC 1002 session rsp")); cFYI(1, ("Good RFC 1002 session rsp"));
continue; continue;
} else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) { } else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) {
/* we get this from Windows 98 instead of /* we get this from Windows 98 instead of
an error on SMB negprot response */ an error on SMB negprot response */
cFYI(1,("Negative RFC1002 Session Response Error 0x%x)", cFYI(1, ("Negative RFC1002 Session Response Error 0x%x)",
pdu_length)); pdu_length));
if(server->tcpStatus == CifsNew) { if (server->tcpStatus == CifsNew) {
/* if nack on negprot (rather than /* if nack on negprot (rather than
ret of smb negprot error) reconnecting ret of smb negprot error) reconnecting
not going to help, ret error to mount */ not going to help, ret error to mount */
break; break;
...@@ -481,10 +481,10 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -481,10 +481,10 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
msleep(1000); msleep(1000);
/* always try 445 first on reconnect /* always try 445 first on reconnect
since we get NACK on some if we ever since we get NACK on some if we ever
connected to port 139 (the NACK is connected to port 139 (the NACK is
since we do not begin with RFC1001 since we do not begin with RFC1001
session initialize frame) */ session initialize frame) */
server->addr.sockAddr.sin_port = server->addr.sockAddr.sin_port =
htons(CIFS_PORT); htons(CIFS_PORT);
cifs_reconnect(server); cifs_reconnect(server);
csocket = server->ssocket; csocket = server->ssocket;
...@@ -492,7 +492,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -492,7 +492,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
continue; continue;
} }
} else if (temp != (char) 0) { } else if (temp != (char) 0) {
cERROR(1,("Unknown RFC 1002 frame")); cERROR(1, ("Unknown RFC 1002 frame"));
cifs_dump_mem(" Received Data: ", (char *)smb_buffer, cifs_dump_mem(" Received Data: ", (char *)smb_buffer,
length); length);
cifs_reconnect(server); cifs_reconnect(server);
...@@ -501,7 +501,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -501,7 +501,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
} }
/* else we have an SMB response */ /* else we have an SMB response */
if((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) ||
(pdu_length < sizeof (struct smb_hdr) - 1 - 4)) { (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) {
cERROR(1, ("Invalid size SMB length %d pdu_length %d", cERROR(1, ("Invalid size SMB length %d pdu_length %d",
length, pdu_length+4)); length, pdu_length+4));
...@@ -509,12 +509,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -509,12 +509,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
csocket = server->ssocket; csocket = server->ssocket;
wake_up(&server->response_q); wake_up(&server->response_q);
continue; continue;
} }
/* else length ok */ /* else length ok */
reconnect = 0; reconnect = 0;
if(pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) {
isLargeBuf = TRUE; isLargeBuf = TRUE;
memcpy(bigbuf, smallbuf, 4); memcpy(bigbuf, smallbuf, 4);
smb_buffer = bigbuf; smb_buffer = bigbuf;
...@@ -522,11 +522,11 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -522,11 +522,11 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
length = 0; length = 0;
iov.iov_base = 4 + (char *)smb_buffer; iov.iov_base = 4 + (char *)smb_buffer;
iov.iov_len = pdu_length; iov.iov_len = pdu_length;
for (total_read = 0; total_read < pdu_length; for (total_read = 0; total_read < pdu_length;
total_read += length) { total_read += length) {
length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, length = kernel_recvmsg(csocket, &smb_msg, &iov, 1,
pdu_length - total_read, 0); pdu_length - total_read, 0);
if( kthread_should_stop() || if ( kthread_should_stop() ||
(length == -EINTR)) { (length == -EINTR)) {
/* then will exit */ /* then will exit */
reconnect = 2; reconnect = 2;
...@@ -534,19 +534,19 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -534,19 +534,19 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
} else if (server->tcpStatus == CifsNeedReconnect) { } else if (server->tcpStatus == CifsNeedReconnect) {
cifs_reconnect(server); cifs_reconnect(server);
csocket = server->ssocket; csocket = server->ssocket;
/* Reconnect wakes up rspns q */ /* Reconnect wakes up rspns q */
/* Now we will reread sock */ /* Now we will reread sock */
reconnect = 1; reconnect = 1;
break; break;
} else if ((length == -ERESTARTSYS) || } else if ((length == -ERESTARTSYS) ||
(length == -EAGAIN)) { (length == -EAGAIN)) {
msleep(1); /* minimum sleep to prevent looping, msleep(1); /* minimum sleep to prevent looping,
allowing socket to clear and app allowing socket to clear and app
threads to set tcpStatus threads to set tcpStatus
CifsNeedReconnect if server hung*/ CifsNeedReconnect if server hung*/
continue; continue;
} else if (length <= 0) { } else if (length <= 0) {
cERROR(1,("Received no data, expecting %d", cERROR(1, ("Received no data, expecting %d",
pdu_length - total_read)); pdu_length - total_read));
cifs_reconnect(server); cifs_reconnect(server);
csocket = server->ssocket; csocket = server->ssocket;
...@@ -554,9 +554,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -554,9 +554,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
break; break;
} }
} }
if(reconnect == 2) if (reconnect == 2)
break; break;
else if(reconnect == 1) else if (reconnect == 1)
continue; continue;
length += 4; /* account for rfc1002 hdr */ length += 4; /* account for rfc1002 hdr */
...@@ -577,12 +577,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -577,12 +577,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
if ((mid_entry->mid == smb_buffer->Mid) && if ((mid_entry->mid == smb_buffer->Mid) &&
(mid_entry->midState == MID_REQUEST_SUBMITTED) && (mid_entry->midState == MID_REQUEST_SUBMITTED) &&
(mid_entry->command == smb_buffer->Command)) { (mid_entry->command == smb_buffer->Command)) {
if(check2ndT2(smb_buffer,server->maxBuf) > 0) { if (check2ndT2(smb_buffer,server->maxBuf) > 0) {
/* We have a multipart transact2 resp */ /* We have a multipart transact2 resp */
isMultiRsp = TRUE; isMultiRsp = TRUE;
if(mid_entry->resp_buf) { if (mid_entry->resp_buf) {
/* merge response - fix up 1st*/ /* merge response - fix up 1st*/
if(coalesce_t2(smb_buffer, if (coalesce_t2(smb_buffer,
mid_entry->resp_buf)) { mid_entry->resp_buf)) {
mid_entry->multiRsp = 1; mid_entry->multiRsp = 1;
break; break;
...@@ -592,7 +592,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -592,7 +592,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
goto multi_t2_fnd; goto multi_t2_fnd;
} }
} else { } else {
if(!isLargeBuf) { if (!isLargeBuf) {
cERROR(1,("1st trans2 resp needs bigbuf")); cERROR(1,("1st trans2 resp needs bigbuf"));
/* BB maybe we can fix this up, switch /* BB maybe we can fix this up, switch
to already allocated large buffer? */ to already allocated large buffer? */
...@@ -607,7 +607,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -607,7 +607,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
break; break;
} }
mid_entry->resp_buf = smb_buffer; mid_entry->resp_buf = smb_buffer;
if(isLargeBuf) if (isLargeBuf)
mid_entry->largeBuf = 1; mid_entry->largeBuf = 1;
else else
mid_entry->largeBuf = 0; mid_entry->largeBuf = 0;
...@@ -627,9 +627,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -627,9 +627,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
if (task_to_wake) { if (task_to_wake) {
/* Was previous buf put in mpx struct for multi-rsp? */ /* Was previous buf put in mpx struct for multi-rsp? */
if(!isMultiRsp) { if (!isMultiRsp) {
/* smb buffer will be freed by user thread */ /* smb buffer will be freed by user thread */
if(isLargeBuf) { if (isLargeBuf) {
bigbuf = NULL; bigbuf = NULL;
} else } else
smallbuf = NULL; smallbuf = NULL;
...@@ -654,7 +654,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -654,7 +654,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
/* check if we have blocked requests that need to free */ /* check if we have blocked requests that need to free */
/* Note that cifs_max_pending is normally 50, but /* Note that cifs_max_pending is normally 50, but
can be set at module install time to as little as two */ can be set at module install time to as little as two */
if(atomic_read(&server->inFlight) >= cifs_max_pending) if (atomic_read(&server->inFlight) >= cifs_max_pending)
atomic_set(&server->inFlight, cifs_max_pending - 1); atomic_set(&server->inFlight, cifs_max_pending - 1);
/* We do not want to set the max_pending too low or we /* We do not want to set the max_pending too low or we
could end up with the counter going negative */ could end up with the counter going negative */
...@@ -668,7 +668,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -668,7 +668,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
/* give those requests time to exit */ /* give those requests time to exit */
msleep(125); msleep(125);
if(server->ssocket) { if (server->ssocket) {
sock_release(csocket); sock_release(csocket);
server->ssocket = NULL; server->ssocket = NULL;
} }
...@@ -711,7 +711,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -711,7 +711,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
cFYI(1, cFYI(1,
("Clearing Mid 0x%x - waking up ",mid_entry->mid)); ("Clearing Mid 0x%x - waking up ",mid_entry->mid));
task_to_wake = mid_entry->tsk; task_to_wake = mid_entry->tsk;
if(task_to_wake) { if (task_to_wake) {
wake_up_process(task_to_wake); wake_up_process(task_to_wake);
} }
} }
...@@ -753,7 +753,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -753,7 +753,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
write_unlock(&GlobalSMBSeslock); write_unlock(&GlobalSMBSeslock);
kfree(server); kfree(server);
if(length > 0) { if (length > 0) {
mempool_resize(cifs_req_poolp, mempool_resize(cifs_req_poolp,
length + cifs_min_rcv, length + cifs_min_rcv,
GFP_KERNEL); GFP_KERNEL);
...@@ -804,8 +804,8 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -804,8 +804,8 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
if (!options) if (!options)
return 1; return 1;
if(strncmp(options,"sep=",4) == 0) { if (strncmp(options,"sep=",4) == 0) {
if(options[4] != 0) { if (options[4] != 0) {
separator[0] = options[4]; separator[0] = options[4];
options += 5; options += 5;
} else { } else {
...@@ -828,7 +828,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -828,7 +828,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
printk(KERN_WARNING printk(KERN_WARNING
"CIFS: invalid or missing username\n"); "CIFS: invalid or missing username\n");
return 1; /* needs_arg; */ return 1; /* needs_arg; */
} else if(!*value) { } else if (!*value) {
/* null user, ie anonymous, authentication */ /* null user, ie anonymous, authentication */
vol->nullauth = 1; vol->nullauth = 1;
} }
...@@ -842,12 +842,12 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -842,12 +842,12 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
if (!value) { if (!value) {
vol->password = NULL; vol->password = NULL;
continue; continue;
} else if(value[0] == 0) { } else if (value[0] == 0) {
/* check if string begins with double comma /* check if string begins with double comma
since that would mean the password really since that would mean the password really
does start with a comma, and would not does start with a comma, and would not
indicate an empty string */ indicate an empty string */
if(value[1] != separator[0]) { if (value[1] != separator[0]) {
vol->password = NULL; vol->password = NULL;
continue; continue;
} }
...@@ -885,7 +885,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -885,7 +885,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
} }
temp_len++; temp_len++;
} }
if(value[temp_len] == 0) { if (value[temp_len] == 0) {
options = NULL; options = NULL;
} else { } else {
value[temp_len] = 0; value[temp_len] = 0;
...@@ -896,13 +896,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -896,13 +896,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
double commas to singles. Note that this ends up double commas to singles. Note that this ends up
allocating a few bytes too many, which is ok */ allocating a few bytes too many, which is ok */
vol->password = kzalloc(temp_len, GFP_KERNEL); vol->password = kzalloc(temp_len, GFP_KERNEL);
if(vol->password == NULL) { if (vol->password == NULL) {
printk("CIFS: no memory for pass\n"); printk("CIFS: no memory for pass\n");
return 1; return 1;
} }
for(i=0,j=0;i<temp_len;i++,j++) { for(i=0,j=0;i<temp_len;i++,j++) {
vol->password[j] = value[i]; vol->password[j] = value[i];
if(value[i] == separator[0] if (value[i] == separator[0]
&& value[i+1] == separator[0]) { && value[i+1] == separator[0]) {
/* skip second comma */ /* skip second comma */
i++; i++;
...@@ -911,7 +911,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -911,7 +911,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
vol->password[j] = 0; vol->password[j] = 0;
} else { } else {
vol->password = kzalloc(temp_len+1, GFP_KERNEL); vol->password = kzalloc(temp_len+1, GFP_KERNEL);
if(vol->password == NULL) { if (vol->password == NULL) {
printk("CIFS: no memory for pass\n"); printk("CIFS: no memory for pass\n");
return 1; return 1;
} }
...@@ -1089,7 +1089,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1089,7 +1089,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
} }
} else if (strnicmp(data, "netbiosname", 4) == 0) { } else if (strnicmp(data, "netbiosname", 4) == 0) {
if (!value || !*value || (*value == ' ')) { if (!value || !*value || (*value == ' ')) {
cFYI(1,("invalid (empty) netbiosname specified")); cFYI(1, ("invalid (empty) netbiosname specified"));
} else { } else {
memset(vol->source_rfc1001_name,0x20,15); memset(vol->source_rfc1001_name,0x20,15);
for(i=0;i<15;i++) { for(i=0;i<15;i++) {
...@@ -1187,7 +1187,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1187,7 +1187,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
/* turn off mandatory locking in mode /* turn off mandatory locking in mode
if remote locking is turned off since the if remote locking is turned off since the
local vfs will do advisory */ local vfs will do advisory */
if(vol->file_mode == (S_IALLUGO & ~(S_ISUID | S_IXGRP))) if (vol->file_mode == (S_IALLUGO & ~(S_ISUID | S_IXGRP)))
vol->file_mode = S_IALLUGO; vol->file_mode = S_IALLUGO;
} else if (strnicmp(data, "setuids", 7) == 0) { } else if (strnicmp(data, "setuids", 7) == 0) {
vol->setuids = 1; vol->setuids = 1;
...@@ -1257,7 +1257,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1257,7 +1257,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
return 1; return 1;
} }
} }
if(vol->UNCip == NULL) if (vol->UNCip == NULL)
vol->UNCip = &vol->UNC[2]; vol->UNCip = &vol->UNC[2];
return 0; return 0;
...@@ -1276,7 +1276,7 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr, ...@@ -1276,7 +1276,7 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr,
list_for_each(tmp, &GlobalSMBSessionList) { list_for_each(tmp, &GlobalSMBSessionList) {
ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
if (ses->server) { if (ses->server) {
if((target_ip_addr && if ((target_ip_addr &&
(ses->server->addr.sockAddr.sin_addr.s_addr (ses->server->addr.sockAddr.sin_addr.s_addr
== target_ip_addr->s_addr)) || (target_ip6_addr == target_ip_addr->s_addr)) || (target_ip6_addr
&& memcmp(&ses->server->addr.sockAddr6.sin6_addr, && memcmp(&ses->server->addr.sockAddr6.sin6_addr,
...@@ -1319,7 +1319,7 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) ...@@ -1319,7 +1319,7 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName)
/* BB lock tcon, server and tcp session and increment use count here? */ /* BB lock tcon, server and tcp session and increment use count here? */
/* found a match on the TCP session */ /* found a match on the TCP session */
/* BB check if reconnection needed */ /* BB check if reconnection needed */
cFYI(1,("IP match, old UNC: %s new: %s", cFYI(1, ("IP match, old UNC: %s new: %s",
tcon->treeName, uncName)); tcon->treeName, uncName));
if (strncmp if (strncmp
(tcon->treeName, uncName, (tcon->treeName, uncName,
...@@ -1423,7 +1423,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, ...@@ -1423,7 +1423,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
int connected = 0; int connected = 0;
__be16 orig_port = 0; __be16 orig_port = 0;
if(*csocket == NULL) { if (*csocket == NULL) {
rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket);
if (rc < 0) { if (rc < 0) {
cERROR(1, ("Error %d creating socket",rc)); cERROR(1, ("Error %d creating socket",rc));
...@@ -1437,7 +1437,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, ...@@ -1437,7 +1437,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
} }
psin_server->sin_family = AF_INET; psin_server->sin_family = AF_INET;
if(psin_server->sin_port) { /* user overrode default port */ if (psin_server->sin_port) { /* user overrode default port */
rc = (*csocket)->ops->connect(*csocket, rc = (*csocket)->ops->connect(*csocket,
(struct sockaddr *) psin_server, (struct sockaddr *) psin_server,
sizeof (struct sockaddr_in),0); sizeof (struct sockaddr_in),0);
...@@ -1445,13 +1445,13 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, ...@@ -1445,13 +1445,13 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
connected = 1; connected = 1;
} }
if(!connected) { if (!connected) {
/* save original port so we can retry user specified port /* save original port so we can retry user specified port
later if fall back ports fail this time */ later if fall back ports fail this time */
orig_port = psin_server->sin_port; orig_port = psin_server->sin_port;
/* do not retry on the same port we just failed on */ /* do not retry on the same port we just failed on */
if(psin_server->sin_port != htons(CIFS_PORT)) { if (psin_server->sin_port != htons(CIFS_PORT)) {
psin_server->sin_port = htons(CIFS_PORT); psin_server->sin_port = htons(CIFS_PORT);
rc = (*csocket)->ops->connect(*csocket, rc = (*csocket)->ops->connect(*csocket,
...@@ -1472,9 +1472,9 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, ...@@ -1472,9 +1472,9 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
/* give up here - unless we want to retry on different /* give up here - unless we want to retry on different
protocol families some day */ protocol families some day */
if (!connected) { if (!connected) {
if(orig_port) if (orig_port)
psin_server->sin_port = orig_port; psin_server->sin_port = orig_port;
cFYI(1,("Error %d connecting to server via ipv4",rc)); cFYI(1, ("Error %d connecting to server via ipv4",rc));
sock_release(*csocket); sock_release(*csocket);
*csocket = NULL; *csocket = NULL;
return rc; return rc;
...@@ -1482,26 +1482,26 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, ...@@ -1482,26 +1482,26 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
/* Eventually check for other socket options to change from /* Eventually check for other socket options to change from
the default. sock_setsockopt not used because it expects the default. sock_setsockopt not used because it expects
user space buffer */ user space buffer */
cFYI(1,("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sk_sndbuf, cFYI(1, ("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sk_sndbuf,
(*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo));
(*csocket)->sk->sk_rcvtimeo = 7 * HZ; (*csocket)->sk->sk_rcvtimeo = 7 * HZ;
/* make the bufsizes depend on wsize/rsize and max requests */ /* make the bufsizes depend on wsize/rsize and max requests */
if((*csocket)->sk->sk_sndbuf < (200 * 1024)) if ((*csocket)->sk->sk_sndbuf < (200 * 1024))
(*csocket)->sk->sk_sndbuf = 200 * 1024; (*csocket)->sk->sk_sndbuf = 200 * 1024;
if((*csocket)->sk->sk_rcvbuf < (140 * 1024)) if ((*csocket)->sk->sk_rcvbuf < (140 * 1024))
(*csocket)->sk->sk_rcvbuf = 140 * 1024; (*csocket)->sk->sk_rcvbuf = 140 * 1024;
/* send RFC1001 sessinit */ /* send RFC1001 sessinit */
if(psin_server->sin_port == htons(RFC1001_PORT)) { if (psin_server->sin_port == htons(RFC1001_PORT)) {
/* some servers require RFC1001 sessinit before sending /* some servers require RFC1001 sessinit before sending
negprot - BB check reconnection in case where second negprot - BB check reconnection in case where second
sessinit is sent but no second negprot */ sessinit is sent but no second negprot */
struct rfc1002_session_packet * ses_init_buf; struct rfc1002_session_packet * ses_init_buf;
struct smb_hdr * smb_buf; struct smb_hdr * smb_buf;
ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL);
if(ses_init_buf) { if (ses_init_buf) {
ses_init_buf->trailer.session_req.called_len = 32; ses_init_buf->trailer.session_req.called_len = 32;
if(target_name && (target_name[0] != 0)) { if (target_name && (target_name[0] != 0)) {
rfc1002mangle(ses_init_buf->trailer.session_req.called_name, rfc1002mangle(ses_init_buf->trailer.session_req.called_name,
target_name, 16); target_name, 16);
} else { } else {
...@@ -1512,7 +1512,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, ...@@ -1512,7 +1512,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
ses_init_buf->trailer.session_req.calling_len = 32; ses_init_buf->trailer.session_req.calling_len = 32;
/* calling name ends in null (byte 16) from old smb /* calling name ends in null (byte 16) from old smb
convention. */ convention. */
if(netbios_name && (netbios_name[0] !=0)) { if (netbios_name && (netbios_name[0] !=0)) {
rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, rfc1002mangle(ses_init_buf->trailer.session_req.calling_name,
netbios_name,16); netbios_name,16);
} else { } else {
...@@ -1551,7 +1551,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) ...@@ -1551,7 +1551,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
int connected = 0; int connected = 0;
__be16 orig_port = 0; __be16 orig_port = 0;
if(*csocket == NULL) { if (*csocket == NULL) {
rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket);
if (rc < 0) { if (rc < 0) {
cERROR(1, ("Error %d creating ipv6 socket",rc)); cERROR(1, ("Error %d creating ipv6 socket",rc));
...@@ -1559,14 +1559,14 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) ...@@ -1559,14 +1559,14 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
return rc; return rc;
} else { } else {
/* BB other socket options to set KEEPALIVE, NODELAY? */ /* BB other socket options to set KEEPALIVE, NODELAY? */
cFYI(1,("ipv6 Socket created")); cFYI(1, ("ipv6 Socket created"));
(*csocket)->sk->sk_allocation = GFP_NOFS; (*csocket)->sk->sk_allocation = GFP_NOFS;
} }
} }
psin_server->sin6_family = AF_INET6; psin_server->sin6_family = AF_INET6;
if(psin_server->sin6_port) { /* user overrode default port */ if (psin_server->sin6_port) { /* user overrode default port */
rc = (*csocket)->ops->connect(*csocket, rc = (*csocket)->ops->connect(*csocket,
(struct sockaddr *) psin_server, (struct sockaddr *) psin_server,
sizeof (struct sockaddr_in6),0); sizeof (struct sockaddr_in6),0);
...@@ -1574,13 +1574,13 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) ...@@ -1574,13 +1574,13 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
connected = 1; connected = 1;
} }
if(!connected) { if (!connected) {
/* save original port so we can retry user specified port /* save original port so we can retry user specified port
later if fall back ports fail this time */ later if fall back ports fail this time */
orig_port = psin_server->sin6_port; orig_port = psin_server->sin6_port;
/* do not retry on the same port we just failed on */ /* do not retry on the same port we just failed on */
if(psin_server->sin6_port != htons(CIFS_PORT)) { if (psin_server->sin6_port != htons(CIFS_PORT)) {
psin_server->sin6_port = htons(CIFS_PORT); psin_server->sin6_port = htons(CIFS_PORT);
rc = (*csocket)->ops->connect(*csocket, rc = (*csocket)->ops->connect(*csocket,
...@@ -1601,9 +1601,9 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) ...@@ -1601,9 +1601,9 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
/* give up here - unless we want to retry on different /* give up here - unless we want to retry on different
protocol families some day */ protocol families some day */
if (!connected) { if (!connected) {
if(orig_port) if (orig_port)
psin_server->sin6_port = orig_port; psin_server->sin6_port = orig_port;
cFYI(1,("Error %d connecting to server via ipv6",rc)); cFYI(1, ("Error %d connecting to server via ipv6",rc));
sock_release(*csocket); sock_release(*csocket);
*csocket = NULL; *csocket = NULL;
return rc; return rc;
...@@ -1631,12 +1631,12 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, ...@@ -1631,12 +1631,12 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon,
__u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
if(!CIFSSMBQFSUnixInfo(xid, tcon)) { if (!CIFSSMBQFSUnixInfo(xid, tcon)) {
__u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
/* check for reconnect case in which we do not /* check for reconnect case in which we do not
want to change the mount behavior if we can avoid it */ want to change the mount behavior if we can avoid it */
if(vol_info == NULL) { if (vol_info == NULL) {
/* turn off POSIX ACL and PATHNAMES if not set /* turn off POSIX ACL and PATHNAMES if not set
originally at mount time */ originally at mount time */
if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0)
...@@ -1653,15 +1653,15 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, ...@@ -1653,15 +1653,15 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon,
if (vol_info && vol_info->no_psx_acl) if (vol_info && vol_info->no_psx_acl)
cap &= ~CIFS_UNIX_POSIX_ACL_CAP; cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { else if (CIFS_UNIX_POSIX_ACL_CAP & cap) {
cFYI(1,("negotiated posix acl support")); cFYI(1, ("negotiated posix acl support"));
if(sb) if (sb)
sb->s_flags |= MS_POSIXACL; sb->s_flags |= MS_POSIXACL;
} }
if (vol_info && vol_info->posix_paths == 0) if (vol_info && vol_info->posix_paths == 0)
cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
cFYI(1,("negotiate posix pathnames")); cFYI(1, ("negotiate posix pathnames"));
if (sb) if (sb)
CIFS_SB(sb)->mnt_cifs_flags |= CIFS_SB(sb)->mnt_cifs_flags |=
CIFS_MOUNT_POSIX_PATHS; CIFS_MOUNT_POSIX_PATHS;
...@@ -1677,31 +1677,31 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, ...@@ -1677,31 +1677,31 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon,
if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) {
CIFS_SB(sb)->rsize = 127 * 1024; CIFS_SB(sb)->rsize = 127 * 1024;
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("larger reads not supported by srv")); cFYI(1, ("larger reads not supported by srv"));
#endif #endif
} }
} }
cFYI(1,("Negotiate caps 0x%x",(int)cap)); cFYI(1, ("Negotiate caps 0x%x",(int)cap));
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
if (cap & CIFS_UNIX_FCNTL_CAP) if (cap & CIFS_UNIX_FCNTL_CAP)
cFYI(1,("FCNTL cap")); cFYI(1, ("FCNTL cap"));
if (cap & CIFS_UNIX_EXTATTR_CAP) if (cap & CIFS_UNIX_EXTATTR_CAP)
cFYI(1,("EXTATTR cap")); cFYI(1, ("EXTATTR cap"));
if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP)
cFYI(1,("POSIX path cap")); cFYI(1, ("POSIX path cap"));
if (cap & CIFS_UNIX_XATTR_CAP) if (cap & CIFS_UNIX_XATTR_CAP)
cFYI(1,("XATTR cap")); cFYI(1, ("XATTR cap"));
if (cap & CIFS_UNIX_POSIX_ACL_CAP) if (cap & CIFS_UNIX_POSIX_ACL_CAP)
cFYI(1,("POSIX ACL cap")); cFYI(1, ("POSIX ACL cap"));
if (cap & CIFS_UNIX_LARGE_READ_CAP) if (cap & CIFS_UNIX_LARGE_READ_CAP)
cFYI(1,("very large read cap")); cFYI(1, ("very large read cap"));
if (cap & CIFS_UNIX_LARGE_WRITE_CAP) if (cap & CIFS_UNIX_LARGE_WRITE_CAP)
cFYI(1,("very large write cap")); cFYI(1, ("very large write cap"));
#endif /* CIFS_DEBUG2 */ #endif /* CIFS_DEBUG2 */
if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) {
cFYI(1,("setting capabilities failed")); cFYI(1, ("setting capabilities failed"));
} }
} }
} }
...@@ -1736,7 +1736,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1736,7 +1736,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
} }
if (volume_info.nullauth) { if (volume_info.nullauth) {
cFYI(1,("null user")); cFYI(1, ("null user"));
volume_info.username = NULL; volume_info.username = NULL;
} else if (volume_info.username) { } else if (volume_info.username) {
/* BB fixme parse for domain name here */ /* BB fixme parse for domain name here */
...@@ -1755,16 +1755,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1755,16 +1755,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
if (volume_info.UNCip && volume_info.UNC) { if (volume_info.UNCip && volume_info.UNC) {
rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr); rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr);
if(rc <= 0) { if (rc <= 0) {
/* not ipv4 address, try ipv6 */ /* not ipv4 address, try ipv6 */
rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u);
if(rc > 0) if (rc > 0)
address_type = AF_INET6; address_type = AF_INET6;
} else { } else {
address_type = AF_INET; address_type = AF_INET;
} }
if(rc <= 0) { if (rc <= 0) {
/* we failed translating address */ /* we failed translating address */
kfree(volume_info.UNC); kfree(volume_info.UNC);
kfree(volume_info.password); kfree(volume_info.password);
...@@ -1795,12 +1795,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1795,12 +1795,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
} }
/* this is needed for ASCII cp to Unicode converts */ /* this is needed for ASCII cp to Unicode converts */
if(volume_info.iocharset == NULL) { if (volume_info.iocharset == NULL) {
cifs_sb->local_nls = load_nls_default(); cifs_sb->local_nls = load_nls_default();
/* load_nls_default can not return null */ /* load_nls_default can not return null */
} else { } else {
cifs_sb->local_nls = load_nls(volume_info.iocharset); cifs_sb->local_nls = load_nls(volume_info.iocharset);
if(cifs_sb->local_nls == NULL) { if (cifs_sb->local_nls == NULL) {
cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset));
kfree(volume_info.UNC); kfree(volume_info.UNC);
kfree(volume_info.password); kfree(volume_info.password);
...@@ -1810,12 +1810,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1810,12 +1810,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
} }
} }
if(address_type == AF_INET) if (address_type == AF_INET)
existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr,
NULL /* no ipv6 addr */, NULL /* no ipv6 addr */,
volume_info.username, &srvTcp); volume_info.username, &srvTcp);
else if(address_type == AF_INET6) { else if (address_type == AF_INET6) {
cFYI(1,("looking for ipv6 address")); cFYI(1, ("looking for ipv6 address"));
existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */,
&sin_server6.sin6_addr, &sin_server6.sin6_addr,
volume_info.username, &srvTcp); volume_info.username, &srvTcp);
...@@ -1836,7 +1836,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1836,7 +1836,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
else else
sin_server.sin_port = 0; sin_server.sin_port = 0;
if (address_type == AF_INET6) { if (address_type == AF_INET6) {
cFYI(1,("attempting ipv6 connect")); cFYI(1, ("attempting ipv6 connect"));
/* BB should we allow ipv6 on port 139? */ /* BB should we allow ipv6 on port 139? */
/* other OS never observed in Wild doing 139 with v6 */ /* other OS never observed in Wild doing 139 with v6 */
rc = ipv6_connect(&sin_server6,&csocket); rc = ipv6_connect(&sin_server6,&csocket);
...@@ -2091,7 +2091,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2091,7 +2091,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
send_sig call */ send_sig call */
force_sig(SIGKILL,srvTcp->tsk); force_sig(SIGKILL,srvTcp->tsk);
tsk = srvTcp->tsk; tsk = srvTcp->tsk;
if(tsk) if (tsk)
kthread_stop(tsk); kthread_stop(tsk);
} }
} }
...@@ -2133,7 +2133,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2133,7 +2133,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
/* tell server which Unix caps we support */ /* tell server which Unix caps we support */
if (tcon->ses->capabilities & CAP_UNIX) if (tcon->ses->capabilities & CAP_UNIX)
reset_cifs_unix_caps(xid, tcon, sb, &volume_info); reset_cifs_unix_caps(xid, tcon, sb, &volume_info);
else if(cifs_sb->rsize > (1024 * 127)) { else if (cifs_sb->rsize > (1024 * 127)) {
cifs_sb->rsize = 1024 * 127; cifs_sb->rsize = 1024 * 127;
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("no very large read support, rsize 127K")); cFYI(1, ("no very large read support, rsize 127K"));
...@@ -2200,7 +2200,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2200,7 +2200,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
...@@ -2330,10 +2330,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2330,10 +2330,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
/* We look for obvious messed up bcc or strings in response so we do not go off /* We look for obvious messed up bcc or strings in response so we do not go off
the end since (at least) WIN2K and Windows XP have a major bug in not null the end since (at least) WIN2K and Windows XP have a major bug in not null
terminating last Unicode string in response */ terminating last Unicode string in response */
if(ses->serverOS) if (ses->serverOS)
kfree(ses->serverOS); kfree(ses->serverOS);
ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL); ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL);
if(ses->serverOS == NULL) if (ses->serverOS == NULL)
goto sesssetup_nomem; goto sesssetup_nomem;
cifs_strfromUCS_le(ses->serverOS, cifs_strfromUCS_le(ses->serverOS,
(__le16 *)bcc_ptr, len,nls_codepage); (__le16 *)bcc_ptr, len,nls_codepage);
...@@ -2346,14 +2346,14 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2346,14 +2346,14 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
remaining_words-1); remaining_words-1);
kfree(ses->serverNOS); kfree(ses->serverNOS);
ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL);
if(ses->serverNOS == NULL) if (ses->serverNOS == NULL)
goto sesssetup_nomem; goto sesssetup_nomem;
cifs_strfromUCS_le(ses->serverNOS, cifs_strfromUCS_le(ses->serverNOS,
(__le16 *)bcc_ptr,len,nls_codepage); (__le16 *)bcc_ptr,len,nls_codepage);
bcc_ptr += 2 * (len + 1); bcc_ptr += 2 * (len + 1);
ses->serverNOS[2 * len] = 0; ses->serverNOS[2 * len] = 0;
ses->serverNOS[1 + (2 * len)] = 0; ses->serverNOS[1 + (2 * len)] = 0;
if(strncmp(ses->serverNOS, if (strncmp(ses->serverNOS,
"NT LAN Manager 4",16) == 0) { "NT LAN Manager 4",16) == 0) {
cFYI(1, ("NT4 server")); cFYI(1, ("NT4 server"));
ses->flags |= CIFS_SES_NT4; ses->flags |= CIFS_SES_NT4;
...@@ -2362,11 +2362,11 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2362,11 +2362,11 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
if (remaining_words > 0) { if (remaining_words > 0) {
len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
/* last string is not always null terminated (for e.g. for Windows XP & 2000) */ /* last string is not always null terminated (for e.g. for Windows XP & 2000) */
if(ses->serverDomain) if (ses->serverDomain)
kfree(ses->serverDomain); kfree(ses->serverDomain);
ses->serverDomain = ses->serverDomain =
kzalloc(2*(len+1),GFP_KERNEL); kzalloc(2*(len+1),GFP_KERNEL);
if(ses->serverDomain == NULL) if (ses->serverDomain == NULL)
goto sesssetup_nomem; goto sesssetup_nomem;
cifs_strfromUCS_le(ses->serverDomain, cifs_strfromUCS_le(ses->serverDomain,
(__le16 *)bcc_ptr,len,nls_codepage); (__le16 *)bcc_ptr,len,nls_codepage);
...@@ -2375,7 +2375,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2375,7 +2375,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
ses->serverDomain[1+(2*len)] = 0; ses->serverDomain[1+(2*len)] = 0;
} /* else no more room so create dummy domain string */ } /* else no more room so create dummy domain string */
else { else {
if(ses->serverDomain) if (ses->serverDomain)
kfree(ses->serverDomain); kfree(ses->serverDomain);
ses->serverDomain = ses->serverDomain =
kzalloc(2, GFP_KERNEL); kzalloc(2, GFP_KERNEL);
...@@ -2398,7 +2398,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2398,7 +2398,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
<= BCC(smb_buffer_response)) { <= BCC(smb_buffer_response)) {
kfree(ses->serverOS); kfree(ses->serverOS);
ses->serverOS = kzalloc(len + 1,GFP_KERNEL); ses->serverOS = kzalloc(len + 1,GFP_KERNEL);
if(ses->serverOS == NULL) if (ses->serverOS == NULL)
goto sesssetup_nomem; goto sesssetup_nomem;
strncpy(ses->serverOS,bcc_ptr, len); strncpy(ses->serverOS,bcc_ptr, len);
...@@ -2409,7 +2409,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2409,7 +2409,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
len = strnlen(bcc_ptr, 1024); len = strnlen(bcc_ptr, 1024);
kfree(ses->serverNOS); kfree(ses->serverNOS);
ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); ses->serverNOS = kzalloc(len + 1,GFP_KERNEL);
if(ses->serverNOS == NULL) if (ses->serverNOS == NULL)
goto sesssetup_nomem; goto sesssetup_nomem;
strncpy(ses->serverNOS, bcc_ptr, len); strncpy(ses->serverNOS, bcc_ptr, len);
bcc_ptr += len; bcc_ptr += len;
...@@ -2417,10 +2417,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2417,10 +2417,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
bcc_ptr++; bcc_ptr++;
len = strnlen(bcc_ptr, 1024); len = strnlen(bcc_ptr, 1024);
if(ses->serverDomain) if (ses->serverDomain)
kfree(ses->serverDomain); kfree(ses->serverDomain);
ses->serverDomain = kzalloc(len + 1,GFP_KERNEL); ses->serverDomain = kzalloc(len + 1,GFP_KERNEL);
if(ses->serverDomain == NULL) if (ses->serverDomain == NULL)
goto sesssetup_nomem; goto sesssetup_nomem;
strncpy(ses->serverDomain, bcc_ptr, len); strncpy(ses->serverDomain, bcc_ptr, len);
bcc_ptr += len; bcc_ptr += len;
...@@ -2472,7 +2472,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2472,7 +2472,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
__u16 count; __u16 count;
cFYI(1, ("In NTLMSSP sesssetup (negotiate)")); cFYI(1, ("In NTLMSSP sesssetup (negotiate)"));
if(ses == NULL) if (ses == NULL)
return -EINVAL; return -EINVAL;
domain = ses->domainName; domain = ses->domainName;
*pNTLMv2_flag = FALSE; *pNTLMv2_flag = FALSE;
...@@ -2496,7 +2496,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2496,7 +2496,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
...@@ -2524,9 +2524,9 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2524,9 +2524,9 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM |
NTLMSSP_NEGOTIATE_56 | NTLMSSP_NEGOTIATE_56 |
/* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128;
if(sign_CIFS_PDUs) if (sign_CIFS_PDUs)
negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN;
/* if(ntlmv2_support) /* if (ntlmv2_support)
negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/ negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/
/* setup pointers to domain name and workstation name */ /* setup pointers to domain name and workstation name */
bcc_ptr += SecurityBlobLength; bcc_ptr += SecurityBlobLength;
...@@ -2626,11 +2626,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2626,11 +2626,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
memcpy(ses->server->cryptKey, memcpy(ses->server->cryptKey,
SecurityBlob2->Challenge, SecurityBlob2->Challenge,
CIFS_CRYPTO_KEY_SIZE); CIFS_CRYPTO_KEY_SIZE);
if(SecurityBlob2->NegotiateFlags & if (SecurityBlob2->NegotiateFlags &
cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2))
*pNTLMv2_flag = TRUE; *pNTLMv2_flag = TRUE;
if((SecurityBlob2->NegotiateFlags & if ((SecurityBlob2->NegotiateFlags &
cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN))
|| (sign_CIFS_PDUs > 1)) || (sign_CIFS_PDUs > 1))
ses->server->secMode |= ses->server->secMode |=
...@@ -2657,7 +2657,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2657,7 +2657,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
/* We look for obvious messed up bcc or strings in response so we do not go off /* We look for obvious messed up bcc or strings in response so we do not go off
the end since (at least) WIN2K and Windows XP have a major bug in not null the end since (at least) WIN2K and Windows XP have a major bug in not null
terminating last Unicode string in response */ terminating last Unicode string in response */
if(ses->serverOS) if (ses->serverOS)
kfree(ses->serverOS); kfree(ses->serverOS);
ses->serverOS = ses->serverOS =
kzalloc(2 * (len + 1), GFP_KERNEL); kzalloc(2 * (len + 1), GFP_KERNEL);
...@@ -2729,7 +2729,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2729,7 +2729,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
if (((long) bcc_ptr + len) - (long) if (((long) bcc_ptr + len) - (long)
pByteArea(smb_buffer_response) pByteArea(smb_buffer_response)
<= BCC(smb_buffer_response)) { <= BCC(smb_buffer_response)) {
if(ses->serverOS) if (ses->serverOS)
kfree(ses->serverOS); kfree(ses->serverOS);
ses->serverOS = ses->serverOS =
kzalloc(len + 1, kzalloc(len + 1,
...@@ -2806,7 +2806,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2806,7 +2806,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
__u16 count; __u16 count;
cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); cFYI(1, ("In NTLMSSPSessSetup (Authenticate)"));
if(ses == NULL) if (ses == NULL)
return -EINVAL; return -EINVAL;
user = ses->userName; user = ses->userName;
domain = ses->domainName; domain = ses->domainName;
...@@ -2831,7 +2831,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2831,7 +2831,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
pSMB->req.hdr.Uid = ses->Suid; pSMB->req.hdr.Uid = ses->Suid;
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
...@@ -2859,9 +2859,9 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2859,9 +2859,9 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET |
NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO |
0x80000000 | NTLMSSP_NEGOTIATE_128; 0x80000000 | NTLMSSP_NEGOTIATE_128;
if(sign_CIFS_PDUs) if (sign_CIFS_PDUs)
negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN;
if(ntlmv2_flag) if (ntlmv2_flag)
negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2; negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;
/* setup pointers to domain name and workstation name */ /* setup pointers to domain name and workstation name */
...@@ -3018,7 +3018,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3018,7 +3018,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
le16_to_cpu(pSMBr->resp.SecurityBlobLength); le16_to_cpu(pSMBr->resp.SecurityBlobLength);
if (action & GUEST_LOGIN) if (action & GUEST_LOGIN)
cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */
/* if(SecurityBlob2->MessageType != NtLm??){ /* if (SecurityBlob2->MessageType != NtLm??){
cFYI("Unexpected message type on auth response is %d ")); cFYI("Unexpected message type on auth response is %d "));
} */ } */
if (ses) { if (ses) {
...@@ -3057,7 +3057,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3057,7 +3057,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
/* We look for obvious messed up bcc or strings in response so we do not go off /* We look for obvious messed up bcc or strings in response so we do not go off
the end since (at least) WIN2K and Windows XP have a major bug in not null the end since (at least) WIN2K and Windows XP have a major bug in not null
terminating last Unicode string in response */ terminating last Unicode string in response */
if(ses->serverOS) if (ses->serverOS)
kfree(ses->serverOS); kfree(ses->serverOS);
ses->serverOS = ses->serverOS =
kzalloc(2 * (len + 1), GFP_KERNEL); kzalloc(2 * (len + 1), GFP_KERNEL);
...@@ -3091,7 +3091,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3091,7 +3091,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
if (remaining_words > 0) { if (remaining_words > 0) {
len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
/* last string not always null terminated (e.g. for Windows XP & 2000) */ /* last string not always null terminated (e.g. for Windows XP & 2000) */
if(ses->serverDomain) if (ses->serverDomain)
kfree(ses->serverDomain); kfree(ses->serverDomain);
ses->serverDomain = ses->serverDomain =
kzalloc(2 * kzalloc(2 *
...@@ -3119,12 +3119,12 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3119,12 +3119,12 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
= 0; = 0;
} /* else no more room so create dummy domain string */ } /* else no more room so create dummy domain string */
else { else {
if(ses->serverDomain) if (ses->serverDomain)
kfree(ses->serverDomain); kfree(ses->serverDomain);
ses->serverDomain = kzalloc(2,GFP_KERNEL); ses->serverDomain = kzalloc(2,GFP_KERNEL);
} }
} else { /* no room so create dummy domain and NOS string */ } else { /* no room so create dummy domain and NOS string */
if(ses->serverDomain) if (ses->serverDomain)
kfree(ses->serverDomain); kfree(ses->serverDomain);
ses->serverDomain = kzalloc(2, GFP_KERNEL); ses->serverDomain = kzalloc(2, GFP_KERNEL);
kfree(ses->serverNOS); kfree(ses->serverNOS);
...@@ -3135,7 +3135,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3135,7 +3135,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
if (((long) bcc_ptr + len) - if (((long) bcc_ptr + len) -
(long) pByteArea(smb_buffer_response) (long) pByteArea(smb_buffer_response)
<= BCC(smb_buffer_response)) { <= BCC(smb_buffer_response)) {
if(ses->serverOS) if (ses->serverOS)
kfree(ses->serverOS); kfree(ses->serverOS);
ses->serverOS = kzalloc(len + 1,GFP_KERNEL); ses->serverOS = kzalloc(len + 1,GFP_KERNEL);
strncpy(ses->serverOS,bcc_ptr, len); strncpy(ses->serverOS,bcc_ptr, len);
...@@ -3153,7 +3153,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3153,7 +3153,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
bcc_ptr++; bcc_ptr++;
len = strnlen(bcc_ptr, 1024); len = strnlen(bcc_ptr, 1024);
if(ses->serverDomain) if (ses->serverDomain)
kfree(ses->serverDomain); kfree(ses->serverDomain);
ses->serverDomain = kzalloc(len+1,GFP_KERNEL); ses->serverDomain = kzalloc(len+1,GFP_KERNEL);
strncpy(ses->serverDomain, bcc_ptr, len); strncpy(ses->serverDomain, bcc_ptr, len);
...@@ -3219,7 +3219,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3219,7 +3219,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
pSMB->AndXCommand = 0xFF; pSMB->AndXCommand = 0xFF;
pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);
bcc_ptr = &pSMB->Password[0]; bcc_ptr = &pSMB->Password[0];
if((ses->server->secMode) & SECMODE_USER) { if ((ses->server->secMode) & SECMODE_USER) {
pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
*bcc_ptr = 0; /* password is null byte */ *bcc_ptr = 0; /* password is null byte */
bcc_ptr++; /* skip password */ bcc_ptr++; /* skip password */
...@@ -3233,7 +3233,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3233,7 +3233,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
by Samba (not sure whether other servers allow by Samba (not sure whether other servers allow
NTLMv2 password here) */ NTLMv2 password here) */
#ifdef CONFIG_CIFS_WEAK_PW_HASH #ifdef CONFIG_CIFS_WEAK_PW_HASH
if((extended_security & CIFSSEC_MAY_LANMAN) && if ((extended_security & CIFSSEC_MAY_LANMAN) &&
(ses->server->secType == LANMAN)) (ses->server->secType == LANMAN))
calc_lanman_hash(ses, bcc_ptr); calc_lanman_hash(ses, bcc_ptr);
else else
...@@ -3243,14 +3243,14 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3243,14 +3243,14 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
bcc_ptr); bcc_ptr);
bcc_ptr += CIFS_SESS_KEY_SIZE; bcc_ptr += CIFS_SESS_KEY_SIZE;
if(ses->capabilities & CAP_UNICODE) { if (ses->capabilities & CAP_UNICODE) {
/* must align unicode strings */ /* must align unicode strings */
*bcc_ptr = 0; /* null byte password */ *bcc_ptr = 0; /* null byte password */
bcc_ptr++; bcc_ptr++;
} }
} }
if(ses->server->secMode & if (ses->server->secMode &
(SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
...@@ -3321,7 +3321,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3321,7 +3321,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
} }
/* else do not bother copying these informational fields */ /* else do not bother copying these informational fields */
} }
if((smb_buffer_response->WordCount == 3) || if ((smb_buffer_response->WordCount == 3) ||
(smb_buffer_response->WordCount == 7)) (smb_buffer_response->WordCount == 7))
/* field is in same location */ /* field is in same location */
tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport);
...@@ -3401,16 +3401,16 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3401,16 +3401,16 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
int first_time = 0; int first_time = 0;
/* what if server changes its buffer size after dropping the session? */ /* what if server changes its buffer size after dropping the session? */
if(pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { if (pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ {
rc = CIFSSMBNegotiate(xid, pSesInfo); rc = CIFSSMBNegotiate(xid, pSesInfo);
if(rc == -EAGAIN) /* retry only once on 1st time connection */ { if (rc == -EAGAIN) /* retry only once on 1st time connection */ {
rc = CIFSSMBNegotiate(xid, pSesInfo); rc = CIFSSMBNegotiate(xid, pSesInfo);
if(rc == -EAGAIN) if (rc == -EAGAIN)
rc = -EHOSTDOWN; rc = -EHOSTDOWN;
} }
if(rc == 0) { if (rc == 0) {
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if(pSesInfo->server->tcpStatus != CifsExiting) if (pSesInfo->server->tcpStatus != CifsExiting)
pSesInfo->server->tcpStatus = CifsGood; pSesInfo->server->tcpStatus = CifsGood;
else else
rc = -EHOSTDOWN; rc = -EHOSTDOWN;
...@@ -3422,14 +3422,14 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3422,14 +3422,14 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
if (!rc) { if (!rc) {
pSesInfo->flags = 0; pSesInfo->flags = 0;
pSesInfo->capabilities = pSesInfo->server->capabilities; pSesInfo->capabilities = pSesInfo->server->capabilities;
if(linuxExtEnabled == 0) if (linuxExtEnabled == 0)
pSesInfo->capabilities &= (~CAP_UNIX); pSesInfo->capabilities &= (~CAP_UNIX);
/* pSesInfo->sequence_number = 0;*/ /* pSesInfo->sequence_number = 0;*/
cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", cFYI(1, ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d",
pSesInfo->server->secMode, pSesInfo->server->secMode,
pSesInfo->server->capabilities, pSesInfo->server->capabilities,
pSesInfo->server->timeAdj)); pSesInfo->server->timeAdj));
if(experimEnabled < 2) if (experimEnabled < 2)
rc = CIFS_SessSetup(xid, pSesInfo, rc = CIFS_SessSetup(xid, pSesInfo,
first_time, nls_info); first_time, nls_info);
else if (extended_security else if (extended_security
...@@ -3446,18 +3446,18 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3446,18 +3446,18 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
&ntlmv2_flag, &ntlmv2_flag,
nls_info); nls_info);
if (!rc) { if (!rc) {
if(ntlmv2_flag) { if (ntlmv2_flag) {
char * v2_response; char * v2_response;
cFYI(1, ("more secure NTLM ver2 hash")); cFYI(1, ("more secure NTLM ver2 hash"));
if(CalcNTLMv2_partial_mac_key(pSesInfo, if (CalcNTLMv2_partial_mac_key(pSesInfo,
nls_info)) { nls_info)) {
rc = -ENOMEM; rc = -ENOMEM;
goto ss_err_exit; goto ss_err_exit;
} else } else
v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL);
if(v2_response) { if (v2_response) {
CalcNTLMv2_response(pSesInfo,v2_response); CalcNTLMv2_response(pSesInfo,v2_response);
/* if(first_time) /* if (first_time)
cifs_calculate_ntlmv2_mac_key( cifs_calculate_ntlmv2_mac_key(
pSesInfo->server->mac_signing_key, pSesInfo->server->mac_signing_key,
response, ntlm_session_key, */ response, ntlm_session_key, */
...@@ -3473,7 +3473,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3473,7 +3473,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
pSesInfo->server->cryptKey, pSesInfo->server->cryptKey,
ntlm_session_key); ntlm_session_key);
if(first_time) if (first_time)
cifs_calculate_mac_key( cifs_calculate_mac_key(
&pSesInfo->server->mac_signing_key, &pSesInfo->server->mac_signing_key,
ntlm_session_key, ntlm_session_key,
...@@ -3493,7 +3493,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3493,7 +3493,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
pSesInfo->server->cryptKey, pSesInfo->server->cryptKey,
ntlm_session_key); ntlm_session_key);
if(first_time) if (first_time)
cifs_calculate_mac_key( cifs_calculate_mac_key(
&pSesInfo->server->mac_signing_key, &pSesInfo->server->mac_signing_key,
ntlm_session_key, pSesInfo->password); ntlm_session_key, pSesInfo->password);
...@@ -3502,7 +3502,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, ...@@ -3502,7 +3502,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
ntlm_session_key, nls_info); ntlm_session_key, nls_info);
} }
if (rc) { if (rc) {
cERROR(1,("Send error in SessSetup = %d",rc)); cERROR(1, ("Send error in SessSetup = %d", rc));
} else { } else {
cFYI(1, ("CIFS Session Established successfully")); cFYI(1, ("CIFS Session Established successfully"));
pSesInfo->status = CifsGood; pSesInfo->status = CifsGood;
......
...@@ -135,10 +135,10 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -135,10 +135,10 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
char *full_path = NULL; char *full_path = NULL;
FILE_ALL_INFO * buf = NULL; FILE_ALL_INFO *buf = NULL;
struct inode *newinode = NULL; struct inode *newinode = NULL;
struct cifsFileInfo * pCifsFile = NULL; struct cifsFileInfo *pCifsFile = NULL;
struct cifsInodeInfo * pCifsInode; struct cifsInodeInfo *pCifsInode;
int disposition = FILE_OVERWRITE_IF; int disposition = FILE_OVERWRITE_IF;
int write_only = FALSE; int write_only = FALSE;
...@@ -323,7 +323,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, ...@@ -323,7 +323,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
char *full_path = NULL; char *full_path = NULL;
struct inode * newinode = NULL; struct inode *newinode = NULL;
if (!old_valid_dev(device_number)) if (!old_valid_dev(device_number))
return -EINVAL; return -EINVAL;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Author(s): Steve French (sfrench@us.ibm.com) * Author(s): Steve French (sfrench@us.ibm.com)
* *
* Common Internet FileSystem (CIFS) client * Common Internet FileSystem (CIFS) client
* *
* Operations related to support for exporting files via NFSD * Operations related to support for exporting files via NFSD
* *
* This library is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or modify
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* /*
* See Documentation/filesystems/Exporting * See Documentation/filesystems/Exporting
* and examples in fs/exportfs * and examples in fs/exportfs
*/ */
...@@ -34,19 +34,19 @@ ...@@ -34,19 +34,19 @@
static struct dentry *cifs_get_parent(struct dentry *dentry) static struct dentry *cifs_get_parent(struct dentry *dentry)
{ {
/* BB need to add code here eventually to enable export via NFSD */ /* BB need to add code here eventually to enable export via NFSD */
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
} }
struct export_operations cifs_export_ops = { struct export_operations cifs_export_ops = {
.get_parent = cifs_get_parent, .get_parent = cifs_get_parent,
/* Following five export operations are unneeded so far and can default */ /* Following five export operations are unneeded so far and can default:
/* .get_dentry = .get_dentry =
.get_name = .get_name =
.find_exported_dentry = .find_exported_dentry =
.decode_fh = .decode_fh =
.encode_fs = */ .encode_fs = */
}; };
#endif /* EXPERIMENTAL */ #endif /* EXPERIMENTAL */
...@@ -66,7 +66,7 @@ static __u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags) ...@@ -66,7 +66,7 @@ static __u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags)
return cifs_ntfy_flags; return cifs_ntfy_flags;
} }
int cifs_dir_notify(struct file * file, unsigned long arg) int cifs_dir_notify(struct file *file, unsigned long arg)
{ {
int xid; int xid;
int rc = -EINVAL; int rc = -EINVAL;
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* fs/cifs/file.c * fs/cifs/file.c
* *
* vfs operations that deal with files * vfs operations that deal with files
* *
* Copyright (C) International Business Machines Corp., 2002,2003 * Copyright (C) International Business Machines Corp., 2002,2007
* Author(s): Steve French (sfrench@us.ibm.com) * Author(s): Steve French (sfrench@us.ibm.com)
* Jeremy Allison (jra@samba.org) * Jeremy Allison (jra@samba.org)
* *
...@@ -45,7 +45,7 @@ static inline struct cifsFileInfo *cifs_init_private( ...@@ -45,7 +45,7 @@ static inline struct cifsFileInfo *cifs_init_private(
{ {
memset(private_data, 0, sizeof(struct cifsFileInfo)); memset(private_data, 0, sizeof(struct cifsFileInfo));
private_data->netfid = netfid; private_data->netfid = netfid;
private_data->pid = current->tgid; private_data->pid = current->tgid;
init_MUTEX(&private_data->fh_sem); init_MUTEX(&private_data->fh_sem);
mutex_init(&private_data->lock_mutex); mutex_init(&private_data->lock_mutex);
INIT_LIST_HEAD(&private_data->llist); INIT_LIST_HEAD(&private_data->llist);
...@@ -57,7 +57,7 @@ static inline struct cifsFileInfo *cifs_init_private( ...@@ -57,7 +57,7 @@ static inline struct cifsFileInfo *cifs_init_private(
does not tell us which handle the write is for so there can does not tell us which handle the write is for so there can
be a close (overlapping with write) of the filehandle that be a close (overlapping with write) of the filehandle that
cifs_writepages chose to use */ cifs_writepages chose to use */
atomic_set(&private_data->wrtPending,0); atomic_set(&private_data->wrtPending, 0);
return private_data; return private_data;
} }
...@@ -105,7 +105,7 @@ static inline int cifs_open_inode_helper(struct inode *inode, struct file *file, ...@@ -105,7 +105,7 @@ static inline int cifs_open_inode_helper(struct inode *inode, struct file *file,
in the list so we do not have to walk the in the list so we do not have to walk the
list to search for one in prepare_write */ list to search for one in prepare_write */
if ((file->f_flags & O_ACCMODE) == O_WRONLY) { if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
list_add_tail(&pCifsFile->flist, list_add_tail(&pCifsFile->flist,
&pCifsInode->openFileList); &pCifsInode->openFileList);
} else { } else {
list_add(&pCifsFile->flist, list_add(&pCifsFile->flist,
...@@ -218,9 +218,9 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -218,9 +218,9 @@ int cifs_open(struct inode *inode, struct file *file)
/********************************************************************* /*********************************************************************
* open flag mapping table: * open flag mapping table:
* *
* POSIX Flag CIFS Disposition * POSIX Flag CIFS Disposition
* ---------- ---------------- * ---------- ----------------
* O_CREAT FILE_OPEN_IF * O_CREAT FILE_OPEN_IF
* O_CREAT | O_EXCL FILE_CREATE * O_CREAT | O_EXCL FILE_CREATE
* O_CREAT | O_TRUNC FILE_OVERWRITE_IF * O_CREAT | O_TRUNC FILE_OVERWRITE_IF
...@@ -228,12 +228,12 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -228,12 +228,12 @@ int cifs_open(struct inode *inode, struct file *file)
* none of the above FILE_OPEN * none of the above FILE_OPEN
* *
* Note that there is not a direct match between disposition * Note that there is not a direct match between disposition
* FILE_SUPERSEDE (ie create whether or not file exists although * FILE_SUPERSEDE (ie create whether or not file exists although
* O_CREAT | O_TRUNC is similar but truncates the existing * O_CREAT | O_TRUNC is similar but truncates the existing
* file rather than creating a new file as FILE_SUPERSEDE does * file rather than creating a new file as FILE_SUPERSEDE does
* (which uses the attributes / metadata passed in on open call) * (which uses the attributes / metadata passed in on open call)
*? *?
*? O_SYNC is a reasonable match to CIFS writethrough flag *? O_SYNC is a reasonable match to CIFS writethrough flag
*? and the read write flags match reasonably. O_LARGEFILE *? and the read write flags match reasonably. O_LARGEFILE
*? is irrelevant because largefile support is always used *? is irrelevant because largefile support is always used
*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, *? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY,
...@@ -253,8 +253,8 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -253,8 +253,8 @@ int cifs_open(struct inode *inode, struct file *file)
and calling get_inode_info with returned buf (at least helps and calling get_inode_info with returned buf (at least helps
non-Unix server case) */ non-Unix server case) */
/* BB we can not do this if this is the second open of a file /* BB we can not do this if this is the second open of a file
and the first handle has writebehind data, we might be and the first handle has writebehind data, we might be
able to simply do a filemap_fdatawrite/filemap_fdatawait first */ able to simply do a filemap_fdatawrite/filemap_fdatawait first */
buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
if (!buf) { if (!buf) {
...@@ -263,7 +263,7 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -263,7 +263,7 @@ int cifs_open(struct inode *inode, struct file *file)
} }
if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
& CIFS_MOUNT_MAP_SPECIAL_CHR); & CIFS_MOUNT_MAP_SPECIAL_CHR);
...@@ -300,7 +300,7 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -300,7 +300,7 @@ int cifs_open(struct inode *inode, struct file *file)
write_unlock(&GlobalSMBSeslock); write_unlock(&GlobalSMBSeslock);
} }
if (oplock & CIFS_CREATE_ACTION) { if (oplock & CIFS_CREATE_ACTION) {
/* time to set mode which we can not set earlier due to /* time to set mode which we can not set earlier due to
problems creating new read-only files */ problems creating new read-only files */
if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
...@@ -308,7 +308,7 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -308,7 +308,7 @@ int cifs_open(struct inode *inode, struct file *file)
inode->i_mode, inode->i_mode,
(__u64)-1, (__u64)-1, 0 /* dev */, (__u64)-1, (__u64)-1, 0 /* dev */,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
} else { } else {
/* BB implement via Windows security descriptors eg /* BB implement via Windows security descriptors eg
...@@ -345,7 +345,7 @@ static int cifs_reopen_file(struct file *file, int can_flush) ...@@ -345,7 +345,7 @@ static int cifs_reopen_file(struct file *file, int can_flush)
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
struct cifsFileInfo *pCifsFile; struct cifsFileInfo *pCifsFile;
struct cifsInodeInfo *pCifsInode; struct cifsInodeInfo *pCifsInode;
struct inode * inode; struct inode *inode;
char *full_path = NULL; char *full_path = NULL;
int desiredAccess; int desiredAccess;
int disposition = FILE_OPEN; int disposition = FILE_OPEN;
...@@ -372,7 +372,7 @@ static int cifs_reopen_file(struct file *file, int can_flush) ...@@ -372,7 +372,7 @@ static int cifs_reopen_file(struct file *file, int can_flush)
} }
inode = file->f_path.dentry->d_inode; inode = file->f_path.dentry->d_inode;
if(inode == NULL) { if (inode == NULL) {
cERROR(1, ("inode not valid")); cERROR(1, ("inode not valid"));
dump_stack(); dump_stack();
rc = -EBADF; rc = -EBADF;
...@@ -396,7 +396,7 @@ static int cifs_reopen_file(struct file *file, int can_flush) ...@@ -396,7 +396,7 @@ static int cifs_reopen_file(struct file *file, int can_flush)
} }
cFYI(1, ("inode = 0x%p file flags 0x%x for %s", cFYI(1, ("inode = 0x%p file flags 0x%x for %s",
inode, file->f_flags,full_path)); inode, file->f_flags, full_path));
desiredAccess = cifs_convert_flags(file->f_flags); desiredAccess = cifs_convert_flags(file->f_flags);
if (oplockEnabled) if (oplockEnabled)
...@@ -405,14 +405,14 @@ static int cifs_reopen_file(struct file *file, int can_flush) ...@@ -405,14 +405,14 @@ static int cifs_reopen_file(struct file *file, int can_flush)
oplock = FALSE; oplock = FALSE;
/* Can not refresh inode by passing in file_info buf to be returned /* Can not refresh inode by passing in file_info buf to be returned
by SMBOpen and then calling get_inode_info with returned buf by SMBOpen and then calling get_inode_info with returned buf
since file might have write behind data that needs to be flushed since file might have write behind data that needs to be flushed
and server version of file size can be stale. If we knew for sure and server version of file size can be stale. If we knew for sure
that inode was not dirty locally we could do this */ that inode was not dirty locally we could do this */
rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
CREATE_NOT_DIR, &netfid, &oplock, NULL, CREATE_NOT_DIR, &netfid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc) { if (rc) {
up(&pCifsFile->fh_sem); up(&pCifsFile->fh_sem);
...@@ -486,22 +486,22 @@ int cifs_close(struct inode *inode, struct file *file) ...@@ -486,22 +486,22 @@ int cifs_close(struct inode *inode, struct file *file)
already closed */ already closed */
if (pTcon->tidStatus != CifsNeedReconnect) { if (pTcon->tidStatus != CifsNeedReconnect) {
int timeout = 2; int timeout = 2;
while((atomic_read(&pSMBFile->wrtPending) != 0) while ((atomic_read(&pSMBFile->wrtPending) != 0)
&& (timeout < 1000) ) { && (timeout < 1000) ) {
/* Give write a better chance to get to /* Give write a better chance to get to
server ahead of the close. We do not server ahead of the close. We do not
want to add a wait_q here as it would want to add a wait_q here as it would
increase the memory utilization as increase the memory utilization as
the struct would be in each open file, the struct would be in each open file,
but this should give enough time to but this should give enough time to
clear the socket */ clear the socket */
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("close delay, write pending")); cFYI(1, ("close delay, write pending"));
#endif /* DEBUG2 */ #endif /* DEBUG2 */
msleep(timeout); msleep(timeout);
timeout *= 4; timeout *= 4;
} }
if(atomic_read(&pSMBFile->wrtPending)) if (atomic_read(&pSMBFile->wrtPending))
cERROR(1,("close with pending writes")); cERROR(1,("close with pending writes"));
rc = CIFSSMBClose(xid, pTcon, rc = CIFSSMBClose(xid, pTcon,
pSMBFile->netfid); pSMBFile->netfid);
...@@ -534,7 +534,7 @@ int cifs_close(struct inode *inode, struct file *file) ...@@ -534,7 +534,7 @@ int cifs_close(struct inode *inode, struct file *file)
CIFS_I(inode)->clientCanCacheRead = FALSE; CIFS_I(inode)->clientCanCacheRead = FALSE;
CIFS_I(inode)->clientCanCacheAll = FALSE; CIFS_I(inode)->clientCanCacheAll = FALSE;
} }
if ((rc ==0) && CIFS_I(inode)->write_behind_rc) if ((rc == 0) && CIFS_I(inode)->write_behind_rc)
rc = CIFS_I(inode)->write_behind_rc; rc = CIFS_I(inode)->write_behind_rc;
FreeXid(xid); FreeXid(xid);
return rc; return rc;
...@@ -554,7 +554,8 @@ int cifs_closedir(struct inode *inode, struct file *file) ...@@ -554,7 +554,8 @@ int cifs_closedir(struct inode *inode, struct file *file)
if (pCFileStruct) { if (pCFileStruct) {
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); struct cifs_sb_info *cifs_sb =
CIFS_SB(file->f_path.dentry->d_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
...@@ -572,7 +573,7 @@ int cifs_closedir(struct inode *inode, struct file *file) ...@@ -572,7 +573,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
if (ptmp) { if (ptmp) {
cFYI(1, ("closedir free smb buf in srch struct")); cFYI(1, ("closedir free smb buf in srch struct"));
pCFileStruct->srch_inf.ntwrk_buf_start = NULL; pCFileStruct->srch_inf.ntwrk_buf_start = NULL;
if(pCFileStruct->srch_inf.smallBuf) if (pCFileStruct->srch_inf.smallBuf)
cifs_small_buf_release(ptmp); cifs_small_buf_release(ptmp);
else else
cifs_buf_release(ptmp); cifs_buf_release(ptmp);
...@@ -594,7 +595,8 @@ int cifs_closedir(struct inode *inode, struct file *file) ...@@ -594,7 +595,8 @@ int cifs_closedir(struct inode *inode, struct file *file)
static int store_file_lock(struct cifsFileInfo *fid, __u64 len, static int store_file_lock(struct cifsFileInfo *fid, __u64 len,
__u64 offset, __u8 lockType) __u64 offset, __u8 lockType)
{ {
struct cifsLockInfo *li = kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL); struct cifsLockInfo *li =
kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL);
if (li == NULL) if (li == NULL)
return -ENOMEM; return -ENOMEM;
li->offset = offset; li->offset = offset;
...@@ -625,8 +627,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -625,8 +627,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
cFYI(1, ("Lock parm: 0x%x flockflags: " cFYI(1, ("Lock parm: 0x%x flockflags: "
"0x%x flocktype: 0x%x start: %lld end: %lld", "0x%x flocktype: 0x%x start: %lld end: %lld",
cmd, pfLock->fl_flags, pfLock->fl_type, pfLock->fl_start, cmd, pfLock->fl_flags, pfLock->fl_type, pfLock->fl_start,
pfLock->fl_end)); pfLock->fl_end));
if (pfLock->fl_flags & FL_POSIX) if (pfLock->fl_flags & FL_POSIX)
cFYI(1, ("Posix")); cFYI(1, ("Posix"));
...@@ -641,7 +643,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -641,7 +643,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
"not implemented yet")); "not implemented yet"));
if (pfLock->fl_flags & FL_LEASE) if (pfLock->fl_flags & FL_LEASE)
cFYI(1, ("Lease on file - not implemented yet")); cFYI(1, ("Lease on file - not implemented yet"));
if (pfLock->fl_flags & if (pfLock->fl_flags &
(~(FL_POSIX | FL_FLOCK | FL_SLEEP | FL_ACCESS | FL_LEASE))) (~(FL_POSIX | FL_FLOCK | FL_SLEEP | FL_ACCESS | FL_LEASE)))
cFYI(1, ("Unknown lock flags 0x%x", pfLock->fl_flags)); cFYI(1, ("Unknown lock flags 0x%x", pfLock->fl_flags));
...@@ -683,9 +685,9 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -683,9 +685,9 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
account for negative length which we can not accept over the account for negative length which we can not accept over the
wire */ wire */
if (IS_GETLK(cmd)) { if (IS_GETLK(cmd)) {
if(posix_locking) { if (posix_locking) {
int posix_lock_type; int posix_lock_type;
if(lockType & LOCKING_ANDX_SHARED_LOCK) if (lockType & LOCKING_ANDX_SHARED_LOCK)
posix_lock_type = CIFS_RDLCK; posix_lock_type = CIFS_RDLCK;
else else
posix_lock_type = CIFS_WRLCK; posix_lock_type = CIFS_WRLCK;
...@@ -700,7 +702,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -700,7 +702,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start, rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start,
0, 1, lockType, 0 /* wait flag */ ); 0, 1, lockType, 0 /* wait flag */ );
if (rc == 0) { if (rc == 0) {
rc = CIFSSMBLock(xid, pTcon, netfid, length, rc = CIFSSMBLock(xid, pTcon, netfid, length,
pfLock->fl_start, 1 /* numUnlock */ , pfLock->fl_start, 1 /* numUnlock */ ,
0 /* numLock */ , lockType, 0 /* numLock */ , lockType,
0 /* wait flag */ ); 0 /* wait flag */ );
...@@ -729,22 +731,24 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -729,22 +731,24 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
if (posix_locking) { if (posix_locking) {
int posix_lock_type; int posix_lock_type;
if(lockType & LOCKING_ANDX_SHARED_LOCK) if (lockType & LOCKING_ANDX_SHARED_LOCK)
posix_lock_type = CIFS_RDLCK; posix_lock_type = CIFS_RDLCK;
else else
posix_lock_type = CIFS_WRLCK; posix_lock_type = CIFS_WRLCK;
if(numUnlock == 1) if (numUnlock == 1)
posix_lock_type = CIFS_UNLCK; posix_lock_type = CIFS_UNLCK;
rc = CIFSSMBPosixLock(xid, pTcon, netfid, 0 /* set */, rc = CIFSSMBPosixLock(xid, pTcon, netfid, 0 /* set */,
length, pfLock, length, pfLock,
posix_lock_type, wait_flag); posix_lock_type, wait_flag);
} else { } else {
struct cifsFileInfo *fid = (struct cifsFileInfo *)file->private_data; struct cifsFileInfo *fid =
(struct cifsFileInfo *)file->private_data;
if (numLock) { if (numLock) {
rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start, rc = CIFSSMBLock(xid, pTcon, netfid, length,
pfLock->fl_start,
0, numLock, lockType, wait_flag); 0, numLock, lockType, wait_flag);
if (rc == 0) { if (rc == 0) {
...@@ -763,7 +767,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -763,7 +767,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
list_for_each_entry_safe(li, tmp, &fid->llist, llist) { list_for_each_entry_safe(li, tmp, &fid->llist, llist) {
if (pfLock->fl_start <= li->offset && if (pfLock->fl_start <= li->offset &&
length >= li->length) { length >= li->length) {
stored_rc = CIFSSMBLock(xid, pTcon, netfid, stored_rc = CIFSSMBLock(xid, pTcon,
netfid,
li->length, li->offset, li->length, li->offset,
1, 0, li->type, FALSE); 1, 0, li->type, FALSE);
if (stored_rc) if (stored_rc)
...@@ -824,7 +829,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -824,7 +829,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
and blocked, and the file has been freed on us while and blocked, and the file has been freed on us while
we blocked so return what we managed to write */ we blocked so return what we managed to write */
return total_written; return total_written;
} }
if (open_file->closePend) { if (open_file->closePend) {
FreeXid(xid); FreeXid(xid);
if (total_written) if (total_written)
...@@ -867,8 +872,8 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -867,8 +872,8 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
/* since the write may have blocked check these pointers again */ /* since the write may have blocked check these pointers again */
if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) { if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
/* Do not update local mtime - server will set its actual value on write /* Do not update local mtime - server will set its actual value on write
* inode->i_ctime = inode->i_mtime = * inode->i_ctime = inode->i_mtime =
* current_fs_time(inode->i_sb);*/ * current_fs_time(inode->i_sb);*/
if (total_written > 0) { if (total_written > 0) {
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
...@@ -877,7 +882,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -877,7 +882,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
*poffset); *poffset);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
} }
mark_inode_dirty_sync(file->f_path.dentry->d_inode); mark_inode_dirty_sync(file->f_path.dentry->d_inode);
} }
FreeXid(xid); FreeXid(xid);
return total_written; return total_written;
...@@ -898,7 +903,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -898,7 +903,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
cFYI(1,("write %zd bytes to offset %lld of %s", write_size, cFYI(1, ("write %zd bytes to offset %lld of %s", write_size,
*poffset, file->f_path.dentry->d_name.name)); *poffset, file->f_path.dentry->d_name.name));
if (file->private_data == NULL) if (file->private_data == NULL)
...@@ -921,10 +926,10 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -921,10 +926,10 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
FreeXid(xid); FreeXid(xid);
/* if we have gotten here we have written some data /* if we have gotten here we have written some data
and blocked, and the file has been freed on us and blocked, and the file has been freed on us
while we blocked so return what we managed to while we blocked so return what we managed to
write */ write */
return total_written; return total_written;
} }
if (open_file->closePend) { if (open_file->closePend) {
FreeXid(xid); FreeXid(xid);
if (total_written) if (total_written)
...@@ -935,14 +940,14 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -935,14 +940,14 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
if (open_file->invalidHandle) { if (open_file->invalidHandle) {
/* we could deadlock if we called /* we could deadlock if we called
filemap_fdatawait from here so tell filemap_fdatawait from here so tell
reopen_file not to flush data to reopen_file not to flush data to
server now */ server now */
rc = cifs_reopen_file(file, FALSE); rc = cifs_reopen_file(file, FALSE);
if (rc != 0) if (rc != 0)
break; break;
} }
if(experimEnabled || (pTcon->ses->server && if (experimEnabled || (pTcon->ses->server &&
((pTcon->ses->server->secMode & ((pTcon->ses->server->secMode &
(SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
== 0))) { == 0))) {
struct kvec iov[2]; struct kvec iov[2];
...@@ -976,7 +981,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -976,7 +981,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
} }
} else } else
*poffset += bytes_written; *poffset += bytes_written;
long_op = FALSE; /* subsequent writes fast - long_op = FALSE; /* subsequent writes fast -
15 seconds is plenty */ 15 seconds is plenty */
} }
...@@ -1009,8 +1014,8 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) ...@@ -1009,8 +1014,8 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)
the VFS or MM) should not happen but we had reports of on oops (due to the VFS or MM) should not happen but we had reports of on oops (due to
it being zero) during stress testcases so we need to check for it */ it being zero) during stress testcases so we need to check for it */
if(cifs_inode == NULL) { if (cifs_inode == NULL) {
cERROR(1,("Null inode passed to cifs_writeable_file")); cERROR(1, ("Null inode passed to cifs_writeable_file"));
dump_stack(); dump_stack();
return NULL; return NULL;
} }
...@@ -1024,13 +1029,13 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) ...@@ -1024,13 +1029,13 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)
(open_file->pfile->f_flags & O_WRONLY))) { (open_file->pfile->f_flags & O_WRONLY))) {
atomic_inc(&open_file->wrtPending); atomic_inc(&open_file->wrtPending);
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
if((open_file->invalidHandle) && if ((open_file->invalidHandle) &&
(!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) { (!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) {
rc = cifs_reopen_file(open_file->pfile, FALSE); rc = cifs_reopen_file(open_file->pfile, FALSE);
/* if it fails, try another handle - might be */ /* if it fails, try another handle - might be */
/* dangerous to hold up writepages with retry */ /* dangerous to hold up writepages with retry */
if(rc) { if (rc) {
cFYI(1,("failed on reopen file in wp")); cFYI(1, ("failed on reopen file in wp"));
read_lock(&GlobalSMBSeslock); read_lock(&GlobalSMBSeslock);
/* can not use this handle, no write /* can not use this handle, no write
pending on this one after all */ pending on this one after all */
...@@ -1082,7 +1087,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to) ...@@ -1082,7 +1087,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
/* check to make sure that we are not extending the file */ /* check to make sure that we are not extending the file */
if (mapping->host->i_size - offset < (loff_t)to) if (mapping->host->i_size - offset < (loff_t)to)
to = (unsigned)(mapping->host->i_size - offset); to = (unsigned)(mapping->host->i_size - offset);
open_file = find_writable_file(CIFS_I(mapping->host)); open_file = find_writable_file(CIFS_I(mapping->host));
if (open_file) { if (open_file) {
...@@ -1116,8 +1121,8 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -1116,8 +1121,8 @@ static int cifs_writepages(struct address_space *mapping,
int done = 0; int done = 0;
pgoff_t end; pgoff_t end;
pgoff_t index; pgoff_t index;
int range_whole = 0; int range_whole = 0;
struct kvec * iov; struct kvec *iov;
int len; int len;
int n_iov = 0; int n_iov = 0;
pgoff_t next; pgoff_t next;
...@@ -1139,14 +1144,14 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -1139,14 +1144,14 @@ static int cifs_writepages(struct address_space *mapping,
if (cifs_sb->wsize < PAGE_CACHE_SIZE) if (cifs_sb->wsize < PAGE_CACHE_SIZE)
return generic_writepages(mapping, wbc); return generic_writepages(mapping, wbc);
if((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->server)) if ((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->server))
if(cifs_sb->tcon->ses->server->secMode & if (cifs_sb->tcon->ses->server->secMode &
(SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
if(!experimEnabled) if (!experimEnabled)
return generic_writepages(mapping, wbc); return generic_writepages(mapping, wbc);
iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL); iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL);
if(iov == NULL) if (iov == NULL)
return generic_writepages(mapping, wbc); return generic_writepages(mapping, wbc);
...@@ -1295,8 +1300,8 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -1295,8 +1300,8 @@ static int cifs_writepages(struct address_space *mapping,
success rc but too little data written? */ success rc but too little data written? */
/* BB investigate retry logic on temporary /* BB investigate retry logic on temporary
server crash cases and how recovery works server crash cases and how recovery works
when page marked as error */ when page marked as error */
if(rc) if (rc)
SetPageError(page); SetPageError(page);
kunmap(page); kunmap(page);
unlock_page(page); unlock_page(page);
...@@ -1326,7 +1331,7 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -1326,7 +1331,7 @@ static int cifs_writepages(struct address_space *mapping,
return rc; return rc;
} }
static int cifs_writepage(struct page* page, struct writeback_control *wbc) static int cifs_writepage(struct page *page, struct writeback_control *wbc)
{ {
int rc = -EFAULT; int rc = -EFAULT;
int xid; int xid;
...@@ -1334,7 +1339,7 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc) ...@@ -1334,7 +1339,7 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc)
xid = GetXid(); xid = GetXid();
/* BB add check for wbc flags */ /* BB add check for wbc flags */
page_cache_get(page); page_cache_get(page);
if (!PageUptodate(page)) { if (!PageUptodate(page)) {
cFYI(1, ("ppw - page not up to date")); cFYI(1, ("ppw - page not up to date"));
} }
...@@ -1348,7 +1353,7 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc) ...@@ -1348,7 +1353,7 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc)
* Just unlocking the page will cause the radix tree tag-bits * Just unlocking the page will cause the radix tree tag-bits
* to fail to update with the state of the page correctly. * to fail to update with the state of the page correctly.
*/ */
set_page_writeback(page); set_page_writeback(page);
rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE); rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE);
SetPageUptodate(page); /* BB add check for error and Clearuptodate? */ SetPageUptodate(page); /* BB add check for error and Clearuptodate? */
unlock_page(page); unlock_page(page);
...@@ -1368,7 +1373,7 @@ static int cifs_commit_write(struct file *file, struct page *page, ...@@ -1368,7 +1373,7 @@ static int cifs_commit_write(struct file *file, struct page *page,
char *page_data; char *page_data;
xid = GetXid(); xid = GetXid();
cFYI(1, ("commit write for page %p up to position %lld for %d", cFYI(1, ("commit write for page %p up to position %lld for %d",
page, position, to)); page, position, to));
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
if (position > inode->i_size) { if (position > inode->i_size) {
...@@ -1396,7 +1401,7 @@ static int cifs_commit_write(struct file *file, struct page *page, ...@@ -1396,7 +1401,7 @@ static int cifs_commit_write(struct file *file, struct page *page,
rc = 0; rc = 0;
/* else if (rc < 0) should we set writebehind rc? */ /* else if (rc < 0) should we set writebehind rc? */
kunmap(page); kunmap(page);
} else { } else {
set_page_dirty(page); set_page_dirty(page);
} }
...@@ -1412,7 +1417,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync) ...@@ -1412,7 +1417,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
xid = GetXid(); xid = GetXid();
cFYI(1, ("Sync file - name: %s datasync: 0x%x", cFYI(1, ("Sync file - name: %s datasync: 0x%x",
dentry->d_name.name, datasync)); dentry->d_name.name, datasync));
rc = filemap_fdatawrite(inode->i_mapping); rc = filemap_fdatawrite(inode->i_mapping);
...@@ -1438,7 +1443,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync) ...@@ -1438,7 +1443,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
if (!inode) if (!inode)
return; */ return; */
/* fill in rpages then /* fill in rpages then
result = cifs_pagein_inode(inode, index, rpages); */ /* BB finish */ result = cifs_pagein_inode(inode, index, rpages); */ /* BB finish */
/* cFYI(1, ("rpages is %d for sync page of Index %ld", rpages, index)); /* cFYI(1, ("rpages is %d for sync page of Index %ld", rpages, index));
...@@ -1456,7 +1461,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync) ...@@ -1456,7 +1461,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync)
*/ */
int cifs_flush(struct file *file, fl_owner_t id) int cifs_flush(struct file *file, fl_owner_t id)
{ {
struct inode * inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
int rc = 0; int rc = 0;
/* Rather than do the steps manually: /* Rather than do the steps manually:
...@@ -1472,7 +1477,7 @@ int cifs_flush(struct file *file, fl_owner_t id) ...@@ -1472,7 +1477,7 @@ int cifs_flush(struct file *file, fl_owner_t id)
if (!rc) /* reset wb rc if we were able to write out dirty pages */ if (!rc) /* reset wb rc if we were able to write out dirty pages */
CIFS_I(inode)->write_behind_rc = 0; CIFS_I(inode)->write_behind_rc = 0;
cFYI(1, ("Flush inode %p file %p rc %d",inode,file,rc)); cFYI(1, ("Flush inode %p file %p rc %d", inode, file, rc));
return rc; return rc;
} }
...@@ -1508,13 +1513,13 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1508,13 +1513,13 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
for (total_read = 0, current_offset = read_data; for (total_read = 0, current_offset = read_data;
read_size > total_read; read_size > total_read;
total_read += bytes_read, current_offset += bytes_read) { total_read += bytes_read, current_offset += bytes_read) {
current_read_size = min_t(const int, read_size - total_read, current_read_size = min_t(const int, read_size - total_read,
cifs_sb->rsize); cifs_sb->rsize);
rc = -EAGAIN; rc = -EAGAIN;
smb_read_data = NULL; smb_read_data = NULL;
while (rc == -EAGAIN) { while (rc == -EAGAIN) {
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
if ((open_file->invalidHandle) && if ((open_file->invalidHandle) &&
(!open_file->closePend)) { (!open_file->closePend)) {
rc = cifs_reopen_file(file, TRUE); rc = cifs_reopen_file(file, TRUE);
if (rc != 0) if (rc != 0)
...@@ -1535,9 +1540,9 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1535,9 +1540,9 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
rc = -EFAULT; rc = -EFAULT;
} }
if(buf_type == CIFS_SMALL_BUFFER) if (buf_type == CIFS_SMALL_BUFFER)
cifs_small_buf_release(smb_read_data); cifs_small_buf_release(smb_read_data);
else if(buf_type == CIFS_LARGE_BUFFER) else if (buf_type == CIFS_LARGE_BUFFER)
cifs_buf_release(smb_read_data); cifs_buf_release(smb_read_data);
smb_read_data = NULL; smb_read_data = NULL;
} }
...@@ -1586,21 +1591,21 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1586,21 +1591,21 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
if ((file->f_flags & O_ACCMODE) == O_WRONLY) if ((file->f_flags & O_ACCMODE) == O_WRONLY)
cFYI(1, ("attempting read on write only file instance")); cFYI(1, ("attempting read on write only file instance"));
for (total_read = 0, current_offset = read_data; for (total_read = 0, current_offset = read_data;
read_size > total_read; read_size > total_read;
total_read += bytes_read, current_offset += bytes_read) { total_read += bytes_read, current_offset += bytes_read) {
current_read_size = min_t(const int, read_size - total_read, current_read_size = min_t(const int, read_size - total_read,
cifs_sb->rsize); cifs_sb->rsize);
/* For windows me and 9x we do not want to request more /* For windows me and 9x we do not want to request more
than it negotiated since it will refuse the read then */ than it negotiated since it will refuse the read then */
if((pTcon->ses) && if ((pTcon->ses) &&
!(pTcon->ses->capabilities & CAP_LARGE_FILES)) { !(pTcon->ses->capabilities & CAP_LARGE_FILES)) {
current_read_size = min_t(const int, current_read_size, current_read_size = min_t(const int, current_read_size,
pTcon->ses->server->maxBuf - 128); pTcon->ses->server->maxBuf - 128);
} }
rc = -EAGAIN; rc = -EAGAIN;
while (rc == -EAGAIN) { while (rc == -EAGAIN) {
if ((open_file->invalidHandle) && if ((open_file->invalidHandle) &&
(!open_file->closePend)) { (!open_file->closePend)) {
rc = cifs_reopen_file(file, TRUE); rc = cifs_reopen_file(file, TRUE);
if (rc != 0) if (rc != 0)
...@@ -1646,7 +1651,7 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1646,7 +1651,7 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
} }
static void cifs_copy_cache_pages(struct address_space *mapping, static void cifs_copy_cache_pages(struct address_space *mapping,
struct list_head *pages, int bytes_read, char *data, struct list_head *pages, int bytes_read, char *data,
struct pagevec *plru_pvec) struct pagevec *plru_pvec)
{ {
...@@ -1669,12 +1674,12 @@ static void cifs_copy_cache_pages(struct address_space *mapping, ...@@ -1669,12 +1674,12 @@ static void cifs_copy_cache_pages(struct address_space *mapping,
continue; continue;
} }
target = kmap_atomic(page,KM_USER0); target = kmap_atomic(page, KM_USER0);
if (PAGE_CACHE_SIZE > bytes_read) { if (PAGE_CACHE_SIZE > bytes_read) {
memcpy(target, data, bytes_read); memcpy(target, data, bytes_read);
/* zero the tail end of this partial page */ /* zero the tail end of this partial page */
memset(target + bytes_read, 0, memset(target + bytes_read, 0,
PAGE_CACHE_SIZE - bytes_read); PAGE_CACHE_SIZE - bytes_read);
bytes_read = 0; bytes_read = 0;
} else { } else {
...@@ -1703,7 +1708,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1703,7 +1708,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
int bytes_read = 0; int bytes_read = 0;
unsigned int read_size,i; unsigned int read_size, i;
char *smb_read_data = NULL; char *smb_read_data = NULL;
struct smb_com_read_rsp *pSMBr; struct smb_com_read_rsp *pSMBr;
struct pagevec lru_pvec; struct pagevec lru_pvec;
...@@ -1721,8 +1726,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1721,8 +1726,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
pagevec_init(&lru_pvec, 0); pagevec_init(&lru_pvec, 0);
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("rpages: num pages %d", num_pages)); cFYI(1, ("rpages: num pages %d", num_pages));
#endif #endif
for (i = 0; i < num_pages; ) { for (i = 0; i < num_pages; ) {
unsigned contig_pages; unsigned contig_pages;
struct page *tmp_page; struct page *tmp_page;
...@@ -1736,14 +1741,14 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1736,14 +1741,14 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
/* count adjacent pages that we will read into */ /* count adjacent pages that we will read into */
contig_pages = 0; contig_pages = 0;
expected_index = expected_index =
list_entry(page_list->prev, struct page, lru)->index; list_entry(page_list->prev, struct page, lru)->index;
list_for_each_entry_reverse(tmp_page,page_list,lru) { list_for_each_entry_reverse(tmp_page, page_list, lru) {
if (tmp_page->index == expected_index) { if (tmp_page->index == expected_index) {
contig_pages++; contig_pages++;
expected_index++; expected_index++;
} else } else
break; break;
} }
if (contig_pages + i > num_pages) if (contig_pages + i > num_pages)
contig_pages = num_pages - i; contig_pages = num_pages - i;
...@@ -1756,12 +1761,12 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1756,12 +1761,12 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
read_size = min_t(const unsigned int, read_size, read_size = min_t(const unsigned int, read_size,
cifs_sb->rsize & PAGE_CACHE_MASK); cifs_sb->rsize & PAGE_CACHE_MASK);
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("rpages: read size 0x%x contiguous pages %d", cFYI(1, ("rpages: read size 0x%x contiguous pages %d",
read_size, contig_pages)); read_size, contig_pages));
#endif #endif
rc = -EAGAIN; rc = -EAGAIN;
while (rc == -EAGAIN) { while (rc == -EAGAIN) {
if ((open_file->invalidHandle) && if ((open_file->invalidHandle) &&
(!open_file->closePend)) { (!open_file->closePend)) {
rc = cifs_reopen_file(file, TRUE); rc = cifs_reopen_file(file, TRUE);
if (rc != 0) if (rc != 0)
...@@ -1774,11 +1779,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1774,11 +1779,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
&bytes_read, &smb_read_data, &bytes_read, &smb_read_data,
&buf_type); &buf_type);
/* BB more RC checks ? */ /* BB more RC checks ? */
if (rc== -EAGAIN) { if (rc == -EAGAIN) {
if (smb_read_data) { if (smb_read_data) {
if(buf_type == CIFS_SMALL_BUFFER) if (buf_type == CIFS_SMALL_BUFFER)
cifs_small_buf_release(smb_read_data); cifs_small_buf_release(smb_read_data);
else if(buf_type == CIFS_LARGE_BUFFER) else if (buf_type == CIFS_LARGE_BUFFER)
cifs_buf_release(smb_read_data); cifs_buf_release(smb_read_data);
smb_read_data = NULL; smb_read_data = NULL;
} }
...@@ -1799,10 +1804,10 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1799,10 +1804,10 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) { if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) {
i++; /* account for partial page */ i++; /* account for partial page */
/* server copy of file can have smaller size /* server copy of file can have smaller size
than client */ than client */
/* BB do we need to verify this common case ? /* BB do we need to verify this common case ?
this case is ok - if we are at server EOF this case is ok - if we are at server EOF
we will hit it on next read */ we will hit it on next read */
/* break; */ /* break; */
...@@ -1811,14 +1816,14 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1811,14 +1816,14 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
cFYI(1, ("No bytes read (%d) at offset %lld . " cFYI(1, ("No bytes read (%d) at offset %lld . "
"Cleaning remaining pages from readahead list", "Cleaning remaining pages from readahead list",
bytes_read, offset)); bytes_read, offset));
/* BB turn off caching and do new lookup on /* BB turn off caching and do new lookup on
file size at server? */ file size at server? */
break; break;
} }
if (smb_read_data) { if (smb_read_data) {
if(buf_type == CIFS_SMALL_BUFFER) if (buf_type == CIFS_SMALL_BUFFER)
cifs_small_buf_release(smb_read_data); cifs_small_buf_release(smb_read_data);
else if(buf_type == CIFS_LARGE_BUFFER) else if (buf_type == CIFS_LARGE_BUFFER)
cifs_buf_release(smb_read_data); cifs_buf_release(smb_read_data);
smb_read_data = NULL; smb_read_data = NULL;
} }
...@@ -1829,12 +1834,12 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1829,12 +1834,12 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
/* need to free smb_read_data buf before exit */ /* need to free smb_read_data buf before exit */
if (smb_read_data) { if (smb_read_data) {
if(buf_type == CIFS_SMALL_BUFFER) if (buf_type == CIFS_SMALL_BUFFER)
cifs_small_buf_release(smb_read_data); cifs_small_buf_release(smb_read_data);
else if(buf_type == CIFS_LARGE_BUFFER) else if (buf_type == CIFS_LARGE_BUFFER)
cifs_buf_release(smb_read_data); cifs_buf_release(smb_read_data);
smb_read_data = NULL; smb_read_data = NULL;
} }
FreeXid(xid); FreeXid(xid);
return rc; return rc;
...@@ -1849,26 +1854,26 @@ static int cifs_readpage_worker(struct file *file, struct page *page, ...@@ -1849,26 +1854,26 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
page_cache_get(page); page_cache_get(page);
read_data = kmap(page); read_data = kmap(page);
/* for reads over a certain size could initiate async read ahead */ /* for reads over a certain size could initiate async read ahead */
rc = cifs_read(file, read_data, PAGE_CACHE_SIZE, poffset); rc = cifs_read(file, read_data, PAGE_CACHE_SIZE, poffset);
if (rc < 0) if (rc < 0)
goto io_error; goto io_error;
else else
cFYI(1, ("Bytes read %d",rc)); cFYI(1, ("Bytes read %d", rc));
file->f_path.dentry->d_inode->i_atime = file->f_path.dentry->d_inode->i_atime =
current_fs_time(file->f_path.dentry->d_inode->i_sb); current_fs_time(file->f_path.dentry->d_inode->i_sb);
if (PAGE_CACHE_SIZE > rc) if (PAGE_CACHE_SIZE > rc)
memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc); memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc);
flush_dcache_page(page); flush_dcache_page(page);
SetPageUptodate(page); SetPageUptodate(page);
rc = 0; rc = 0;
io_error: io_error:
kunmap(page); kunmap(page);
page_cache_release(page); page_cache_release(page);
return rc; return rc;
} }
...@@ -1886,7 +1891,7 @@ static int cifs_readpage(struct file *file, struct page *page) ...@@ -1886,7 +1891,7 @@ static int cifs_readpage(struct file *file, struct page *page)
return -EBADF; return -EBADF;
} }
cFYI(1, ("readpage %p at offset %d 0x%x\n", cFYI(1, ("readpage %p at offset %d 0x%x\n",
page, (int)offset, (int)offset)); page, (int)offset, (int)offset));
rc = cifs_readpage_worker(file, page, &offset); rc = cifs_readpage_worker(file, page, &offset);
...@@ -1900,7 +1905,7 @@ static int cifs_readpage(struct file *file, struct page *page) ...@@ -1900,7 +1905,7 @@ static int cifs_readpage(struct file *file, struct page *page)
/* We do not want to update the file size from server for inodes /* We do not want to update the file size from server for inodes
open for write - to avoid races with writepage extending open for write - to avoid races with writepage extending
the file - in the future we could consider allowing the file - in the future we could consider allowing
refreshing the inode only on increases in the file size refreshing the inode only on increases in the file size
but this is tricky to do without racing with writebehind but this is tricky to do without racing with writebehind
page caching in the current Linux kernel design */ page caching in the current Linux kernel design */
int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
...@@ -1910,7 +1915,7 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) ...@@ -1910,7 +1915,7 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
if (cifsInode) if (cifsInode)
open_file = find_writable_file(cifsInode); open_file = find_writable_file(cifsInode);
if(open_file) { if (open_file) {
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
/* there is not actually a write pending so let /* there is not actually a write pending so let
...@@ -1920,12 +1925,12 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) ...@@ -1920,12 +1925,12 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb);
if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) { if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) {
/* since no page cache to corrupt on directio /* since no page cache to corrupt on directio
we can change size safely */ we can change size safely */
return 1; return 1;
} }
if(i_size_read(&cifsInode->vfs_inode) < end_of_file) if (i_size_read(&cifsInode->vfs_inode) < end_of_file)
return 1; return 1;
return 0; return 0;
...@@ -1940,7 +1945,7 @@ static int cifs_prepare_write(struct file *file, struct page *page, ...@@ -1940,7 +1945,7 @@ static int cifs_prepare_write(struct file *file, struct page *page,
loff_t i_size; loff_t i_size;
loff_t offset; loff_t offset;
cFYI(1, ("prepare write for page %p from %d to %d",page,from,to)); cFYI(1, ("prepare write for page %p from %d to %d", page, from, to));
if (PageUptodate(page)) if (PageUptodate(page))
return 0; return 0;
...@@ -1979,8 +1984,8 @@ static int cifs_prepare_write(struct file *file, struct page *page, ...@@ -1979,8 +1984,8 @@ static int cifs_prepare_write(struct file *file, struct page *page,
this will be written out by commit_write so is fine */ this will be written out by commit_write so is fine */
} }
/* we do not need to pass errors back /* we do not need to pass errors back
e.g. if we do not have read access to the file e.g. if we do not have read access to the file
because cifs_commit_write will do the right thing. -- shaggy */ because cifs_commit_write will do the right thing. -- shaggy */
return 0; return 0;
......
...@@ -57,14 +57,14 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -57,14 +57,14 @@ int cifs_get_inode_info_unix(struct inode **pinode,
if (tmp_path == NULL) { if (tmp_path == NULL) {
return -ENOMEM; return -ENOMEM;
} }
/* have to skip first of the double backslash of /* have to skip first of the double backslash of
UNC name */ UNC name */
strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE);
strncat(tmp_path, search_path, MAX_PATHCONF); strncat(tmp_path, search_path, MAX_PATHCONF);
rc = connect_to_dfs_path(xid, pTcon->ses, rc = connect_to_dfs_path(xid, pTcon->ses,
/* treename + */ tmp_path, /* treename + */ tmp_path,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
kfree(tmp_path); kfree(tmp_path);
...@@ -81,7 +81,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -81,7 +81,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
/* get new inode */ /* get new inode */
if (*pinode == NULL) { if (*pinode == NULL) {
*pinode = new_inode(sb); *pinode = new_inode(sb);
if (*pinode == NULL) if (*pinode == NULL)
return -ENOMEM; return -ENOMEM;
/* Is an i_ino of zero legal? */ /* Is an i_ino of zero legal? */
/* Are there sanity checks we can use to ensure that /* Are there sanity checks we can use to ensure that
...@@ -103,7 +103,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -103,7 +103,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
cifsInfo->time = jiffies; cifsInfo->time = jiffies;
cFYI(1, ("New time %ld", cifsInfo->time)); cFYI(1, ("New time %ld", cifsInfo->time));
/* this is ok to set on every inode revalidate */ /* this is ok to set on every inode revalidate */
atomic_set(&cifsInfo->inUse,1); atomic_set(&cifsInfo->inUse, 1);
inode->i_atime = inode->i_atime =
cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime)); cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime));
...@@ -114,8 +114,8 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -114,8 +114,8 @@ int cifs_get_inode_info_unix(struct inode **pinode,
cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange)); cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange));
inode->i_mode = le64_to_cpu(findData.Permissions); inode->i_mode = le64_to_cpu(findData.Permissions);
/* since we set the inode type below we need to mask off /* since we set the inode type below we need to mask off
to avoid strange results if bits set above */ to avoid strange results if bits set above */
inode->i_mode &= ~S_IFMT; inode->i_mode &= ~S_IFMT;
if (type == UNIX_FILE) { if (type == UNIX_FILE) {
inode->i_mode |= S_IFREG; inode->i_mode |= S_IFREG;
} else if (type == UNIX_SYMLINK) { } else if (type == UNIX_SYMLINK) {
...@@ -137,7 +137,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -137,7 +137,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
} else { } else {
/* safest to call it a file if we do not know */ /* safest to call it a file if we do not know */
inode->i_mode |= S_IFREG; inode->i_mode |= S_IFREG;
cFYI(1,("unknown type %d",type)); cFYI(1, ("unknown type %d", type));
} }
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
...@@ -183,17 +183,17 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -183,17 +183,17 @@ int cifs_get_inode_info_unix(struct inode **pinode,
inode->i_op = &cifs_file_inode_ops; inode->i_op = &cifs_file_inode_ops;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
inode->i_fop = inode->i_fop =
&cifs_file_direct_nobrl_ops; &cifs_file_direct_nobrl_ops;
else else
inode->i_fop = &cifs_file_direct_ops; inode->i_fop = &cifs_file_direct_ops;
} else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
inode->i_fop = &cifs_file_nobrl_ops; inode->i_fop = &cifs_file_nobrl_ops;
else /* not direct, send byte range locks */ else /* not direct, send byte range locks */
inode->i_fop = &cifs_file_ops; inode->i_fop = &cifs_file_ops;
/* check if server can support readpages */ /* check if server can support readpages */
if (pTcon->ses->server->maxBuf < if (pTcon->ses->server->maxBuf <
PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
inode->i_data.a_ops = &cifs_addr_ops_smallbuf; inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else else
...@@ -215,7 +215,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -215,7 +215,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
return rc; return rc;
} }
static int decode_sfu_inode(struct inode * inode, __u64 size, static int decode_sfu_inode(struct inode *inode, __u64 size,
const unsigned char *path, const unsigned char *path,
struct cifs_sb_info *cifs_sb, int xid) struct cifs_sb_info *cifs_sb, int xid)
{ {
...@@ -225,7 +225,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -225,7 +225,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
struct cifsTconInfo *pTcon = cifs_sb->tcon; struct cifsTconInfo *pTcon = cifs_sb->tcon;
char buf[24]; char buf[24];
unsigned int bytes_read; unsigned int bytes_read;
char * pbuf; char *pbuf;
pbuf = buf; pbuf = buf;
...@@ -241,16 +241,16 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -241,16 +241,16 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc==0) { if (rc == 0) {
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
/* Read header */ /* Read header */
rc = CIFSSMBRead(xid, pTcon, rc = CIFSSMBRead(xid, pTcon,
netfid, netfid,
24 /* length */, 0 /* offset */, 24 /* length */, 0 /* offset */,
&bytes_read, &pbuf, &buf_type); &bytes_read, &pbuf, &buf_type);
if ((rc == 0) && (bytes_read >= 8)) { if ((rc == 0) && (bytes_read >= 8)) {
if (memcmp("IntxBLK", pbuf, 8) == 0) { if (memcmp("IntxBLK", pbuf, 8) == 0) {
cFYI(1,("Block device")); cFYI(1, ("Block device"));
inode->i_mode |= S_IFBLK; inode->i_mode |= S_IFBLK;
if (bytes_read == 24) { if (bytes_read == 24) {
/* we have enough to decode dev num */ /* we have enough to decode dev num */
...@@ -261,7 +261,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -261,7 +261,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
inode->i_rdev = MKDEV(mjr, mnr); inode->i_rdev = MKDEV(mjr, mnr);
} }
} else if (memcmp("IntxCHR", pbuf, 8) == 0) { } else if (memcmp("IntxCHR", pbuf, 8) == 0) {
cFYI(1,("Char device")); cFYI(1, ("Char device"));
inode->i_mode |= S_IFCHR; inode->i_mode |= S_IFCHR;
if (bytes_read == 24) { if (bytes_read == 24) {
/* we have enough to decode dev num */ /* we have enough to decode dev num */
...@@ -270,18 +270,18 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -270,18 +270,18 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
mjr = le64_to_cpu(*(__le64 *)(pbuf+8)); mjr = le64_to_cpu(*(__le64 *)(pbuf+8));
mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
inode->i_rdev = MKDEV(mjr, mnr); inode->i_rdev = MKDEV(mjr, mnr);
} }
} else if (memcmp("IntxLNK", pbuf, 7) == 0) { } else if (memcmp("IntxLNK", pbuf, 7) == 0) {
cFYI(1,("Symlink")); cFYI(1, ("Symlink"));
inode->i_mode |= S_IFLNK; inode->i_mode |= S_IFLNK;
} else { } else {
inode->i_mode |= S_IFREG; /* file? */ inode->i_mode |= S_IFREG; /* file? */
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
} }
} else { } else {
inode->i_mode |= S_IFREG; /* then it is a file */ inode->i_mode |= S_IFREG; /* then it is a file */
rc = -EOPNOTSUPP; /* or some unknown SFU type */ rc = -EOPNOTSUPP; /* or some unknown SFU type */
} }
CIFSSMBClose(xid, pTcon, netfid); CIFSSMBClose(xid, pTcon, netfid);
} }
return rc; return rc;
...@@ -290,7 +290,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -290,7 +290,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
#define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */ #define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */
static int get_sfu_uid_mode(struct inode * inode, static int get_sfu_uid_mode(struct inode *inode,
const unsigned char *path, const unsigned char *path,
struct cifs_sb_info *cifs_sb, int xid) struct cifs_sb_info *cifs_sb, int xid)
{ {
...@@ -301,15 +301,15 @@ static int get_sfu_uid_mode(struct inode * inode, ...@@ -301,15 +301,15 @@ static int get_sfu_uid_mode(struct inode * inode,
rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS",
ea_value, 4 /* size of buf */, cifs_sb->local_nls, ea_value, 4 /* size of buf */, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc < 0) if (rc < 0)
return (int)rc; return (int)rc;
else if (rc > 3) { else if (rc > 3) {
mode = le32_to_cpu(*((__le32 *)ea_value)); mode = le32_to_cpu(*((__le32 *)ea_value));
inode->i_mode &= ~SFBITS_MASK; inode->i_mode &= ~SFBITS_MASK;
cFYI(1,("special bits 0%o org mode 0%o", mode, inode->i_mode)); cFYI(1, ("special bits 0%o org mode 0%o", mode, inode->i_mode));
inode->i_mode = (mode & SFBITS_MASK) | inode->i_mode; inode->i_mode = (mode & SFBITS_MASK) | inode->i_mode;
cFYI(1,("special mode bits 0%o", mode)); cFYI(1, ("special mode bits 0%o", mode));
return 0; return 0;
} else { } else {
return 0; return 0;
...@@ -334,11 +334,11 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -334,11 +334,11 @@ int cifs_get_inode_info(struct inode **pinode,
int adjustTZ = FALSE; int adjustTZ = FALSE;
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
cFYI(1,("Getting info on %s", search_path)); cFYI(1, ("Getting info on %s", search_path));
if ((pfindData == NULL) && (*pinode != NULL)) { if ((pfindData == NULL) && (*pinode != NULL)) {
if (CIFS_I(*pinode)->clientCanCacheRead) { if (CIFS_I(*pinode)->clientCanCacheRead) {
cFYI(1,("No need to revalidate cached inode sizes")); cFYI(1, ("No need to revalidate cached inode sizes"));
return rc; return rc;
} }
} }
...@@ -359,7 +359,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -359,7 +359,7 @@ int cifs_get_inode_info(struct inode **pinode,
failed at least once - set flag in tcon or mount */ failed at least once - set flag in tcon or mount */
if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
rc = SMBQueryInformation(xid, pTcon, search_path, rc = SMBQueryInformation(xid, pTcon, search_path,
pfindData, cifs_sb->local_nls, pfindData, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
adjustTZ = TRUE; adjustTZ = TRUE;
...@@ -384,8 +384,8 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -384,8 +384,8 @@ int cifs_get_inode_info(struct inode **pinode,
strncat(tmp_path, search_path, MAX_PATHCONF); strncat(tmp_path, search_path, MAX_PATHCONF);
rc = connect_to_dfs_path(xid, pTcon->ses, rc = connect_to_dfs_path(xid, pTcon->ses,
/* treename + */ tmp_path, /* treename + */ tmp_path,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
kfree(tmp_path); kfree(tmp_path);
/* BB fix up inode etc. */ /* BB fix up inode etc. */
...@@ -419,17 +419,17 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -419,17 +419,17 @@ int cifs_get_inode_info(struct inode **pinode,
there Windows server or network appliances for which there Windows server or network appliances for which
IndexNumber field is not guaranteed unique? */ IndexNumber field is not guaranteed unique? */
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM){ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
int rc1 = 0; int rc1 = 0;
__u64 inode_num; __u64 inode_num;
rc1 = CIFSGetSrvInodeNumber(xid, pTcon, rc1 = CIFSGetSrvInodeNumber(xid, pTcon,
search_path, &inode_num, search_path, &inode_num,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc1) { if (rc1) {
cFYI(1,("GetSrvInodeNum rc %d", rc1)); cFYI(1, ("GetSrvInodeNum rc %d", rc1));
/* BB EOPNOSUPP disable SERVER_INUM? */ /* BB EOPNOSUPP disable SERVER_INUM? */
} else /* do we need cast or hash to ino? */ } else /* do we need cast or hash to ino? */
(*pinode)->i_ino = inode_num; (*pinode)->i_ino = inode_num;
...@@ -463,7 +463,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -463,7 +463,7 @@ int cifs_get_inode_info(struct inode **pinode,
cFYI(0, ("Attributes came in as 0x%x", attr)); cFYI(0, ("Attributes came in as 0x%x", attr));
if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) {
inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj;
inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj;
} }
/* set default mode. will override for dirs below */ /* set default mode. will override for dirs below */
...@@ -471,8 +471,9 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -471,8 +471,9 @@ int cifs_get_inode_info(struct inode **pinode,
/* new inode, can safely set these fields */ /* new inode, can safely set these fields */
inode->i_mode = cifs_sb->mnt_file_mode; inode->i_mode = cifs_sb->mnt_file_mode;
else /* since we set the inode type below we need to mask off else /* since we set the inode type below we need to mask off
to avoid strange results if type changes and both get orred in */ to avoid strange results if type changes and both
inode->i_mode &= ~S_IFMT; get orred in */
inode->i_mode &= ~S_IFMT;
/* if (attr & ATTR_REPARSE) */ /* if (attr & ATTR_REPARSE) */
/* We no longer handle these as symlinks because we could not /* We no longer handle these as symlinks because we could not
follow them due to the absolute path with drive letter */ follow them due to the absolute path with drive letter */
...@@ -490,13 +491,13 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -490,13 +491,13 @@ int cifs_get_inode_info(struct inode **pinode,
/* BB Finish for SFU style symlinks and devices */ /* BB Finish for SFU style symlinks and devices */
} else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) &&
(cifsInfo->cifsAttrs & ATTR_SYSTEM)) { (cifsInfo->cifsAttrs & ATTR_SYSTEM)) {
if (decode_sfu_inode(inode, if (decode_sfu_inode(inode,
le64_to_cpu(pfindData->EndOfFile), le64_to_cpu(pfindData->EndOfFile),
search_path, search_path,
cifs_sb, xid)) { cifs_sb, xid)) {
cFYI(1,("Unrecognized sfu inode type")); cFYI(1, ("Unrecognized sfu inode type"));
} }
cFYI(1,("sfu mode 0%o",inode->i_mode)); cFYI(1, ("sfu mode 0%o", inode->i_mode));
} else { } else {
inode->i_mode |= S_IFREG; inode->i_mode |= S_IFREG;
/* treat the dos attribute of read-only as read-only /* treat the dos attribute of read-only as read-only
...@@ -517,7 +518,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -517,7 +518,7 @@ int cifs_get_inode_info(struct inode **pinode,
if (is_size_safe_to_change(cifsInfo, le64_to_cpu(pfindData->EndOfFile))) { if (is_size_safe_to_change(cifsInfo, le64_to_cpu(pfindData->EndOfFile))) {
/* can not safely shrink the file size here if the /* can not safely shrink the file size here if the
client is writing to it due to potential races */ client is writing to it due to potential races */
i_size_write(inode,le64_to_cpu(pfindData->EndOfFile)); i_size_write(inode, le64_to_cpu(pfindData->EndOfFile));
/* 512 bytes (2**9) is the fake blocksize that must be /* 512 bytes (2**9) is the fake blocksize that must be
used for this calculation */ used for this calculation */
...@@ -528,7 +529,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -528,7 +529,7 @@ int cifs_get_inode_info(struct inode **pinode,
inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks); inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks);
/* BB fill in uid and gid here? with help from winbind? /* BB fill in uid and gid here? with help from winbind?
or retrieve from NTFS stream extended attribute */ or retrieve from NTFS stream extended attribute */
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
/* fill in uid, gid, mode from server ACL */ /* fill in uid, gid, mode from server ACL */
...@@ -540,7 +541,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -540,7 +541,7 @@ int cifs_get_inode_info(struct inode **pinode,
inode->i_gid = cifs_sb->mnt_gid; inode->i_gid = cifs_sb->mnt_gid;
/* set so we do not keep refreshing these fields with /* set so we do not keep refreshing these fields with
bad data after user has changed them in memory */ bad data after user has changed them in memory */
atomic_set(&cifsInfo->inUse,1); atomic_set(&cifsInfo->inUse, 1);
} }
if (S_ISREG(inode->i_mode)) { if (S_ISREG(inode->i_mode)) {
...@@ -557,7 +558,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -557,7 +558,7 @@ int cifs_get_inode_info(struct inode **pinode,
else /* not direct, send byte range locks */ else /* not direct, send byte range locks */
inode->i_fop = &cifs_file_ops; inode->i_fop = &cifs_file_ops;
if (pTcon->ses->server->maxBuf < if (pTcon->ses->server->maxBuf <
PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
inode->i_data.a_ops = &cifs_addr_ops_smallbuf; inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else else
...@@ -587,9 +588,9 @@ void cifs_read_inode(struct inode *inode) ...@@ -587,9 +588,9 @@ void cifs_read_inode(struct inode *inode)
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
xid = GetXid(); xid = GetXid();
if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)
cifs_get_inode_info_unix(&inode, "", inode->i_sb,xid); cifs_get_inode_info_unix(&inode, "", inode->i_sb, xid);
else else
cifs_get_inode_info(&inode, "", NULL, inode->i_sb,xid); cifs_get_inode_info(&inode, "", NULL, inode->i_sb, xid);
/* can not call macro FreeXid here since in a void func */ /* can not call macro FreeXid here since in a void func */
_FreeXid(xid); _FreeXid(xid);
} }
...@@ -638,12 +639,12 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) ...@@ -638,12 +639,12 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE,
CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE,
&netfid, &oplock, NULL, cifs_sb->local_nls, &netfid, &oplock, NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc==0) { if (rc == 0) {
CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL, CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
CIFSSMBClose(xid, pTcon, netfid); CIFSSMBClose(xid, pTcon, netfid);
if (direntry->d_inode) if (direntry->d_inode)
...@@ -659,7 +660,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) ...@@ -659,7 +660,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
rc = CIFSSMBSetTimes(xid, pTcon, full_path, rc = CIFSSMBSetTimes(xid, pTcon, full_path,
pinfo_buf, pinfo_buf,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
else else
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
...@@ -670,7 +671,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) ...@@ -670,7 +671,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
/* rc = CIFSSMBSetAttrLegacy(xid, pTcon, /* rc = CIFSSMBSetAttrLegacy(xid, pTcon,
full_path, full_path,
(__u16)ATTR_NORMAL, (__u16)ATTR_NORMAL,
cifs_sb->local_nls); cifs_sb->local_nls);
For some strange reason it seems that NT4 eats the For some strange reason it seems that NT4 eats the
old setattr call without actually setting the old setattr call without actually setting the
attributes so on to the third attempted workaround attributes so on to the third attempted workaround
...@@ -683,9 +684,9 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) ...@@ -683,9 +684,9 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
FILE_WRITE_ATTRIBUTES, 0, FILE_WRITE_ATTRIBUTES, 0,
&netfid, &oplock, NULL, &netfid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc==0) { if (rc == 0) {
rc = CIFSSMBSetFileTimes(xid, pTcon, rc = CIFSSMBSetFileTimes(xid, pTcon,
pinfo_buf, pinfo_buf,
netfid); netfid);
...@@ -694,10 +695,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) ...@@ -694,10 +695,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
} }
kfree(pinfo_buf); kfree(pinfo_buf);
} }
if (rc==0) { if (rc == 0) {
rc = CIFSSMBDelFile(xid, pTcon, full_path, rc = CIFSSMBDelFile(xid, pTcon, full_path,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (!rc) { if (!rc) {
if (direntry->d_inode) if (direntry->d_inode)
...@@ -711,10 +712,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) ...@@ -711,10 +712,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
CREATE_NOT_DIR | CREATE_NOT_DIR |
CREATE_DELETE_ON_CLOSE, CREATE_DELETE_ON_CLOSE,
&netfid, &oplock, NULL, &netfid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc==0) { if (rc == 0) {
CIFSSMBRenameOpenFile(xid, pTcon, CIFSSMBRenameOpenFile(xid, pTcon,
netfid, NULL, netfid, NULL,
cifs_sb->local_nls, cifs_sb->local_nls,
...@@ -773,8 +774,8 @@ static void posix_fill_in_inode(struct inode *tmp_inode, ...@@ -773,8 +774,8 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
tmp_inode->i_mode = le64_to_cpu(pData->Permissions); tmp_inode->i_mode = le64_to_cpu(pData->Permissions);
/* since we set the inode type below we need to mask off type /* since we set the inode type below we need to mask off type
to avoid strange results if bits above were corrupt */ to avoid strange results if bits above were corrupt */
tmp_inode->i_mode &= ~S_IFMT; tmp_inode->i_mode &= ~S_IFMT;
if (type == UNIX_FILE) { if (type == UNIX_FILE) {
*pobject_type = DT_REG; *pobject_type = DT_REG;
tmp_inode->i_mode |= S_IFREG; tmp_inode->i_mode |= S_IFREG;
...@@ -804,11 +805,11 @@ static void posix_fill_in_inode(struct inode *tmp_inode, ...@@ -804,11 +805,11 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
/* safest to just call it a file */ /* safest to just call it a file */
*pobject_type = DT_REG; *pobject_type = DT_REG;
tmp_inode->i_mode |= S_IFREG; tmp_inode->i_mode |= S_IFREG;
cFYI(1,("unknown inode type %d",type)); cFYI(1, ("unknown inode type %d", type));
} }
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("object type: %d", type)); cFYI(1, ("object type: %d", type));
#endif #endif
tmp_inode->i_uid = le64_to_cpu(pData->Uid); tmp_inode->i_uid = le64_to_cpu(pData->Uid);
tmp_inode->i_gid = le64_to_cpu(pData->Gid); tmp_inode->i_gid = le64_to_cpu(pData->Gid);
...@@ -816,7 +817,7 @@ static void posix_fill_in_inode(struct inode *tmp_inode, ...@@ -816,7 +817,7 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
spin_lock(&tmp_inode->i_lock); spin_lock(&tmp_inode->i_lock);
if (is_size_safe_to_change(cifsInfo, end_of_file)) { if (is_size_safe_to_change(cifsInfo, end_of_file)) {
/* can not safely change the file size here if the /* can not safely change the file size here if the
client is writing to it due to potential races */ client is writing to it due to potential races */
i_size_write(tmp_inode, end_of_file); i_size_write(tmp_inode, end_of_file);
...@@ -830,27 +831,28 @@ static void posix_fill_in_inode(struct inode *tmp_inode, ...@@ -830,27 +831,28 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
cFYI(1, ("File inode")); cFYI(1, ("File inode"));
tmp_inode->i_op = &cifs_file_inode_ops; tmp_inode->i_op = &cifs_file_inode_ops;
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; tmp_inode->i_fop = &cifs_file_direct_nobrl_ops;
else else
tmp_inode->i_fop = &cifs_file_direct_ops; tmp_inode->i_fop = &cifs_file_direct_ops;
} else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
tmp_inode->i_fop = &cifs_file_nobrl_ops; tmp_inode->i_fop = &cifs_file_nobrl_ops;
else else
tmp_inode->i_fop = &cifs_file_ops; tmp_inode->i_fop = &cifs_file_ops;
if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
(cifs_sb->tcon->ses->server->maxBuf < (cifs_sb->tcon->ses->server->maxBuf <
PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else else
tmp_inode->i_data.a_ops = &cifs_addr_ops; tmp_inode->i_data.a_ops = &cifs_addr_ops;
if(isNewInode) if (isNewInode)
return; /* No sense invalidating pages for new inode since we return; /* No sense invalidating pages for new inode
have not started caching readahead file data yet */ since we we have not started caching
readahead file data yet */
if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) && if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
(local_size == tmp_inode->i_size)) { (local_size == tmp_inode->i_size)) {
...@@ -869,10 +871,10 @@ static void posix_fill_in_inode(struct inode *tmp_inode, ...@@ -869,10 +871,10 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
tmp_inode->i_op = &cifs_symlink_inode_ops; tmp_inode->i_op = &cifs_symlink_inode_ops;
/* tmp_inode->i_fop = *//* do not need to set to anything */ /* tmp_inode->i_fop = *//* do not need to set to anything */
} else { } else {
cFYI(1, ("Special inode")); cFYI(1, ("Special inode"));
init_special_inode(tmp_inode, tmp_inode->i_mode, init_special_inode(tmp_inode, tmp_inode->i_mode,
tmp_inode->i_rdev); tmp_inode->i_rdev);
} }
} }
int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
...@@ -897,21 +899,21 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -897,21 +899,21 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
return -ENOMEM; return -ENOMEM;
} }
if((pTcon->ses->capabilities & CAP_UNIX) && if ((pTcon->ses->capabilities & CAP_UNIX) &&
(CIFS_UNIX_POSIX_PATH_OPS_CAP & (CIFS_UNIX_POSIX_PATH_OPS_CAP &
le64_to_cpu(pTcon->fsUnixInfo.Capability))) { le64_to_cpu(pTcon->fsUnixInfo.Capability))) {
u32 oplock = 0; u32 oplock = 0;
FILE_UNIX_BASIC_INFO * pInfo = FILE_UNIX_BASIC_INFO * pInfo =
kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
if(pInfo == NULL) { if (pInfo == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto mkdir_out; goto mkdir_out;
} }
rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT, rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT,
mode, NULL /* netfid */, pInfo, &oplock, mode, NULL /* netfid */, pInfo, &oplock,
full_path, cifs_sb->local_nls, full_path, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc) { if (rc) {
cFYI(1, ("posix mkdir returned 0x%x", rc)); cFYI(1, ("posix mkdir returned 0x%x", rc));
...@@ -919,8 +921,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -919,8 +921,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
} else { } else {
int obj_type; int obj_type;
if (pInfo->Type == -1) /* no return info - go query */ if (pInfo->Type == -1) /* no return info - go query */
goto mkdir_get_info; goto mkdir_get_info;
/*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need to set uid/gid */ /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need
to set uid/gid */
inc_nlink(inode); inc_nlink(inode);
if (pTcon->nocase) if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops; direntry->d_op = &cifs_ci_dentry_ops;
...@@ -937,7 +940,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -937,7 +940,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
newinode->i_ino = newinode->i_ino =
(unsigned long)pInfo->UniqueId; (unsigned long)pInfo->UniqueId;
} /* note ino incremented to unique num in new_inode */ } /* note ino incremented to unique num in new_inode */
if(inode->i_sb->s_flags & MS_NOATIME) if (inode->i_sb->s_flags & MS_NOATIME)
newinode->i_flags |= S_NOATIME | S_NOCMTIME; newinode->i_flags |= S_NOATIME | S_NOCMTIME;
newinode->i_nlink = 2; newinode->i_nlink = 2;
...@@ -949,17 +952,17 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -949,17 +952,17 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
posix_fill_in_inode(direntry->d_inode, posix_fill_in_inode(direntry->d_inode,
pInfo, &obj_type, 1 /* NewInode */); pInfo, &obj_type, 1 /* NewInode */);
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("instantiated dentry %p %s to inode %p", cFYI(1, ("instantiated dentry %p %s to inode %p",
direntry, direntry->d_name.name, newinode)); direntry, direntry->d_name.name, newinode));
if(newinode->i_nlink != 2) if (newinode->i_nlink != 2)
cFYI(1,("unexpected number of links %d", cFYI(1, ("unexpected number of links %d",
newinode->i_nlink)); newinode->i_nlink));
#endif #endif
} }
kfree(pInfo); kfree(pInfo);
goto mkdir_out; goto mkdir_out;
} }
/* BB add setting the equivalent of mode via CreateX w/ACLs */ /* BB add setting the equivalent of mode via CreateX w/ACLs */
rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls, rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls,
...@@ -968,14 +971,14 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -968,14 +971,14 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
cFYI(1, ("cifs_mkdir returned 0x%x", rc)); cFYI(1, ("cifs_mkdir returned 0x%x", rc));
d_drop(direntry); d_drop(direntry);
} else { } else {
mkdir_get_info: mkdir_get_info:
inc_nlink(inode); inc_nlink(inode);
if (pTcon->ses->capabilities & CAP_UNIX) if (pTcon->ses->capabilities & CAP_UNIX)
rc = cifs_get_inode_info_unix(&newinode, full_path, rc = cifs_get_inode_info_unix(&newinode, full_path,
inode->i_sb,xid); inode->i_sb, xid);
else else
rc = cifs_get_inode_info(&newinode, full_path, NULL, rc = cifs_get_inode_info(&newinode, full_path, NULL,
inode->i_sb,xid); inode->i_sb, xid);
if (pTcon->nocase) if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops; direntry->d_op = &cifs_ci_dentry_ops;
...@@ -983,9 +986,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -983,9 +986,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
direntry->d_op = &cifs_dentry_ops; direntry->d_op = &cifs_dentry_ops;
d_instantiate(direntry, newinode); d_instantiate(direntry, newinode);
/* setting nlink not necessary except in cases where we /* setting nlink not necessary except in cases where we
* failed to get it from the server or was set bogus */ * failed to get it from the server or was set bogus */
if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
direntry->d_inode->i_nlink = 2; direntry->d_inode->i_nlink = 2;
if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
mode &= ~current->fs->umask; mode &= ~current->fs->umask;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
...@@ -1002,27 +1005,27 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -1002,27 +1005,27 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
mode, (__u64)-1, mode, (__u64)-1,
(__u64)-1, 0 /* dev_t */, (__u64)-1, 0 /* dev_t */,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
} }
} else { } else {
/* BB to be implemented via Windows secrty descriptors /* BB to be implemented via Windows secrty descriptors
eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
-1, -1, local_nls); */ -1, -1, local_nls); */
if(direntry->d_inode) { if (direntry->d_inode) {
direntry->d_inode->i_mode = mode; direntry->d_inode->i_mode = mode;
direntry->d_inode->i_mode |= S_IFDIR; direntry->d_inode->i_mode |= S_IFDIR;
if(cifs_sb->mnt_cifs_flags & if (cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_SET_UID) { CIFS_MOUNT_SET_UID) {
direntry->d_inode->i_uid = direntry->d_inode->i_uid =
current->fsuid; current->fsuid;
direntry->d_inode->i_gid = direntry->d_inode->i_gid =
current->fsgid; current->fsgid;
} }
} }
} }
} }
mkdir_out: mkdir_out:
kfree(full_path); kfree(full_path);
FreeXid(xid); FreeXid(xid);
return rc; return rc;
...@@ -1056,7 +1059,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) ...@@ -1056,7 +1059,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
if (!rc) { if (!rc) {
drop_nlink(inode); drop_nlink(inode);
spin_lock(&direntry->d_inode->i_lock); spin_lock(&direntry->d_inode->i_lock);
i_size_write(direntry->d_inode,0); i_size_write(direntry->d_inode, 0);
clear_nlink(direntry->d_inode); clear_nlink(direntry->d_inode);
spin_unlock(&direntry->d_inode->i_lock); spin_unlock(&direntry->d_inode->i_lock);
} }
...@@ -1121,7 +1124,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, ...@@ -1121,7 +1124,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
info_buf_target = info_buf_source + 1; info_buf_target = info_buf_source + 1;
if (pTcon->ses->capabilities & CAP_UNIX) if (pTcon->ses->capabilities & CAP_UNIX)
rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName,
info_buf_source, info_buf_source,
cifs_sb_source->local_nls, cifs_sb_source->local_nls,
cifs_sb_source->mnt_cifs_flags & cifs_sb_source->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
...@@ -1171,12 +1174,12 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, ...@@ -1171,12 +1174,12 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
might not right be right access to request */ might not right be right access to request */
rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ, rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ,
CREATE_NOT_DIR, &netfid, &oplock, NULL, CREATE_NOT_DIR, &netfid, &oplock, NULL,
cifs_sb_source->local_nls, cifs_sb_source->local_nls,
cifs_sb_source->mnt_cifs_flags & cifs_sb_source->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc==0) { if (rc == 0) {
rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName, rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName,
cifs_sb_source->local_nls, cifs_sb_source->local_nls,
cifs_sb_source->mnt_cifs_flags & cifs_sb_source->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
CIFSSMBClose(xid, pTcon, netfid); CIFSSMBClose(xid, pTcon, netfid);
...@@ -1249,7 +1252,7 @@ int cifs_revalidate(struct dentry *direntry) ...@@ -1249,7 +1252,7 @@ int cifs_revalidate(struct dentry *direntry)
if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path, rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path,
direntry->d_sb,xid); direntry->d_sb, xid);
if (rc) { if (rc) {
cFYI(1, ("error on getting revalidate info %d", rc)); cFYI(1, ("error on getting revalidate info %d", rc));
/* if (rc != -ENOENT) /* if (rc != -ENOENT)
...@@ -1258,7 +1261,7 @@ int cifs_revalidate(struct dentry *direntry) ...@@ -1258,7 +1261,7 @@ int cifs_revalidate(struct dentry *direntry)
} }
} else { } else {
rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL, rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL,
direntry->d_sb,xid); direntry->d_sb, xid);
if (rc) { if (rc) {
cFYI(1, ("error on getting revalidate info %d", rc)); cFYI(1, ("error on getting revalidate info %d", rc));
/* if (rc != -ENOENT) /* if (rc != -ENOENT)
...@@ -1271,7 +1274,7 @@ int cifs_revalidate(struct dentry *direntry) ...@@ -1271,7 +1274,7 @@ int cifs_revalidate(struct dentry *direntry)
/* if not oplocked, we invalidate inode pages if mtime or file size /* if not oplocked, we invalidate inode pages if mtime or file size
had changed on server */ had changed on server */
if (timespec_equal(&local_mtime,&direntry->d_inode->i_mtime) && if (timespec_equal(&local_mtime, &direntry->d_inode->i_mtime) &&
(local_size == direntry->d_inode->i_size)) { (local_size == direntry->d_inode->i_size)) {
cFYI(1, ("cifs_revalidate - inode unchanged")); cFYI(1, ("cifs_revalidate - inode unchanged"));
} else { } else {
...@@ -1298,7 +1301,7 @@ int cifs_revalidate(struct dentry *direntry) ...@@ -1298,7 +1301,7 @@ int cifs_revalidate(struct dentry *direntry)
if (invalidate_inode) { if (invalidate_inode) {
/* shrink_dcache not necessary now that cifs dentry ops /* shrink_dcache not necessary now that cifs dentry ops
are exported for negative dentries */ are exported for negative dentries */
/* if(S_ISDIR(direntry->d_inode->i_mode)) /* if (S_ISDIR(direntry->d_inode->i_mode))
shrink_dcache_parent(direntry); */ shrink_dcache_parent(direntry); */
if (S_ISREG(direntry->d_inode->i_mode)) { if (S_ISREG(direntry->d_inode->i_mode)) {
if (direntry->d_inode->i_mapping) if (direntry->d_inode->i_mapping)
...@@ -1351,7 +1354,7 @@ static int cifs_truncate_page(struct address_space *mapping, loff_t from) ...@@ -1351,7 +1354,7 @@ static int cifs_truncate_page(struct address_space *mapping, loff_t from)
return rc; return rc;
} }
static int cifs_vmtruncate(struct inode * inode, loff_t offset) static int cifs_vmtruncate(struct inode *inode, loff_t offset)
{ {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
unsigned long limit; unsigned long limit;
...@@ -1424,7 +1427,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1424,7 +1427,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) { if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) {
/* check if we have permission to change attrs */ /* check if we have permission to change attrs */
rc = inode_change_ok(direntry->d_inode, attrs); rc = inode_change_ok(direntry->d_inode, attrs);
if(rc < 0) { if (rc < 0) {
FreeXid(xid); FreeXid(xid);
return rc; return rc;
} else } else
...@@ -1459,16 +1462,16 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1459,16 +1462,16 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size,
nfid, npid, FALSE); nfid, npid, FALSE);
atomic_dec(&open_file->wrtPending); atomic_dec(&open_file->wrtPending);
cFYI(1,("SetFSize for attrs rc = %d", rc)); cFYI(1, ("SetFSize for attrs rc = %d", rc));
if((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
int bytes_written; int bytes_written;
rc = CIFSSMBWrite(xid, pTcon, rc = CIFSSMBWrite(xid, pTcon,
nfid, 0, attrs->ia_size, nfid, 0, attrs->ia_size,
&bytes_written, NULL, NULL, &bytes_written, NULL, NULL,
1 /* 45 seconds */); 1 /* 45 seconds */);
cFYI(1,("Wrt seteof rc %d", rc)); cFYI(1, ("Wrt seteof rc %d", rc));
} }
} else } else
rc = -EINVAL; rc = -EINVAL;
if (rc != 0) { if (rc != 0) {
...@@ -1478,11 +1481,11 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1478,11 +1481,11 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
it by handle */ it by handle */
rc = CIFSSMBSetEOF(xid, pTcon, full_path, rc = CIFSSMBSetEOF(xid, pTcon, full_path,
attrs->ia_size, FALSE, attrs->ia_size, FALSE,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
if((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
__u16 netfid; __u16 netfid;
int oplock = FALSE; int oplock = FALSE;
...@@ -1493,14 +1496,14 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1493,14 +1496,14 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
NULL, cifs_sb->local_nls, NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc==0) { if (rc == 0) {
int bytes_written; int bytes_written;
rc = CIFSSMBWrite(xid, pTcon, rc = CIFSSMBWrite(xid, pTcon,
netfid, 0, netfid, 0,
attrs->ia_size, attrs->ia_size,
&bytes_written, NULL, &bytes_written, NULL,
NULL, 1 /* 45 sec */); NULL, 1 /* 45 sec */);
cFYI(1,("wrt seteof rc %d",rc)); cFYI(1, ("wrt seteof rc %d", rc));
CIFSSMBClose(xid, pTcon, netfid); CIFSSMBClose(xid, pTcon, netfid);
} }
...@@ -1517,7 +1520,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1517,7 +1520,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size); rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size);
cifs_truncate_page(direntry->d_inode->i_mapping, cifs_truncate_page(direntry->d_inode->i_mapping,
direntry->d_inode->i_size); direntry->d_inode->i_size);
} else } else
goto cifs_setattr_exit; goto cifs_setattr_exit;
} }
if (attrs->ia_valid & ATTR_UID) { if (attrs->ia_valid & ATTR_UID) {
...@@ -1539,7 +1542,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1539,7 +1542,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
&& (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID)))
rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid, rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid,
0 /* dev_t */, cifs_sb->local_nls, 0 /* dev_t */, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
else if (attrs->ia_valid & ATTR_MODE) { else if (attrs->ia_valid & ATTR_MODE) {
rc = 0; rc = 0;
...@@ -1559,7 +1562,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1559,7 +1562,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs & time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs &
(~ATTR_READONLY)); (~ATTR_READONLY));
/* Windows ignores set to zero */ /* Windows ignores set to zero */
if(time_buf.Attributes == 0) if (time_buf.Attributes == 0)
time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL); time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL);
} }
/* BB to be implemented - /* BB to be implemented -
...@@ -1624,7 +1627,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1624,7 +1627,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
NULL, cifs_sb->local_nls, NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc==0) { if (rc == 0) {
rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf, rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf,
netfid); netfid);
CIFSSMBClose(xid, pTcon, netfid); CIFSSMBClose(xid, pTcon, netfid);
...@@ -1634,7 +1637,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1634,7 +1637,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
granularity */ granularity */
/* rc = CIFSSMBSetTimesLegacy(xid, pTcon, full_path, /* rc = CIFSSMBSetTimesLegacy(xid, pTcon, full_path,
&time_buf, cifs_sb->local_nls); */ &time_buf, cifs_sb->local_nls); */
} }
} }
/* Even if error on time set, no sense failing the call if /* Even if error on time set, no sense failing the call if
...@@ -1642,7 +1645,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1642,7 +1645,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
and this check ensures that we are not being called from and this check ensures that we are not being called from
sys_utimes in which case we ought to fail the call back to sys_utimes in which case we ought to fail the call back to
the user when the server rejects the call */ the user when the server rejects the call */
if((rc) && (attrs->ia_valid & if ((rc) && (attrs->ia_valid &
(ATTR_MODE | ATTR_GID | ATTR_UID | ATTR_SIZE))) (ATTR_MODE | ATTR_GID | ATTR_UID | ATTR_SIZE)))
rc = 0; rc = 0;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* vfs operations that deal with io control * vfs operations that deal with io control
* *
* Copyright (C) International Business Machines Corp., 2005 * Copyright (C) International Business Machines Corp., 2005,2007
* Author(s): Steve French (sfrench@us.ibm.com) * Author(s): Steve French (sfrench@us.ibm.com)
* *
* This library is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or modify
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) #define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
int cifs_ioctl (struct inode * inode, struct file * filep, int cifs_ioctl (struct inode *inode, struct file *filep,
unsigned int command, unsigned long arg) unsigned int command, unsigned long arg)
{ {
int rc = -ENOTTY; /* strange error - but the precedent */ int rc = -ENOTTY; /* strange error - but the precedent */
......
...@@ -50,32 +50,32 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, ...@@ -50,32 +50,32 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
fromName = build_path_from_dentry(old_file); fromName = build_path_from_dentry(old_file);
toName = build_path_from_dentry(direntry); toName = build_path_from_dentry(direntry);
if((fromName == NULL) || (toName == NULL)) { if ((fromName == NULL) || (toName == NULL)) {
rc = -ENOMEM; rc = -ENOMEM;
goto cifs_hl_exit; goto cifs_hl_exit;
} }
if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX) if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX)
rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName,
cifs_sb_target->local_nls, cifs_sb_target->local_nls,
cifs_sb_target->mnt_cifs_flags & cifs_sb_target->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
else { else {
rc = CIFSCreateHardLink(xid, pTcon, fromName, toName, rc = CIFSCreateHardLink(xid, pTcon, fromName, toName,
cifs_sb_target->local_nls, cifs_sb_target->local_nls,
cifs_sb_target->mnt_cifs_flags & cifs_sb_target->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if((rc == -EIO) || (rc == -EINVAL)) if ((rc == -EIO) || (rc == -EINVAL))
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
} }
d_drop(direntry); /* force new lookup from server of target */ d_drop(direntry); /* force new lookup from server of target */
/* if source file is cached (oplocked) revalidate will not go to server /* if source file is cached (oplocked) revalidate will not go to server
until the file is closed or oplock broken so update nlinks locally */ until the file is closed or oplock broken so update nlinks locally */
if(old_file->d_inode) { if (old_file->d_inode) {
cifsInode = CIFS_I(old_file->d_inode); cifsInode = CIFS_I(old_file->d_inode);
if(rc == 0) { if (rc == 0) {
old_file->d_inode->i_nlink++; old_file->d_inode->i_nlink++;
/* BB should we make this contingent on superblock flag NOATIME? */ /* BB should we make this contingent on superblock flag NOATIME? */
/* old_file->d_inode->i_ctime = CURRENT_TIME;*/ /* old_file->d_inode->i_ctime = CURRENT_TIME;*/
...@@ -84,14 +84,14 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, ...@@ -84,14 +84,14 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
to set the parent dir cifs inode time to zero to set the parent dir cifs inode time to zero
to force revalidate (faster) for it too? */ to force revalidate (faster) for it too? */
} }
/* if not oplocked will force revalidate to get info /* if not oplocked will force revalidate to get info
on source file from srv */ on source file from srv */
cifsInode->time = 0; cifsInode->time = 0;
/* Will update parent dir timestamps from srv within a second. /* Will update parent dir timestamps from srv within a second.
Would it really be worth it to set the parent dir (cifs Would it really be worth it to set the parent dir (cifs
inode) time field to zero to force revalidate on parent inode) time field to zero to force revalidate on parent
directory faster ie directory faster ie
CIFS_I(inode)->time = 0; */ CIFS_I(inode)->time = 0; */
} }
...@@ -109,7 +109,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) ...@@ -109,7 +109,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
int rc = -EACCES; int rc = -EACCES;
int xid; int xid;
char *full_path = NULL; char *full_path = NULL;
char * target_path = ERR_PTR(-ENOMEM); char *target_path = ERR_PTR(-ENOMEM);
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
...@@ -129,7 +129,8 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) ...@@ -129,7 +129,8 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
goto out; goto out;
} }
/* BB add read reparse point symlink code and Unix extensions symlink code here BB */ /* BB add read reparse point symlink code and Unix extensions
symlink code here BB */
if (pTcon->ses->capabilities & CAP_UNIX) if (pTcon->ses->capabilities & CAP_UNIX)
rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path,
target_path, target_path,
...@@ -176,7 +177,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) ...@@ -176,7 +177,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if(full_path == NULL) { if (full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
} }
...@@ -189,15 +190,16 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) ...@@ -189,15 +190,16 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname, rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname,
cifs_sb->local_nls); cifs_sb->local_nls);
/* else /* else
rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,cifs_sb_target->local_nls); */ rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,
cifs_sb_target->local_nls); */
if (rc == 0) { if (rc == 0) {
if (pTcon->ses->capabilities & CAP_UNIX) if (pTcon->ses->capabilities & CAP_UNIX)
rc = cifs_get_inode_info_unix(&newinode, full_path, rc = cifs_get_inode_info_unix(&newinode, full_path,
inode->i_sb,xid); inode->i_sb, xid);
else else
rc = cifs_get_inode_info(&newinode, full_path, NULL, rc = cifs_get_inode_info(&newinode, full_path, NULL,
inode->i_sb,xid); inode->i_sb, xid);
if (rc != 0) { if (rc != 0) {
cFYI(1, ("Create symlink ok, getinodeinfo fail rc = %d", cFYI(1, ("Create symlink ok, getinodeinfo fail rc = %d",
...@@ -226,9 +228,9 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) ...@@ -226,9 +228,9 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
char *full_path = NULL; char *full_path = NULL;
char *tmp_path = NULL; char *tmp_path = NULL;
char * tmpbuffer; char *tmpbuffer;
unsigned char * referrals = NULL; unsigned char *referrals = NULL;
int num_referrals = 0; int num_referrals = 0;
int len; int len;
__u16 fid; __u16 fid;
...@@ -237,13 +239,13 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) ...@@ -237,13 +239,13 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
/* BB would it be safe against deadlock to grab this sem /* BB would it be safe against deadlock to grab this sem
even though rename itself grabs the sem and calls lookup? */ even though rename itself grabs the sem and calls lookup? */
/* mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/ /* mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
/* mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/ /* mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/
if(full_path == NULL) { if (full_path == NULL) {
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
} }
...@@ -251,70 +253,77 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) ...@@ -251,70 +253,77 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
cFYI(1, cFYI(1,
("Full path: %s inode = 0x%p pBuffer = 0x%p buflen = %d", ("Full path: %s inode = 0x%p pBuffer = 0x%p buflen = %d",
full_path, inode, pBuffer, buflen)); full_path, inode, pBuffer, buflen));
if(buflen > PATH_MAX) if (buflen > PATH_MAX)
len = PATH_MAX; len = PATH_MAX;
else else
len = buflen; len = buflen;
tmpbuffer = kmalloc(len,GFP_KERNEL); tmpbuffer = kmalloc(len, GFP_KERNEL);
if(tmpbuffer == NULL) { if (tmpbuffer == NULL) {
kfree(full_path); kfree(full_path);
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return -ENOMEM;
} }
/* BB add read reparse point symlink code and Unix extensions symlink code here BB */ /* BB add read reparse point symlink code and
Unix extensions symlink code here BB */
if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)
rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path,
tmpbuffer, tmpbuffer,
len - 1, len - 1,
cifs_sb->local_nls); cifs_sb->local_nls);
else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
cERROR(1,("SFU style symlinks not implemented yet")); cERROR(1, ("SFU style symlinks not implemented yet"));
/* add open and read as in fs/cifs/inode.c */ /* add open and read as in fs/cifs/inode.c */
} else { } else {
rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ,
OPEN_REPARSE_POINT,&fid, &oplock, NULL, OPEN_REPARSE_POINT, &fid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if(!rc) { if (!rc) {
rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path, rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path,
tmpbuffer, tmpbuffer,
len - 1, len - 1,
fid, fid,
cifs_sb->local_nls); cifs_sb->local_nls);
if(CIFSSMBClose(xid, pTcon, fid)) { if (CIFSSMBClose(xid, pTcon, fid)) {
cFYI(1,("Error closing junction point (open for ioctl)")); cFYI(1,("Error closing junction point (open for ioctl)"));
} }
if(rc == -EIO) { if (rc == -EIO) {
/* Query if DFS Junction */ /* Query if DFS Junction */
tmp_path = tmp_path =
kmalloc(MAX_TREE_SIZE + MAX_PATHCONF + 1, kmalloc(MAX_TREE_SIZE + MAX_PATHCONF + 1,
GFP_KERNEL); GFP_KERNEL);
if (tmp_path) { if (tmp_path) {
strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); strncpy(tmp_path, pTcon->treeName,
strncat(tmp_path, full_path, MAX_PATHCONF); MAX_TREE_SIZE);
rc = get_dfs_path(xid, pTcon->ses, tmp_path, strncat(tmp_path, full_path,
MAX_PATHCONF);
rc = get_dfs_path(xid, pTcon->ses,
tmp_path,
cifs_sb->local_nls, cifs_sb->local_nls,
&num_referrals, &referrals, &num_referrals, &referrals,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
cFYI(1,("Get DFS for %s rc = %d ",tmp_path, rc)); cFYI(1, ("Get DFS for %s rc = %d ",
if((num_referrals == 0) && (rc == 0)) tmp_path, rc));
if ((num_referrals == 0) && (rc == 0))
rc = -EACCES; rc = -EACCES;
else { else {
cFYI(1,("num referral: %d",num_referrals)); cFYI(1, ("num referral: %d",
if(referrals) { num_referrals));
cFYI(1,("referral string: %s",referrals)); if (referrals) {
strncpy(tmpbuffer, referrals, len-1); cFYI(1,("referral string: %s", referrals));
strncpy(tmpbuffer, referrals, len-1);
} }
} }
kfree(referrals); kfree(referrals);
kfree(tmp_path); kfree(tmp_path);
} }
/* BB add code like else decode referrals then memcpy to /* BB add code like else decode referrals
tmpbuffer and free referrals string array BB */ then memcpy to tmpbuffer and free referrals
string array BB */
} }
} }
} }
......
/* /*
Unix SMB/Netbios implementation. Unix SMB/Netbios implementation.
Version 1.9. Version 1.9.
a implementation of MD4 designed for use in the SMB authentication protocol a implementation of MD4 designed for use in the SMB authentication protocol
...@@ -170,7 +170,7 @@ mdfour(unsigned char *out, unsigned char *in, int n) ...@@ -170,7 +170,7 @@ mdfour(unsigned char *out, unsigned char *in, int n)
while (n > 64) { while (n > 64) {
copy64(M, in); copy64(M, in);
mdfour64(M,&A,&B, &C, &D); mdfour64(M, &A, &B, &C, &D);
in += 64; in += 64;
n -= 64; n -= 64;
} }
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
* will fill a supplied 16-byte array with the digest. * will fill a supplied 16-byte array with the digest.
*/ */
/* This code slightly modified to fit into Samba by /* This code slightly modified to fit into Samba by
abartlet@samba.org Jun 2001 abartlet@samba.org Jun 2001
and to fit the cifs vfs by and to fit the cifs vfs by
Steve French sfrench@us.ibm.com */ Steve French sfrench@us.ibm.com */
#include <linux/string.h> #include <linux/string.h>
...@@ -106,7 +106,7 @@ MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) ...@@ -106,7 +106,7 @@ MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
} }
/* /*
* Final wrapup - pad to 64-byte boundary with the bit pattern * Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first) * 1 0* (64-bit count of bits processed, MSB-first)
*/ */
void void
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software * along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/slab.h> #include <linux/slab.h>
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
extern mempool_t *cifs_sm_req_poolp; extern mempool_t *cifs_sm_req_poolp;
extern mempool_t *cifs_req_poolp; extern mempool_t *cifs_req_poolp;
extern struct task_struct * oplockThread; extern struct task_struct *oplockThread;
/* The xid serves as a useful identifier for each incoming vfs request, /* The xid serves as a useful identifier for each incoming vfs request,
in a similar way to the mid which is useful to track each sent smb, in a similar way to the mid which is useful to track each sent smb,
and CurrentXid can also provide a running counter (although it and CurrentXid can also provide a running counter (although it
will eventually wrap past zero) of the total vfs operations handled will eventually wrap past zero) of the total vfs operations handled
since the cifs fs was mounted */ since the cifs fs was mounted */
unsigned int unsigned int
...@@ -50,7 +50,7 @@ _GetXid(void) ...@@ -50,7 +50,7 @@ _GetXid(void)
if (GlobalTotalActiveXid > GlobalMaxActiveXid) if (GlobalTotalActiveXid > GlobalMaxActiveXid)
GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */ GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */
if (GlobalTotalActiveXid > 65000) if (GlobalTotalActiveXid > 65000)
cFYI(1,("warning: more than 65000 requests active")); cFYI(1, ("warning: more than 65000 requests active"));
xid = GlobalCurrentXid++; xid = GlobalCurrentXid++;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
return xid; return xid;
...@@ -144,9 +144,9 @@ cifs_buf_get(void) ...@@ -144,9 +144,9 @@ cifs_buf_get(void)
{ {
struct smb_hdr *ret_buf = NULL; struct smb_hdr *ret_buf = NULL;
/* We could use negotiated size instead of max_msgsize - /* We could use negotiated size instead of max_msgsize -
but it may be more efficient to always alloc same size but it may be more efficient to always alloc same size
albeit slightly larger than necessary and maxbuffersize albeit slightly larger than necessary and maxbuffersize
defaults to this and can not be bigger */ defaults to this and can not be bigger */
ret_buf = ret_buf =
(struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS); (struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS);
...@@ -172,7 +172,7 @@ cifs_buf_release(void *buf_to_free) ...@@ -172,7 +172,7 @@ cifs_buf_release(void *buf_to_free)
/* cFYI(1, ("Null buffer passed to cifs_buf_release"));*/ /* cFYI(1, ("Null buffer passed to cifs_buf_release"));*/
return; return;
} }
mempool_free(buf_to_free,cifs_req_poolp); mempool_free(buf_to_free, cifs_req_poolp);
atomic_dec(&bufAllocCount); atomic_dec(&bufAllocCount);
return; return;
...@@ -183,9 +183,9 @@ cifs_small_buf_get(void) ...@@ -183,9 +183,9 @@ cifs_small_buf_get(void)
{ {
struct smb_hdr *ret_buf = NULL; struct smb_hdr *ret_buf = NULL;
/* We could use negotiated size instead of max_msgsize - /* We could use negotiated size instead of max_msgsize -
but it may be more efficient to always alloc same size but it may be more efficient to always alloc same size
albeit slightly larger than necessary and maxbuffersize albeit slightly larger than necessary and maxbuffersize
defaults to this and can not be bigger */ defaults to this and can not be bigger */
ret_buf = ret_buf =
(struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS); (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS);
...@@ -209,30 +209,30 @@ cifs_small_buf_release(void *buf_to_free) ...@@ -209,30 +209,30 @@ cifs_small_buf_release(void *buf_to_free)
cFYI(1, ("Null buffer passed to cifs_small_buf_release")); cFYI(1, ("Null buffer passed to cifs_small_buf_release"));
return; return;
} }
mempool_free(buf_to_free,cifs_sm_req_poolp); mempool_free(buf_to_free, cifs_sm_req_poolp);
atomic_dec(&smBufAllocCount); atomic_dec(&smBufAllocCount);
return; return;
} }
/* /*
Find a free multiplex id (SMB mid). Otherwise there could be Find a free multiplex id (SMB mid). Otherwise there could be
mid collisions which might cause problems, demultiplexing the mid collisions which might cause problems, demultiplexing the
wrong response to this request. Multiplex ids could collide if wrong response to this request. Multiplex ids could collide if
one of a series requests takes much longer than the others, or one of a series requests takes much longer than the others, or
if a very large number of long lived requests (byte range if a very large number of long lived requests (byte range
locks or FindNotify requests) are pending. No more than locks or FindNotify requests) are pending. No more than
64K-1 requests can be outstanding at one time. If no 64K-1 requests can be outstanding at one time. If no
mids are available, return zero. A future optimization mids are available, return zero. A future optimization
could make the combination of mids and uid the key we use could make the combination of mids and uid the key we use
to demultiplex on (rather than mid alone). to demultiplex on (rather than mid alone).
In addition to the above check, the cifs demultiplex In addition to the above check, the cifs demultiplex
code already used the command code as a secondary code already used the command code as a secondary
check of the frame and if signing is negotiated the check of the frame and if signing is negotiated the
response would be discarded if the mid were the same response would be discarded if the mid were the same
but the signature was wrong. Since the mid is not put in the but the signature was wrong. Since the mid is not put in the
pending queue until later (when it is about to be dispatched) pending queue until later (when it is about to be dispatched)
we do have to limit the number of outstanding requests we do have to limit the number of outstanding requests
to somewhat less than 64K-1 although it is hard to imagine to somewhat less than 64K-1 although it is hard to imagine
so many threads being in the vfs at one time. so many threads being in the vfs at one time.
*/ */
...@@ -240,7 +240,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server) ...@@ -240,7 +240,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
{ {
__u16 mid = 0; __u16 mid = 0;
__u16 last_mid; __u16 last_mid;
int collision; int collision;
if (server == NULL) if (server == NULL)
return mid; return mid;
...@@ -249,13 +249,13 @@ __u16 GetNextMid(struct TCP_Server_Info *server) ...@@ -249,13 +249,13 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
last_mid = server->CurrentMid; /* we do not want to loop forever */ last_mid = server->CurrentMid; /* we do not want to loop forever */
server->CurrentMid++; server->CurrentMid++;
/* This nested loop looks more expensive than it is. /* This nested loop looks more expensive than it is.
In practice the list of pending requests is short, In practice the list of pending requests is short,
fewer than 50, and the mids are likely to be unique fewer than 50, and the mids are likely to be unique
on the first pass through the loop unless some request on the first pass through the loop unless some request
takes longer than the 64 thousand requests before it takes longer than the 64 thousand requests before it
(and it would also have to have been a request that (and it would also have to have been a request that
did not time out) */ did not time out) */
while(server->CurrentMid != last_mid) { while (server->CurrentMid != last_mid) {
struct list_head *tmp; struct list_head *tmp;
struct mid_q_entry *mid_entry; struct mid_q_entry *mid_entry;
...@@ -290,11 +290,11 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , ...@@ -290,11 +290,11 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
const struct cifsTconInfo *treeCon, int word_count const struct cifsTconInfo *treeCon, int word_count
/* length of fixed section (word count) in two byte units */) /* length of fixed section (word count) in two byte units */)
{ {
struct list_head* temp_item; struct list_head *temp_item;
struct cifsSesInfo * ses; struct cifsSesInfo *ses;
char *temp = (char *) buffer; char *temp = (char *) buffer;
memset(temp,0,256); /* bigger than MAX_CIFS_HDR_SIZE */ memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */
buffer->smb_buf_length = buffer->smb_buf_length =
(2 * word_count) + sizeof (struct smb_hdr) - (2 * word_count) + sizeof (struct smb_hdr) -
...@@ -348,7 +348,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , ...@@ -348,7 +348,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
/* flag were disabled. */ /* flag were disabled. */
/* BB Add support for establishing new tCon and SMB Session */ /* BB Add support for establishing new tCon and SMB Session */
/* with userid/password pairs found on the smb session */ /* with userid/password pairs found on the smb session */
/* for other target tcp/ip addresses BB */ /* for other target tcp/ip addresses BB */
if (current->fsuid != treeCon->ses->linux_uid) { if (current->fsuid != treeCon->ses->linux_uid) {
cFYI(1,("Multiuser mode and UID did not match tcon uid")); cFYI(1,("Multiuser mode and UID did not match tcon uid"));
...@@ -357,12 +357,12 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , ...@@ -357,12 +357,12 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList);
if (ses->linux_uid == current->fsuid) { if (ses->linux_uid == current->fsuid) {
if (ses->server == treeCon->ses->server) { if (ses->server == treeCon->ses->server) {
cFYI(1,("found matching uid substitute right smb_uid")); cFYI(1, ("found matching uid substitute right smb_uid"));
buffer->Uid = ses->Suid; buffer->Uid = ses->Suid;
break; break;
} else { } else {
/* BB eventually call cifs_setup_session here */ /* BB eventually call cifs_setup_session here */
cFYI(1,("local UID found but smb sess with this server does not exist")); cFYI(1, ("local UID found but no smb sess with this server exists"));
} }
} }
} }
...@@ -388,18 +388,18 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , ...@@ -388,18 +388,18 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
static int static int
checkSMBhdr(struct smb_hdr *smb, __u16 mid) checkSMBhdr(struct smb_hdr *smb, __u16 mid)
{ {
/* Make sure that this really is an SMB, that it is a response, /* Make sure that this really is an SMB, that it is a response,
and that the message ids match */ and that the message ids match */
if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) && if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) &&
(mid == smb->Mid)) { (mid == smb->Mid)) {
if (smb->Flags & SMBFLG_RESPONSE) if (smb->Flags & SMBFLG_RESPONSE)
return 0; return 0;
else { else {
/* only one valid case where server sends us request */ /* only one valid case where server sends us request */
if (smb->Command == SMB_COM_LOCKING_ANDX) if (smb->Command == SMB_COM_LOCKING_ANDX)
return 0; return 0;
else else
cERROR(1, ("Rcvd Request not response")); cERROR(1, ("Received Request not response"));
} }
} else { /* bad signature or mid */ } else { /* bad signature or mid */
if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff))
...@@ -426,9 +426,9 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) ...@@ -426,9 +426,9 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
smb->WordCount = 0; smb->WordCount = 0;
/* some error cases do not return wct and bcc */ /* some error cases do not return wct and bcc */
return 0; return 0;
} else if ((length == sizeof(struct smb_hdr) + 1) && } else if ((length == sizeof(struct smb_hdr) + 1) &&
(smb->WordCount == 0)) { (smb->WordCount == 0)) {
char * tmp = (char *)smb; char *tmp = (char *)smb;
/* Need to work around a bug in two servers here */ /* Need to work around a bug in two servers here */
/* First, check if the part of bcc they sent was zero */ /* First, check if the part of bcc they sent was zero */
if (tmp[sizeof(struct smb_hdr)] == 0) { if (tmp[sizeof(struct smb_hdr)] == 0) {
...@@ -442,7 +442,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) ...@@ -442,7 +442,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
tmp[sizeof(struct smb_hdr)+1] = 0; tmp[sizeof(struct smb_hdr)+1] = 0;
return 0; return 0;
} }
cERROR(1,("rcvd invalid byte count (bcc)")); cERROR(1, ("rcvd invalid byte count (bcc)"));
} else { } else {
cERROR(1, ("Length less than smb header size")); cERROR(1, ("Length less than smb header size"));
} }
...@@ -468,15 +468,15 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) ...@@ -468,15 +468,15 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
if ((len > 64 * 1024) && (len > clc_len)) { if ((len > 64 * 1024) && (len > clc_len)) {
/* check if lengths match mod 64K */ /* check if lengths match mod 64K */
if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF)) if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF))
return 0; /* bcc wrapped */ return 0; /* bcc wrapped */
} }
cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d", cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d",
clc_len, 4 + len, smb->Mid)); clc_len, 4 + len, smb->Mid));
/* Windows XP can return a few bytes too much, presumably /* Windows XP can return a few bytes too much, presumably
an illegal pad, at the end of byte range lock responses an illegal pad, at the end of byte range lock responses
so we allow for that three byte pad, as long as actual so we allow for that three byte pad, as long as actual
received length is as long or longer than calculated length */ received length is as long or longer than calculated length */
/* We have now had to extend this more, since there is a /* We have now had to extend this more, since there is a
case in which it needs to be bigger still to handle a case in which it needs to be bigger still to handle a
malformed response to transact2 findfirst from WinXP when malformed response to transact2 findfirst from WinXP when
access denied is returned and thus bcc and wct are zero access denied is returned and thus bcc and wct are zero
...@@ -495,37 +495,38 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) ...@@ -495,37 +495,38 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
} }
int int
is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
{ {
struct smb_com_lock_req * pSMB = (struct smb_com_lock_req *)buf; struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf;
struct list_head *tmp; struct list_head *tmp;
struct list_head *tmp1; struct list_head *tmp1;
struct cifsTconInfo *tcon; struct cifsTconInfo *tcon;
struct cifsFileInfo *netfile; struct cifsFileInfo *netfile;
cFYI(1,("Checking for oplock break or dnotify response")); cFYI(1, ("Checking for oplock break or dnotify response"));
if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) && if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) &&
(pSMB->hdr.Flags & SMBFLG_RESPONSE)) { (pSMB->hdr.Flags & SMBFLG_RESPONSE)) {
struct smb_com_transaction_change_notify_rsp * pSMBr = struct smb_com_transaction_change_notify_rsp *pSMBr =
(struct smb_com_transaction_change_notify_rsp *)buf; (struct smb_com_transaction_change_notify_rsp *)buf;
struct file_notify_information * pnotify; struct file_notify_information *pnotify;
__u32 data_offset = 0; __u32 data_offset = 0;
if (pSMBr->ByteCount > sizeof(struct file_notify_information)) { if (pSMBr->ByteCount > sizeof(struct file_notify_information)) {
data_offset = le32_to_cpu(pSMBr->DataOffset); data_offset = le32_to_cpu(pSMBr->DataOffset);
pnotify = (struct file_notify_information *) pnotify = (struct file_notify_information *)
((char *)&pSMBr->hdr.Protocol + data_offset); ((char *)&pSMBr->hdr.Protocol + data_offset);
cFYI(1,("dnotify on %s Action: 0x%x",pnotify->FileName, cFYI(1,("dnotify on %s Action: 0x%x", pnotify->FileName,
pnotify->Action)); /* BB removeme BB */ pnotify->Action)); /* BB removeme BB */
/* cifs_dump_mem("Rcvd notify Data: ",buf, /* cifs_dump_mem("Rcvd notify Data: ",buf,
sizeof(struct smb_hdr)+60); */ sizeof(struct smb_hdr)+60); */
return TRUE; return TRUE;
} }
if (pSMBr->hdr.Status.CifsError) { if (pSMBr->hdr.Status.CifsError) {
cFYI(1,("notify err 0x%d",pSMBr->hdr.Status.CifsError)); cFYI(1, ("notify err 0x%d",
pSMBr->hdr.Status.CifsError));
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
return FALSE; return FALSE;
if (pSMB->hdr.Flags & SMBFLG_RESPONSE) { if (pSMB->hdr.Flags & SMBFLG_RESPONSE) {
...@@ -533,13 +534,13 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) ...@@ -533,13 +534,13 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
break - harmless race between close request and oplock break - harmless race between close request and oplock
break response is expected from time to time writing out break response is expected from time to time writing out
large dirty files cached on the client */ large dirty files cached on the client */
if ((NT_STATUS_INVALID_HANDLE) == if ((NT_STATUS_INVALID_HANDLE) ==
le32_to_cpu(pSMB->hdr.Status.CifsError)) { le32_to_cpu(pSMB->hdr.Status.CifsError)) {
cFYI(1,("invalid handle on oplock break")); cFYI(1, ("invalid handle on oplock break"));
return TRUE; return TRUE;
} else if (ERRbadfid == } else if (ERRbadfid ==
le16_to_cpu(pSMB->hdr.Status.DosError.Error)) { le16_to_cpu(pSMB->hdr.Status.DosError.Error)) {
return TRUE; return TRUE;
} else { } else {
return FALSE; /* on valid oplock brk we get "request" */ return FALSE; /* on valid oplock brk we get "request" */
} }
...@@ -547,9 +548,10 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) ...@@ -547,9 +548,10 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
if (pSMB->hdr.WordCount != 8) if (pSMB->hdr.WordCount != 8)
return FALSE; return FALSE;
cFYI(1,(" oplock type 0x%d level 0x%d",pSMB->LockType,pSMB->OplockLevel)); cFYI(1, ("oplock type 0x%d level 0x%d",
pSMB->LockType, pSMB->OplockLevel));
if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE))
return FALSE; return FALSE;
/* look up tcon based on tid & uid */ /* look up tcon based on tid & uid */
read_lock(&GlobalSMBSeslock); read_lock(&GlobalSMBSeslock);
...@@ -557,14 +559,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) ...@@ -557,14 +559,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
if ((tcon->tid == buf->Tid) && (srv == tcon->ses->server)) { if ((tcon->tid == buf->Tid) && (srv == tcon->ses->server)) {
cifs_stats_inc(&tcon->num_oplock_brks); cifs_stats_inc(&tcon->num_oplock_brks);
list_for_each(tmp1,&tcon->openFileList){ list_for_each(tmp1, &tcon->openFileList) {
netfile = list_entry(tmp1,struct cifsFileInfo, netfile = list_entry(tmp1, struct cifsFileInfo,
tlist); tlist);
if (pSMB->Fid == netfile->netfid) { if (pSMB->Fid == netfile->netfid) {
struct cifsInodeInfo *pCifsInode; struct cifsInodeInfo *pCifsInode;
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
cFYI(1,("file id match, oplock break")); cFYI(1,("file id match, oplock break"));
pCifsInode = pCifsInode =
CIFS_I(netfile->pInode); CIFS_I(netfile->pInode);
pCifsInode->clientCanCacheAll = FALSE; pCifsInode->clientCanCacheAll = FALSE;
if (pSMB->OplockLevel == 0) if (pSMB->OplockLevel == 0)
...@@ -581,12 +583,12 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) ...@@ -581,12 +583,12 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
} }
} }
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
cFYI(1,("No matching file for oplock break")); cFYI(1, ("No matching file for oplock break"));
return TRUE; return TRUE;
} }
} }
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
cFYI(1,("Can not process oplock break for non-existent connection")); cFYI(1, ("Can not process oplock break for non-existent connection"));
return TRUE; return TRUE;
} }
...@@ -643,13 +645,13 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length) ...@@ -643,13 +645,13 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length)
only legal in POSIX-like OS (if they are present in the string). Path only legal in POSIX-like OS (if they are present in the string). Path
names are little endian 16 bit Unicode on the wire */ names are little endian 16 bit Unicode on the wire */
int int
cifs_convertUCSpath(char *target, const __le16 * source, int maxlen, cifs_convertUCSpath(char *target, const __le16 *source, int maxlen,
const struct nls_table * cp) const struct nls_table *cp)
{ {
int i,j,len; int i, j, len;
__u16 src_char; __u16 src_char;
for(i = 0, j = 0; i < maxlen; i++) { for (i = 0, j = 0; i < maxlen; i++) {
src_char = le16_to_cpu(source[i]); src_char = le16_to_cpu(source[i]);
switch (src_char) { switch (src_char) {
case 0: case 0:
...@@ -678,8 +680,8 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen, ...@@ -678,8 +680,8 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
case UNI_LESSTHAN: case UNI_LESSTHAN:
target[j] = '<'; target[j] = '<';
break; break;
default: default:
len = cp->uni2char(src_char, &target[j], len = cp->uni2char(src_char, &target[j],
NLS_MAX_CHARSET_SIZE); NLS_MAX_CHARSET_SIZE);
if (len > 0) { if (len > 0) {
j += len; j += len;
...@@ -703,10 +705,10 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen, ...@@ -703,10 +705,10 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
only legal in POSIX-like OS (if they are present in the string). Path only legal in POSIX-like OS (if they are present in the string). Path
names are little endian 16 bit Unicode on the wire */ names are little endian 16 bit Unicode on the wire */
int int
cifsConvertToUCS(__le16 * target, const char *source, int maxlen, cifsConvertToUCS(__le16 *target, const char *source, int maxlen,
const struct nls_table * cp, int mapChars) const struct nls_table *cp, int mapChars)
{ {
int i,j,charlen; int i, j, charlen;
int len_remaining = maxlen; int len_remaining = maxlen;
char src_char; char src_char;
__u16 temp; __u16 temp;
...@@ -714,7 +716,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, ...@@ -714,7 +716,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
if (!mapChars) if (!mapChars)
return cifs_strtoUCS(target, source, PATH_MAX, cp); return cifs_strtoUCS(target, source, PATH_MAX, cp);
for(i = 0, j = 0; i < maxlen; j++) { for (i = 0, j = 0; i < maxlen; j++) {
src_char = source[i]; src_char = source[i];
switch (src_char) { switch (src_char) {
case 0: case 0:
...@@ -737,7 +739,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, ...@@ -737,7 +739,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
break; break;
case '|': case '|':
target[j] = cpu_to_le16(UNI_PIPE); target[j] = cpu_to_le16(UNI_PIPE);
break; break;
/* BB We can not handle remapping slash until /* BB We can not handle remapping slash until
all the calls to build_path_from_dentry all the calls to build_path_from_dentry
are modified, as they use slash as separator BB */ are modified, as they use slash as separator BB */
...@@ -758,7 +760,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, ...@@ -758,7 +760,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
/* character may take more than one byte in the /* character may take more than one byte in the
the source string, but will take exactly two the source string, but will take exactly two
bytes in the target string */ bytes in the target string */
i+= charlen; i += charlen;
continue; continue;
} }
i++; /* move to next char in source string */ i++; /* move to next char in source string */
......
...@@ -145,7 +145,7 @@ cifs_inet_pton(int address_family, char *cp, void *dst) ...@@ -145,7 +145,7 @@ cifs_inet_pton(int address_family, char *cp, void *dst)
ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
} }
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("address conversion returned %d for %s", ret, cp)); cFYI(1, ("address conversion returned %d for %s", ret, cp));
#endif #endif
if (ret > 0) if (ret > 0)
ret = 1; ret = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment