} 
} else rc = -EINVAL;  
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;	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;	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) {		/* 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 */		open_file = find_writable_file(cifsInode);		if (open_file) {			__u16 nfid = open_file->netfid;			__u32 npid = open_file->pid;			rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size,						nfid, npid, FALSE);			atomic_dec(&open_file->wrtPending);			cFYI(1,("SetFSize for attrs rc = %d", rc));			if(rc == -EINVAL) {				int bytes_written;				rc = CIFSSMBWrite(xid, pTcon,						  nfid, 0, attrs->ia_size,						  &bytes_written, NULL, NULL,						  1 /* 45 seconds */);				cFYI(1,("Wrt seteof rc %d", rc));			}		}		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, 					   cifs_sb->mnt_cifs_flags &						CIFS_MOUNT_MAP_SPECIAL_CHR);			cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));			if(rc == -EINVAL) {				__u16 netfid;				int oplock = FALSE;				rc = SMBLegacyOpen(xid, pTcon, full_path,					FILE_OPEN,					SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,					CREATE_NOT_DIR, &netfid, &oplock,					NULL, cifs_sb->local_nls,					cifs_sb->mnt_cifs_flags &						CIFS_MOUNT_MAP_SPECIAL_CHR);				if (rc==0) {					int bytes_written;					rc = CIFSSMBWrite(xid, pTcon,							netfid, 0,							attrs->ia_size,							&bytes_written, NULL,							NULL, 1 /* 45 sec */);					cFYI(1,("wrt seteof rc %d",rc));					CIFSSMBClose(xid, pTcon, netfid);				}			}		}		/* 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);		} else 			goto cifs_setattr_exit;	}	if (attrs->ia_valid & ATTR_UID) {		cFYI(1, ("UID changed to %d", attrs->ia_uid));		uid = attrs->ia_uid;	}	if (attrs->ia_valid & ATTR_GID) {		cFYI(1, ("GID changed to %d", attrs->ia_gid));		gid = attrs->ia_gid;	}	time_buf.Attributes = 0;	if (attrs->ia_valid & ATTR_MODE) {		cFYI(1, ("Mode changed to 0x%x", attrs->ia_mode));		mode = attrs->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,					 cifs_sb->mnt_cifs_flags & 						CIFS_MOUNT_MAP_SPECIAL_CHR);	else if (attrs->ia_valid & ATTR_MODE) {		rc = 0;		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;	/* Do not set ctime explicitly unless other time	   stamps are changed explicitly (i.e. by utime()	   since we would then have a mix of client and	   server times */	   	if (set_time && (attrs->ia_valid & ATTR_CTIME)) {		set_time = TRUE;		/* Although Samba throws this field away		it may be useful to Windows - but we do		not want to set ctime unless some other		timestamp is changing */		cFYI(1, ("CIFS - CTIME changed "));		time_buf.ChangeTime =		    cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime));	} else		time_buf.ChangeTime = 0;	if (set_time || time_buf.Attributes) {		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,					     cifs_sb->mnt_cifs_flags &						CIFS_MOUNT_MAP_SPECIAL_CHR);		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,					 cifs_sb->mnt_cifs_flags &						CIFS_MOUNT_MAP_SPECIAL_CHR);			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); */			}		}		/* Even if error on time set, no sense failing the call if		the server would set the time to a reasonable value anyway,		and this check ensures that we are not being called from		sys_utimes in which case we ought to fail the call back to		the user when the server rejects the call */		if((rc) && (attrs->ia_valid &&			 (ATTR_MODE | ATTR_GID | ATTR_UID | ATTR_SIZE)))			rc = 0;	}	/* do not need local check to inode_check_ok since the server does	   that */	if (!rc)		rc = inode_setattr(direntry->d_inode, attrs);cifs_setattr_exit:	kfree(full_path);	FreeXid(xid);	return rc;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/6473a559c336d5c407f9df412ca2f55357767ff8/inode.c/buggy/fs/cifs/inode.c