Commit 85a6dac5 authored by Steve French's avatar Steve French

[CIFS] Endian convert UniqueId when reporting inode numbers from server files

Jeff made a good point that we should endian convert the UniqueId when we use
it to set i_ino Even though this value is opaque to the client, when comparing
the inode numbers of the same server file from two different clients (one
big endian, one little endian) or when we compare a big endian client's view
of i_ino with what the server thinks - we should get the same value
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 74496d36
...@@ -15,7 +15,8 @@ Posix file open support added (turned off after one attempt if server ...@@ -15,7 +15,8 @@ Posix file open support added (turned off after one attempt if server
fails to support it properly, as with Samba server versions prior to 3.3.2) fails to support it properly, as with Samba server versions prior to 3.3.2)
Fix "redzone overwritten" bug in cifs_put_tcon (CIFSTcon may allocate too Fix "redzone overwritten" bug in cifs_put_tcon (CIFSTcon may allocate too
little memory for the "nativeFileSystem" field returned by the server little memory for the "nativeFileSystem" field returned by the server
during mount). during mount). Endian convert inode numbers if necessary (makes it easier
to compare inode numbers on network files from big endian systems).
Version 1.56 Version 1.56
------------ ------------
......
...@@ -2163,7 +2163,7 @@ typedef struct { ...@@ -2163,7 +2163,7 @@ typedef struct {
__le32 Type; __le32 Type;
__le64 DevMajor; __le64 DevMajor;
__le64 DevMinor; __le64 DevMinor;
__u64 UniqueId; __le64 UniqueId;
__le64 Permissions; __le64 Permissions;
__le64 Nlinks; __le64 Nlinks;
} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */ } __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
...@@ -2308,7 +2308,7 @@ struct unlink_psx_rq { /* level 0x20a SetPathInfo */ ...@@ -2308,7 +2308,7 @@ struct unlink_psx_rq { /* level 0x20a SetPathInfo */
} __attribute__((packed)); } __attribute__((packed));
struct file_internal_info { struct file_internal_info {
__u64 UniqueId; /* inode number */ __le64 UniqueId; /* inode number */
} __attribute__((packed)); /* level 0x3ee */ } __attribute__((packed)); /* level 0x3ee */
struct file_mode_info { struct file_mode_info {
...@@ -2338,7 +2338,7 @@ typedef struct { ...@@ -2338,7 +2338,7 @@ typedef struct {
__le32 Type; __le32 Type;
__le64 DevMajor; __le64 DevMajor;
__le64 DevMinor; __le64 DevMinor;
__u64 UniqueId; __le64 UniqueId;
__le64 Permissions; __le64 Permissions;
__le64 Nlinks; __le64 Nlinks;
char FileName[1]; char FileName[1];
...@@ -2386,7 +2386,7 @@ typedef struct { ...@@ -2386,7 +2386,7 @@ typedef struct {
__le32 FileNameLength; __le32 FileNameLength;
__le32 EaSize; /* EA size */ __le32 EaSize; /* EA size */
__le32 Reserved; __le32 Reserved;
__u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/ __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
char FileName[1]; char FileName[1];
} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */ } __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
......
...@@ -3918,7 +3918,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, ...@@ -3918,7 +3918,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
} }
pfinfo = (struct file_internal_info *) pfinfo = (struct file_internal_info *)
(data_offset + (char *) &pSMBr->hdr.Protocol); (data_offset + (char *) &pSMBr->hdr.Protocol);
*inode_number = pfinfo->UniqueId; *inode_number = le64_to_cpu(pfinfo->UniqueId);
} }
} }
GetInodeNumOut: GetInodeNumOut:
......
...@@ -187,8 +187,10 @@ int cifs_posix_open(char *full_path, struct inode **pinode, ...@@ -187,8 +187,10 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
if (!pinode) if (!pinode)
goto posix_open_ret; /* caller does not need info */ goto posix_open_ret; /* caller does not need info */
if (*pinode == NULL) if (*pinode == NULL) {
*pinode = cifs_new_inode(sb, &presp_data->UniqueId); __u64 unique_id = le64_to_cpu(presp_data->UniqueId);
*pinode = cifs_new_inode(sb, &unique_id);
}
/* else an inode was passed in. Update its info, don't create one */ /* else an inode was passed in. Update its info, don't create one */
/* We do not need to close the file if new_inode fails since /* We do not need to close the file if new_inode fails since
......
...@@ -276,7 +276,8 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -276,7 +276,8 @@ int cifs_get_inode_info_unix(struct inode **pinode,
/* get new inode */ /* get new inode */
if (*pinode == NULL) { if (*pinode == NULL) {
*pinode = cifs_new_inode(sb, &find_data.UniqueId); __u64 unique_id = le64_to_cpu(find_data.UniqueId);
*pinode = cifs_new_inode(sb, &unique_id);
if (*pinode == NULL) { if (*pinode == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto cgiiu_exit; goto cgiiu_exit;
...@@ -1138,6 +1139,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -1138,6 +1139,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
cFYI(1, ("posix mkdir returned 0x%x", rc)); cFYI(1, ("posix mkdir returned 0x%x", rc));
d_drop(direntry); d_drop(direntry);
} else { } else {
__u64 unique_id;
if (pInfo->Type == cpu_to_le32(-1)) { if (pInfo->Type == cpu_to_le32(-1)) {
/* no return info, go query for it */ /* no return info, go query for it */
kfree(pInfo); kfree(pInfo);
...@@ -1151,8 +1153,8 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -1151,8 +1153,8 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
else else
direntry->d_op = &cifs_dentry_ops; direntry->d_op = &cifs_dentry_ops;
newinode = cifs_new_inode(inode->i_sb, unique_id = le64_to_cpu(pInfo->UniqueId);
&pInfo->UniqueId); newinode = cifs_new_inode(inode->i_sb, &unique_id);
if (newinode == NULL) { if (newinode == NULL) {
kfree(pInfo); kfree(pInfo);
goto mkdir_get_info; goto mkdir_get_info;
......
...@@ -840,7 +840,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, ...@@ -840,7 +840,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
len = strnlen(filename, PATH_MAX); len = strnlen(filename, PATH_MAX);
} }
*pinum = pFindData->UniqueId; *pinum = le64_to_cpu(pFindData->UniqueId);
} else if (level == SMB_FIND_FILE_DIRECTORY_INFO) { } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
FILE_DIRECTORY_INFO *pFindData = FILE_DIRECTORY_INFO *pFindData =
(FILE_DIRECTORY_INFO *)current_entry; (FILE_DIRECTORY_INFO *)current_entry;
...@@ -856,7 +856,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, ...@@ -856,7 +856,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
(SEARCH_ID_FULL_DIR_INFO *)current_entry; (SEARCH_ID_FULL_DIR_INFO *)current_entry;
filename = &pFindData->FileName[0]; filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength); len = le32_to_cpu(pFindData->FileNameLength);
*pinum = pFindData->UniqueId; *pinum = le64_to_cpu(pFindData->UniqueId);
} else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
FILE_BOTH_DIRECTORY_INFO *pFindData = FILE_BOTH_DIRECTORY_INFO *pFindData =
(FILE_BOTH_DIRECTORY_INFO *)current_entry; (FILE_BOTH_DIRECTORY_INFO *)current_entry;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment