CIFS: Implement follow_link for SMB2
[cascardo/linux.git] / fs / cifs / smb2file.c
index 5da1b55..020245d 100644 (file)
@@ -40,7 +40,8 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
        oplock &= 0xFF;
        if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
                return;
-       if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
+       if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE ||
+           oplock == SMB2_OPLOCK_LEVEL_BATCH) {
                cinode->clientCanCacheAll = true;
                cinode->clientCanCacheRead = true;
                cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n",
@@ -57,17 +58,16 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
 }
 
 int
-smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path,
-              int disposition, int desired_access, int create_options,
-              struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf,
-              struct cifs_sb_info *cifs_sb)
+smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
+              __u32 *oplock, FILE_ALL_INFO *buf)
 {
        int rc;
        __le16 *smb2_path;
        struct smb2_file_all_info *smb2_data = NULL;
        __u8 smb2_oplock[17];
+       struct cifs_fid *fid = oparms->fid;
 
-       smb2_path = cifs_convert_path_to_utf16(path, cifs_sb);
+       smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb);
        if (smb2_path == NULL) {
                rc = -ENOMEM;
                goto out;
@@ -80,21 +80,19 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path,
                goto out;
        }
 
-       desired_access |= FILE_READ_ATTRIBUTES;
-       *smb2_oplock = SMB2_OPLOCK_LEVEL_EXCLUSIVE;
+       oparms->desired_access |= FILE_READ_ATTRIBUTES;
+       *smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH;
 
-       if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
+       if (oparms->tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
                memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE);
 
-       rc = SMB2_open(xid, tcon, smb2_path, &fid->persistent_fid,
-                      &fid->volatile_fid, desired_access, disposition,
-                      0, 0, smb2_oplock, smb2_data);
+       rc = SMB2_open(xid, oparms, smb2_path, smb2_oplock, smb2_data, NULL);
        if (rc)
                goto out;
 
        if (buf) {
                /* open response does not have IndexNumber field - get it */
-               rc = SMB2_get_srv_num(xid, tcon, fid->persistent_fid,
+               rc = SMB2_get_srv_num(xid, oparms->tcon, fid->persistent_fid,
                                      fid->volatile_fid,
                                      &smb2_data->IndexNumber);
                if (rc) {