Commit 4cf97e3c authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] cifs: annotate stat-related structures

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 781cd275
...@@ -1579,43 +1579,43 @@ typedef struct { ...@@ -1579,43 +1579,43 @@ typedef struct {
} FILE_SYSTEM_ATTRIBUTE_INFO; } FILE_SYSTEM_ATTRIBUTE_INFO;
typedef struct { /* data block encoding of response to level 263 QPathInfo */ typedef struct { /* data block encoding of response to level 263 QPathInfo */
__u64 CreationTime; __le64 CreationTime;
__u64 LastAccessTime; __le64 LastAccessTime;
__u64 LastWriteTime; __le64 LastWriteTime;
__u64 ChangeTime; __le64 ChangeTime;
__u32 Attributes; __le32 Attributes;
__u32 Pad1; __u32 Pad1;
__u64 AllocationSize; __le64 AllocationSize;
__u64 EndOfFile; /* size ie offset to first free byte in file */ __le64 EndOfFile; /* size ie offset to first free byte in file */
__u32 NumberOfLinks; /* hard links */ __le32 NumberOfLinks; /* hard links */
__u8 DeletePending; __u8 DeletePending;
__u8 Directory; __u8 Directory;
__u16 Pad2; __u16 Pad2;
__u64 IndexNumber; __u64 IndexNumber;
__u32 EASize; __le32 EASize;
__u32 AccessFlags; __le32 AccessFlags;
__u64 IndexNumber1; __u64 IndexNumber1;
__u64 CurrentByteOffset; __le64 CurrentByteOffset;
__u32 Mode; __le32 Mode;
__u32 AlignmentRequirement; __le32 AlignmentRequirement;
__u32 FileNameLength; __le32 FileNameLength;
char FileName[1]; char FileName[1];
} FILE_ALL_INFO; /* level 263 QPathInfo */ } FILE_ALL_INFO; /* level 263 QPathInfo */
typedef struct { typedef struct {
__u64 EndOfFile; __le64 EndOfFile;
__u64 NumOfBytes; __le64 NumOfBytes;
__u64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */ __le64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */
__u64 LastAccessTime; __le64 LastAccessTime;
__u64 LastModificationTime; __le64 LastModificationTime;
__u64 Uid; __le64 Uid;
__u64 Gid; __le64 Gid;
__u32 Type; __le32 Type;
__u64 DevMajor; __le64 DevMajor;
__u64 DevMinor; __le64 DevMinor;
__u64 UniqueId; __u64 UniqueId;
__u64 Permissions; __le64 Permissions;
__u64 Nlinks; __le64 Nlinks;
} FILE_UNIX_BASIC_INFO; /* level 512 QPathInfo */ } FILE_UNIX_BASIC_INFO; /* level 512 QPathInfo */
typedef struct { typedef struct {
...@@ -1645,30 +1645,30 @@ typedef struct { ...@@ -1645,30 +1645,30 @@ typedef struct {
#define UNIX_SOCKET 6 #define UNIX_SOCKET 6
typedef struct { typedef struct {
__u32 NextEntryOffset; __le32 NextEntryOffset;
__u32 ResumeKey; __le32 ResumeKey;
__u64 EndOfFile; __le64 EndOfFile;
__u64 NumOfBytes; __le64 NumOfBytes;
__u64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */ __le64 LastStatusChange; /*SNIA spec says DCE time for the three time fields */
__u64 LastAccessTime; __le64 LastAccessTime;
__u64 LastModificationTime; __le64 LastModificationTime;
__u64 Uid; __le64 Uid;
__u64 Gid; __le64 Gid;
__u32 Type; __le32 Type;
__u64 DevMajor; __le64 DevMajor;
__u64 DevMinor; __le64 DevMinor;
__u64 UniqueId; __le64 UniqueId;
__u64 Permissions; __le64 Permissions;
__u64 Nlinks; __le64 Nlinks;
char FileName[1]; char FileName[1];
} FILE_UNIX_INFO; } FILE_UNIX_INFO;
typedef struct { typedef struct {
__u64 CreationTime; __le64 CreationTime;
__u64 LastAccessTime; __le64 LastAccessTime;
__u64 LastWriteTime; __le64 LastWriteTime;
__u64 ChangeTime; __le64 ChangeTime;
__u32 Attributes; __le32 Attributes;
__u32 Pad; __u32 Pad;
} FILE_BASIC_INFO; /* size info, level 0x101 */ } FILE_BASIC_INFO; /* size info, level 0x101 */
......
...@@ -1441,6 +1441,9 @@ unix_fill_in_inode(struct inode *tmp_inode, ...@@ -1441,6 +1441,9 @@ unix_fill_in_inode(struct inode *tmp_inode,
FILE_UNIX_INFO * pfindData, int *pobject_type) FILE_UNIX_INFO * pfindData, int *pobject_type)
{ {
struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
__u32 type = le32_to_cpu(pfindData->Type);
__u64 num_of_bytes = le64_to_cpu(pfindData->NumOfBytes);
__u64 end_of_file = le64_to_cpu(pfindData->EndOfFile);
cifsInfo->time = jiffies; cifsInfo->time = jiffies;
atomic_inc(&cifsInfo->inUse); atomic_inc(&cifsInfo->inUse);
...@@ -1452,30 +1455,29 @@ unix_fill_in_inode(struct inode *tmp_inode, ...@@ -1452,30 +1455,29 @@ unix_fill_in_inode(struct inode *tmp_inode,
cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastStatusChange)); cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastStatusChange));
tmp_inode->i_mode = le64_to_cpu(pfindData->Permissions); tmp_inode->i_mode = le64_to_cpu(pfindData->Permissions);
pfindData->Type = le32_to_cpu(pfindData->Type); if (type == UNIX_FILE) {
if (pfindData->Type == UNIX_FILE) {
*pobject_type = DT_REG; *pobject_type = DT_REG;
tmp_inode->i_mode |= S_IFREG; tmp_inode->i_mode |= S_IFREG;
} else if (pfindData->Type == UNIX_SYMLINK) { } else if (type == UNIX_SYMLINK) {
*pobject_type = DT_LNK; *pobject_type = DT_LNK;
tmp_inode->i_mode |= S_IFLNK; tmp_inode->i_mode |= S_IFLNK;
} else if (pfindData->Type == UNIX_DIR) { } else if (type == UNIX_DIR) {
*pobject_type = DT_DIR; *pobject_type = DT_DIR;
tmp_inode->i_mode |= S_IFDIR; tmp_inode->i_mode |= S_IFDIR;
} else if (pfindData->Type == UNIX_CHARDEV) { } else if (type == UNIX_CHARDEV) {
*pobject_type = DT_CHR; *pobject_type = DT_CHR;
tmp_inode->i_mode |= S_IFCHR; tmp_inode->i_mode |= S_IFCHR;
tmp_inode->i_rdev = MKDEV(le64_to_cpu(pfindData->DevMajor), tmp_inode->i_rdev = MKDEV(le64_to_cpu(pfindData->DevMajor),
le64_to_cpu(pfindData->DevMinor) & MINORMASK); le64_to_cpu(pfindData->DevMinor) & MINORMASK);
} else if (pfindData->Type == UNIX_BLOCKDEV) { } else if (type == UNIX_BLOCKDEV) {
*pobject_type = DT_BLK; *pobject_type = DT_BLK;
tmp_inode->i_mode |= S_IFBLK; tmp_inode->i_mode |= S_IFBLK;
tmp_inode->i_rdev = MKDEV(le64_to_cpu(pfindData->DevMajor), tmp_inode->i_rdev = MKDEV(le64_to_cpu(pfindData->DevMajor),
le64_to_cpu(pfindData->DevMinor) & MINORMASK); le64_to_cpu(pfindData->DevMinor) & MINORMASK);
} else if (pfindData->Type == UNIX_FIFO) { } else if (type == UNIX_FIFO) {
*pobject_type = DT_FIFO; *pobject_type = DT_FIFO;
tmp_inode->i_mode |= S_IFIFO; tmp_inode->i_mode |= S_IFIFO;
} else if (pfindData->Type == UNIX_SOCKET) { } else if (type == UNIX_SOCKET) {
*pobject_type = DT_SOCK; *pobject_type = DT_SOCK;
tmp_inode->i_mode |= S_IFSOCK; tmp_inode->i_mode |= S_IFSOCK;
} }
...@@ -1484,17 +1486,15 @@ unix_fill_in_inode(struct inode *tmp_inode, ...@@ -1484,17 +1486,15 @@ unix_fill_in_inode(struct inode *tmp_inode,
tmp_inode->i_gid = le64_to_cpu(pfindData->Gid); tmp_inode->i_gid = le64_to_cpu(pfindData->Gid);
tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks); tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks);
pfindData->NumOfBytes = le64_to_cpu(pfindData->NumOfBytes);
if(is_size_safe_to_change(cifsInfo)) { if(is_size_safe_to_change(cifsInfo)) {
/* can not safely change the file size here if the /* can not safely change the file size here if the
client is writing to it due to potential races */ client is writing to it due to potential races */
pfindData->EndOfFile = le64_to_cpu(pfindData->EndOfFile); i_size_write(tmp_inode,end_of_file);
i_size_write(tmp_inode,pfindData->EndOfFile);
/* 512 bytes (2**9) is the fake blocksize that must be used */ /* 512 bytes (2**9) is the fake blocksize that must be used */
/* for this calculation, not the real blocksize */ /* for this calculation, not the real blocksize */
tmp_inode->i_blocks = (512 - 1 + pfindData->NumOfBytes) >> 9; tmp_inode->i_blocks = (512 - 1 + num_of_bytes) >> 9;
} }
if (S_ISREG(tmp_inode->i_mode)) { if (S_ISREG(tmp_inode->i_mode)) {
......
...@@ -76,6 +76,9 @@ cifs_get_inode_info_unix(struct inode **pinode, ...@@ -76,6 +76,9 @@ cifs_get_inode_info_unix(struct inode **pinode,
} else { } else {
struct cifsInodeInfo *cifsInfo; struct cifsInodeInfo *cifsInfo;
__u32 type = le32_to_cpu(findData.Type);
__u64 num_of_bytes = le64_to_cpu(findData.NumOfBytes);
__u64 end_of_file = le64_to_cpu(findData.EndOfFile);
/* get new inode */ /* get new inode */
if (*pinode == NULL) { if (*pinode == NULL) {
...@@ -101,37 +104,34 @@ cifs_get_inode_info_unix(struct inode **pinode, ...@@ -101,37 +104,34 @@ cifs_get_inode_info_unix(struct inode **pinode,
inode->i_ctime = inode->i_ctime =
cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange)); cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange));
inode->i_mode = le64_to_cpu(findData.Permissions); inode->i_mode = le64_to_cpu(findData.Permissions);
findData.Type = le32_to_cpu(findData.Type); if (type == UNIX_FILE) {
if (findData.Type == UNIX_FILE) {
inode->i_mode |= S_IFREG; inode->i_mode |= S_IFREG;
} else if (findData.Type == UNIX_SYMLINK) { } else if (type == UNIX_SYMLINK) {
inode->i_mode |= S_IFLNK; inode->i_mode |= S_IFLNK;
} else if (findData.Type == UNIX_DIR) { } else if (type == UNIX_DIR) {
inode->i_mode |= S_IFDIR; inode->i_mode |= S_IFDIR;
} else if (findData.Type == UNIX_CHARDEV) { } else if (type == UNIX_CHARDEV) {
inode->i_mode |= S_IFCHR; inode->i_mode |= S_IFCHR;
inode->i_rdev = MKDEV(le64_to_cpu(findData.DevMajor), inode->i_rdev = MKDEV(le64_to_cpu(findData.DevMajor),
le64_to_cpu(findData.DevMinor) & MINORMASK); le64_to_cpu(findData.DevMinor) & MINORMASK);
} else if (findData.Type == UNIX_BLOCKDEV) { } else if (type == UNIX_BLOCKDEV) {
inode->i_mode |= S_IFBLK; inode->i_mode |= S_IFBLK;
inode->i_rdev = MKDEV(le64_to_cpu(findData.DevMajor), inode->i_rdev = MKDEV(le64_to_cpu(findData.DevMajor),
le64_to_cpu(findData.DevMinor) & MINORMASK); le64_to_cpu(findData.DevMinor) & MINORMASK);
} else if (findData.Type == UNIX_FIFO) { } else if (type == UNIX_FIFO) {
inode->i_mode |= S_IFIFO; inode->i_mode |= S_IFIFO;
} else if (findData.Type == UNIX_SOCKET) { } else if (type == UNIX_SOCKET) {
inode->i_mode |= S_IFSOCK; inode->i_mode |= S_IFSOCK;
} }
inode->i_uid = le64_to_cpu(findData.Uid); inode->i_uid = le64_to_cpu(findData.Uid);
inode->i_gid = le64_to_cpu(findData.Gid); inode->i_gid = le64_to_cpu(findData.Gid);
inode->i_nlink = le64_to_cpu(findData.Nlinks); inode->i_nlink = le64_to_cpu(findData.Nlinks);
findData.NumOfBytes = le64_to_cpu(findData.NumOfBytes);
findData.EndOfFile = le64_to_cpu(findData.EndOfFile);
if(is_size_safe_to_change(cifsInfo)) { if(is_size_safe_to_change(cifsInfo)) {
/* can not safely change the file size here if the /* can not safely change the file size here if the
client is writing to it due to potential races */ client is writing to it due to potential races */
i_size_write(inode,findData.EndOfFile); i_size_write(inode, end_of_file);
/* blksize needs to be multiple of two. So safer to default to blksize /* blksize needs to be multiple of two. So safer to default to blksize
and blkbits set in superblock so 2**blkbits and blksize will match */ and blkbits set in superblock so 2**blkbits and blksize will match */
/* inode->i_blksize = /* inode->i_blksize =
...@@ -143,14 +143,14 @@ cifs_get_inode_info_unix(struct inode **pinode, ...@@ -143,14 +143,14 @@ cifs_get_inode_info_unix(struct inode **pinode,
/* inode->i_blocks = /* inode->i_blocks =
(inode->i_blksize - 1 + findData.NumOfBytes) >> inode->i_blkbits;*/ (inode->i_blksize - 1 + num_of_bytes) >> inode->i_blkbits;*/
/* 512 bytes (2**9) is the fake blocksize that must be used */ /* 512 bytes (2**9) is the fake blocksize that must be used */
/* for this calculation */ /* for this calculation */
inode->i_blocks = (512 - 1 + findData.NumOfBytes) >> 9; inode->i_blocks = (512 - 1 + num_of_bytes) >> 9;
} }
if (findData.NumOfBytes < findData.EndOfFile) if (num_of_bytes < end_of_file)
cFYI(1, ("Server inconsistency Error: it says allocation size less than end of file ")); cFYI(1, ("Server inconsistency Error: it says allocation size less than end of file "));
cFYI(1, cFYI(1,
("Size %ld and blocks %ld ", ("Size %ld and blocks %ld ",
...@@ -237,6 +237,7 @@ cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path, ...@@ -237,6 +237,7 @@ cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path,
} }
} else { } else {
struct cifsInodeInfo *cifsInfo; struct cifsInodeInfo *cifsInfo;
__u32 attr = le32_to_cpu(pfindData->Attributes);
/* get new inode */ /* get new inode */
if (*pinode == NULL) { if (*pinode == NULL) {
...@@ -247,8 +248,7 @@ cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path, ...@@ -247,8 +248,7 @@ cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path,
} }
inode = *pinode; inode = *pinode;
cifsInfo = CIFS_I(inode); cifsInfo = CIFS_I(inode);
pfindData->Attributes = le32_to_cpu(pfindData->Attributes); cifsInfo->cifsAttrs = attr;
cifsInfo->cifsAttrs = pfindData->Attributes;
cFYI(1, (" Old time %ld ", cifsInfo->time)); cFYI(1, (" Old time %ld ", cifsInfo->time));
cifsInfo->time = jiffies; cifsInfo->time = jiffies;
cFYI(1, (" New time %ld ", cifsInfo->time)); cFYI(1, (" New time %ld ", cifsInfo->time));
...@@ -266,17 +266,17 @@ cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path, ...@@ -266,17 +266,17 @@ cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path,
inode->i_ctime = inode->i_ctime =
cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
cFYI(0, cFYI(0,
(" Attributes came in as 0x%x ", pfindData->Attributes)); (" Attributes came in as 0x%x ", attr));
/* set default mode. will override for dirs below */ /* set default mode. will override for dirs below */
if(atomic_read(&cifsInfo->inUse) == 0) if(atomic_read(&cifsInfo->inUse) == 0)
/* new inode, can safely set these fields */ /* new inode, can safely set these fields */
inode->i_mode = cifs_sb->mnt_file_mode; inode->i_mode = cifs_sb->mnt_file_mode;
if (pfindData->Attributes & ATTR_REPARSE) { if (attr & ATTR_REPARSE) {
/* Can IFLNK be set as it basically is on windows with IFREG or IFDIR? */ /* Can IFLNK be set as it basically is on windows with IFREG or IFDIR? */
inode->i_mode |= S_IFLNK; inode->i_mode |= S_IFLNK;
} else if (pfindData->Attributes & ATTR_DIRECTORY) { } else if (attr & ATTR_DIRECTORY) {
/* override default perms since we do not do byte range locking on dirs */ /* override default perms since we do not do byte range locking on dirs */
inode->i_mode = cifs_sb->mnt_dir_mode; inode->i_mode = cifs_sb->mnt_dir_mode;
inode->i_mode |= S_IFDIR; inode->i_mode |= S_IFDIR;
...@@ -298,7 +298,6 @@ cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path, ...@@ -298,7 +298,6 @@ cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path,
inode->i_blocks = (512 - 1 + le64_to_cpu(pfindData->AllocationSize)) inode->i_blocks = (512 - 1 + le64_to_cpu(pfindData->AllocationSize))
>> 9; >> 9;
} }
pfindData->AllocationSize = le64_to_cpu(pfindData->AllocationSize);
inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks); inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks);
...@@ -951,7 +950,7 @@ cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -951,7 +950,7 @@ cifs_setattr(struct dentry *direntry, struct iattr *attrs)
} else } else
time_buf.ChangeTime = 0; time_buf.ChangeTime = 0;
if (set_time | time_buf.Attributes) { if (set_time || time_buf.Attributes) {
/* BB what if setting one attribute fails /* BB what if setting one attribute fails
(such as size) but time setting works */ (such as size) but time setting works */
time_buf.CreationTime = 0; /* do not change */ time_buf.CreationTime = 0; /* do not change */
......
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