full_path = build_path_from_dentry(file->f_dentry, cifs_sb); 
full_path = build_path_from_dentry(file->f_dentry); 
int cifs_open(struct inode *inode, struct file *file){	int rc = -EACCES;	int xid, oplock;	struct cifs_sb_info *cifs_sb;	struct cifsTconInfo *pTcon;	struct cifsFileInfo *pCifsFile;	struct cifsInodeInfo *pCifsInode;	struct list_head *tmp;	char *full_path = NULL;	int desiredAccess;	int disposition;	__u16 netfid;	FILE_ALL_INFO *buf = NULL;	xid = GetXid();	cifs_sb = CIFS_SB(inode->i_sb);	pTcon = cifs_sb->tcon;	if (file->f_flags & O_CREAT) {		/* search inode for this file and fill in file->private_data */		pCifsInode = CIFS_I(file->f_dentry->d_inode);		read_lock(&GlobalSMBSeslock);		list_for_each(tmp, &pCifsInode->openFileList) {			pCifsFile = list_entry(tmp, struct cifsFileInfo,					       flist);			if ((pCifsFile->pfile == NULL) &&			    (pCifsFile->pid == current->tgid)) {				/* mode set in cifs_create */				/* needed for writepage */				pCifsFile->pfile = file;								file->private_data = pCifsFile;				break;			}		}		read_unlock(&GlobalSMBSeslock);		if (file->private_data != NULL) {			rc = 0;			FreeXid(xid);			return rc;		} else {			if (file->f_flags & O_EXCL)				cERROR(1, ("could not find file instance for "					   "new file %p ", file));		}	}	down(&inode->i_sb->s_vfs_rename_sem);	full_path = build_path_from_dentry(file->f_dentry, cifs_sb);	up(&inode->i_sb->s_vfs_rename_sem);	if (full_path == NULL) {		FreeXid(xid);		return -ENOMEM;	}	cFYI(1, (" inode = 0x%p file flags are 0x%x for %s",		 inode, file->f_flags, full_path));	desiredAccess = cifs_convert_flags(file->f_flags);/********************************************************************* *  open flag mapping table: *   *	POSIX Flag            CIFS Disposition *	----------            ----------------  *	O_CREAT               FILE_OPEN_IF *	O_CREAT | O_EXCL      FILE_CREATE *	O_CREAT | O_TRUNC     FILE_OVERWRITE_IF *	O_TRUNC               FILE_OVERWRITE *	none of the above     FILE_OPEN * *	Note that there is not a direct match between disposition *	FILE_SUPERSEDE (ie create whether or not file exists although  *	O_CREAT | O_TRUNC is similar but truncates the existing *	file rather than creating a new file as FILE_SUPERSEDE does *	(which uses the attributes / metadata passed in on open call) *? *?  O_SYNC is a reasonable match to CIFS writethrough flag   *?  and the read write flags match reasonably.  O_LARGEFILE *?  is irrelevant because largefile support is always used *?  by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, *	 O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation *********************************************************************/	disposition = cifs_get_disposition(file->f_flags);	if (oplockEnabled)		oplock = REQ_OPLOCK;	else		oplock = FALSE;	/* BB pass O_SYNC flag through on file attributes .. BB */	/* Also refresh inode by passing in file_info buf returned by SMBOpen	   and calling get_inode_info with returned buf (at least helps	   non-Unix server case) */	/* 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 	   able to simply do a filemap_fdatawrite/filemap_fdatawait first */	buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);	if (!buf) {		rc = -ENOMEM;		goto out;	}	rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,			 CREATE_NOT_DIR, &netfid, &oplock, buf,			 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags				 & CIFS_MOUNT_MAP_SPECIAL_CHR);	if (rc == -EIO) {		/* Old server, try legacy style OpenX */		rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,			desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,			cifs_sb->local_nls, cifs_sb->mnt_cifs_flags				& CIFS_MOUNT_MAP_SPECIAL_CHR);	}	if (rc) {		cFYI(1, ("cifs_open returned 0x%x ", rc));		goto out;	}	file->private_data =		kmalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);	if (file->private_data == NULL) {		rc = -ENOMEM;		goto out;	}	pCifsFile = cifs_init_private(file->private_data, inode, file, netfid);	write_lock(&file->f_owner.lock);	write_lock(&GlobalSMBSeslock);	list_add(&pCifsFile->tlist, &pTcon->openFileList);	pCifsInode = CIFS_I(file->f_dentry->d_inode);	if (pCifsInode) {		rc = cifs_open_inode_helper(inode, file, pCifsInode,					    pCifsFile, pTcon,					    &oplock, buf, full_path, xid);	} else {		write_unlock(&GlobalSMBSeslock);		write_unlock(&file->f_owner.lock);	}	if (oplock & CIFS_CREATE_ACTION) {           		/* time to set mode which we can not set earlier due to		   problems creating new read-only files */		if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {			CIFSSMBUnixSetPerms(xid, pTcon, full_path,					    inode->i_mode,					    (__u64)-1, (__u64)-1, 0 /* dev */,					    cifs_sb->local_nls,					    cifs_sb->mnt_cifs_flags & 						CIFS_MOUNT_MAP_SPECIAL_CHR);		} else {			/* BB implement via Windows security descriptors eg			   CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,					      -1, -1, local_nls);			   in the meantime could set r/o dos attribute when			   perms are eg: mode & 0222 == 0 */		}	}out:	kfree(buf);	kfree(full_path);	FreeXid(xid);	return rc;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/7f57356b70dda014ef269135942426e4a852023e/file.c/buggy/fs/cifs/file.c