1
0
Fork 0

[CIFS] more whitespace cleanup

Signed-off-by: Steve French <sfrench@us.ibm.com>
hifive-unleashed-5.1
Steve French 2007-07-07 19:25:05 +00:00
parent 6dc0f87e35
commit 790fe579f5
7 changed files with 541 additions and 535 deletions

View File

@ -98,7 +98,7 @@ cifs_read_super(struct super_block *sb, void *data,
/* BB should we make this contingent on mount parm? */
sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL);
sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
cifs_sb = CIFS_SB(sb);
if (cifs_sb == NULL)
return -ENOMEM;
@ -117,9 +117,10 @@ cifs_read_super(struct super_block *sb, void *data,
#ifdef CONFIG_CIFS_EXPERIMENTAL
if (experimEnabled != 0)
sb->s_export_op = &cifs_export_ops;
#endif /* EXPERIMENTAL */
#endif /* EXPERIMENTAL */
/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
sb->s_blocksize =
cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
#ifdef CONFIG_CIFS_QUOTA
sb->s_qcop = &cifs_quotactl_ops;
#endif
@ -164,10 +165,10 @@ cifs_put_super(struct super_block *sb)
cFYI(1, ("In cifs_put_super"));
cifs_sb = CIFS_SB(sb);
if (cifs_sb == NULL) {
cFYI(1,("Empty cifs superblock info passed to unmount"));
cFYI(1, ("Empty cifs superblock info passed to unmount"));
return;
}
rc = cifs_umount(sb, cifs_sb);
rc = cifs_umount(sb, cifs_sb);
if (rc) {
cERROR(1, ("cifs_umount failed with return code %d", rc));
}
@ -180,7 +181,7 @@ static int
cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
{
struct super_block *sb = dentry->d_sb;
int xid;
int xid;
int rc = -EOPNOTSUPP;
struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon;
@ -193,7 +194,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_type = CIFS_MAGIC_NUMBER;
/* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */
buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would
buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would
presumably be total path, but note
that some servers (includinng Samba 3)
have a shorter maximum path */
@ -217,8 +218,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
bypassed it because we detected that this was an older LANMAN sess */
if (rc)
rc = SMBOldQFSInfo(xid, pTcon, buf);
/*
int f_type;
/* int f_type;
__fsid_t f_fsid;
int f_namelen; */
/* BB get from info in tcon struct at mount time call to QFSAttrInfo */

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/*
* fs/cifs/misc.c
*
* Copyright (C) International Business Machines Corp., 2002,2005
* Copyright (C) International Business Machines Corp., 2002,2007
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
@ -49,7 +49,7 @@ _GetXid(void)
GlobalTotalActiveXid++;
if (GlobalTotalActiveXid > GlobalMaxActiveXid)
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"));
xid = GlobalCurrentXid++;
spin_unlock(&GlobalMid_Lock);
@ -60,7 +60,7 @@ void
_FreeXid(unsigned int xid)
{
spin_lock(&GlobalMid_Lock);
/* if(GlobalTotalActiveXid == 0)
/* if (GlobalTotalActiveXid == 0)
BUG(); */
GlobalTotalActiveXid--;
spin_unlock(&GlobalMid_Lock);
@ -242,7 +242,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
__u16 last_mid;
int collision;
if(server == NULL)
if (server == NULL)
return mid;
spin_lock(&GlobalMid_Lock);
@ -260,7 +260,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
struct mid_q_entry *mid_entry;
collision = 0;
if(server->CurrentMid == 0)
if (server->CurrentMid == 0)
server->CurrentMid++;
list_for_each(tmp, &server->pending_mid_q) {
@ -273,7 +273,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
break;
}
}
if(collision == 0) {
if (collision == 0) {
mid = server->CurrentMid;
break;
}
@ -325,7 +325,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
/* Uid is not converted */
buffer->Uid = treeCon->ses->Suid;
buffer->Mid = GetNextMid(treeCon->ses->server);
if(multiuser_mount != 0) {
if (multiuser_mount != 0) {
/* For the multiuser case, there are few obvious technically */
/* possible mechanisms to match the local linux user (uid) */
/* to a valid remote smb user (smb_uid): */
@ -350,13 +350,13 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
/* BB Add support for establishing new tCon and SMB Session */
/* with userid/password pairs found on the smb session */
/* 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"));
read_lock(&GlobalSMBSeslock);
list_for_each(temp_item, &GlobalSMBSessionList) {
ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList);
if(ses->linux_uid == current->fsuid) {
if(ses->server == treeCon->ses->server) {
if (ses->linux_uid == current->fsuid) {
if (ses->server == treeCon->ses->server) {
cFYI(1,("found matching uid substitute right smb_uid"));
buffer->Uid = ses->Suid;
break;
@ -374,8 +374,8 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
buffer->Flags2 |= SMBFLG2_DFS;
if (treeCon->nocase)
buffer->Flags |= SMBFLG_CASELESS;
if((treeCon->ses) && (treeCon->ses->server))
if(treeCon->ses->server->secMode &
if ((treeCon->ses) && (treeCon->ses->server))
if (treeCon->ses->server->secMode &
(SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
}
@ -392,11 +392,11 @@ checkSMBhdr(struct smb_hdr *smb, __u16 mid)
and that the message ids match */
if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) &&
(mid == smb->Mid)) {
if(smb->Flags & SMBFLG_RESPONSE)
if (smb->Flags & SMBFLG_RESPONSE)
return 0;
else {
/* 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;
else
cERROR(1, ("Rcvd Request not response"));
@ -458,16 +458,16 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
return 1;
clc_len = smbCalcSize_LE(smb);
if(4 + len != length) {
if (4 + len != length) {
cERROR(1, ("Length read does not match RFC1001 length %d",len));
return 1;
}
if (4 + len != clc_len) {
/* check if bcc wrapped around for large read responses */
if((len > 64 * 1024) && (len > clc_len)) {
if ((len > 64 * 1024) && (len > clc_len)) {
/* check if lengths match mod 64K */
if(((4 + len) & 0xFFFF) == (clc_len & 0xFFFF))
if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF))
return 0; /* bcc wrapped */
}
cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d",
@ -483,7 +483,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
but server says length is 0x21 bytes too long as if the server
forget to reset the smb rfc1001 length when it reset the
wct and bcc to minimum size and drop the t2 parms and data */
if((4+len > clc_len) && (len <= clc_len + 512))
if ((4+len > clc_len) && (len <= clc_len + 512))
return 0;
else {
cERROR(1, ("RFC1001 size %d bigger than SMB for Mid=%d",
@ -503,13 +503,13 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
struct cifsFileInfo *netfile;
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)) {
struct smb_com_transaction_change_notify_rsp * pSMBr =
(struct smb_com_transaction_change_notify_rsp *)buf;
struct file_notify_information * pnotify;
__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);
pnotify = (struct file_notify_information *)
@ -520,15 +520,15 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
sizeof(struct smb_hdr)+60); */
return TRUE;
}
if(pSMBr->hdr.Status.CifsError) {
if (pSMBr->hdr.Status.CifsError) {
cFYI(1,("notify err 0x%d",pSMBr->hdr.Status.CifsError));
return TRUE;
}
return FALSE;
}
if(pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
return FALSE;
if(pSMB->hdr.Flags & SMBFLG_RESPONSE) {
if (pSMB->hdr.Flags & SMBFLG_RESPONSE) {
/* no sense logging error on invalid handle on oplock
break - harmless race between close request and oplock
break response is expected from time to time writing out
@ -544,11 +544,11 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
return FALSE; /* on valid oplock brk we get "request" */
}
}
if(pSMB->hdr.WordCount != 8)
if (pSMB->hdr.WordCount != 8)
return FALSE;
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;
/* look up tcon based on tid & uid */
@ -560,14 +560,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
list_for_each(tmp1,&tcon->openFileList){
netfile = list_entry(tmp1,struct cifsFileInfo,
tlist);
if(pSMB->Fid == netfile->netfid) {
if (pSMB->Fid == netfile->netfid) {
struct cifsInodeInfo *pCifsInode;
read_unlock(&GlobalSMBSeslock);
cFYI(1,("file id match, oplock break"));
pCifsInode =
CIFS_I(netfile->pInode);
pCifsInode->clientCanCacheAll = FALSE;
if(pSMB->OplockLevel == 0)
if (pSMB->OplockLevel == 0)
pCifsInode->clientCanCacheRead
= FALSE;
pCifsInode->oplockPending = TRUE;
@ -575,7 +575,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
netfile->netfid,
tcon);
cFYI(1,("about to wake up oplock thd"));
if(oplockThread)
if (oplockThread)
wake_up_process(oplockThread);
return TRUE;
}
@ -681,7 +681,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
default:
len = cp->uni2char(src_char, &target[j],
NLS_MAX_CHARSET_SIZE);
if(len > 0) {
if (len > 0) {
j += len;
continue;
} else {
@ -690,7 +690,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
}
j++;
/* make sure we do not overrun callers allocated temp buffer */
if(j >= (2 * NAME_MAX))
if (j >= (2 * NAME_MAX))
break;
}
cUCS_out:
@ -711,7 +711,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
char src_char;
__u16 temp;
if(!mapChars)
if (!mapChars)
return cifs_strtoUCS(target, source, PATH_MAX, cp);
for(i = 0, j = 0; i < maxlen; j++) {
@ -749,7 +749,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
len_remaining, &temp);
/* if no match, use question mark, which
at least in some cases servers as wild card */
if(charlen < 1) {
if (charlen < 1) {
target[j] = cpu_to_le16(0x003f);
charlen = 1;
} else

View File

@ -140,9 +140,9 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
/* calculate length by finding first slash or NULL */
/* BB Should we convert '/' slash to '\' here since it seems already done
before this */
if( address_family == AF_INET ){
if ( address_family == AF_INET ) {
ret = in4_pton(cp, -1 /* len */, dst , '\\', NULL);
} else if( address_family == AF_INET6 ){
} else if ( address_family == AF_INET6 ) {
ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
}
#ifdef CONFIG_CIFS_DEBUG2
@ -773,7 +773,7 @@ map_smb_to_linux_error(struct smb_hdr *smb)
if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
/* translate the newer STATUS codes to old style errors and then to POSIX errors */
__u32 err = le32_to_cpu(smb->Status.CifsError);
if(cifsFYI & CIFS_RC)
if (cifsFYI & CIFS_RC)
cifs_print_status(err);
ntstatus_to_dos(err, &smberrclass, &smberrcode);
} else {
@ -889,15 +889,15 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
sec = 2 * st->TwoSeconds;
min = st->Minutes;
if((sec > 59) || (min > 59))
if ((sec > 59) || (min > 59))
cERROR(1,("illegal time min %d sec %d", min, sec));
sec += (min * 60);
sec += 60 * 60 * st->Hours;
if(st->Hours > 24)
if (st->Hours > 24)
cERROR(1,("illegal hours %d",st->Hours));
days = sd->Day;
month = sd->Month;
if((days > 31) || (month > 12))
if ((days > 31) || (month > 12))
cERROR(1,("illegal date, month %d day: %d", month, days));
month -= 1;
days += total_days_of_prev_months[month];
@ -911,13 +911,13 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
consider 2 special case years, ie the years 2000 and 2100, and only
adjust for the lack of leap year for the year 2100, as 2000 was a
leap year (divisable by 400) */
if(year >= 120) /* the year 2100 */
if (year >= 120) /* the year 2100 */
days = days - 1; /* do not count leap year for the year 2100 */
/* adjust for leap year where we are still before leap day */
if(year != 120)
if (year != 120)
days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
sec += 24 * 60 * 60 * days;
sec += 24 * 60 * 60 * days;
ts.tv_sec = sec;

View File

@ -110,7 +110,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
return rc;
}
static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
static void AdjustForTZ(struct cifsTconInfo *tcon, struct inode *inode)
{
if ((tcon) && (tcon->ses) && (tcon->ses->server)) {
inode->i_ctime.tv_sec += tcon->ses->server->timeAdj;
@ -122,7 +122,7 @@ static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
char * buf, int *pobject_type, int isNewInode)
char *buf, int *pobject_type, int isNewInode)
{
loff_t local_size;
struct timespec local_mtime;
@ -151,7 +151,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
} else { /* legacy, OS2 and DOS style */
/* struct timespec ts;*/
FIND_FILE_STANDARD_INFO * pfindData =
FIND_FILE_STANDARD_INFO * pfindData =
(FIND_FILE_STANDARD_INFO *)buf;
tmp_inode->i_mtime = cnvrtDosUnixTm(
@ -176,7 +176,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
/* treat dos attribute of read-only as read-only mode bit e.g. 555? */
/* 2767 perms - indicate mandatory locking */
/* 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 */
if (atomic_read(&cifsInfo->inUse) == 0) {
tmp_inode->i_uid = cifs_sb->mnt_uid;
@ -197,7 +197,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
}
tmp_inode->i_mode |= S_IFDIR;
} else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) &&
} else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) &&
(attr & ATTR_SYSTEM)) {
if (end_of_file == 0) {
*pobject_type = DT_FIFO;
@ -207,13 +207,13 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
inode as needing revalidate and get the real type
(blk vs chr vs. symlink) later ie in lookup */
*pobject_type = DT_REG;
tmp_inode->i_mode |= S_IFREG;
cifsInfo->time = 0;
tmp_inode->i_mode |= S_IFREG;
cifsInfo->time = 0;
}
/* we no longer mark these because we could not follow them */
/* } else if (attr & ATTR_REPARSE) {
*pobject_type = DT_LNK;
tmp_inode->i_mode |= S_IFLNK; */
*pobject_type = DT_LNK;
tmp_inode->i_mode |= S_IFLNK; */
} else {
*pobject_type = DT_REG;
tmp_inode->i_mode |= S_IFREG;
@ -221,7 +221,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
tmp_inode->i_mode &= ~(S_IWUGO);
else if ((tmp_inode->i_mode & S_IWUGO) == 0)
/* the ATTR_READONLY flag may have been changed on */
/* server -- set any w bits allowed by mnt_file_mode */
/* server -- set any w bits allowed by mnt_file_mode */
tmp_inode->i_mode |= (S_IWUGO & cifs_sb->mnt_file_mode);
} /* could add code here - to validate if device or weird share type? */
@ -232,7 +232,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
spin_lock(&tmp_inode->i_lock);
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 */
i_size_write(tmp_inode, end_of_file);
@ -323,8 +323,8 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
tmp_inode->i_mode = le64_to_cpu(pfindData->Permissions);
/* since we set the inode type below we need to mask off type
to avoid strange results if bits above were corrupt */
tmp_inode->i_mode &= ~S_IFMT;
to avoid strange results if bits above were corrupt */
tmp_inode->i_mode &= ~S_IFMT;
if (type == UNIX_FILE) {
*pobject_type = DT_REG;
tmp_inode->i_mode |= S_IFREG;
@ -354,7 +354,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
/* safest to just call it a file */
*pobject_type = DT_REG;
tmp_inode->i_mode |= S_IFREG;
cFYI(1,("unknown inode type %d",type));
cFYI(1, ("unknown inode type %d", type));
}
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
@ -369,7 +369,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
spin_lock(&tmp_inode->i_lock);
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 */
i_size_write(tmp_inode, end_of_file);
@ -394,15 +394,16 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
tmp_inode->i_fop = &cifs_file_ops;
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))
tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else
tmp_inode->i_data.a_ops = &cifs_addr_ops;
if (isNewInode)
return; /* No sense invalidating pages for new inode since we
have not started caching readahead file data yet */
return; /* No sense invalidating pages for new inode
since we have not started caching readahead
file data for it yet */
if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
(local_size == tmp_inode->i_size)) {
@ -421,7 +422,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
tmp_inode->i_op = &cifs_symlink_inode_ops;
/* tmp_inode->i_fop = *//* do not need to set to anything */
} else {
cFYI(1, ("Special inode"));
cFYI(1, ("Special inode"));
init_special_inode(tmp_inode, tmp_inode->i_mode,
tmp_inode->i_rdev);
}
@ -500,7 +501,7 @@ static int cifs_unicode_bytelen(char *str)
if (ustr[len] == 0)
return len << 1;
}
cFYI(1,("Unicode string longer than PATH_MAX found"));
cFYI(1, ("Unicode string longer than PATH_MAX found"));
return len << 1;
}
@ -517,7 +518,7 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
pfData->FileNameLength;
} else
new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset);
cFYI(1,("new entry %p old entry %p",new_entry,old_entry));
cFYI(1, ("new entry %p old entry %p", new_entry, old_entry));
/* validate that new_entry is not past end of SMB */
if (new_entry >= end_of_smb) {
cERROR(1,
@ -583,7 +584,8 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
filename = &pFindData->FileName[0];
len = pFindData->FileNameLength;
} else {
cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level));
cFYI(1, ("Unknown findfirst level %d",
cfile->srch_inf.info_level));
}
if (filename) {
@ -604,7 +606,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
if (filename[0] == '.')
rc = 1;
} else if (len == 2) {
if((filename[0] == '.') && (filename[1] == '.'))
if ((filename[0] == '.') && (filename[1] == '.'))
rc = 2;
}
}
@ -665,13 +667,13 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
is_dir_changed(file)) ||
(index_to_find < first_entry_in_buffer)) {
/* close and restart search */
cFYI(1,("search backing up - close and restart search"));
cFYI(1, ("search backing up - close and restart search"));
cifsFile->invalidHandle = TRUE;
CIFSFindClose(xid, pTcon, cifsFile->netfid);
kfree(cifsFile->search_resume_name);
cifsFile->search_resume_name = NULL;
if (cifsFile->srch_inf.ntwrk_buf_start) {
cFYI(1,("freeing SMB ff cache buf on search rewind"));
cFYI(1, ("freeing SMB ff cache buf on search rewind"));
if (cifsFile->srch_inf.smallBuf)
cifs_small_buf_release(cifsFile->srch_inf.
ntwrk_buf_start);
@ -681,14 +683,15 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
}
rc = initiate_cifs_search(xid,file);
if (rc) {
cFYI(1,("error %d reinitiating a search on rewind",rc));
cFYI(1, ("error %d reinitiating a search on rewind",
rc));
return rc;
}
}
while((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
(rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)){
cFYI(1,("calling findnext2"));
cFYI(1, ("calling findnext2"));
rc = CIFSFindNext(xid,pTcon,cifsFile->netfid,
&cifsFile->srch_inf);
if (rc)
@ -707,14 +710,14 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry
- cifsFile->srch_inf.entries_in_buffer;
pos_in_buf = index_to_find - first_entry_in_buffer;
cFYI(1,("found entry - pos_in_buf %d",pos_in_buf));
cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf));
for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) {
/* go entry by entry figuring out which is first */
current_entry = nxt_dir_entry(current_entry,end_of_smb,
cifsFile->srch_inf.info_level);
}
if((current_entry == NULL) && (i < pos_in_buf)) {
if ((current_entry == NULL) && (i < pos_in_buf)) {
/* BB fixme - check if we should flag this error */
cERROR(1,("reached end of buf searching for pos in buf"
" %d index to find %lld rc %d",
@ -723,12 +726,12 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
rc = 0;
*ppCurrentEntry = current_entry;
} else {
cFYI(1,("index not in buffer - could not findnext into it"));
cFYI(1, ("index not in buffer - could not findnext into it"));
return 0;
}
if(pos_in_buf >= cifsFile->srch_inf.entries_in_buffer) {
cFYI(1,("can not return entries pos_in_buf beyond last entry"));
if (pos_in_buf >= cifsFile->srch_inf.entries_in_buffer) {
cFYI(1, ("can not return entries pos_in_buf beyond last"));
*num_to_ret = 0;
} else
*num_to_ret = cifsFile->srch_inf.entries_in_buffer - pos_in_buf;
@ -748,11 +751,11 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
*pinum = 0;
if(level == SMB_FIND_FILE_UNIX) {
if (level == SMB_FIND_FILE_UNIX) {
FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
filename = &pFindData->FileName[0];
if(unicode) {
if (unicode) {
len = cifs_unicode_bytelen(filename);
} else {
/* BB should we make this strnlen of PATH_MAX? */
@ -760,49 +763,49 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
}
/* BB fixme - hash low and high 32 bits if not 64 bit arch BB fixme */
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
*pinum = pFindData->UniqueId;
} else if(level == SMB_FIND_FILE_DIRECTORY_INFO) {
} else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
FILE_DIRECTORY_INFO * pFindData =
(FILE_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
} else if(level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
} else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
FILE_FULL_DIRECTORY_INFO * pFindData =
(FILE_FULL_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
} else if(level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
} else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
SEARCH_ID_FULL_DIR_INFO * pFindData =
(SEARCH_ID_FULL_DIR_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
*pinum = pFindData->UniqueId;
} else if(level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
} else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
FILE_BOTH_DIRECTORY_INFO * pFindData =
(FILE_BOTH_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
} else if(level == SMB_FIND_FILE_INFO_STANDARD) {
} else if (level == SMB_FIND_FILE_INFO_STANDARD) {
FIND_FILE_STANDARD_INFO * pFindData =
(FIND_FILE_STANDARD_INFO *)current_entry;
filename = &pFindData->FileName[0];
/* one byte length, no name conversion */
len = (unsigned int)pFindData->FileNameLength;
} else {
cFYI(1,("Unknown findfirst level %d",level));
cFYI(1, ("Unknown findfirst level %d", level));
return -EINVAL;
}
if(len > max_len) {
if (len > max_len) {
cERROR(1,("bad search response length %d past smb end", len));
return -EINVAL;
}
if(unicode) {
if (unicode) {
/* BB fixme - test with long names */
/* Note converted filename can be longer than in unicode */
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
pqst->len = cifs_convertUCSpath((char *)pqst->name,
(__le16 *)filename, len/2, nlt);
else
@ -813,7 +816,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
pqst->len = len;
}
pqst->hash = full_name_hash(pqst->name,pqst->len);
/* cFYI(1,("filldir on %s",pqst->name)); */
/* cFYI(1, ("filldir on %s",pqst->name)); */
return rc;
}
@ -832,17 +835,17 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
/* get filename and len into qstring */
/* get dentry */
/* decide whether to create and populate ionde */
if((direntry == NULL) || (file == NULL))
if ((direntry == NULL) || (file == NULL))
return -EINVAL;
pCifsF = file->private_data;
if((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL))
if ((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL))
return -ENOENT;
rc = cifs_entry_is_dot(pfindEntry,pCifsF);
/* skip . and .. since we added them first */
if(rc != 0)
if (rc != 0)
return 0;
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
@ -854,16 +857,16 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
max_len,
&inum /* returned */);
if(rc)
if (rc)
return rc;
rc = construct_dentry(&qstring,file,&tmp_inode, &tmp_dentry);
if((tmp_inode == NULL) || (tmp_dentry == NULL))
if ((tmp_inode == NULL) || (tmp_dentry == NULL))
return -ENOMEM;
if(rc) {
if (rc) {
/* inode created, we need to hash it with right inode number */
if(inum != 0) {
if (inum != 0) {
/* BB fixme - hash the 2 32 quantities bits together if necessary BB */
tmp_inode->i_ino = inum;
}
@ -873,27 +876,27 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
/* we pass in rc below, indicating whether it is a new inode,
so we can figure out whether to invalidate the inode cached
data if the file has changed */
if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX)
if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX)
unix_fill_in_inode(tmp_inode,
(FILE_UNIX_INFO *)pfindEntry,
&obj_type, rc);
else if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD)
else if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD)
fill_in_inode(tmp_inode, 0 /* old level 1 buffer type */,
pfindEntry, &obj_type, rc);
else
fill_in_inode(tmp_inode, 1 /* NT */, pfindEntry, &obj_type, rc);
if(rc) /* new inode - needs to be tied to dentry */ {
if (rc) /* new inode - needs to be tied to dentry */ {
d_instantiate(tmp_dentry, tmp_inode);
if(rc == 2)
if (rc == 2)
d_rehash(tmp_dentry);
}
rc = filldir(direntry,qstring.name,qstring.len,file->f_pos,
tmp_inode->i_ino,obj_type);
if(rc) {
cFYI(1,("filldir rc = %d",rc));
if (rc) {
cFYI(1, ("filldir rc = %d", rc));
/* we can not return filldir errors to the caller
since they are "normal" when the stat blocksize
is too small - we return remapped error instead */
@ -912,47 +915,47 @@ static int cifs_save_resume_key(const char *current_entry,
__u16 level;
char * filename;
if((cifsFile == NULL) || (current_entry == NULL))
if ((cifsFile == NULL) || (current_entry == NULL))
return -EINVAL;
level = cifsFile->srch_inf.info_level;
if(level == SMB_FIND_FILE_UNIX) {
if (level == SMB_FIND_FILE_UNIX) {
FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
filename = &pFindData->FileName[0];
if(cifsFile->srch_inf.unicode) {
if (cifsFile->srch_inf.unicode) {
len = cifs_unicode_bytelen(filename);
} else {
/* BB should we make this strnlen of PATH_MAX? */
len = strnlen(filename, PATH_MAX);
}
cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
} else if(level == SMB_FIND_FILE_DIRECTORY_INFO) {
} else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
FILE_DIRECTORY_INFO * pFindData =
(FILE_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
cifsFile->srch_inf.resume_key = pFindData->FileIndex;
} else if(level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
} else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
FILE_FULL_DIRECTORY_INFO * pFindData =
(FILE_FULL_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
cifsFile->srch_inf.resume_key = pFindData->FileIndex;
} else if(level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
} else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
SEARCH_ID_FULL_DIR_INFO * pFindData =
(SEARCH_ID_FULL_DIR_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
cifsFile->srch_inf.resume_key = pFindData->FileIndex;
} else if(level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
} else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
FILE_BOTH_DIRECTORY_INFO * pFindData =
(FILE_BOTH_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
cifsFile->srch_inf.resume_key = pFindData->FileIndex;
} else if(level == SMB_FIND_FILE_INFO_STANDARD) {
} else if (level == SMB_FIND_FILE_INFO_STANDARD) {
FIND_FILE_STANDARD_INFO * pFindData =
(FIND_FILE_STANDARD_INFO *)current_entry;
filename = &pFindData->FileName[0];
@ -960,7 +963,7 @@ static int cifs_save_resume_key(const char *current_entry,
len = (unsigned int)pFindData->FileNameLength;
cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
} else {
cFYI(1,("Unknown findfirst level %d",level));
cFYI(1, ("Unknown findfirst level %d", level));
return -EINVAL;
}
cifsFile->srch_inf.resume_name_len = len;
@ -985,7 +988,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
pTcon = cifs_sb->tcon;
if(pTcon == NULL)
if (pTcon == NULL)
return -EINVAL;
switch ((int) file->f_pos) {
@ -1011,22 +1014,22 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
if it before then restart search
if after then keep searching till find it */
if(file->private_data == NULL) {
if (file->private_data == NULL) {
rc = initiate_cifs_search(xid,file);
cFYI(1,("initiate cifs search rc %d",rc));
if(rc) {
cFYI(1, ("initiate cifs search rc %d", rc));
if (rc) {
FreeXid(xid);
return rc;
}
}
if(file->private_data == NULL) {
if (file->private_data == NULL) {
rc = -EINVAL;
FreeXid(xid);
return rc;
}
cifsFile = file->private_data;
if (cifsFile->srch_inf.endOfSearch) {
if(cifsFile->srch_inf.emptyDir) {
if (cifsFile->srch_inf.emptyDir) {
cFYI(1, ("End of search, empty dir"));
rc = 0;
break;
@ -1040,17 +1043,17 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
rc = find_cifs_entry(xid,pTcon, file,
&current_entry,&num_to_fill);
if(rc) {
cFYI(1,("fce error %d",rc));
if (rc) {
cFYI(1, ("fce error %d", rc));
goto rddir2_exit;
} else if (current_entry != NULL) {
cFYI(1,("entry %lld found",file->f_pos));
cFYI(1, ("entry %lld found", file->f_pos));
} else {
cFYI(1,("could not find entry"));
cFYI(1, ("could not find entry"));
goto rddir2_exit;
}
cFYI(1,("loop through %d times filling dir for net buf %p",
num_to_fill,cifsFile->srch_inf.ntwrk_buf_start));
cFYI(1, ("loop through %d times filling dir for net buf %p",
num_to_fill, cifsFile->srch_inf.ntwrk_buf_start));
max_len = smbCalcSize((struct smb_hdr *)
cifsFile->srch_inf.ntwrk_buf_start);
end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
@ -1060,8 +1063,8 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
such multibyte target UTF-8 characters. cifs_unicode.c,
which actually does the conversion, has the same limit */
tmp_buf = kmalloc((2 * NAME_MAX) + 4, GFP_KERNEL);
for(i=0;(i<num_to_fill) && (rc == 0);i++) {
if(current_entry == NULL) {
for (i = 0; (i < num_to_fill) && (rc == 0); i++) {
if (current_entry == NULL) {
/* evaluate whether this case is an error */
cERROR(1,("past end of SMB num to fill %d i %d",
num_to_fill, i));
@ -1071,20 +1074,20 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
we want to check for that here? */
rc = cifs_filldir(current_entry, file,
filldir, direntry, tmp_buf, max_len);
if(rc == -EOVERFLOW) {
if (rc == -EOVERFLOW) {
rc = 0;
break;
}
file->f_pos++;
if(file->f_pos ==
if (file->f_pos ==
cifsFile->srch_inf.index_of_last_entry) {
cFYI(1,("last entry in buf at pos %lld %s",
file->f_pos,tmp_buf));
cifs_save_resume_key(current_entry,cifsFile);
cFYI(1, ("last entry in buf at pos %lld %s",
file->f_pos, tmp_buf));
cifs_save_resume_key(current_entry, cifsFile);
break;
} else
current_entry =
} else
current_entry =
nxt_dir_entry(current_entry, end_of_smb,
cifsFile->srch_inf.info_level);
}

View File

@ -3,7 +3,7 @@
*
* SMB/CIFS session setup handling routines
*
* Copyright (c) International Business Machines Corp., 2006
* Copyright (c) International Business Machines Corp., 2006, 2007
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
@ -31,7 +31,7 @@
#include <linux/utsname.h>
extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
unsigned char *p24);
unsigned char *p24);
static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
{
@ -45,13 +45,14 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
/* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
/* BB verify whether signing required on neg or just on auth frame
/* BB verify whether signing required on neg or just on auth frame
(and NTLM case) */
capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
CAP_LARGE_WRITE_X | CAP_LARGE_READ_X;
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
if (ses->server->secMode &
(SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
if (ses->capabilities & CAP_UNICODE) {
@ -75,9 +76,9 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
}
static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
const struct nls_table * nls_cp)
const struct nls_table *nls_cp)
{
char * bcc_ptr = *pbcc_area;
char *bcc_ptr = *pbcc_area;
int bytes_ret = 0;
/* BB FIXME add check that strings total less
@ -89,7 +90,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
bcc_ptr++;
} */
/* copy user */
if(ses->userName == NULL) {
if (ses->userName == NULL) {
/* null user mount */
*bcc_ptr = 0;
*(bcc_ptr+1) = 0;
@ -100,7 +101,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
bcc_ptr += 2 * bytes_ret;
bcc_ptr += 2; /* account for null termination */
/* copy domain */
if(ses->domainName == NULL) {
if (ses->domainName == NULL) {
/* Sending null domain better than using a bogus domain name (as
we did briefly in 2.6.18) since server will use its default */
*bcc_ptr = 0;
@ -122,7 +123,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
bcc_ptr += 2; /* trailing null */
bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
32, nls_cp);
32, nls_cp);
bcc_ptr += 2 * bytes_ret;
bcc_ptr += 2; /* trailing null */
@ -130,29 +131,29 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
}
static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
const struct nls_table * nls_cp)
const struct nls_table *nls_cp)
{
char * bcc_ptr = *pbcc_area;
char *bcc_ptr = *pbcc_area;
/* copy user */
/* BB what about null user mounts - check that we do this BB */
/* copy user */
if(ses->userName == NULL) {
/* BB what about null user mounts - check that we do this BB */
} else { /* 300 should be long enough for any conceivable user name */
strncpy(bcc_ptr, ses->userName, 300);
}
/* copy user */
if (ses->userName == NULL) {
/* BB what about null user mounts - check that we do this BB */
} else { /* 300 should be long enough for any conceivable user name */
strncpy(bcc_ptr, ses->userName, 300);
}
/* BB improve check for overflow */
bcc_ptr += strnlen(ses->userName, 300);
bcc_ptr += strnlen(ses->userName, 300);
*bcc_ptr = 0;
bcc_ptr++; /* account for null termination */
bcc_ptr++; /* account for null termination */
/* copy domain */
if(ses->domainName != NULL) {
strncpy(bcc_ptr, ses->domainName, 256);
/* copy domain */
if (ses->domainName != NULL) {
strncpy(bcc_ptr, ses->domainName, 256);
bcc_ptr += strnlen(ses->domainName, 256);
} /* else we will send a null domain name
} /* else we will send a null domain name
so the server will default to its own domain */
*bcc_ptr = 0;
bcc_ptr++;
@ -167,19 +168,20 @@ static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
strcpy(bcc_ptr, CIFS_NETWORK_OPSYS);
bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1;
*pbcc_area = bcc_ptr;
*pbcc_area = bcc_ptr;
}
static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo *ses,
const struct nls_table * nls_cp)
static int decode_unicode_ssetup(char **pbcc_area, int bleft,
struct cifsSesInfo *ses,
const struct nls_table *nls_cp)
{
int rc = 0;
int words_left, len;
char * data = *pbcc_area;
char *data = *pbcc_area;
cFYI(1,("bleft %d",bleft));
cFYI(1, ("bleft %d", bleft));
/* SMB header is unaligned, so cifs servers word align start of
@ -198,14 +200,14 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
/* 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
terminating last Unicode string in response */
if(len >= words_left)
if (len >= words_left)
return rc;
if(ses->serverOS)
if (ses->serverOS)
kfree(ses->serverOS);
/* UTF-8 string will not grow more than four times as big as UCS-16 */
ses->serverOS = kzalloc(4 * len, GFP_KERNEL);
if(ses->serverOS != NULL) {
if (ses->serverOS != NULL) {
cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len,
nls_cp);
}
@ -215,67 +217,68 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
/* save off server network operating system */
len = UniStrnlen((wchar_t *) data, words_left);
if(len >= words_left)
if (len >= words_left)
return rc;
if(ses->serverNOS)
if (ses->serverNOS)
kfree(ses->serverNOS);
ses->serverNOS = kzalloc(4 * len, GFP_KERNEL); /* BB this is wrong length FIXME BB */
if(ses->serverNOS != NULL) {
if (ses->serverNOS != NULL) {
cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len,
nls_cp);
if(strncmp(ses->serverNOS, "NT LAN Manager 4",16) == 0) {
cFYI(1,("NT4 server"));
if (strncmp(ses->serverNOS, "NT LAN Manager 4", 16) == 0) {
cFYI(1, ("NT4 server"));
ses->flags |= CIFS_SES_NT4;
}
}
data += 2 * (len + 1);
words_left -= len + 1;
/* save off server domain */
len = UniStrnlen((wchar_t *) data, words_left);
/* save off server domain */
len = UniStrnlen((wchar_t *) data, words_left);
if(len > words_left)
return rc;
if (len > words_left)
return rc;
if(ses->serverDomain)
kfree(ses->serverDomain);
ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */
if(ses->serverDomain != NULL) {
cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len,
nls_cp);
ses->serverDomain[2*len] = 0;
ses->serverDomain[(2*len) + 1] = 0;
}
data += 2 * (len + 1);
words_left -= len + 1;
cFYI(1,("words left: %d",words_left));
if (ses->serverDomain)
kfree(ses->serverDomain);
ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */
if (ses->serverDomain != NULL) {
cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len,
nls_cp);
ses->serverDomain[2*len] = 0;
ses->serverDomain[(2*len) + 1] = 0;
}
data += 2 * (len + 1);
words_left -= len + 1;
cFYI(1, ("words left: %d", words_left));
return rc;
}
static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo *ses,
const struct nls_table * nls_cp)
static int decode_ascii_ssetup(char **pbcc_area, int bleft,
struct cifsSesInfo *ses,
const struct nls_table *nls_cp)
{
int rc = 0;
int len;
char * bcc_ptr = *pbcc_area;
char *bcc_ptr = *pbcc_area;
cFYI(1,("decode sessetup ascii. bleft %d", bleft));
cFYI(1, ("decode sessetup ascii. bleft %d", bleft));
len = strnlen(bcc_ptr, bleft);
if(len >= bleft)
if (len >= bleft)
return rc;
if(ses->serverOS)
if (ses->serverOS)
kfree(ses->serverOS);
ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
if(ses->serverOS)
if (ses->serverOS)
strncpy(ses->serverOS, bcc_ptr, len);
if(strncmp(ses->serverOS, "OS/2",4) == 0) {
cFYI(1,("OS/2 server"));
if (strncmp(ses->serverOS, "OS/2", 4) == 0) {
cFYI(1, ("OS/2 server"));
ses->flags |= CIFS_SES_OS2;
}
@ -283,34 +286,34 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo
bleft -= len + 1;
len = strnlen(bcc_ptr, bleft);
if(len >= bleft)
if (len >= bleft)
return rc;
if(ses->serverNOS)
if (ses->serverNOS)
kfree(ses->serverNOS);
ses->serverNOS = kzalloc(len + 1, GFP_KERNEL);
if(ses->serverNOS)
if (ses->serverNOS)
strncpy(ses->serverNOS, bcc_ptr, len);
bcc_ptr += len + 1;
bleft -= len + 1;
len = strnlen(bcc_ptr, bleft);
if(len > bleft)
return rc;
len = strnlen(bcc_ptr, bleft);
if (len > bleft)
return rc;
/* No domain field in LANMAN case. Domain is
returned by old servers in the SMB negprot response */
/* BB For newer servers which do not support Unicode,
but thus do return domain here we could add parsing
for it later, but it is not very important */
cFYI(1,("ascii: bytes left %d",bleft));
cFYI(1, ("ascii: bytes left %d", bleft));
return rc;
}
int
int
CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
const struct nls_table *nls_cp)
{
@ -328,13 +331,13 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
__u16 action;
int bytes_remaining;
if(ses == NULL)
if (ses == NULL)
return -EINVAL;
type = ses->server->secType;
cFYI(1,("sess setup type %d",type));
if(type == LANMAN) {
cFYI(1, ("sess setup type %d", type));
if (type == LANMAN) {
#ifndef CONFIG_CIFS_WEAK_PW_HASH
/* LANMAN and plaintext are less secure and off by default.
So we make this explicitly be turned on in kconfig (in the
@ -344,15 +347,15 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
return -EOPNOTSUPP;
#endif
wct = 10; /* lanman 2 style sessionsetup */
} else if((type == NTLM) || (type == NTLMv2)) {
} else if ((type == NTLM) || (type == NTLMv2)) {
/* For NTLMv2 failures eventually may need to retry NTLM */
wct = 13; /* old style NTLM sessionsetup */
} else /* same size for negotiate or auth, NTLMSSP or extended security */
} else /* same size: negotiate or auth, NTLMSSP or extended security */
wct = 12;
rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses,
(void **)&smb_buf);
if(rc)
if (rc)
return rc;
pSMB = (SESSION_SETUP_ANDX *)smb_buf;
@ -364,8 +367,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
second part which will include the strings
and rest of bcc area, in order to avoid having
to do a large buffer 17K allocation */
iov[0].iov_base = (char *)pSMB;
iov[0].iov_len = smb_buf->smb_buf_length + 4;
iov[0].iov_base = (char *)pSMB;
iov[0].iov_len = smb_buf->smb_buf_length + 4;
/* 2000 big enough to fit max user, domain, NOS name etc. */
str_area = kmalloc(2000, GFP_KERNEL);
@ -373,18 +376,18 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
ses->flags &= ~CIFS_SES_LANMAN;
if(type == LANMAN) {
if (type == LANMAN) {
#ifdef CONFIG_CIFS_WEAK_PW_HASH
char lnm_session_key[CIFS_SESS_KEY_SIZE];
/* no capabilities flags in old lanman negotiation */
pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
/* BB calculate hash with password */
/* and copy into bcc */
calc_lanman_hash(ses, lnm_session_key);
ses->flags |= CIFS_SES_LANMAN;
ses->flags |= CIFS_SES_LANMAN;
/* #ifdef CONFIG_CIFS_DEBUG2
cifs_dump_mem("cryptkey: ",ses->server->cryptKey,
CIFS_SESS_KEY_SIZE);
@ -397,10 +400,10 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
changed to do higher than lanman dialect and
we reconnected would we ever calc signing_key? */
cFYI(1,("Negotiating LANMAN setting up strings"));
cFYI(1, ("Negotiating LANMAN setting up strings"));
/* Unicode not allowed for LANMAN dialects */
ascii_ssetup_strings(&bcc_ptr, ses, nls_cp);
#endif
#endif
} else if (type == NTLM) {
char ntlm_session_key[CIFS_SESS_KEY_SIZE];
@ -414,33 +417,33 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
SMBNTencrypt(ses->password, ses->server->cryptKey,
ntlm_session_key);
if(first_time) /* should this be moved into common code
if (first_time) /* should this be moved into common code
with similar ntlmv2 path? */
cifs_calculate_mac_key(ses->server->mac_signing_key,
ntlm_session_key, ses->password);
/* copy session key */
memcpy(bcc_ptr, (char *)ntlm_session_key,CIFS_SESS_KEY_SIZE);
memcpy(bcc_ptr, (char *)ntlm_session_key, CIFS_SESS_KEY_SIZE);
bcc_ptr += CIFS_SESS_KEY_SIZE;
memcpy(bcc_ptr, (char *)ntlm_session_key,CIFS_SESS_KEY_SIZE);
memcpy(bcc_ptr, (char *)ntlm_session_key, CIFS_SESS_KEY_SIZE);
bcc_ptr += CIFS_SESS_KEY_SIZE;
if(ses->capabilities & CAP_UNICODE) {
if (ses->capabilities & CAP_UNICODE) {
/* unicode strings must be word aligned */
if (iov[0].iov_len % 2) {
*bcc_ptr = 0;
bcc_ptr++;
}
bcc_ptr++;
}
unicode_ssetup_strings(&bcc_ptr, ses, nls_cp);
} else
ascii_ssetup_strings(&bcc_ptr, ses, nls_cp);
} else if (type == NTLMv2) {
char * v2_sess_key =
char *v2_sess_key =
kmalloc(sizeof(struct ntlmv2_resp), GFP_KERNEL);
/* BB FIXME change all users of v2_sess_key to
struct ntlmv2_resp */
if(v2_sess_key == NULL) {
if (v2_sess_key == NULL) {
cifs_small_buf_release(smb_buf);
return -ENOMEM;
}
@ -456,8 +459,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
/* calculate session key */
setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp);
if(first_time) /* should this be moved into common code
with similar ntlmv2 path? */
if (first_time) /* should this be moved into common code
with similar ntlmv2 path? */
/* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key,
response BB FIXME, v2_sess_key); */
@ -468,8 +471,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
memcpy(bcc_ptr, (char *)v2_sess_key, sizeof(struct ntlmv2_resp));
bcc_ptr += sizeof(struct ntlmv2_resp);
kfree(v2_sess_key);
if(ses->capabilities & CAP_UNICODE) {
if(iov[0].iov_len % 2) {
if (ses->capabilities & CAP_UNICODE) {
if (iov[0].iov_len % 2) {
*bcc_ptr = 0;
} bcc_ptr++;
unicode_ssetup_strings(&bcc_ptr, ses, nls_cp);
@ -488,20 +491,20 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
BCC_LE(smb_buf) = cpu_to_le16(count);
iov[1].iov_base = str_area;
iov[1].iov_len = count;
iov[1].iov_len = count;
rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, 0);
/* SMB request buf freed in SendReceive2 */
cFYI(1,("ssetup rc from sendrecv2 is %d",rc));
if(rc)
cFYI(1, ("ssetup rc from sendrecv2 is %d", rc));
if (rc)
goto ssetup_exit;
pSMB = (SESSION_SETUP_ANDX *)iov[0].iov_base;
smb_buf = (struct smb_hdr *)iov[0].iov_base;
if((smb_buf->WordCount != 3) && (smb_buf->WordCount != 4)) {
if ((smb_buf->WordCount != 3) && (smb_buf->WordCount != 4)) {
rc = -EIO;
cERROR(1,("bad word count %d", smb_buf->WordCount));
cERROR(1, ("bad word count %d", smb_buf->WordCount));
goto ssetup_exit;
}
action = le16_to_cpu(pSMB->resp.Action);
@ -514,20 +517,20 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
bytes_remaining = BCC(smb_buf);
bcc_ptr = pByteArea(smb_buf);
if(smb_buf->WordCount == 4) {
if (smb_buf->WordCount == 4) {
__u16 blob_len;
blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
bcc_ptr += blob_len;
if(blob_len > bytes_remaining) {
cERROR(1,("bad security blob length %d", blob_len));
if (blob_len > bytes_remaining) {
cERROR(1, ("bad security blob length %d", blob_len));
rc = -EINVAL;
goto ssetup_exit;
}
bytes_remaining -= blob_len;
}
}
/* BB check if Unicode and decode strings */
if(smb_buf->Flags2 & SMBFLG2_UNICODE)
if (smb_buf->Flags2 & SMBFLG2_UNICODE)
rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining,
ses, nls_cp);
else
@ -535,10 +538,10 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
ssetup_exit:
kfree(str_area);
if(resp_buf_type == CIFS_SMALL_BUFFER) {
cFYI(1,("ssetup freeing small buf %p", iov[0].iov_base));
if (resp_buf_type == CIFS_SMALL_BUFFER) {
cFYI(1, ("ssetup freeing small buf %p", iov[0].iov_base));
cifs_small_buf_release(iov[0].iov_base);
} else if(resp_buf_type == CIFS_LARGE_BUFFER)
} else if (resp_buf_type == CIFS_LARGE_BUFFER)
cifs_buf_release(iov[0].iov_base);
return rc;

View File

@ -1,4 +1,4 @@
/*
/*
Unix SMB/Netbios implementation.
Version 1.9.
SMB parameters and setup
@ -57,7 +57,7 @@ void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
/*
This implements the X/Open SMB password encryption
It takes a password, a 8 byte "crypt key" and puts 24 bytes of
It takes a password, a 8 byte "crypt key" and puts 24 bytes of
encrypted password into p24 */
/* Note that password must be uppercased and null terminated */
void
@ -74,8 +74,8 @@ SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
SMBOWFencrypt(p21, c8, p24);
memset(p14,0,15);
memset(p21,0,21);
memset(p14, 0, 15);
memset(p21, 0, 21);
}
/* Routines for Windows NT MD4 Hash functions. */
@ -90,14 +90,14 @@ _my_wcslen(__u16 * str)
/*
* Convert a string into an NT UNICODE string.
* Note that regardless of processor type
* Note that regardless of processor type
* this must be in intel (little-endian)
* format.
*/
static int
_my_mbstowcs(__u16 * dst, const unsigned char *src, int len)
{ /* not a very good conversion routine - change/fix */
{ /* BB not a very good conversion routine - change/fix */
int i;
__u16 val;
@ -112,7 +112,7 @@ _my_mbstowcs(__u16 * dst, const unsigned char *src, int len)
return i;
}
/*
/*
* Creates the MD4 Hash of the users password in NT UNICODE.
*/
@ -123,7 +123,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
__u16 wpwd[129];
/* Password cannot be longer than 128 characters */
if(passwd) {
if (passwd) {
len = strlen((char *) passwd);
if (len > 128) {
len = 128;
@ -138,7 +138,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
len = _my_wcslen(wpwd) * sizeof (__u16);
mdfour(p16, (unsigned char *) wpwd, len);
memset(wpwd,0,129 * 2);
memset(wpwd, 0, 129 * 2);
}
#if 0 /* currently unused */
@ -184,8 +184,8 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
struct HMACMD5Context ctx;
/* might as well do one alloc to hold both (user_u and dom_u) */
user_u = kmalloc(2048 * sizeof(wchar_t),GFP_KERNEL);
if(user_u == NULL)
user_u = kmalloc(2048 * sizeof(wchar_t), GFP_KERNEL);
if (user_u == NULL)
return;
dom_u = user_u + 1024;
@ -206,7 +206,7 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
kfree(user_u);
}
#endif
#endif
/* Does the des encryption from the NT or LM MD4 hash. */
static void
@ -256,15 +256,15 @@ SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
#if 0
static void
SMBOWFencrypt_ntv2(const unsigned char kr[16],
const struct data_blob * srv_chal,
const struct data_blob * cli_chal, unsigned char resp_buf[16])
const struct data_blob *srv_chal,
const struct data_blob *cli_chal, unsigned char resp_buf[16])
{
struct HMACMD5Context ctx;
struct HMACMD5Context ctx;
hmac_md5_init_limK_to_64(kr, 16, &ctx);
hmac_md5_update(srv_chal->data, srv_chal->length, &ctx);
hmac_md5_update(cli_chal->data, cli_chal->length, &ctx);
hmac_md5_final(resp_buf, &ctx);
hmac_md5_init_limK_to_64(kr, 16, &ctx);
hmac_md5_update(srv_chal->data, srv_chal->length, &ctx);
hmac_md5_update(cli_chal->data, cli_chal->length, &ctx);
hmac_md5_final(resp_buf, &ctx);
}
static void