Skip to content

Commit

Permalink
[CIFS] Endian convert UniqueId when reporting inode numbers from serv…
Browse files Browse the repository at this point in the history
…er 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: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Steve French committed Apr 17, 2009
1 parent 74496d3 commit 85a6dac
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion fs/cifs/CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Fix "redzone overwritten" bug in cifs_put_tcon (CIFSTcon may allocate too
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
------------
Expand Down
8 changes: 4 additions & 4 deletions fs/cifs/cifspdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ typedef struct {
__le32 Type;
__le64 DevMajor;
__le64 DevMinor;
__u64 UniqueId;
__le64 UniqueId;
__le64 Permissions;
__le64 Nlinks;
} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
Expand Down Expand Up @@ -2308,7 +2308,7 @@ struct unlink_psx_rq { /* level 0x20a SetPathInfo */
} __attribute__((packed));

struct file_internal_info {
__u64 UniqueId; /* inode number */
__le64 UniqueId; /* inode number */
} __attribute__((packed)); /* level 0x3ee */

struct file_mode_info {
Expand Down Expand Up @@ -2338,7 +2338,7 @@ typedef struct {
__le32 Type;
__le64 DevMajor;
__le64 DevMinor;
__u64 UniqueId;
__le64 UniqueId;
__le64 Permissions;
__le64 Nlinks;
char FileName[1];
Expand Down Expand Up @@ -2386,7 +2386,7 @@ typedef struct {
__le32 FileNameLength;
__le32 EaSize; /* EA size */
__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];
} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */

Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifssmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3918,7 +3918,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
}
pfinfo = (struct file_internal_info *)
(data_offset + (char *) &pSMBr->hdr.Protocol);
*inode_number = pfinfo->UniqueId;
*inode_number = le64_to_cpu(pfinfo->UniqueId);
}
}
GetInodeNumOut:
Expand Down
6 changes: 4 additions & 2 deletions fs/cifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
if (!pinode)
goto posix_open_ret; /* caller does not need info */

if (*pinode == NULL)
*pinode = cifs_new_inode(sb, &presp_data->UniqueId);
if (*pinode == NULL) {
__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 */

/* We do not need to close the file if new_inode fails since
Expand Down
8 changes: 5 additions & 3 deletions fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ int cifs_get_inode_info_unix(struct inode **pinode,

/* get new inode */
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) {
rc = -ENOMEM;
goto cgiiu_exit;
Expand Down Expand Up @@ -1138,6 +1139,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
cFYI(1, ("posix mkdir returned 0x%x", rc));
d_drop(direntry);
} else {
__u64 unique_id;
if (pInfo->Type == cpu_to_le32(-1)) {
/* no return info, go query for it */
kfree(pInfo);
Expand All @@ -1151,8 +1153,8 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
else
direntry->d_op = &cifs_dentry_ops;

newinode = cifs_new_inode(inode->i_sb,
&pInfo->UniqueId);
unique_id = le64_to_cpu(pInfo->UniqueId);
newinode = cifs_new_inode(inode->i_sb, &unique_id);
if (newinode == NULL) {
kfree(pInfo);
goto mkdir_get_info;
Expand Down
4 changes: 2 additions & 2 deletions fs/cifs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
len = strnlen(filename, PATH_MAX);
}

*pinum = pFindData->UniqueId;
*pinum = le64_to_cpu(pFindData->UniqueId);
} else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
FILE_DIRECTORY_INFO *pFindData =
(FILE_DIRECTORY_INFO *)current_entry;
Expand All @@ -856,7 +856,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
(SEARCH_ID_FULL_DIR_INFO *)current_entry;
filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength);
*pinum = pFindData->UniqueId;
*pinum = le64_to_cpu(pFindData->UniqueId);
} else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
FILE_BOTH_DIRECTORY_INFO *pFindData =
(FILE_BOTH_DIRECTORY_INFO *)current_entry;
Expand Down

0 comments on commit 85a6dac

Please sign in to comment.