smb3: allow more detailed protocol info on open files for debugging
[platform/kernel/linux-rpi.git] / fs / cifs / smb2ops.c
index 23c0a21..225fec1 100644 (file)
@@ -747,6 +747,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
        int rc = 0;
        unsigned int ea_name_len = ea_name ? strlen(ea_name) : 0;
        char *name, *value;
+       size_t buf_size = dst_size;
        size_t name_len, value_len, user_name_len;
 
        while (src_size > 0) {
@@ -782,9 +783,10 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
                        /* 'user.' plus a terminating null */
                        user_name_len = 5 + 1 + name_len;
 
-                       rc += user_name_len;
-
-                       if (dst_size >= user_name_len) {
+                       if (buf_size == 0) {
+                               /* skip copy - calc size only */
+                               rc += user_name_len;
+                       } else if (dst_size >= user_name_len) {
                                dst_size -= user_name_len;
                                memcpy(dst, "user.", 5);
                                dst += 5;
@@ -792,8 +794,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
                                dst += name_len;
                                *dst = 0;
                                ++dst;
-                       } else if (dst_size == 0) {
-                               /* skip copy - calc size only */
+                               rc += user_name_len;
                        } else {
                                /* stop before overrun buffer */
                                rc = -ERANGE;
@@ -1078,6 +1079,9 @@ smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
 
        cfile->fid.persistent_fid = fid->persistent_fid;
        cfile->fid.volatile_fid = fid->volatile_fid;
+#ifdef CONFIG_CIFS_DEBUG2
+       cfile->fid.mid = fid->mid;
+#endif /* CIFS_DEBUG2 */
        server->ops->set_oplock_level(cinode, oplock, fid->epoch,
                                      &fid->purge_cache);
        cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);