NULL, cifs_sb->local_nls);
NULL, cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
int cifs_setattr(struct dentry *direntry, struct iattr *attrs){	int xid;	struct cifs_sb_info *cifs_sb;	struct cifsTconInfo *pTcon;	char *full_path = NULL;	int rc = -EACCES;	int found = FALSE;	struct cifsFileInfo *open_file = NULL;	FILE_BASIC_INFO time_buf;	int set_time = FALSE;	__u64 mode = 0xFFFFFFFFFFFFFFFFULL;	__u64 uid = 0xFFFFFFFFFFFFFFFFULL;	__u64 gid = 0xFFFFFFFFFFFFFFFFULL;	struct cifsInodeInfo *cifsInode;	struct list_head *tmp;	xid = GetXid();	cFYI(1, (" In cifs_setattr, name = %s attrs->iavalid 0x%x ",		 direntry->d_name.name, attrs->ia_valid));	cifs_sb = CIFS_SB(direntry->d_inode->i_sb);	pTcon = cifs_sb->tcon;	down(&direntry->d_sb->s_vfs_rename_sem);	full_path = build_path_from_dentry(direntry);	up(&direntry->d_sb->s_vfs_rename_sem);	if (full_path == NULL) {		FreeXid(xid);		return -ENOMEM;	}	cifsInode = CIFS_I(direntry->d_inode);	/* BB check if we need to refresh inode from server now ? BB */	/* need to flush data before changing file size on server */	filemap_fdatawrite(direntry->d_inode->i_mapping);	filemap_fdatawait(direntry->d_inode->i_mapping);	if (attrs->ia_valid & ATTR_SIZE) {		read_lock(&GlobalSMBSeslock);		/* To avoid spurious oplock breaks from server, in the case of		   inodes that we already have open, avoid doing path based		   setting of file size if we can do it by handle.		   This keeps our caching token (oplock) and avoids timeouts		   when the local oplock break takes longer to flush		   writebehind data than the SMB timeout for the SetPathInfo		   request would allow */		list_for_each(tmp, &cifsInode->openFileList) {			open_file = list_entry(tmp, struct cifsFileInfo,					       flist);			/* We check if file is open for writing first */			if ((open_file->pfile) &&			    ((open_file->pfile->f_flags & O_RDWR) ||			    (open_file->pfile->f_flags & O_WRONLY))) {				if (open_file->invalidHandle == FALSE) {					/* we found a valid, writeable network					   file handle to use to try to set the					   file size */					__u16 nfid = open_file->netfid;					__u32 npid = open_file->pid;					read_unlock(&GlobalSMBSeslock);					found = TRUE;					rc = CIFSSMBSetFileSize(xid, pTcon,						attrs->ia_size, nfid, npid,						FALSE);					cFYI(1, ("SetFileSize by handle "						 "(setattrs) rc = %d", rc));					/* Do not need reopen and retry on					   EAGAIN since we will retry by					   pathname below */					/* now that we found one valid file					   handle no sense continuing to loop					   trying others, so break here */					break;				}			}		}		if (found == FALSE)			read_unlock(&GlobalSMBSeslock);		if (rc != 0) {			/* Set file size by pathname rather than by handle			   either because no valid, writeable file handle for			   it was found or because there was an error setting			   it by handle */			rc = CIFSSMBSetEOF(xid, pTcon, full_path,					   attrs->ia_size, FALSE,					   cifs_sb->local_nls);			cFYI(1, (" SetEOF by path (setattrs) rc = %d", rc));		}		/* Server is ok setting allocation size implicitly - no need		   to call:		CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, TRUE,			 cifs_sb->local_nls);		   */		if (rc == 0) {			rc = vmtruncate(direntry->d_inode, attrs->ia_size);			cifs_truncate_page(direntry->d_inode->i_mapping,					   direntry->d_inode->i_size);		}	}	if (attrs->ia_valid & ATTR_UID) {		cFYI(1, (" CIFS - UID changed to %d", attrs->ia_uid));		uid = attrs->ia_uid;		/* entry->uid = cpu_to_le16(attr->ia_uid); */	}	if (attrs->ia_valid & ATTR_GID) {		cFYI(1, (" CIFS - GID changed to %d", attrs->ia_gid));		gid = attrs->ia_gid;		/* entry->gid = cpu_to_le16(attr->ia_gid); */	}	time_buf.Attributes = 0;	if (attrs->ia_valid & ATTR_MODE) {		cFYI(1, (" CIFS - Mode changed to 0x%x", attrs->ia_mode));		mode = attrs->ia_mode;		/* entry->mode = cpu_to_le16(attr->ia_mode); */	}	if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX)	    && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID)))		rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid,					 0 /* dev_t */, cifs_sb->local_nls);	else if (attrs->ia_valid & ATTR_MODE) {		if ((mode & S_IWUGO) == 0) /* not writeable */ {			if ((cifsInode->cifsAttrs & ATTR_READONLY) == 0)				time_buf.Attributes =					cpu_to_le32(cifsInode->cifsAttrs |						    ATTR_READONLY);		} else if ((mode & S_IWUGO) == S_IWUGO) {			if (cifsInode->cifsAttrs & ATTR_READONLY)				time_buf.Attributes =					cpu_to_le32(cifsInode->cifsAttrs &						    (~ATTR_READONLY));		}		/* BB to be implemented -		   via Windows security descriptors or streams */		/* CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, uid, gid,				      cifs_sb->local_nls); */	}	if (attrs->ia_valid & ATTR_ATIME) {		set_time = TRUE;		time_buf.LastAccessTime =		    cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime));	} else		time_buf.LastAccessTime = 0;	if (attrs->ia_valid & ATTR_MTIME) {		set_time = TRUE;		time_buf.LastWriteTime =		    cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime));	} else		time_buf.LastWriteTime = 0;	if (attrs->ia_valid & ATTR_CTIME) {		set_time = TRUE;		cFYI(1, (" CIFS - CTIME changed ")); /* BB probably no need */		time_buf.ChangeTime =		    cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime));	} else		time_buf.ChangeTime = 0;	if (set_time || time_buf.Attributes) {		/* BB what if setting one attribute fails (such as size) but		   time setting works? */		time_buf.CreationTime = 0;	/* do not change */		/* In the future we should experiment - try setting timestamps		   via Handle (SetFileInfo) instead of by path */		if (!(pTcon->ses->flags & CIFS_SES_NT4))			rc = CIFSSMBSetTimes(xid, pTcon, full_path, &time_buf,					     cifs_sb->local_nls);		else			rc = -EOPNOTSUPP;		if (rc == -EOPNOTSUPP) {			int oplock = FALSE;			__u16 netfid;			cFYI(1, ("calling SetFileInfo since SetPathInfo for "				 "times not supported by this server"));			/* BB we could scan to see if we already have it open			   and pass in pid of opener to function */			rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,					 SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,					 CREATE_NOT_DIR, &netfid, &oplock,					 NULL, cifs_sb->local_nls);			if (rc==0) {				rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf,							 netfid);				CIFSSMBClose(xid, pTcon, netfid);			} else {			/* BB For even older servers we could convert time_buf			   into old DOS style which uses two second			   granularity */			/* rc = CIFSSMBSetTimesLegacy(xid, pTcon, full_path,        	        		&time_buf, cifs_sb->local_nls); */			}		}	}	/* do not need local check to inode_check_ok since the server does	   that */	if (!rc)		rc = inode_setattr(direntry->d_inode, attrs);	kfree(full_path);	FreeXid(xid);	return rc;}