diff options
Diffstat (limited to 'fs/cifs/inode.c')
-rw-r--r-- | fs/cifs/inode.c | 320 |
1 files changed, 164 insertions, 156 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index f0ff12b3f398..dd4167762a8e 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -57,14 +57,14 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
57 | if (tmp_path == NULL) { | 57 | if (tmp_path == NULL) { |
58 | return -ENOMEM; | 58 | return -ENOMEM; |
59 | } | 59 | } |
60 | /* have to skip first of the double backslash of | 60 | /* have to skip first of the double backslash of |
61 | UNC name */ | 61 | UNC name */ |
62 | strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); | 62 | strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); |
63 | strncat(tmp_path, search_path, MAX_PATHCONF); | 63 | strncat(tmp_path, search_path, MAX_PATHCONF); |
64 | rc = connect_to_dfs_path(xid, pTcon->ses, | 64 | rc = connect_to_dfs_path(xid, pTcon->ses, |
65 | /* treename + */ tmp_path, | 65 | /* treename + */ tmp_path, |
66 | cifs_sb->local_nls, | 66 | cifs_sb->local_nls, |
67 | cifs_sb->mnt_cifs_flags & | 67 | cifs_sb->mnt_cifs_flags & |
68 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 68 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
69 | kfree(tmp_path); | 69 | kfree(tmp_path); |
70 | 70 | ||
@@ -81,7 +81,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
81 | /* get new inode */ | 81 | /* get new inode */ |
82 | if (*pinode == NULL) { | 82 | if (*pinode == NULL) { |
83 | *pinode = new_inode(sb); | 83 | *pinode = new_inode(sb); |
84 | if (*pinode == NULL) | 84 | if (*pinode == NULL) |
85 | return -ENOMEM; | 85 | return -ENOMEM; |
86 | /* Is an i_ino of zero legal? */ | 86 | /* Is an i_ino of zero legal? */ |
87 | /* Are there sanity checks we can use to ensure that | 87 | /* Are there sanity checks we can use to ensure that |
@@ -92,7 +92,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
92 | } /* note ino incremented to unique num in new_inode */ | 92 | } /* note ino incremented to unique num in new_inode */ |
93 | if (sb->s_flags & MS_NOATIME) | 93 | if (sb->s_flags & MS_NOATIME) |
94 | (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; | 94 | (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; |
95 | 95 | ||
96 | insert_inode_hash(*pinode); | 96 | insert_inode_hash(*pinode); |
97 | } | 97 | } |
98 | 98 | ||
@@ -103,7 +103,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
103 | cifsInfo->time = jiffies; | 103 | cifsInfo->time = jiffies; |
104 | cFYI(1, ("New time %ld", cifsInfo->time)); | 104 | cFYI(1, ("New time %ld", cifsInfo->time)); |
105 | /* this is ok to set on every inode revalidate */ | 105 | /* this is ok to set on every inode revalidate */ |
106 | atomic_set(&cifsInfo->inUse,1); | 106 | atomic_set(&cifsInfo->inUse, 1); |
107 | 107 | ||
108 | inode->i_atime = | 108 | inode->i_atime = |
109 | cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime)); | 109 | cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime)); |
@@ -114,8 +114,8 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
114 | cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange)); | 114 | cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange)); |
115 | inode->i_mode = le64_to_cpu(findData.Permissions); | 115 | inode->i_mode = le64_to_cpu(findData.Permissions); |
116 | /* since we set the inode type below we need to mask off | 116 | /* since we set the inode type below we need to mask off |
117 | to avoid strange results if bits set above */ | 117 | to avoid strange results if bits set above */ |
118 | inode->i_mode &= ~S_IFMT; | 118 | inode->i_mode &= ~S_IFMT; |
119 | if (type == UNIX_FILE) { | 119 | if (type == UNIX_FILE) { |
120 | inode->i_mode |= S_IFREG; | 120 | inode->i_mode |= S_IFREG; |
121 | } else if (type == UNIX_SYMLINK) { | 121 | } else if (type == UNIX_SYMLINK) { |
@@ -137,9 +137,9 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
137 | } else { | 137 | } else { |
138 | /* safest to call it a file if we do not know */ | 138 | /* safest to call it a file if we do not know */ |
139 | inode->i_mode |= S_IFREG; | 139 | inode->i_mode |= S_IFREG; |
140 | cFYI(1,("unknown type %d",type)); | 140 | cFYI(1, ("unknown type %d", type)); |
141 | } | 141 | } |
142 | 142 | ||
143 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) | 143 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) |
144 | inode->i_uid = cifs_sb->mnt_uid; | 144 | inode->i_uid = cifs_sb->mnt_uid; |
145 | else | 145 | else |
@@ -149,7 +149,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
149 | inode->i_gid = cifs_sb->mnt_gid; | 149 | inode->i_gid = cifs_sb->mnt_gid; |
150 | else | 150 | else |
151 | inode->i_gid = le64_to_cpu(findData.Gid); | 151 | inode->i_gid = le64_to_cpu(findData.Gid); |
152 | 152 | ||
153 | inode->i_nlink = le64_to_cpu(findData.Nlinks); | 153 | inode->i_nlink = le64_to_cpu(findData.Nlinks); |
154 | 154 | ||
155 | spin_lock(&inode->i_lock); | 155 | spin_lock(&inode->i_lock); |
@@ -183,17 +183,17 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
183 | inode->i_op = &cifs_file_inode_ops; | 183 | inode->i_op = &cifs_file_inode_ops; |
184 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | 184 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { |
185 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 185 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
186 | inode->i_fop = | 186 | inode->i_fop = |
187 | &cifs_file_direct_nobrl_ops; | 187 | &cifs_file_direct_nobrl_ops; |
188 | else | 188 | else |
189 | inode->i_fop = &cifs_file_direct_ops; | 189 | inode->i_fop = &cifs_file_direct_ops; |
190 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 190 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
191 | inode->i_fop = &cifs_file_nobrl_ops; | 191 | inode->i_fop = &cifs_file_nobrl_ops; |
192 | else /* not direct, send byte range locks */ | 192 | else /* not direct, send byte range locks */ |
193 | inode->i_fop = &cifs_file_ops; | 193 | inode->i_fop = &cifs_file_ops; |
194 | 194 | ||
195 | /* check if server can support readpages */ | 195 | /* check if server can support readpages */ |
196 | if (pTcon->ses->server->maxBuf < | 196 | if (pTcon->ses->server->maxBuf < |
197 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | 197 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) |
198 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 198 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
199 | else | 199 | else |
@@ -215,7 +215,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
215 | return rc; | 215 | return rc; |
216 | } | 216 | } |
217 | 217 | ||
218 | static int decode_sfu_inode(struct inode * inode, __u64 size, | 218 | static int decode_sfu_inode(struct inode *inode, __u64 size, |
219 | const unsigned char *path, | 219 | const unsigned char *path, |
220 | struct cifs_sb_info *cifs_sb, int xid) | 220 | struct cifs_sb_info *cifs_sb, int xid) |
221 | { | 221 | { |
@@ -225,7 +225,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
225 | struct cifsTconInfo *pTcon = cifs_sb->tcon; | 225 | struct cifsTconInfo *pTcon = cifs_sb->tcon; |
226 | char buf[24]; | 226 | char buf[24]; |
227 | unsigned int bytes_read; | 227 | unsigned int bytes_read; |
228 | char * pbuf; | 228 | char *pbuf; |
229 | 229 | ||
230 | pbuf = buf; | 230 | pbuf = buf; |
231 | 231 | ||
@@ -235,22 +235,22 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
235 | } else if (size < 8) { | 235 | } else if (size < 8) { |
236 | return -EINVAL; /* EOPNOTSUPP? */ | 236 | return -EINVAL; /* EOPNOTSUPP? */ |
237 | } | 237 | } |
238 | 238 | ||
239 | rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ, | 239 | rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ, |
240 | CREATE_NOT_DIR, &netfid, &oplock, NULL, | 240 | CREATE_NOT_DIR, &netfid, &oplock, NULL, |
241 | cifs_sb->local_nls, | 241 | cifs_sb->local_nls, |
242 | cifs_sb->mnt_cifs_flags & | 242 | cifs_sb->mnt_cifs_flags & |
243 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 243 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
244 | if (rc==0) { | 244 | if (rc == 0) { |
245 | int buf_type = CIFS_NO_BUFFER; | 245 | int buf_type = CIFS_NO_BUFFER; |
246 | /* Read header */ | 246 | /* Read header */ |
247 | rc = CIFSSMBRead(xid, pTcon, | 247 | rc = CIFSSMBRead(xid, pTcon, |
248 | netfid, | 248 | netfid, |
249 | 24 /* length */, 0 /* offset */, | 249 | 24 /* length */, 0 /* offset */, |
250 | &bytes_read, &pbuf, &buf_type); | 250 | &bytes_read, &pbuf, &buf_type); |
251 | if ((rc == 0) && (bytes_read >= 8)) { | 251 | if ((rc == 0) && (bytes_read >= 8)) { |
252 | if (memcmp("IntxBLK", pbuf, 8) == 0) { | 252 | if (memcmp("IntxBLK", pbuf, 8) == 0) { |
253 | cFYI(1,("Block device")); | 253 | cFYI(1, ("Block device")); |
254 | inode->i_mode |= S_IFBLK; | 254 | inode->i_mode |= S_IFBLK; |
255 | if (bytes_read == 24) { | 255 | if (bytes_read == 24) { |
256 | /* we have enough to decode dev num */ | 256 | /* we have enough to decode dev num */ |
@@ -261,7 +261,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
261 | inode->i_rdev = MKDEV(mjr, mnr); | 261 | inode->i_rdev = MKDEV(mjr, mnr); |
262 | } | 262 | } |
263 | } else if (memcmp("IntxCHR", pbuf, 8) == 0) { | 263 | } else if (memcmp("IntxCHR", pbuf, 8) == 0) { |
264 | cFYI(1,("Char device")); | 264 | cFYI(1, ("Char device")); |
265 | inode->i_mode |= S_IFCHR; | 265 | inode->i_mode |= S_IFCHR; |
266 | if (bytes_read == 24) { | 266 | if (bytes_read == 24) { |
267 | /* we have enough to decode dev num */ | 267 | /* we have enough to decode dev num */ |
@@ -270,27 +270,26 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
270 | mjr = le64_to_cpu(*(__le64 *)(pbuf+8)); | 270 | mjr = le64_to_cpu(*(__le64 *)(pbuf+8)); |
271 | mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); | 271 | mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); |
272 | inode->i_rdev = MKDEV(mjr, mnr); | 272 | inode->i_rdev = MKDEV(mjr, mnr); |
273 | } | 273 | } |
274 | } else if (memcmp("IntxLNK", pbuf, 7) == 0) { | 274 | } else if (memcmp("IntxLNK", pbuf, 7) == 0) { |
275 | cFYI(1,("Symlink")); | 275 | cFYI(1, ("Symlink")); |
276 | inode->i_mode |= S_IFLNK; | 276 | inode->i_mode |= S_IFLNK; |
277 | } else { | 277 | } else { |
278 | inode->i_mode |= S_IFREG; /* file? */ | 278 | inode->i_mode |= S_IFREG; /* file? */ |
279 | rc = -EOPNOTSUPP; | 279 | rc = -EOPNOTSUPP; |
280 | } | 280 | } |
281 | } else { | 281 | } else { |
282 | inode->i_mode |= S_IFREG; /* then it is a file */ | 282 | inode->i_mode |= S_IFREG; /* then it is a file */ |
283 | rc = -EOPNOTSUPP; /* or some unknown SFU type */ | 283 | rc = -EOPNOTSUPP; /* or some unknown SFU type */ |
284 | } | 284 | } |
285 | CIFSSMBClose(xid, pTcon, netfid); | 285 | CIFSSMBClose(xid, pTcon, netfid); |
286 | } | 286 | } |
287 | return rc; | 287 | return rc; |
288 | |||
289 | } | 288 | } |
290 | 289 | ||
291 | #define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */ | 290 | #define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */ |
292 | 291 | ||
293 | static int get_sfu_uid_mode(struct inode * inode, | 292 | static int get_sfu_uid_mode(struct inode *inode, |
294 | const unsigned char *path, | 293 | const unsigned char *path, |
295 | struct cifs_sb_info *cifs_sb, int xid) | 294 | struct cifs_sb_info *cifs_sb, int xid) |
296 | { | 295 | { |
@@ -301,15 +300,15 @@ static int get_sfu_uid_mode(struct inode * inode, | |||
301 | 300 | ||
302 | rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", | 301 | rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", |
303 | ea_value, 4 /* size of buf */, cifs_sb->local_nls, | 302 | ea_value, 4 /* size of buf */, cifs_sb->local_nls, |
304 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 303 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
305 | if (rc < 0) | 304 | if (rc < 0) |
306 | return (int)rc; | 305 | return (int)rc; |
307 | else if (rc > 3) { | 306 | else if (rc > 3) { |
308 | mode = le32_to_cpu(*((__le32 *)ea_value)); | 307 | mode = le32_to_cpu(*((__le32 *)ea_value)); |
309 | inode->i_mode &= ~SFBITS_MASK; | 308 | inode->i_mode &= ~SFBITS_MASK; |
310 | cFYI(1,("special bits 0%o org mode 0%o", mode, inode->i_mode)); | 309 | cFYI(1, ("special bits 0%o org mode 0%o", mode, inode->i_mode)); |
311 | inode->i_mode = (mode & SFBITS_MASK) | inode->i_mode; | 310 | inode->i_mode = (mode & SFBITS_MASK) | inode->i_mode; |
312 | cFYI(1,("special mode bits 0%o", mode)); | 311 | cFYI(1, ("special mode bits 0%o", mode)); |
313 | return 0; | 312 | return 0; |
314 | } else { | 313 | } else { |
315 | return 0; | 314 | return 0; |
@@ -317,8 +316,6 @@ static int get_sfu_uid_mode(struct inode * inode, | |||
317 | #else | 316 | #else |
318 | return -EOPNOTSUPP; | 317 | return -EOPNOTSUPP; |
319 | #endif | 318 | #endif |
320 | |||
321 | |||
322 | } | 319 | } |
323 | 320 | ||
324 | int cifs_get_inode_info(struct inode **pinode, | 321 | int cifs_get_inode_info(struct inode **pinode, |
@@ -334,11 +331,11 @@ int cifs_get_inode_info(struct inode **pinode, | |||
334 | int adjustTZ = FALSE; | 331 | int adjustTZ = FALSE; |
335 | 332 | ||
336 | pTcon = cifs_sb->tcon; | 333 | pTcon = cifs_sb->tcon; |
337 | cFYI(1,("Getting info on %s", search_path)); | 334 | cFYI(1, ("Getting info on %s", search_path)); |
338 | 335 | ||
339 | if ((pfindData == NULL) && (*pinode != NULL)) { | 336 | if ((pfindData == NULL) && (*pinode != NULL)) { |
340 | if (CIFS_I(*pinode)->clientCanCacheRead) { | 337 | if (CIFS_I(*pinode)->clientCanCacheRead) { |
341 | cFYI(1,("No need to revalidate cached inode sizes")); | 338 | cFYI(1, ("No need to revalidate cached inode sizes")); |
342 | return rc; | 339 | return rc; |
343 | } | 340 | } |
344 | } | 341 | } |
@@ -359,12 +356,11 @@ int cifs_get_inode_info(struct inode **pinode, | |||
359 | failed at least once - set flag in tcon or mount */ | 356 | failed at least once - set flag in tcon or mount */ |
360 | if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { | 357 | if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { |
361 | rc = SMBQueryInformation(xid, pTcon, search_path, | 358 | rc = SMBQueryInformation(xid, pTcon, search_path, |
362 | pfindData, cifs_sb->local_nls, | 359 | pfindData, cifs_sb->local_nls, |
363 | cifs_sb->mnt_cifs_flags & | 360 | cifs_sb->mnt_cifs_flags & |
364 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 361 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
365 | adjustTZ = TRUE; | 362 | adjustTZ = TRUE; |
366 | } | 363 | } |
367 | |||
368 | } | 364 | } |
369 | /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */ | 365 | /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */ |
370 | if (rc) { | 366 | if (rc) { |
@@ -384,8 +380,8 @@ int cifs_get_inode_info(struct inode **pinode, | |||
384 | strncat(tmp_path, search_path, MAX_PATHCONF); | 380 | strncat(tmp_path, search_path, MAX_PATHCONF); |
385 | rc = connect_to_dfs_path(xid, pTcon->ses, | 381 | rc = connect_to_dfs_path(xid, pTcon->ses, |
386 | /* treename + */ tmp_path, | 382 | /* treename + */ tmp_path, |
387 | cifs_sb->local_nls, | 383 | cifs_sb->local_nls, |
388 | cifs_sb->mnt_cifs_flags & | 384 | cifs_sb->mnt_cifs_flags & |
389 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 385 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
390 | kfree(tmp_path); | 386 | kfree(tmp_path); |
391 | /* BB fix up inode etc. */ | 387 | /* BB fix up inode etc. */ |
@@ -419,17 +415,17 @@ int cifs_get_inode_info(struct inode **pinode, | |||
419 | there Windows server or network appliances for which | 415 | there Windows server or network appliances for which |
420 | IndexNumber field is not guaranteed unique? */ | 416 | IndexNumber field is not guaranteed unique? */ |
421 | 417 | ||
422 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM){ | 418 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { |
423 | int rc1 = 0; | 419 | int rc1 = 0; |
424 | __u64 inode_num; | 420 | __u64 inode_num; |
425 | 421 | ||
426 | rc1 = CIFSGetSrvInodeNumber(xid, pTcon, | 422 | rc1 = CIFSGetSrvInodeNumber(xid, pTcon, |
427 | search_path, &inode_num, | 423 | search_path, &inode_num, |
428 | cifs_sb->local_nls, | 424 | cifs_sb->local_nls, |
429 | cifs_sb->mnt_cifs_flags & | 425 | cifs_sb->mnt_cifs_flags & |
430 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 426 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
431 | if (rc1) { | 427 | if (rc1) { |
432 | cFYI(1,("GetSrvInodeNum rc %d", rc1)); | 428 | cFYI(1, ("GetSrvInodeNum rc %d", rc1)); |
433 | /* BB EOPNOSUPP disable SERVER_INUM? */ | 429 | /* BB EOPNOSUPP disable SERVER_INUM? */ |
434 | } else /* do we need cast or hash to ino? */ | 430 | } else /* do we need cast or hash to ino? */ |
435 | (*pinode)->i_ino = inode_num; | 431 | (*pinode)->i_ino = inode_num; |
@@ -463,7 +459,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
463 | cFYI(0, ("Attributes came in as 0x%x", attr)); | 459 | cFYI(0, ("Attributes came in as 0x%x", attr)); |
464 | if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { | 460 | if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { |
465 | inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; | 461 | inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; |
466 | inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; | 462 | inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; |
467 | } | 463 | } |
468 | 464 | ||
469 | /* set default mode. will override for dirs below */ | 465 | /* set default mode. will override for dirs below */ |
@@ -471,8 +467,9 @@ int cifs_get_inode_info(struct inode **pinode, | |||
471 | /* new inode, can safely set these fields */ | 467 | /* new inode, can safely set these fields */ |
472 | inode->i_mode = cifs_sb->mnt_file_mode; | 468 | inode->i_mode = cifs_sb->mnt_file_mode; |
473 | else /* since we set the inode type below we need to mask off | 469 | else /* since we set the inode type below we need to mask off |
474 | to avoid strange results if type changes and both get orred in */ | 470 | to avoid strange results if type changes and both |
475 | inode->i_mode &= ~S_IFMT; | 471 | get orred in */ |
472 | inode->i_mode &= ~S_IFMT; | ||
476 | /* if (attr & ATTR_REPARSE) */ | 473 | /* if (attr & ATTR_REPARSE) */ |
477 | /* We no longer handle these as symlinks because we could not | 474 | /* We no longer handle these as symlinks because we could not |
478 | follow them due to the absolute path with drive letter */ | 475 | follow them due to the absolute path with drive letter */ |
@@ -490,13 +487,13 @@ int cifs_get_inode_info(struct inode **pinode, | |||
490 | /* BB Finish for SFU style symlinks and devices */ | 487 | /* BB Finish for SFU style symlinks and devices */ |
491 | } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && | 488 | } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && |
492 | (cifsInfo->cifsAttrs & ATTR_SYSTEM)) { | 489 | (cifsInfo->cifsAttrs & ATTR_SYSTEM)) { |
493 | if (decode_sfu_inode(inode, | 490 | if (decode_sfu_inode(inode, |
494 | le64_to_cpu(pfindData->EndOfFile), | 491 | le64_to_cpu(pfindData->EndOfFile), |
495 | search_path, | 492 | search_path, |
496 | cifs_sb, xid)) { | 493 | cifs_sb, xid)) { |
497 | cFYI(1,("Unrecognized sfu inode type")); | 494 | cFYI(1, ("Unrecognized sfu inode type")); |
498 | } | 495 | } |
499 | cFYI(1,("sfu mode 0%o",inode->i_mode)); | 496 | cFYI(1, ("sfu mode 0%o", inode->i_mode)); |
500 | } else { | 497 | } else { |
501 | inode->i_mode |= S_IFREG; | 498 | inode->i_mode |= S_IFREG; |
502 | /* treat the dos attribute of read-only as read-only | 499 | /* treat the dos attribute of read-only as read-only |
@@ -512,12 +509,12 @@ int cifs_get_inode_info(struct inode **pinode, | |||
512 | /* BB add code here - | 509 | /* BB add code here - |
513 | validate if device or weird share or device type? */ | 510 | validate if device or weird share or device type? */ |
514 | } | 511 | } |
515 | 512 | ||
516 | spin_lock(&inode->i_lock); | 513 | spin_lock(&inode->i_lock); |
517 | if (is_size_safe_to_change(cifsInfo, le64_to_cpu(pfindData->EndOfFile))) { | 514 | if (is_size_safe_to_change(cifsInfo, le64_to_cpu(pfindData->EndOfFile))) { |
518 | /* can not safely shrink the file size here if the | 515 | /* can not safely shrink the file size here if the |
519 | client is writing to it due to potential races */ | 516 | client is writing to it due to potential races */ |
520 | i_size_write(inode,le64_to_cpu(pfindData->EndOfFile)); | 517 | i_size_write(inode, le64_to_cpu(pfindData->EndOfFile)); |
521 | 518 | ||
522 | /* 512 bytes (2**9) is the fake blocksize that must be | 519 | /* 512 bytes (2**9) is the fake blocksize that must be |
523 | used for this calculation */ | 520 | used for this calculation */ |
@@ -528,7 +525,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
528 | 525 | ||
529 | inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks); | 526 | inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks); |
530 | 527 | ||
531 | /* BB fill in uid and gid here? with help from winbind? | 528 | /* BB fill in uid and gid here? with help from winbind? |
532 | or retrieve from NTFS stream extended attribute */ | 529 | or retrieve from NTFS stream extended attribute */ |
533 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { | 530 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { |
534 | /* fill in uid, gid, mode from server ACL */ | 531 | /* fill in uid, gid, mode from server ACL */ |
@@ -540,7 +537,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
540 | inode->i_gid = cifs_sb->mnt_gid; | 537 | inode->i_gid = cifs_sb->mnt_gid; |
541 | /* set so we do not keep refreshing these fields with | 538 | /* set so we do not keep refreshing these fields with |
542 | bad data after user has changed them in memory */ | 539 | bad data after user has changed them in memory */ |
543 | atomic_set(&cifsInfo->inUse,1); | 540 | atomic_set(&cifsInfo->inUse, 1); |
544 | } | 541 | } |
545 | 542 | ||
546 | if (S_ISREG(inode->i_mode)) { | 543 | if (S_ISREG(inode->i_mode)) { |
@@ -557,7 +554,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
557 | else /* not direct, send byte range locks */ | 554 | else /* not direct, send byte range locks */ |
558 | inode->i_fop = &cifs_file_ops; | 555 | inode->i_fop = &cifs_file_ops; |
559 | 556 | ||
560 | if (pTcon->ses->server->maxBuf < | 557 | if (pTcon->ses->server->maxBuf < |
561 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | 558 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) |
562 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 559 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
563 | else | 560 | else |
@@ -586,10 +583,11 @@ void cifs_read_inode(struct inode *inode) | |||
586 | 583 | ||
587 | cifs_sb = CIFS_SB(inode->i_sb); | 584 | cifs_sb = CIFS_SB(inode->i_sb); |
588 | xid = GetXid(); | 585 | xid = GetXid(); |
589 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) | 586 | |
590 | cifs_get_inode_info_unix(&inode, "", inode->i_sb,xid); | 587 | if (cifs_sb->tcon->unix_ext) |
588 | cifs_get_inode_info_unix(&inode, "", inode->i_sb, xid); | ||
591 | else | 589 | else |
592 | cifs_get_inode_info(&inode, "", NULL, inode->i_sb,xid); | 590 | cifs_get_inode_info(&inode, "", NULL, inode->i_sb, xid); |
593 | /* can not call macro FreeXid here since in a void func */ | 591 | /* can not call macro FreeXid here since in a void func */ |
594 | _FreeXid(xid); | 592 | _FreeXid(xid); |
595 | } | 593 | } |
@@ -623,9 +621,21 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
623 | FreeXid(xid); | 621 | FreeXid(xid); |
624 | return -ENOMEM; | 622 | return -ENOMEM; |
625 | } | 623 | } |
626 | rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls, | 624 | |
625 | if ((pTcon->ses->capabilities & CAP_UNIX) && | ||
626 | (CIFS_UNIX_POSIX_PATH_OPS_CAP & | ||
627 | le64_to_cpu(pTcon->fsUnixInfo.Capability))) { | ||
628 | rc = CIFSPOSIXDelFile(xid, pTcon, full_path, | ||
629 | SMB_POSIX_UNLINK_FILE_TARGET, cifs_sb->local_nls, | ||
627 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 630 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
631 | cFYI(1, ("posix del rc %d", rc)); | ||
632 | if ((rc == 0) || (rc == -ENOENT)) | ||
633 | goto psx_del_no_retry; | ||
634 | } | ||
628 | 635 | ||
636 | rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls, | ||
637 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
638 | psx_del_no_retry: | ||
629 | if (!rc) { | 639 | if (!rc) { |
630 | if (direntry->d_inode) | 640 | if (direntry->d_inode) |
631 | drop_nlink(direntry->d_inode); | 641 | drop_nlink(direntry->d_inode); |
@@ -638,12 +648,12 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
638 | rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, | 648 | rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, |
639 | CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, | 649 | CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, |
640 | &netfid, &oplock, NULL, cifs_sb->local_nls, | 650 | &netfid, &oplock, NULL, cifs_sb->local_nls, |
641 | cifs_sb->mnt_cifs_flags & | 651 | cifs_sb->mnt_cifs_flags & |
642 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 652 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
643 | if (rc==0) { | 653 | if (rc == 0) { |
644 | CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL, | 654 | CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL, |
645 | cifs_sb->local_nls, | 655 | cifs_sb->local_nls, |
646 | cifs_sb->mnt_cifs_flags & | 656 | cifs_sb->mnt_cifs_flags & |
647 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 657 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
648 | CIFSSMBClose(xid, pTcon, netfid); | 658 | CIFSSMBClose(xid, pTcon, netfid); |
649 | if (direntry->d_inode) | 659 | if (direntry->d_inode) |
@@ -659,7 +669,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
659 | rc = CIFSSMBSetTimes(xid, pTcon, full_path, | 669 | rc = CIFSSMBSetTimes(xid, pTcon, full_path, |
660 | pinfo_buf, | 670 | pinfo_buf, |
661 | cifs_sb->local_nls, | 671 | cifs_sb->local_nls, |
662 | cifs_sb->mnt_cifs_flags & | 672 | cifs_sb->mnt_cifs_flags & |
663 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 673 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
664 | else | 674 | else |
665 | rc = -EOPNOTSUPP; | 675 | rc = -EOPNOTSUPP; |
@@ -670,7 +680,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
670 | /* rc = CIFSSMBSetAttrLegacy(xid, pTcon, | 680 | /* rc = CIFSSMBSetAttrLegacy(xid, pTcon, |
671 | full_path, | 681 | full_path, |
672 | (__u16)ATTR_NORMAL, | 682 | (__u16)ATTR_NORMAL, |
673 | cifs_sb->local_nls); | 683 | cifs_sb->local_nls); |
674 | For some strange reason it seems that NT4 eats the | 684 | For some strange reason it seems that NT4 eats the |
675 | old setattr call without actually setting the | 685 | old setattr call without actually setting the |
676 | attributes so on to the third attempted workaround | 686 | attributes so on to the third attempted workaround |
@@ -683,9 +693,9 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
683 | FILE_WRITE_ATTRIBUTES, 0, | 693 | FILE_WRITE_ATTRIBUTES, 0, |
684 | &netfid, &oplock, NULL, | 694 | &netfid, &oplock, NULL, |
685 | cifs_sb->local_nls, | 695 | cifs_sb->local_nls, |
686 | cifs_sb->mnt_cifs_flags & | 696 | cifs_sb->mnt_cifs_flags & |
687 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 697 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
688 | if (rc==0) { | 698 | if (rc == 0) { |
689 | rc = CIFSSMBSetFileTimes(xid, pTcon, | 699 | rc = CIFSSMBSetFileTimes(xid, pTcon, |
690 | pinfo_buf, | 700 | pinfo_buf, |
691 | netfid); | 701 | netfid); |
@@ -694,10 +704,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
694 | } | 704 | } |
695 | kfree(pinfo_buf); | 705 | kfree(pinfo_buf); |
696 | } | 706 | } |
697 | if (rc==0) { | 707 | if (rc == 0) { |
698 | rc = CIFSSMBDelFile(xid, pTcon, full_path, | 708 | rc = CIFSSMBDelFile(xid, pTcon, full_path, |
699 | cifs_sb->local_nls, | 709 | cifs_sb->local_nls, |
700 | cifs_sb->mnt_cifs_flags & | 710 | cifs_sb->mnt_cifs_flags & |
701 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 711 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
702 | if (!rc) { | 712 | if (!rc) { |
703 | if (direntry->d_inode) | 713 | if (direntry->d_inode) |
@@ -711,10 +721,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
711 | CREATE_NOT_DIR | | 721 | CREATE_NOT_DIR | |
712 | CREATE_DELETE_ON_CLOSE, | 722 | CREATE_DELETE_ON_CLOSE, |
713 | &netfid, &oplock, NULL, | 723 | &netfid, &oplock, NULL, |
714 | cifs_sb->local_nls, | 724 | cifs_sb->local_nls, |
715 | cifs_sb->mnt_cifs_flags & | 725 | cifs_sb->mnt_cifs_flags & |
716 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 726 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
717 | if (rc==0) { | 727 | if (rc == 0) { |
718 | CIFSSMBRenameOpenFile(xid, pTcon, | 728 | CIFSSMBRenameOpenFile(xid, pTcon, |
719 | netfid, NULL, | 729 | netfid, NULL, |
720 | cifs_sb->local_nls, | 730 | cifs_sb->local_nls, |
@@ -773,8 +783,8 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
773 | 783 | ||
774 | tmp_inode->i_mode = le64_to_cpu(pData->Permissions); | 784 | tmp_inode->i_mode = le64_to_cpu(pData->Permissions); |
775 | /* since we set the inode type below we need to mask off type | 785 | /* since we set the inode type below we need to mask off type |
776 | to avoid strange results if bits above were corrupt */ | 786 | to avoid strange results if bits above were corrupt */ |
777 | tmp_inode->i_mode &= ~S_IFMT; | 787 | tmp_inode->i_mode &= ~S_IFMT; |
778 | if (type == UNIX_FILE) { | 788 | if (type == UNIX_FILE) { |
779 | *pobject_type = DT_REG; | 789 | *pobject_type = DT_REG; |
780 | tmp_inode->i_mode |= S_IFREG; | 790 | tmp_inode->i_mode |= S_IFREG; |
@@ -804,11 +814,11 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
804 | /* safest to just call it a file */ | 814 | /* safest to just call it a file */ |
805 | *pobject_type = DT_REG; | 815 | *pobject_type = DT_REG; |
806 | tmp_inode->i_mode |= S_IFREG; | 816 | tmp_inode->i_mode |= S_IFREG; |
807 | cFYI(1,("unknown inode type %d",type)); | 817 | cFYI(1, ("unknown inode type %d", type)); |
808 | } | 818 | } |
809 | 819 | ||
810 | #ifdef CONFIG_CIFS_DEBUG2 | 820 | #ifdef CONFIG_CIFS_DEBUG2 |
811 | cFYI(1,("object type: %d", type)); | 821 | cFYI(1, ("object type: %d", type)); |
812 | #endif | 822 | #endif |
813 | tmp_inode->i_uid = le64_to_cpu(pData->Uid); | 823 | tmp_inode->i_uid = le64_to_cpu(pData->Uid); |
814 | tmp_inode->i_gid = le64_to_cpu(pData->Gid); | 824 | tmp_inode->i_gid = le64_to_cpu(pData->Gid); |
@@ -816,7 +826,7 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
816 | 826 | ||
817 | spin_lock(&tmp_inode->i_lock); | 827 | spin_lock(&tmp_inode->i_lock); |
818 | if (is_size_safe_to_change(cifsInfo, end_of_file)) { | 828 | if (is_size_safe_to_change(cifsInfo, end_of_file)) { |
819 | /* can not safely change the file size here if the | 829 | /* can not safely change the file size here if the |
820 | client is writing to it due to potential races */ | 830 | client is writing to it due to potential races */ |
821 | i_size_write(tmp_inode, end_of_file); | 831 | i_size_write(tmp_inode, end_of_file); |
822 | 832 | ||
@@ -830,27 +840,28 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
830 | cFYI(1, ("File inode")); | 840 | cFYI(1, ("File inode")); |
831 | tmp_inode->i_op = &cifs_file_inode_ops; | 841 | tmp_inode->i_op = &cifs_file_inode_ops; |
832 | 842 | ||
833 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | 843 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { |
834 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 844 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
835 | tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; | 845 | tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; |
836 | else | 846 | else |
837 | tmp_inode->i_fop = &cifs_file_direct_ops; | 847 | tmp_inode->i_fop = &cifs_file_direct_ops; |
838 | 848 | ||
839 | } else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 849 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
840 | tmp_inode->i_fop = &cifs_file_nobrl_ops; | 850 | tmp_inode->i_fop = &cifs_file_nobrl_ops; |
841 | else | 851 | else |
842 | tmp_inode->i_fop = &cifs_file_ops; | 852 | tmp_inode->i_fop = &cifs_file_ops; |
843 | 853 | ||
844 | if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && | 854 | if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) && |
845 | (cifs_sb->tcon->ses->server->maxBuf < | 855 | (cifs_sb->tcon->ses->server->maxBuf < |
846 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) | 856 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) |
847 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 857 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
848 | else | 858 | else |
849 | tmp_inode->i_data.a_ops = &cifs_addr_ops; | 859 | tmp_inode->i_data.a_ops = &cifs_addr_ops; |
850 | 860 | ||
851 | if(isNewInode) | 861 | if (isNewInode) |
852 | return; /* No sense invalidating pages for new inode since we | 862 | return; /* No sense invalidating pages for new inode |
853 | have not started caching readahead file data yet */ | 863 | since we we have not started caching |
864 | readahead file data yet */ | ||
854 | 865 | ||
855 | if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) && | 866 | if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) && |
856 | (local_size == tmp_inode->i_size)) { | 867 | (local_size == tmp_inode->i_size)) { |
@@ -869,10 +880,10 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
869 | tmp_inode->i_op = &cifs_symlink_inode_ops; | 880 | tmp_inode->i_op = &cifs_symlink_inode_ops; |
870 | /* tmp_inode->i_fop = *//* do not need to set to anything */ | 881 | /* tmp_inode->i_fop = *//* do not need to set to anything */ |
871 | } else { | 882 | } else { |
872 | cFYI(1, ("Special inode")); | 883 | cFYI(1, ("Special inode")); |
873 | init_special_inode(tmp_inode, tmp_inode->i_mode, | 884 | init_special_inode(tmp_inode, tmp_inode->i_mode, |
874 | tmp_inode->i_rdev); | 885 | tmp_inode->i_rdev); |
875 | } | 886 | } |
876 | } | 887 | } |
877 | 888 | ||
878 | int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | 889 | int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) |
@@ -896,22 +907,22 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
896 | FreeXid(xid); | 907 | FreeXid(xid); |
897 | return -ENOMEM; | 908 | return -ENOMEM; |
898 | } | 909 | } |
899 | 910 | ||
900 | if((pTcon->ses->capabilities & CAP_UNIX) && | 911 | if ((pTcon->ses->capabilities & CAP_UNIX) && |
901 | (CIFS_UNIX_POSIX_PATH_OPS_CAP & | 912 | (CIFS_UNIX_POSIX_PATH_OPS_CAP & |
902 | le64_to_cpu(pTcon->fsUnixInfo.Capability))) { | 913 | le64_to_cpu(pTcon->fsUnixInfo.Capability))) { |
903 | u32 oplock = 0; | 914 | u32 oplock = 0; |
904 | FILE_UNIX_BASIC_INFO * pInfo = | 915 | FILE_UNIX_BASIC_INFO * pInfo = |
905 | kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); | 916 | kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); |
906 | if(pInfo == NULL) { | 917 | if (pInfo == NULL) { |
907 | rc = -ENOMEM; | 918 | rc = -ENOMEM; |
908 | goto mkdir_out; | 919 | goto mkdir_out; |
909 | } | 920 | } |
910 | 921 | ||
911 | rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT, | 922 | rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT, |
912 | mode, NULL /* netfid */, pInfo, &oplock, | 923 | mode, NULL /* netfid */, pInfo, &oplock, |
913 | full_path, cifs_sb->local_nls, | 924 | full_path, cifs_sb->local_nls, |
914 | cifs_sb->mnt_cifs_flags & | 925 | cifs_sb->mnt_cifs_flags & |
915 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 926 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
916 | if (rc) { | 927 | if (rc) { |
917 | cFYI(1, ("posix mkdir returned 0x%x", rc)); | 928 | cFYI(1, ("posix mkdir returned 0x%x", rc)); |
@@ -919,8 +930,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
919 | } else { | 930 | } else { |
920 | int obj_type; | 931 | int obj_type; |
921 | if (pInfo->Type == -1) /* no return info - go query */ | 932 | if (pInfo->Type == -1) /* no return info - go query */ |
922 | goto mkdir_get_info; | 933 | goto mkdir_get_info; |
923 | /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need to set uid/gid */ | 934 | /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need |
935 | to set uid/gid */ | ||
924 | inc_nlink(inode); | 936 | inc_nlink(inode); |
925 | if (pTcon->nocase) | 937 | if (pTcon->nocase) |
926 | direntry->d_op = &cifs_ci_dentry_ops; | 938 | direntry->d_op = &cifs_ci_dentry_ops; |
@@ -937,7 +949,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
937 | newinode->i_ino = | 949 | newinode->i_ino = |
938 | (unsigned long)pInfo->UniqueId; | 950 | (unsigned long)pInfo->UniqueId; |
939 | } /* note ino incremented to unique num in new_inode */ | 951 | } /* note ino incremented to unique num in new_inode */ |
940 | if(inode->i_sb->s_flags & MS_NOATIME) | 952 | if (inode->i_sb->s_flags & MS_NOATIME) |
941 | newinode->i_flags |= S_NOATIME | S_NOCMTIME; | 953 | newinode->i_flags |= S_NOATIME | S_NOCMTIME; |
942 | newinode->i_nlink = 2; | 954 | newinode->i_nlink = 2; |
943 | 955 | ||
@@ -949,18 +961,18 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
949 | posix_fill_in_inode(direntry->d_inode, | 961 | posix_fill_in_inode(direntry->d_inode, |
950 | pInfo, &obj_type, 1 /* NewInode */); | 962 | pInfo, &obj_type, 1 /* NewInode */); |
951 | #ifdef CONFIG_CIFS_DEBUG2 | 963 | #ifdef CONFIG_CIFS_DEBUG2 |
952 | cFYI(1,("instantiated dentry %p %s to inode %p", | 964 | cFYI(1, ("instantiated dentry %p %s to inode %p", |
953 | direntry, direntry->d_name.name, newinode)); | 965 | direntry, direntry->d_name.name, newinode)); |
954 | 966 | ||
955 | if(newinode->i_nlink != 2) | 967 | if (newinode->i_nlink != 2) |
956 | cFYI(1,("unexpected number of links %d", | 968 | cFYI(1, ("unexpected number of links %d", |
957 | newinode->i_nlink)); | 969 | newinode->i_nlink)); |
958 | #endif | 970 | #endif |
959 | } | 971 | } |
960 | kfree(pInfo); | 972 | kfree(pInfo); |
961 | goto mkdir_out; | 973 | goto mkdir_out; |
962 | } | 974 | } |
963 | 975 | ||
964 | /* BB add setting the equivalent of mode via CreateX w/ACLs */ | 976 | /* BB add setting the equivalent of mode via CreateX w/ACLs */ |
965 | rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls, | 977 | rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls, |
966 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 978 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
@@ -968,14 +980,14 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
968 | cFYI(1, ("cifs_mkdir returned 0x%x", rc)); | 980 | cFYI(1, ("cifs_mkdir returned 0x%x", rc)); |
969 | d_drop(direntry); | 981 | d_drop(direntry); |
970 | } else { | 982 | } else { |
971 | mkdir_get_info: | 983 | mkdir_get_info: |
972 | inc_nlink(inode); | 984 | inc_nlink(inode); |
973 | if (pTcon->ses->capabilities & CAP_UNIX) | 985 | if (pTcon->unix_ext) |
974 | rc = cifs_get_inode_info_unix(&newinode, full_path, | 986 | rc = cifs_get_inode_info_unix(&newinode, full_path, |
975 | inode->i_sb,xid); | 987 | inode->i_sb, xid); |
976 | else | 988 | else |
977 | rc = cifs_get_inode_info(&newinode, full_path, NULL, | 989 | rc = cifs_get_inode_info(&newinode, full_path, NULL, |
978 | inode->i_sb,xid); | 990 | inode->i_sb, xid); |
979 | 991 | ||
980 | if (pTcon->nocase) | 992 | if (pTcon->nocase) |
981 | direntry->d_op = &cifs_ci_dentry_ops; | 993 | direntry->d_op = &cifs_ci_dentry_ops; |
@@ -983,10 +995,10 @@ mkdir_get_info: | |||
983 | direntry->d_op = &cifs_dentry_ops; | 995 | direntry->d_op = &cifs_dentry_ops; |
984 | d_instantiate(direntry, newinode); | 996 | d_instantiate(direntry, newinode); |
985 | /* setting nlink not necessary except in cases where we | 997 | /* setting nlink not necessary except in cases where we |
986 | * failed to get it from the server or was set bogus */ | 998 | * failed to get it from the server or was set bogus */ |
987 | if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) | 999 | if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) |
988 | direntry->d_inode->i_nlink = 2; | 1000 | direntry->d_inode->i_nlink = 2; |
989 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { | 1001 | if (pTcon->unix_ext) { |
990 | mode &= ~current->fs->umask; | 1002 | mode &= ~current->fs->umask; |
991 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { | 1003 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
992 | CIFSSMBUnixSetPerms(xid, pTcon, full_path, | 1004 | CIFSSMBUnixSetPerms(xid, pTcon, full_path, |
@@ -1002,27 +1014,27 @@ mkdir_get_info: | |||
1002 | mode, (__u64)-1, | 1014 | mode, (__u64)-1, |
1003 | (__u64)-1, 0 /* dev_t */, | 1015 | (__u64)-1, 0 /* dev_t */, |
1004 | cifs_sb->local_nls, | 1016 | cifs_sb->local_nls, |
1005 | cifs_sb->mnt_cifs_flags & | 1017 | cifs_sb->mnt_cifs_flags & |
1006 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1018 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1007 | } | 1019 | } |
1008 | } else { | 1020 | } else { |
1009 | /* BB to be implemented via Windows secrty descriptors | 1021 | /* BB to be implemented via Windows secrty descriptors |
1010 | eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, | 1022 | eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, |
1011 | -1, -1, local_nls); */ | 1023 | -1, -1, local_nls); */ |
1012 | if(direntry->d_inode) { | 1024 | if (direntry->d_inode) { |
1013 | direntry->d_inode->i_mode = mode; | 1025 | direntry->d_inode->i_mode = mode; |
1014 | direntry->d_inode->i_mode |= S_IFDIR; | 1026 | direntry->d_inode->i_mode |= S_IFDIR; |
1015 | if(cifs_sb->mnt_cifs_flags & | 1027 | if (cifs_sb->mnt_cifs_flags & |
1016 | CIFS_MOUNT_SET_UID) { | 1028 | CIFS_MOUNT_SET_UID) { |
1017 | direntry->d_inode->i_uid = | 1029 | direntry->d_inode->i_uid = |
1018 | current->fsuid; | 1030 | current->fsuid; |
1019 | direntry->d_inode->i_gid = | 1031 | direntry->d_inode->i_gid = |
1020 | current->fsgid; | 1032 | current->fsgid; |
1021 | } | 1033 | } |
1022 | } | 1034 | } |
1023 | } | 1035 | } |
1024 | } | 1036 | } |
1025 | mkdir_out: | 1037 | mkdir_out: |
1026 | kfree(full_path); | 1038 | kfree(full_path); |
1027 | FreeXid(xid); | 1039 | FreeXid(xid); |
1028 | return rc; | 1040 | return rc; |
@@ -1056,7 +1068,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) | |||
1056 | if (!rc) { | 1068 | if (!rc) { |
1057 | drop_nlink(inode); | 1069 | drop_nlink(inode); |
1058 | spin_lock(&direntry->d_inode->i_lock); | 1070 | spin_lock(&direntry->d_inode->i_lock); |
1059 | i_size_write(direntry->d_inode,0); | 1071 | i_size_write(direntry->d_inode, 0); |
1060 | clear_nlink(direntry->d_inode); | 1072 | clear_nlink(direntry->d_inode); |
1061 | spin_unlock(&direntry->d_inode->i_lock); | 1073 | spin_unlock(&direntry->d_inode->i_lock); |
1062 | } | 1074 | } |
@@ -1119,9 +1131,9 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, | |||
1119 | kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); | 1131 | kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); |
1120 | if (info_buf_source != NULL) { | 1132 | if (info_buf_source != NULL) { |
1121 | info_buf_target = info_buf_source + 1; | 1133 | info_buf_target = info_buf_source + 1; |
1122 | if (pTcon->ses->capabilities & CAP_UNIX) | 1134 | if (pTcon->unix_ext) |
1123 | rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, | 1135 | rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, |
1124 | info_buf_source, | 1136 | info_buf_source, |
1125 | cifs_sb_source->local_nls, | 1137 | cifs_sb_source->local_nls, |
1126 | cifs_sb_source->mnt_cifs_flags & | 1138 | cifs_sb_source->mnt_cifs_flags & |
1127 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1139 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
@@ -1171,12 +1183,12 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, | |||
1171 | might not right be right access to request */ | 1183 | might not right be right access to request */ |
1172 | rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ, | 1184 | rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ, |
1173 | CREATE_NOT_DIR, &netfid, &oplock, NULL, | 1185 | CREATE_NOT_DIR, &netfid, &oplock, NULL, |
1174 | cifs_sb_source->local_nls, | 1186 | cifs_sb_source->local_nls, |
1175 | cifs_sb_source->mnt_cifs_flags & | 1187 | cifs_sb_source->mnt_cifs_flags & |
1176 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1188 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1177 | if (rc==0) { | 1189 | if (rc == 0) { |
1178 | rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName, | 1190 | rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName, |
1179 | cifs_sb_source->local_nls, | 1191 | cifs_sb_source->local_nls, |
1180 | cifs_sb_source->mnt_cifs_flags & | 1192 | cifs_sb_source->mnt_cifs_flags & |
1181 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1193 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1182 | CIFSSMBClose(xid, pTcon, netfid); | 1194 | CIFSSMBClose(xid, pTcon, netfid); |
@@ -1247,9 +1259,9 @@ int cifs_revalidate(struct dentry *direntry) | |||
1247 | local_mtime = direntry->d_inode->i_mtime; | 1259 | local_mtime = direntry->d_inode->i_mtime; |
1248 | local_size = direntry->d_inode->i_size; | 1260 | local_size = direntry->d_inode->i_size; |
1249 | 1261 | ||
1250 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { | 1262 | if (cifs_sb->tcon->unix_ext) { |
1251 | rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path, | 1263 | rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path, |
1252 | direntry->d_sb,xid); | 1264 | direntry->d_sb, xid); |
1253 | if (rc) { | 1265 | if (rc) { |
1254 | cFYI(1, ("error on getting revalidate info %d", rc)); | 1266 | cFYI(1, ("error on getting revalidate info %d", rc)); |
1255 | /* if (rc != -ENOENT) | 1267 | /* if (rc != -ENOENT) |
@@ -1258,7 +1270,7 @@ int cifs_revalidate(struct dentry *direntry) | |||
1258 | } | 1270 | } |
1259 | } else { | 1271 | } else { |
1260 | rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL, | 1272 | rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL, |
1261 | direntry->d_sb,xid); | 1273 | direntry->d_sb, xid); |
1262 | if (rc) { | 1274 | if (rc) { |
1263 | cFYI(1, ("error on getting revalidate info %d", rc)); | 1275 | cFYI(1, ("error on getting revalidate info %d", rc)); |
1264 | /* if (rc != -ENOENT) | 1276 | /* if (rc != -ENOENT) |
@@ -1271,7 +1283,7 @@ int cifs_revalidate(struct dentry *direntry) | |||
1271 | /* if not oplocked, we invalidate inode pages if mtime or file size | 1283 | /* if not oplocked, we invalidate inode pages if mtime or file size |
1272 | had changed on server */ | 1284 | had changed on server */ |
1273 | 1285 | ||
1274 | if (timespec_equal(&local_mtime,&direntry->d_inode->i_mtime) && | 1286 | if (timespec_equal(&local_mtime, &direntry->d_inode->i_mtime) && |
1275 | (local_size == direntry->d_inode->i_size)) { | 1287 | (local_size == direntry->d_inode->i_size)) { |
1276 | cFYI(1, ("cifs_revalidate - inode unchanged")); | 1288 | cFYI(1, ("cifs_revalidate - inode unchanged")); |
1277 | } else { | 1289 | } else { |
@@ -1298,7 +1310,7 @@ int cifs_revalidate(struct dentry *direntry) | |||
1298 | if (invalidate_inode) { | 1310 | if (invalidate_inode) { |
1299 | /* shrink_dcache not necessary now that cifs dentry ops | 1311 | /* shrink_dcache not necessary now that cifs dentry ops |
1300 | are exported for negative dentries */ | 1312 | are exported for negative dentries */ |
1301 | /* if(S_ISDIR(direntry->d_inode->i_mode)) | 1313 | /* if (S_ISDIR(direntry->d_inode->i_mode)) |
1302 | shrink_dcache_parent(direntry); */ | 1314 | shrink_dcache_parent(direntry); */ |
1303 | if (S_ISREG(direntry->d_inode->i_mode)) { | 1315 | if (S_ISREG(direntry->d_inode->i_mode)) { |
1304 | if (direntry->d_inode->i_mapping) | 1316 | if (direntry->d_inode->i_mapping) |
@@ -1313,7 +1325,7 @@ int cifs_revalidate(struct dentry *direntry) | |||
1313 | } | 1325 | } |
1314 | } | 1326 | } |
1315 | /* mutex_unlock(&direntry->d_inode->i_mutex); */ | 1327 | /* mutex_unlock(&direntry->d_inode->i_mutex); */ |
1316 | 1328 | ||
1317 | kfree(full_path); | 1329 | kfree(full_path); |
1318 | FreeXid(xid); | 1330 | FreeXid(xid); |
1319 | return rc; | 1331 | return rc; |
@@ -1335,23 +1347,19 @@ static int cifs_truncate_page(struct address_space *mapping, loff_t from) | |||
1335 | pgoff_t index = from >> PAGE_CACHE_SHIFT; | 1347 | pgoff_t index = from >> PAGE_CACHE_SHIFT; |
1336 | unsigned offset = from & (PAGE_CACHE_SIZE - 1); | 1348 | unsigned offset = from & (PAGE_CACHE_SIZE - 1); |
1337 | struct page *page; | 1349 | struct page *page; |
1338 | char *kaddr; | ||
1339 | int rc = 0; | 1350 | int rc = 0; |
1340 | 1351 | ||
1341 | page = grab_cache_page(mapping, index); | 1352 | page = grab_cache_page(mapping, index); |
1342 | if (!page) | 1353 | if (!page) |
1343 | return -ENOMEM; | 1354 | return -ENOMEM; |
1344 | 1355 | ||
1345 | kaddr = kmap_atomic(page, KM_USER0); | 1356 | zero_user_page(page, offset, PAGE_CACHE_SIZE - offset, KM_USER0); |
1346 | memset(kaddr + offset, 0, PAGE_CACHE_SIZE - offset); | ||
1347 | flush_dcache_page(page); | ||
1348 | kunmap_atomic(kaddr, KM_USER0); | ||
1349 | unlock_page(page); | 1357 | unlock_page(page); |
1350 | page_cache_release(page); | 1358 | page_cache_release(page); |
1351 | return rc; | 1359 | return rc; |
1352 | } | 1360 | } |
1353 | 1361 | ||
1354 | static int cifs_vmtruncate(struct inode * inode, loff_t offset) | 1362 | static int cifs_vmtruncate(struct inode *inode, loff_t offset) |
1355 | { | 1363 | { |
1356 | struct address_space *mapping = inode->i_mapping; | 1364 | struct address_space *mapping = inode->i_mapping; |
1357 | unsigned long limit; | 1365 | unsigned long limit; |
@@ -1424,13 +1432,13 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1424 | if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) { | 1432 | if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) { |
1425 | /* check if we have permission to change attrs */ | 1433 | /* check if we have permission to change attrs */ |
1426 | rc = inode_change_ok(direntry->d_inode, attrs); | 1434 | rc = inode_change_ok(direntry->d_inode, attrs); |
1427 | if(rc < 0) { | 1435 | if (rc < 0) { |
1428 | FreeXid(xid); | 1436 | FreeXid(xid); |
1429 | return rc; | 1437 | return rc; |
1430 | } else | 1438 | } else |
1431 | rc = 0; | 1439 | rc = 0; |
1432 | } | 1440 | } |
1433 | 1441 | ||
1434 | full_path = build_path_from_dentry(direntry); | 1442 | full_path = build_path_from_dentry(direntry); |
1435 | if (full_path == NULL) { | 1443 | if (full_path == NULL) { |
1436 | FreeXid(xid); | 1444 | FreeXid(xid); |
@@ -1459,16 +1467,16 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1459 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, | 1467 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, |
1460 | nfid, npid, FALSE); | 1468 | nfid, npid, FALSE); |
1461 | atomic_dec(&open_file->wrtPending); | 1469 | atomic_dec(&open_file->wrtPending); |
1462 | cFYI(1,("SetFSize for attrs rc = %d", rc)); | 1470 | cFYI(1, ("SetFSize for attrs rc = %d", rc)); |
1463 | if((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | 1471 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { |
1464 | int bytes_written; | 1472 | int bytes_written; |
1465 | rc = CIFSSMBWrite(xid, pTcon, | 1473 | rc = CIFSSMBWrite(xid, pTcon, |
1466 | nfid, 0, attrs->ia_size, | 1474 | nfid, 0, attrs->ia_size, |
1467 | &bytes_written, NULL, NULL, | 1475 | &bytes_written, NULL, NULL, |
1468 | 1 /* 45 seconds */); | 1476 | 1 /* 45 seconds */); |
1469 | cFYI(1,("Wrt seteof rc %d", rc)); | 1477 | cFYI(1, ("Wrt seteof rc %d", rc)); |
1470 | } | 1478 | } |
1471 | } else | 1479 | } else |
1472 | rc = -EINVAL; | 1480 | rc = -EINVAL; |
1473 | 1481 | ||
1474 | if (rc != 0) { | 1482 | if (rc != 0) { |
@@ -1478,11 +1486,11 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1478 | it by handle */ | 1486 | it by handle */ |
1479 | rc = CIFSSMBSetEOF(xid, pTcon, full_path, | 1487 | rc = CIFSSMBSetEOF(xid, pTcon, full_path, |
1480 | attrs->ia_size, FALSE, | 1488 | attrs->ia_size, FALSE, |
1481 | cifs_sb->local_nls, | 1489 | cifs_sb->local_nls, |
1482 | cifs_sb->mnt_cifs_flags & | 1490 | cifs_sb->mnt_cifs_flags & |
1483 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1491 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1484 | cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); | 1492 | cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); |
1485 | if((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | 1493 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { |
1486 | __u16 netfid; | 1494 | __u16 netfid; |
1487 | int oplock = FALSE; | 1495 | int oplock = FALSE; |
1488 | 1496 | ||
@@ -1493,14 +1501,14 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1493 | NULL, cifs_sb->local_nls, | 1501 | NULL, cifs_sb->local_nls, |
1494 | cifs_sb->mnt_cifs_flags & | 1502 | cifs_sb->mnt_cifs_flags & |
1495 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1503 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1496 | if (rc==0) { | 1504 | if (rc == 0) { |
1497 | int bytes_written; | 1505 | int bytes_written; |
1498 | rc = CIFSSMBWrite(xid, pTcon, | 1506 | rc = CIFSSMBWrite(xid, pTcon, |
1499 | netfid, 0, | 1507 | netfid, 0, |
1500 | attrs->ia_size, | 1508 | attrs->ia_size, |
1501 | &bytes_written, NULL, | 1509 | &bytes_written, NULL, |
1502 | NULL, 1 /* 45 sec */); | 1510 | NULL, 1 /* 45 sec */); |
1503 | cFYI(1,("wrt seteof rc %d",rc)); | 1511 | cFYI(1, ("wrt seteof rc %d", rc)); |
1504 | CIFSSMBClose(xid, pTcon, netfid); | 1512 | CIFSSMBClose(xid, pTcon, netfid); |
1505 | } | 1513 | } |
1506 | 1514 | ||
@@ -1517,7 +1525,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1517 | rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size); | 1525 | rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size); |
1518 | cifs_truncate_page(direntry->d_inode->i_mapping, | 1526 | cifs_truncate_page(direntry->d_inode->i_mapping, |
1519 | direntry->d_inode->i_size); | 1527 | direntry->d_inode->i_size); |
1520 | } else | 1528 | } else |
1521 | goto cifs_setattr_exit; | 1529 | goto cifs_setattr_exit; |
1522 | } | 1530 | } |
1523 | if (attrs->ia_valid & ATTR_UID) { | 1531 | if (attrs->ia_valid & ATTR_UID) { |
@@ -1535,11 +1543,11 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1535 | mode = attrs->ia_mode; | 1543 | mode = attrs->ia_mode; |
1536 | } | 1544 | } |
1537 | 1545 | ||
1538 | if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) | 1546 | if ((pTcon->unix_ext) |
1539 | && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) | 1547 | && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) |
1540 | rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid, | 1548 | rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid, |
1541 | 0 /* dev_t */, cifs_sb->local_nls, | 1549 | 0 /* dev_t */, cifs_sb->local_nls, |
1542 | cifs_sb->mnt_cifs_flags & | 1550 | cifs_sb->mnt_cifs_flags & |
1543 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1551 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1544 | else if (attrs->ia_valid & ATTR_MODE) { | 1552 | else if (attrs->ia_valid & ATTR_MODE) { |
1545 | rc = 0; | 1553 | rc = 0; |
@@ -1559,7 +1567,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1559 | time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs & | 1567 | time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs & |
1560 | (~ATTR_READONLY)); | 1568 | (~ATTR_READONLY)); |
1561 | /* Windows ignores set to zero */ | 1569 | /* Windows ignores set to zero */ |
1562 | if(time_buf.Attributes == 0) | 1570 | if (time_buf.Attributes == 0) |
1563 | time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL); | 1571 | time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL); |
1564 | } | 1572 | } |
1565 | /* BB to be implemented - | 1573 | /* BB to be implemented - |
@@ -1585,7 +1593,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1585 | stamps are changed explicitly (i.e. by utime() | 1593 | stamps are changed explicitly (i.e. by utime() |
1586 | since we would then have a mix of client and | 1594 | since we would then have a mix of client and |
1587 | server times */ | 1595 | server times */ |
1588 | 1596 | ||
1589 | if (set_time && (attrs->ia_valid & ATTR_CTIME)) { | 1597 | if (set_time && (attrs->ia_valid & ATTR_CTIME)) { |
1590 | set_time = TRUE; | 1598 | set_time = TRUE; |
1591 | /* Although Samba throws this field away | 1599 | /* Although Samba throws this field away |
@@ -1624,7 +1632,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1624 | NULL, cifs_sb->local_nls, | 1632 | NULL, cifs_sb->local_nls, |
1625 | cifs_sb->mnt_cifs_flags & | 1633 | cifs_sb->mnt_cifs_flags & |
1626 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1634 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1627 | if (rc==0) { | 1635 | if (rc == 0) { |
1628 | rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf, | 1636 | rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf, |
1629 | netfid); | 1637 | netfid); |
1630 | CIFSSMBClose(xid, pTcon, netfid); | 1638 | CIFSSMBClose(xid, pTcon, netfid); |
@@ -1634,7 +1642,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1634 | granularity */ | 1642 | granularity */ |
1635 | 1643 | ||
1636 | /* rc = CIFSSMBSetTimesLegacy(xid, pTcon, full_path, | 1644 | /* rc = CIFSSMBSetTimesLegacy(xid, pTcon, full_path, |
1637 | &time_buf, cifs_sb->local_nls); */ | 1645 | &time_buf, cifs_sb->local_nls); */ |
1638 | } | 1646 | } |
1639 | } | 1647 | } |
1640 | /* Even if error on time set, no sense failing the call if | 1648 | /* Even if error on time set, no sense failing the call if |
@@ -1642,7 +1650,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1642 | and this check ensures that we are not being called from | 1650 | and this check ensures that we are not being called from |
1643 | sys_utimes in which case we ought to fail the call back to | 1651 | sys_utimes in which case we ought to fail the call back to |
1644 | the user when the server rejects the call */ | 1652 | the user when the server rejects the call */ |
1645 | if((rc) && (attrs->ia_valid & | 1653 | if ((rc) && (attrs->ia_valid & |
1646 | (ATTR_MODE | ATTR_GID | ATTR_UID | ATTR_SIZE))) | 1654 | (ATTR_MODE | ATTR_GID | ATTR_UID | ATTR_SIZE))) |
1647 | rc = 0; | 1655 | rc = 0; |
1648 | } | 1656 | } |