aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 7935816fa111..293e9b767621 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -219,6 +219,53 @@ posix_open_ret:
219 return rc; 219 return rc;
220} 220}
221 221
222struct cifsFileInfo *
223cifs_new_fileinfo(__u16 fileHandle, struct file *file,
224 struct tcon_link *tlink, __u32 oplock)
225{
226 struct dentry *dentry = file->f_path.dentry;
227 struct inode *inode = dentry->d_inode;
228 struct cifsInodeInfo *pCifsInode = CIFS_I(inode);
229 struct cifsFileInfo *pCifsFile;
230
231 pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
232 if (pCifsFile == NULL)
233 return pCifsFile;
234
235 pCifsFile->netfid = fileHandle;
236 pCifsFile->pid = current->tgid;
237 pCifsFile->uid = current_fsuid();
238 pCifsFile->dentry = dget(dentry);
239 pCifsFile->f_flags = file->f_flags;
240 pCifsFile->invalidHandle = false;
241 pCifsFile->closePend = false;
242 pCifsFile->tlink = cifs_get_tlink(tlink);
243 mutex_init(&pCifsFile->fh_mutex);
244 mutex_init(&pCifsFile->lock_mutex);
245 INIT_LIST_HEAD(&pCifsFile->llist);
246 atomic_set(&pCifsFile->count, 1);
247 INIT_WORK(&pCifsFile->oplock_break, cifs_oplock_break);
248
249 write_lock(&GlobalSMBSeslock);
250 list_add(&pCifsFile->tlist, &(tlink_tcon(tlink)->openFileList));
251 /* if readable file instance put first in list*/
252 if (file->f_mode & FMODE_READ)
253 list_add(&pCifsFile->flist, &pCifsInode->openFileList);
254 else
255 list_add_tail(&pCifsFile->flist, &pCifsInode->openFileList);
256 write_unlock(&GlobalSMBSeslock);
257
258 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
259 pCifsInode->clientCanCacheAll = true;
260 pCifsInode->clientCanCacheRead = true;
261 cFYI(1, "Exclusive Oplock inode %p", inode);
262 } else if ((oplock & 0xF) == OPLOCK_READ)
263 pCifsInode->clientCanCacheRead = true;
264
265 file->private_data = pCifsFile;
266 return pCifsFile;
267}
268
222int cifs_open(struct inode *inode, struct file *file) 269int cifs_open(struct inode *inode, struct file *file)
223{ 270{
224 int rc = -EACCES; 271 int rc = -EACCES;