diff options
author | Pavel Shilovsky <piastryyy@gmail.com> | 2010-11-25 09:20:20 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2011-01-06 14:07:54 -0500 |
commit | 7e12eddb73d4f288b0339ee13832a34d6bc4fd90 (patch) | |
tree | 6beacb189bb82572701e994046d7acb16698d3fb /fs/cifs | |
parent | eeb910a6d46103594eb63e6eba1aeb02022368a4 (diff) |
CIFS: Simplify cifs_open code
Make the code more general for use in posix and non-posix open.
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/file.c | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index f95ba451173f..97ddbf2fdfc3 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -340,6 +340,7 @@ int cifs_open(struct inode *inode, struct file *file) | |||
340 | struct cifsFileInfo *pCifsFile = NULL; | 340 | struct cifsFileInfo *pCifsFile = NULL; |
341 | struct cifsInodeInfo *pCifsInode; | 341 | struct cifsInodeInfo *pCifsInode; |
342 | char *full_path = NULL; | 342 | char *full_path = NULL; |
343 | bool posix_open_ok = false; | ||
343 | __u16 netfid; | 344 | __u16 netfid; |
344 | 345 | ||
345 | xid = GetXid(); | 346 | xid = GetXid(); |
@@ -378,17 +379,7 @@ int cifs_open(struct inode *inode, struct file *file) | |||
378 | file->f_flags, &oplock, &netfid, xid); | 379 | file->f_flags, &oplock, &netfid, xid); |
379 | if (rc == 0) { | 380 | if (rc == 0) { |
380 | cFYI(1, "posix open succeeded"); | 381 | cFYI(1, "posix open succeeded"); |
381 | 382 | posix_open_ok = true; | |
382 | pCifsFile = cifs_new_fileinfo(netfid, file, tlink, | ||
383 | oplock); | ||
384 | if (pCifsFile == NULL) { | ||
385 | CIFSSMBClose(xid, tcon, netfid); | ||
386 | rc = -ENOMEM; | ||
387 | } | ||
388 | |||
389 | cifs_fscache_set_inode_cookie(inode, file); | ||
390 | |||
391 | goto out; | ||
392 | } else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | 383 | } else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { |
393 | if (tcon->ses->serverNOS) | 384 | if (tcon->ses->serverNOS) |
394 | cERROR(1, "server %s of type %s returned" | 385 | cERROR(1, "server %s of type %s returned" |
@@ -405,37 +396,38 @@ int cifs_open(struct inode *inode, struct file *file) | |||
405 | or DFS errors */ | 396 | or DFS errors */ |
406 | } | 397 | } |
407 | 398 | ||
408 | rc = cifs_nt_open(full_path, inode, cifs_sb, tcon, file->f_flags, | 399 | if (!posix_open_ok) { |
409 | &oplock, &netfid, xid); | 400 | rc = cifs_nt_open(full_path, inode, cifs_sb, tcon, |
410 | if (rc) | 401 | file->f_flags, &oplock, &netfid, xid); |
411 | goto out; | 402 | if (rc) |
403 | goto out; | ||
404 | } | ||
412 | 405 | ||
413 | pCifsFile = cifs_new_fileinfo(netfid, file, tlink, oplock); | 406 | pCifsFile = cifs_new_fileinfo(netfid, file, tlink, oplock); |
414 | if (pCifsFile == NULL) { | 407 | if (pCifsFile == NULL) { |
408 | CIFSSMBClose(xid, tcon, netfid); | ||
415 | rc = -ENOMEM; | 409 | rc = -ENOMEM; |
416 | goto out; | 410 | goto out; |
417 | } | 411 | } |
418 | 412 | ||
419 | cifs_fscache_set_inode_cookie(inode, file); | 413 | cifs_fscache_set_inode_cookie(inode, file); |
420 | 414 | ||
421 | if (oplock & CIFS_CREATE_ACTION) { | 415 | if ((oplock & CIFS_CREATE_ACTION) && !posix_open_ok && tcon->unix_ext) { |
422 | /* time to set mode which we can not set earlier due to | 416 | /* time to set mode which we can not set earlier due to |
423 | problems creating new read-only files */ | 417 | problems creating new read-only files */ |
424 | if (tcon->unix_ext) { | 418 | struct cifs_unix_set_info_args args = { |
425 | struct cifs_unix_set_info_args args = { | 419 | .mode = inode->i_mode, |
426 | .mode = inode->i_mode, | 420 | .uid = NO_CHANGE_64, |
427 | .uid = NO_CHANGE_64, | 421 | .gid = NO_CHANGE_64, |
428 | .gid = NO_CHANGE_64, | 422 | .ctime = NO_CHANGE_64, |
429 | .ctime = NO_CHANGE_64, | 423 | .atime = NO_CHANGE_64, |
430 | .atime = NO_CHANGE_64, | 424 | .mtime = NO_CHANGE_64, |
431 | .mtime = NO_CHANGE_64, | 425 | .device = 0, |
432 | .device = 0, | 426 | }; |
433 | }; | 427 | CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args, |
434 | CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args, | 428 | cifs_sb->local_nls, |
435 | cifs_sb->local_nls, | 429 | cifs_sb->mnt_cifs_flags & |
436 | cifs_sb->mnt_cifs_flags & | 430 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
437 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
438 | } | ||
439 | } | 431 | } |
440 | 432 | ||
441 | out: | 433 | out: |