4 * Copyright (C) International Business Machines Corp., 2002,2005
5 * Author(s): Steve French (sfrench@us.ibm.com)
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/stat.h>
23 #include <linux/pagemap.h>
24 #include <asm/div64.h>
28 #include "cifsproto.h"
29 #include "cifs_debug.h"
30 #include "cifs_fs_sb.h"
32 int cifs_get_inode_info_unix(struct inode
**pinode
,
33 const unsigned char *search_path
, struct super_block
*sb
, int xid
)
36 FILE_UNIX_BASIC_INFO findData
;
37 struct cifsTconInfo
*pTcon
;
39 struct cifs_sb_info
*cifs_sb
= CIFS_SB(sb
);
42 pTcon
= cifs_sb
->tcon
;
43 cFYI(1, ("Getting info on %s", search_path
));
44 /* could have done a find first instead but this returns more info */
45 rc
= CIFSSMBUnixQPathInfo(xid
, pTcon
, search_path
, &findData
,
46 cifs_sb
->local_nls
, cifs_sb
->mnt_cifs_flags
&
47 CIFS_MOUNT_MAP_SPECIAL_CHR
);
48 /* dump_mem("\nUnixQPathInfo return data", &findData,
53 kmalloc(strnlen(pTcon
->treeName
,
55 strnlen(search_path
, MAX_PATHCONF
) + 1,
57 if (tmp_path
== NULL
) {
60 /* have to skip first of the double backslash of
62 strncpy(tmp_path
, pTcon
->treeName
, MAX_TREE_SIZE
);
63 strncat(tmp_path
, search_path
, MAX_PATHCONF
);
64 rc
= connect_to_dfs_path(xid
, pTcon
->ses
,
65 /* treename + */ tmp_path
,
67 cifs_sb
->mnt_cifs_flags
&
68 CIFS_MOUNT_MAP_SPECIAL_CHR
);
71 /* BB fix up inode etc. */
76 struct cifsInodeInfo
*cifsInfo
;
77 __u32 type
= le32_to_cpu(findData
.Type
);
78 __u64 num_of_bytes
= le64_to_cpu(findData
.NumOfBytes
);
79 __u64 end_of_file
= le64_to_cpu(findData
.EndOfFile
);
82 if (*pinode
== NULL
) {
83 *pinode
= new_inode(sb
);
86 /* Is an i_ino of zero legal? */
87 /* Are there sanity checks we can use to ensure that
88 the server is really filling in that field? */
89 if (cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_SERVER_INUM
) {
91 (unsigned long)findData
.UniqueId
;
92 } /* note ino incremented to unique num in new_inode */
93 insert_inode_hash(*pinode
);
97 cifsInfo
= CIFS_I(inode
);
99 cFYI(1, ("Old time %ld", cifsInfo
->time
));
100 cifsInfo
->time
= jiffies
;
101 cFYI(1, ("New time %ld", cifsInfo
->time
));
102 /* this is ok to set on every inode revalidate */
103 atomic_set(&cifsInfo
->inUse
,1);
106 cifs_NTtimeToUnix(le64_to_cpu(findData
.LastAccessTime
));
108 cifs_NTtimeToUnix(le64_to_cpu
109 (findData
.LastModificationTime
));
111 cifs_NTtimeToUnix(le64_to_cpu(findData
.LastStatusChange
));
112 inode
->i_mode
= le64_to_cpu(findData
.Permissions
);
113 /* since we set the inode type below we need to mask off
114 to avoid strange results if bits set above */
115 inode
->i_mode
&= ~S_IFMT
;
116 if (type
== UNIX_FILE
) {
117 inode
->i_mode
|= S_IFREG
;
118 } else if (type
== UNIX_SYMLINK
) {
119 inode
->i_mode
|= S_IFLNK
;
120 } else if (type
== UNIX_DIR
) {
121 inode
->i_mode
|= S_IFDIR
;
122 } else if (type
== UNIX_CHARDEV
) {
123 inode
->i_mode
|= S_IFCHR
;
124 inode
->i_rdev
= MKDEV(le64_to_cpu(findData
.DevMajor
),
125 le64_to_cpu(findData
.DevMinor
) & MINORMASK
);
126 } else if (type
== UNIX_BLOCKDEV
) {
127 inode
->i_mode
|= S_IFBLK
;
128 inode
->i_rdev
= MKDEV(le64_to_cpu(findData
.DevMajor
),
129 le64_to_cpu(findData
.DevMinor
) & MINORMASK
);
130 } else if (type
== UNIX_FIFO
) {
131 inode
->i_mode
|= S_IFIFO
;
132 } else if (type
== UNIX_SOCKET
) {
133 inode
->i_mode
|= S_IFSOCK
;
135 /* safest to call it a file if we do not know */
136 inode
->i_mode
|= S_IFREG
;
137 cFYI(1,("unknown type %d",type
));
139 inode
->i_uid
= le64_to_cpu(findData
.Uid
);
140 inode
->i_gid
= le64_to_cpu(findData
.Gid
);
141 inode
->i_nlink
= le64_to_cpu(findData
.Nlinks
);
143 if (is_size_safe_to_change(cifsInfo
)) {
144 /* can not safely change the file size here if the
145 client is writing to it due to potential races */
147 i_size_write(inode
, end_of_file
);
149 /* blksize needs to be multiple of two. So safer to default to
150 blksize and blkbits set in superblock so 2**blkbits and blksize
151 will match rather than setting to:
152 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
154 /* This seems incredibly stupid but it turns out that i_blocks
155 is not related to (i_size / i_blksize), instead 512 byte size
156 is required for calculating num blocks */
158 /* 512 bytes (2**9) is the fake blocksize that must be used */
159 /* for this calculation */
160 inode
->i_blocks
= (512 - 1 + num_of_bytes
) >> 9;
163 if (num_of_bytes
< end_of_file
)
164 cFYI(1, ("allocation size less than end of file"));
165 cFYI(1, ("Size %ld and blocks %llu",
166 (unsigned long) inode
->i_size
,
167 (unsigned long long)inode
->i_blocks
));
168 if (S_ISREG(inode
->i_mode
)) {
169 cFYI(1, ("File inode"));
170 inode
->i_op
= &cifs_file_inode_ops
;
171 if (cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_DIRECT_IO
) {
172 if (cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_NO_BRL
)
174 &cifs_file_direct_nobrl_ops
;
176 inode
->i_fop
= &cifs_file_direct_ops
;
177 } else if(cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_NO_BRL
)
178 inode
->i_fop
= &cifs_file_nobrl_ops
;
179 else /* not direct, send byte range locks */
180 inode
->i_fop
= &cifs_file_ops
;
182 /* check if server can support readpages */
183 if(pTcon
->ses
->server
->maxBuf
<
184 PAGE_CACHE_SIZE
+ MAX_CIFS_HDR_SIZE
)
185 inode
->i_data
.a_ops
= &cifs_addr_ops_smallbuf
;
187 inode
->i_data
.a_ops
= &cifs_addr_ops
;
188 } else if (S_ISDIR(inode
->i_mode
)) {
189 cFYI(1, ("Directory inode"));
190 inode
->i_op
= &cifs_dir_inode_ops
;
191 inode
->i_fop
= &cifs_dir_ops
;
192 } else if (S_ISLNK(inode
->i_mode
)) {
193 cFYI(1, ("Symbolic Link inode"));
194 inode
->i_op
= &cifs_symlink_inode_ops
;
195 /* tmp_inode->i_fop = */ /* do not need to set to anything */
197 cFYI(1, ("Init special inode"));
198 init_special_inode(inode
, inode
->i_mode
,
205 static int decode_sfu_inode(struct inode
* inode
, __u64 size
,
206 const unsigned char *path
,
207 struct cifs_sb_info
*cifs_sb
, int xid
)
212 struct cifsTconInfo
*pTcon
= cifs_sb
->tcon
;
214 unsigned int bytes_read
;
220 inode
->i_mode
|= S_IFIFO
;
222 } else if (size
< 8) {
223 return -EINVAL
; /* EOPNOTSUPP? */
226 rc
= CIFSSMBOpen(xid
, pTcon
, path
, FILE_OPEN
, GENERIC_READ
,
227 CREATE_NOT_DIR
, &netfid
, &oplock
, NULL
,
229 cifs_sb
->mnt_cifs_flags
&
230 CIFS_MOUNT_MAP_SPECIAL_CHR
);
232 int buf_type
= CIFS_NO_BUFFER
;
234 rc
= CIFSSMBRead(xid
, pTcon
,
236 24 /* length */, 0 /* offset */,
237 &bytes_read
, &pbuf
, &buf_type
);
238 if((rc
== 0) && (bytes_read
>= 8)) {
239 if(memcmp("IntxBLK", pbuf
, 8) == 0) {
240 cFYI(1,("Block device"));
241 inode
->i_mode
|= S_IFBLK
;
242 if(bytes_read
== 24) {
243 /* we have enough to decode dev num */
244 __u64 mjr
; /* major */
245 __u64 mnr
; /* minor */
246 mjr
= le64_to_cpu(*(__le64
*)(pbuf
+8));
247 mnr
= le64_to_cpu(*(__le64
*)(pbuf
+16));
248 inode
->i_rdev
= MKDEV(mjr
, mnr
);
250 } else if(memcmp("IntxCHR", pbuf
, 8) == 0) {
251 cFYI(1,("Char device"));
252 inode
->i_mode
|= S_IFCHR
;
253 if(bytes_read
== 24) {
254 /* we have enough to decode dev num */
255 __u64 mjr
; /* major */
256 __u64 mnr
; /* minor */
257 mjr
= le64_to_cpu(*(__le64
*)(pbuf
+8));
258 mnr
= le64_to_cpu(*(__le64
*)(pbuf
+16));
259 inode
->i_rdev
= MKDEV(mjr
, mnr
);
261 } else if(memcmp("IntxLNK", pbuf
, 7) == 0) {
263 inode
->i_mode
|= S_IFLNK
;
265 inode
->i_mode
|= S_IFREG
; /* file? */
269 inode
->i_mode
|= S_IFREG
; /* then it is a file */
270 rc
= -EOPNOTSUPP
; /* or some unknown SFU type */
272 CIFSSMBClose(xid
, pTcon
, netfid
);
278 #define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */
280 static int get_sfu_uid_mode(struct inode
* inode
,
281 const unsigned char *path
,
282 struct cifs_sb_info
*cifs_sb
, int xid
)
284 #ifdef CONFIG_CIFS_XATTR
289 rc
= CIFSSMBQueryEA(xid
, cifs_sb
->tcon
, path
, "SETFILEBITS",
290 ea_value
, 4 /* size of buf */, cifs_sb
->local_nls
,
291 cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_MAP_SPECIAL_CHR
);
295 mode
= le32_to_cpu(*((__le32
*)ea_value
));
296 inode
->i_mode
&= ~SFBITS_MASK
;
297 cFYI(1,("special bits 0%o org mode 0%o", mode
, inode
->i_mode
));
298 inode
->i_mode
= (mode
& SFBITS_MASK
) | inode
->i_mode
;
299 cFYI(1,("special mode bits 0%o", mode
));
311 int cifs_get_inode_info(struct inode
**pinode
,
312 const unsigned char *search_path
, FILE_ALL_INFO
*pfindData
,
313 struct super_block
*sb
, int xid
)
316 struct cifsTconInfo
*pTcon
;
318 struct cifs_sb_info
*cifs_sb
= CIFS_SB(sb
);
322 pTcon
= cifs_sb
->tcon
;
323 cFYI(1,("Getting info on %s", search_path
));
325 if ((pfindData
== NULL
) && (*pinode
!= NULL
)) {
326 if (CIFS_I(*pinode
)->clientCanCacheRead
) {
327 cFYI(1,("No need to revalidate cached inode sizes"));
332 /* if file info not passed in then get it from server */
333 if (pfindData
== NULL
) {
334 buf
= kmalloc(sizeof(FILE_ALL_INFO
), GFP_KERNEL
);
337 pfindData
= (FILE_ALL_INFO
*)buf
;
338 /* could do find first instead but this returns more info */
339 rc
= CIFSSMBQPathInfo(xid
, pTcon
, search_path
, pfindData
,
340 cifs_sb
->local_nls
, cifs_sb
->mnt_cifs_flags
&
341 CIFS_MOUNT_MAP_SPECIAL_CHR
);
342 /* BB optimize code so we do not make the above call
343 when server claims no NT SMB support and the above call
344 failed at least once - set flag in tcon or mount */
345 if((rc
== -EOPNOTSUPP
) || (rc
== -EINVAL
)) {
346 rc
= SMBQueryInformation(xid
, pTcon
, search_path
,
347 pfindData
, cifs_sb
->local_nls
,
348 cifs_sb
->mnt_cifs_flags
&
349 CIFS_MOUNT_MAP_SPECIAL_CHR
);
353 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */
355 if (rc
== -EREMOTE
) {
360 strnlen(search_path
, MAX_PATHCONF
) + 1,
362 if (tmp_path
== NULL
) {
367 strncpy(tmp_path
, pTcon
->treeName
, MAX_TREE_SIZE
);
368 strncat(tmp_path
, search_path
, MAX_PATHCONF
);
369 rc
= connect_to_dfs_path(xid
, pTcon
->ses
,
370 /* treename + */ tmp_path
,
372 cifs_sb
->mnt_cifs_flags
&
373 CIFS_MOUNT_MAP_SPECIAL_CHR
);
375 /* BB fix up inode etc. */
381 struct cifsInodeInfo
*cifsInfo
;
382 __u32 attr
= le32_to_cpu(pfindData
->Attributes
);
385 if (*pinode
== NULL
) {
386 *pinode
= new_inode(sb
);
389 /* Is an i_ino of zero legal? Can we use that to check
390 if the server supports returning inode numbers? Are
391 there other sanity checks we can use to ensure that
392 the server is really filling in that field? */
394 /* We can not use the IndexNumber field by default from
395 Windows or Samba (in ALL_INFO buf) but we can request
396 it explicitly. It may not be unique presumably if
397 the server has multiple devices mounted under one
400 /* There may be higher info levels that work but are
401 there Windows server or network appliances for which
402 IndexNumber field is not guaranteed unique? */
404 if (cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_SERVER_INUM
){
408 rc1
= CIFSGetSrvInodeNumber(xid
, pTcon
,
409 search_path
, &inode_num
,
411 cifs_sb
->mnt_cifs_flags
&
412 CIFS_MOUNT_MAP_SPECIAL_CHR
);
414 cFYI(1,("GetSrvInodeNum rc %d", rc1
));
415 /* BB EOPNOSUPP disable SERVER_INUM? */
416 } else /* do we need cast or hash to ino? */
417 (*pinode
)->i_ino
= inode_num
;
418 } /* else ino incremented to unique num in new_inode*/
419 insert_inode_hash(*pinode
);
422 cifsInfo
= CIFS_I(inode
);
423 cifsInfo
->cifsAttrs
= attr
;
424 cFYI(1, ("Old time %ld", cifsInfo
->time
));
425 cifsInfo
->time
= jiffies
;
426 cFYI(1, ("New time %ld", cifsInfo
->time
));
428 /* blksize needs to be multiple of two. So safer to default to
429 blksize and blkbits set in superblock so 2**blkbits and blksize
430 will match rather than setting to:
431 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
433 /* Linux can not store file creation time so ignore it */
435 cifs_NTtimeToUnix(le64_to_cpu(pfindData
->LastAccessTime
));
437 cifs_NTtimeToUnix(le64_to_cpu(pfindData
->LastWriteTime
));
439 cifs_NTtimeToUnix(le64_to_cpu(pfindData
->ChangeTime
));
440 cFYI(0, ("Attributes came in as 0x%x", attr
));
442 /* set default mode. will override for dirs below */
443 if (atomic_read(&cifsInfo
->inUse
) == 0)
444 /* new inode, can safely set these fields */
445 inode
->i_mode
= cifs_sb
->mnt_file_mode
;
446 else /* since we set the inode type below we need to mask off
447 to avoid strange results if type changes and both get orred in */
448 inode
->i_mode
&= ~S_IFMT
;
449 /* if (attr & ATTR_REPARSE) */
450 /* We no longer handle these as symlinks because we could not
451 follow them due to the absolute path with drive letter */
452 if (attr
& ATTR_DIRECTORY
) {
453 /* override default perms since we do not do byte range locking
455 inode
->i_mode
= cifs_sb
->mnt_dir_mode
;
456 inode
->i_mode
|= S_IFDIR
;
457 } else if ((cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_UNX_EMUL
) &&
458 (cifsInfo
->cifsAttrs
& ATTR_SYSTEM
) &&
459 /* No need to le64 convert size of zero */
460 (pfindData
->EndOfFile
== 0)) {
461 inode
->i_mode
= cifs_sb
->mnt_file_mode
;
462 inode
->i_mode
|= S_IFIFO
;
463 /* BB Finish for SFU style symlinks and devices */
464 } else if ((cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_UNX_EMUL
) &&
465 (cifsInfo
->cifsAttrs
& ATTR_SYSTEM
)) {
466 if (decode_sfu_inode(inode
,
467 le64_to_cpu(pfindData
->EndOfFile
),
470 cFYI(1,("Unrecognized sfu inode type"));
472 cFYI(1,("sfu mode 0%o",inode
->i_mode
));
474 inode
->i_mode
|= S_IFREG
;
475 /* treat the dos attribute of read-only as read-only
477 if (cifsInfo
->cifsAttrs
& ATTR_READONLY
)
478 inode
->i_mode
&= ~(S_IWUGO
);
479 /* BB add code here -
480 validate if device or weird share or device type? */
482 if (is_size_safe_to_change(cifsInfo
)) {
483 /* can not safely change the file size here if the
484 client is writing to it due to potential races */
485 i_size_write(inode
,le64_to_cpu(pfindData
->EndOfFile
));
487 /* 512 bytes (2**9) is the fake blocksize that must be
488 used for this calculation */
489 inode
->i_blocks
= (512 - 1 + le64_to_cpu(
490 pfindData
->AllocationSize
)) >> 9;
493 inode
->i_nlink
= le32_to_cpu(pfindData
->NumberOfLinks
);
495 /* BB fill in uid and gid here? with help from winbind?
496 or retrieve from NTFS stream extended attribute */
497 if(cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_UNX_EMUL
) {
498 /* fill in uid, gid, mode from server ACL */
499 get_sfu_uid_mode(inode
, search_path
, cifs_sb
, xid
);
500 } else if (atomic_read(&cifsInfo
->inUse
) == 0) {
501 inode
->i_uid
= cifs_sb
->mnt_uid
;
502 inode
->i_gid
= cifs_sb
->mnt_gid
;
503 /* set so we do not keep refreshing these fields with
504 bad data after user has changed them in memory */
505 atomic_set(&cifsInfo
->inUse
,1);
508 if (S_ISREG(inode
->i_mode
)) {
509 cFYI(1, ("File inode"));
510 inode
->i_op
= &cifs_file_inode_ops
;
511 if (cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_DIRECT_IO
) {
512 if (cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_NO_BRL
)
514 &cifs_file_direct_nobrl_ops
;
516 inode
->i_fop
= &cifs_file_direct_ops
;
517 } else if(cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_NO_BRL
)
518 inode
->i_fop
= &cifs_file_nobrl_ops
;
519 else /* not direct, send byte range locks */
520 inode
->i_fop
= &cifs_file_ops
;
522 if(pTcon
->ses
->server
->maxBuf
<
523 PAGE_CACHE_SIZE
+ MAX_CIFS_HDR_SIZE
)
524 inode
->i_data
.a_ops
= &cifs_addr_ops_smallbuf
;
526 inode
->i_data
.a_ops
= &cifs_addr_ops
;
527 } else if (S_ISDIR(inode
->i_mode
)) {
528 cFYI(1, ("Directory inode"));
529 inode
->i_op
= &cifs_dir_inode_ops
;
530 inode
->i_fop
= &cifs_dir_ops
;
531 } else if (S_ISLNK(inode
->i_mode
)) {
532 cFYI(1, ("Symbolic Link inode"));
533 inode
->i_op
= &cifs_symlink_inode_ops
;
535 init_special_inode(inode
, inode
->i_mode
,
543 /* gets root inode */
544 void cifs_read_inode(struct inode
*inode
)
547 struct cifs_sb_info
*cifs_sb
;
549 cifs_sb
= CIFS_SB(inode
->i_sb
);
551 if (cifs_sb
->tcon
->ses
->capabilities
& CAP_UNIX
)
552 cifs_get_inode_info_unix(&inode
, "", inode
->i_sb
,xid
);
554 cifs_get_inode_info(&inode
, "", NULL
, inode
->i_sb
,xid
);
555 /* can not call macro FreeXid here since in a void func */
559 int cifs_unlink(struct inode
*inode
, struct dentry
*direntry
)
563 struct cifs_sb_info
*cifs_sb
;
564 struct cifsTconInfo
*pTcon
;
565 char *full_path
= NULL
;
566 struct cifsInodeInfo
*cifsInode
;
567 FILE_BASIC_INFO
*pinfo_buf
;
569 cFYI(1, ("cifs_unlink, inode = 0x%p", inode
));
574 cifs_sb
= CIFS_SB(inode
->i_sb
);
576 cifs_sb
= CIFS_SB(direntry
->d_sb
);
577 pTcon
= cifs_sb
->tcon
;
579 /* Unlink can be called from rename so we can not grab the sem here
580 since we deadlock otherwise */
581 /* mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);*/
582 full_path
= build_path_from_dentry(direntry
);
583 /* mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);*/
584 if (full_path
== NULL
) {
588 rc
= CIFSSMBDelFile(xid
, pTcon
, full_path
, cifs_sb
->local_nls
,
589 cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_MAP_SPECIAL_CHR
);
592 if (direntry
->d_inode
)
593 drop_nlink(direntry
->d_inode
);
594 } else if (rc
== -ENOENT
) {
596 } else if (rc
== -ETXTBSY
) {
600 rc
= CIFSSMBOpen(xid
, pTcon
, full_path
, FILE_OPEN
, DELETE
,
601 CREATE_NOT_DIR
| CREATE_DELETE_ON_CLOSE
,
602 &netfid
, &oplock
, NULL
, cifs_sb
->local_nls
,
603 cifs_sb
->mnt_cifs_flags
&
604 CIFS_MOUNT_MAP_SPECIAL_CHR
);
606 CIFSSMBRenameOpenFile(xid
, pTcon
, netfid
, NULL
,
608 cifs_sb
->mnt_cifs_flags
&
609 CIFS_MOUNT_MAP_SPECIAL_CHR
);
610 CIFSSMBClose(xid
, pTcon
, netfid
);
611 if (direntry
->d_inode
)
612 drop_nlink(direntry
->d_inode
);
614 } else if (rc
== -EACCES
) {
615 /* try only if r/o attribute set in local lookup data? */
616 pinfo_buf
= kzalloc(sizeof(FILE_BASIC_INFO
), GFP_KERNEL
);
618 /* ATTRS set to normal clears r/o bit */
619 pinfo_buf
->Attributes
= cpu_to_le32(ATTR_NORMAL
);
620 if (!(pTcon
->ses
->flags
& CIFS_SES_NT4
))
621 rc
= CIFSSMBSetTimes(xid
, pTcon
, full_path
,
624 cifs_sb
->mnt_cifs_flags
&
625 CIFS_MOUNT_MAP_SPECIAL_CHR
);
629 if (rc
== -EOPNOTSUPP
) {
632 /* rc = CIFSSMBSetAttrLegacy(xid, pTcon,
636 For some strange reason it seems that NT4 eats the
637 old setattr call without actually setting the
638 attributes so on to the third attempted workaround
641 /* BB could scan to see if we already have it open
642 and pass in pid of opener to function */
643 rc
= CIFSSMBOpen(xid
, pTcon
, full_path
,
644 FILE_OPEN
, SYNCHRONIZE
|
645 FILE_WRITE_ATTRIBUTES
, 0,
646 &netfid
, &oplock
, NULL
,
648 cifs_sb
->mnt_cifs_flags
&
649 CIFS_MOUNT_MAP_SPECIAL_CHR
);
651 rc
= CIFSSMBSetFileTimes(xid
, pTcon
,
654 CIFSSMBClose(xid
, pTcon
, netfid
);
660 rc
= CIFSSMBDelFile(xid
, pTcon
, full_path
,
662 cifs_sb
->mnt_cifs_flags
&
663 CIFS_MOUNT_MAP_SPECIAL_CHR
);
665 if (direntry
->d_inode
)
666 drop_nlink(direntry
->d_inode
);
667 } else if (rc
== -ETXTBSY
) {
671 rc
= CIFSSMBOpen(xid
, pTcon
, full_path
,
674 CREATE_DELETE_ON_CLOSE
,
675 &netfid
, &oplock
, NULL
,
677 cifs_sb
->mnt_cifs_flags
&
678 CIFS_MOUNT_MAP_SPECIAL_CHR
);
680 CIFSSMBRenameOpenFile(xid
, pTcon
,
683 cifs_sb
->mnt_cifs_flags
&
684 CIFS_MOUNT_MAP_SPECIAL_CHR
);
685 CIFSSMBClose(xid
, pTcon
, netfid
);
686 if (direntry
->d_inode
)
687 drop_nlink(direntry
->d_inode
);
689 /* BB if rc = -ETXTBUSY goto the rename logic BB */
693 if (direntry
->d_inode
) {
694 cifsInode
= CIFS_I(direntry
->d_inode
);
695 cifsInode
->time
= 0; /* will force revalidate to get info
697 direntry
->d_inode
->i_ctime
= current_fs_time(inode
->i_sb
);
700 inode
->i_ctime
= inode
->i_mtime
= current_fs_time(inode
->i_sb
);
701 cifsInode
= CIFS_I(inode
);
702 cifsInode
->time
= 0; /* force revalidate of dir as well */
710 int cifs_mkdir(struct inode
*inode
, struct dentry
*direntry
, int mode
)
714 struct cifs_sb_info
*cifs_sb
;
715 struct cifsTconInfo
*pTcon
;
716 char *full_path
= NULL
;
717 struct inode
*newinode
= NULL
;
719 cFYI(1, ("In cifs_mkdir, mode = 0x%x inode = 0x%p", mode
, inode
));
723 cifs_sb
= CIFS_SB(inode
->i_sb
);
724 pTcon
= cifs_sb
->tcon
;
726 full_path
= build_path_from_dentry(direntry
);
727 if (full_path
== NULL
) {
731 /* BB add setting the equivalent of mode via CreateX w/ACLs */
732 rc
= CIFSSMBMkDir(xid
, pTcon
, full_path
, cifs_sb
->local_nls
,
733 cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_MAP_SPECIAL_CHR
);
735 cFYI(1, ("cifs_mkdir returned 0x%x", rc
));
739 if (pTcon
->ses
->capabilities
& CAP_UNIX
)
740 rc
= cifs_get_inode_info_unix(&newinode
, full_path
,
743 rc
= cifs_get_inode_info(&newinode
, full_path
, NULL
,
747 direntry
->d_op
= &cifs_ci_dentry_ops
;
749 direntry
->d_op
= &cifs_dentry_ops
;
750 d_instantiate(direntry
, newinode
);
751 if (direntry
->d_inode
)
752 direntry
->d_inode
->i_nlink
= 2;
753 if (cifs_sb
->tcon
->ses
->capabilities
& CAP_UNIX
)
754 if (cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_SET_UID
) {
755 CIFSSMBUnixSetPerms(xid
, pTcon
, full_path
,
757 (__u64
)current
->fsuid
,
758 (__u64
)current
->fsgid
,
761 cifs_sb
->mnt_cifs_flags
&
762 CIFS_MOUNT_MAP_SPECIAL_CHR
);
764 CIFSSMBUnixSetPerms(xid
, pTcon
, full_path
,
766 (__u64
)-1, 0 /* dev_t */,
768 cifs_sb
->mnt_cifs_flags
&
769 CIFS_MOUNT_MAP_SPECIAL_CHR
);
772 /* BB to be implemented via Windows secrty descriptors
773 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
774 -1, -1, local_nls); */
775 if(direntry
->d_inode
) {
776 direntry
->d_inode
->i_mode
= mode
;
777 direntry
->d_inode
->i_mode
|= S_IFDIR
;
778 if(cifs_sb
->mnt_cifs_flags
&
779 CIFS_MOUNT_SET_UID
) {
780 direntry
->d_inode
->i_uid
=
782 direntry
->d_inode
->i_gid
=
793 int cifs_rmdir(struct inode
*inode
, struct dentry
*direntry
)
797 struct cifs_sb_info
*cifs_sb
;
798 struct cifsTconInfo
*pTcon
;
799 char *full_path
= NULL
;
800 struct cifsInodeInfo
*cifsInode
;
802 cFYI(1, ("cifs_rmdir, inode = 0x%p", inode
));
806 cifs_sb
= CIFS_SB(inode
->i_sb
);
807 pTcon
= cifs_sb
->tcon
;
809 full_path
= build_path_from_dentry(direntry
);
810 if (full_path
== NULL
) {
815 rc
= CIFSSMBRmDir(xid
, pTcon
, full_path
, cifs_sb
->local_nls
,
816 cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_MAP_SPECIAL_CHR
);
820 i_size_write(direntry
->d_inode
,0);
821 direntry
->d_inode
->i_nlink
= 0;
824 cifsInode
= CIFS_I(direntry
->d_inode
);
825 cifsInode
->time
= 0; /* force revalidate to go get info when
827 direntry
->d_inode
->i_ctime
= inode
->i_ctime
= inode
->i_mtime
=
828 current_fs_time(inode
->i_sb
);
835 int cifs_rename(struct inode
*source_inode
, struct dentry
*source_direntry
,
836 struct inode
*target_inode
, struct dentry
*target_direntry
)
840 struct cifs_sb_info
*cifs_sb_source
;
841 struct cifs_sb_info
*cifs_sb_target
;
842 struct cifsTconInfo
*pTcon
;
848 cifs_sb_target
= CIFS_SB(target_inode
->i_sb
);
849 cifs_sb_source
= CIFS_SB(source_inode
->i_sb
);
850 pTcon
= cifs_sb_source
->tcon
;
852 if (pTcon
!= cifs_sb_target
->tcon
) {
854 return -EXDEV
; /* BB actually could be allowed if same server,
856 Might eventually add support for this */
859 /* we already have the rename sem so we do not need to grab it again
860 here to protect the path integrity */
861 fromName
= build_path_from_dentry(source_direntry
);
862 toName
= build_path_from_dentry(target_direntry
);
863 if ((fromName
== NULL
) || (toName
== NULL
)) {
865 goto cifs_rename_exit
;
868 rc
= CIFSSMBRename(xid
, pTcon
, fromName
, toName
,
869 cifs_sb_source
->local_nls
,
870 cifs_sb_source
->mnt_cifs_flags
&
871 CIFS_MOUNT_MAP_SPECIAL_CHR
);
873 /* check if they are the same file because rename of hardlinked
875 FILE_UNIX_BASIC_INFO
*info_buf_source
;
876 FILE_UNIX_BASIC_INFO
*info_buf_target
;
879 kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO
), GFP_KERNEL
);
880 if (info_buf_source
!= NULL
) {
881 info_buf_target
= info_buf_source
+ 1;
882 rc
= CIFSSMBUnixQPathInfo(xid
, pTcon
, fromName
,
883 info_buf_source
, cifs_sb_source
->local_nls
,
884 cifs_sb_source
->mnt_cifs_flags
&
885 CIFS_MOUNT_MAP_SPECIAL_CHR
);
887 rc
= CIFSSMBUnixQPathInfo(xid
, pTcon
, toName
,
889 cifs_sb_target
->local_nls
,
890 /* remap based on source sb */
891 cifs_sb_source
->mnt_cifs_flags
&
892 CIFS_MOUNT_MAP_SPECIAL_CHR
);
895 (info_buf_source
->UniqueId
==
896 info_buf_target
->UniqueId
)) {
897 /* do not rename since the files are hardlinked which
900 /* we either can not tell the files are hardlinked
901 (as with Windows servers) or files are not
902 hardlinked so delete the target manually before
903 renaming to follow POSIX rather than Windows
905 cifs_unlink(target_inode
, target_direntry
);
906 rc
= CIFSSMBRename(xid
, pTcon
, fromName
,
908 cifs_sb_source
->local_nls
,
909 cifs_sb_source
->mnt_cifs_flags
910 & CIFS_MOUNT_MAP_SPECIAL_CHR
);
912 kfree(info_buf_source
);
913 } /* if we can not get memory just leave rc as EEXIST */
917 cFYI(1, ("rename rc %d", rc
));
920 if ((rc
== -EIO
) || (rc
== -EEXIST
)) {
924 /* BB FIXME Is Generic Read correct for rename? */
925 /* if renaming directory - we should not say CREATE_NOT_DIR,
926 need to test renaming open directory, also GENERIC_READ
927 might not right be right access to request */
928 rc
= CIFSSMBOpen(xid
, pTcon
, fromName
, FILE_OPEN
, GENERIC_READ
,
929 CREATE_NOT_DIR
, &netfid
, &oplock
, NULL
,
930 cifs_sb_source
->local_nls
,
931 cifs_sb_source
->mnt_cifs_flags
&
932 CIFS_MOUNT_MAP_SPECIAL_CHR
);
934 CIFSSMBRenameOpenFile(xid
, pTcon
, netfid
, toName
,
935 cifs_sb_source
->local_nls
,
936 cifs_sb_source
->mnt_cifs_flags
&
937 CIFS_MOUNT_MAP_SPECIAL_CHR
);
938 CIFSSMBClose(xid
, pTcon
, netfid
);
949 int cifs_revalidate(struct dentry
*direntry
)
954 struct cifs_sb_info
*cifs_sb
;
955 struct cifsInodeInfo
*cifsInode
;
957 struct timespec local_mtime
;
958 int invalidate_inode
= FALSE
;
960 if (direntry
->d_inode
== NULL
)
963 cifsInode
= CIFS_I(direntry
->d_inode
);
965 if (cifsInode
== NULL
)
968 /* no sense revalidating inode info on file that no one can write */
969 if (CIFS_I(direntry
->d_inode
)->clientCanCacheRead
)
974 cifs_sb
= CIFS_SB(direntry
->d_sb
);
976 /* can not safely grab the rename sem here if rename calls revalidate
977 since that would deadlock */
978 full_path
= build_path_from_dentry(direntry
);
979 if (full_path
== NULL
) {
983 cFYI(1, ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld "
984 "jiffies %ld", full_path
, direntry
->d_inode
,
985 direntry
->d_inode
->i_count
.counter
, direntry
,
986 direntry
->d_time
, jiffies
));
988 if (cifsInode
->time
== 0) {
989 /* was set to zero previously to force revalidate */
990 } else if (time_before(jiffies
, cifsInode
->time
+ HZ
) &&
991 lookupCacheEnabled
) {
992 if ((S_ISREG(direntry
->d_inode
->i_mode
) == 0) ||
993 (direntry
->d_inode
->i_nlink
== 1)) {
998 cFYI(1, ("Have to revalidate file due to hardlinks"));
1002 /* save mtime and size */
1003 local_mtime
= direntry
->d_inode
->i_mtime
;
1004 local_size
= direntry
->d_inode
->i_size
;
1006 if (cifs_sb
->tcon
->ses
->capabilities
& CAP_UNIX
) {
1007 rc
= cifs_get_inode_info_unix(&direntry
->d_inode
, full_path
,
1008 direntry
->d_sb
,xid
);
1010 cFYI(1, ("error on getting revalidate info %d", rc
));
1011 /* if (rc != -ENOENT)
1012 rc = 0; */ /* BB should we cache info on
1016 rc
= cifs_get_inode_info(&direntry
->d_inode
, full_path
, NULL
,
1017 direntry
->d_sb
,xid
);
1019 cFYI(1, ("error on getting revalidate info %d", rc
));
1020 /* if (rc != -ENOENT)
1021 rc = 0; */ /* BB should we cache info on
1025 /* should we remap certain errors, access denied?, to zero */
1027 /* if not oplocked, we invalidate inode pages if mtime or file size
1028 had changed on server */
1030 if (timespec_equal(&local_mtime
,&direntry
->d_inode
->i_mtime
) &&
1031 (local_size
== direntry
->d_inode
->i_size
)) {
1032 cFYI(1, ("cifs_revalidate - inode unchanged"));
1034 /* file may have changed on server */
1035 if (cifsInode
->clientCanCacheRead
) {
1036 /* no need to invalidate inode pages since we were the
1037 only ones who could have modified the file and the
1038 server copy is staler than ours */
1040 invalidate_inode
= TRUE
;
1044 /* can not grab this sem since kernel filesys locking documentation
1045 indicates i_mutex may be taken by the kernel on lookup and rename
1046 which could deadlock if we grab the i_mutex here as well */
1047 /* mutex_lock(&direntry->d_inode->i_mutex);*/
1048 /* need to write out dirty pages here */
1049 if (direntry
->d_inode
->i_mapping
) {
1050 /* do we need to lock inode until after invalidate completes
1052 filemap_fdatawrite(direntry
->d_inode
->i_mapping
);
1054 if (invalidate_inode
) {
1055 /* shrink_dcache not necessary now that cifs dentry ops
1056 are exported for negative dentries */
1057 /* if(S_ISDIR(direntry->d_inode->i_mode))
1058 shrink_dcache_parent(direntry); */
1059 if (S_ISREG(direntry
->d_inode
->i_mode
)) {
1060 if (direntry
->d_inode
->i_mapping
)
1061 filemap_fdatawait(direntry
->d_inode
->i_mapping
);
1062 /* may eventually have to do this for open files too */
1063 if (list_empty(&(cifsInode
->openFileList
))) {
1064 /* changed on server - flush read ahead pages */
1065 cFYI(1, ("Invalidating read ahead data on "
1067 invalidate_remote_inode(direntry
->d_inode
);
1071 /* mutex_unlock(&direntry->d_inode->i_mutex); */
1078 int cifs_getattr(struct vfsmount
*mnt
, struct dentry
*dentry
,
1081 int err
= cifs_revalidate(dentry
);
1083 generic_fillattr(dentry
->d_inode
, stat
);
1087 static int cifs_truncate_page(struct address_space
*mapping
, loff_t from
)
1089 pgoff_t index
= from
>> PAGE_CACHE_SHIFT
;
1090 unsigned offset
= from
& (PAGE_CACHE_SIZE
- 1);
1095 page
= grab_cache_page(mapping
, index
);
1099 kaddr
= kmap_atomic(page
, KM_USER0
);
1100 memset(kaddr
+ offset
, 0, PAGE_CACHE_SIZE
- offset
);
1101 flush_dcache_page(page
);
1102 kunmap_atomic(kaddr
, KM_USER0
);
1104 page_cache_release(page
);
1108 int cifs_setattr(struct dentry
*direntry
, struct iattr
*attrs
)
1111 struct cifs_sb_info
*cifs_sb
;
1112 struct cifsTconInfo
*pTcon
;
1113 char *full_path
= NULL
;
1115 struct cifsFileInfo
*open_file
= NULL
;
1116 FILE_BASIC_INFO time_buf
;
1117 int set_time
= FALSE
;
1118 __u64 mode
= 0xFFFFFFFFFFFFFFFFULL
;
1119 __u64 uid
= 0xFFFFFFFFFFFFFFFFULL
;
1120 __u64 gid
= 0xFFFFFFFFFFFFFFFFULL
;
1121 struct cifsInodeInfo
*cifsInode
;
1125 cFYI(1, ("setattr on file %s attrs->iavalid 0x%x",
1126 direntry
->d_name
.name
, attrs
->ia_valid
));
1128 cifs_sb
= CIFS_SB(direntry
->d_inode
->i_sb
);
1129 pTcon
= cifs_sb
->tcon
;
1131 if ((cifs_sb
->mnt_cifs_flags
& CIFS_MOUNT_NO_PERM
) == 0) {
1132 /* check if we have permission to change attrs */
1133 rc
= inode_change_ok(direntry
->d_inode
, attrs
);
1141 full_path
= build_path_from_dentry(direntry
);
1142 if (full_path
== NULL
) {
1146 cifsInode
= CIFS_I(direntry
->d_inode
);
1148 /* BB check if we need to refresh inode from server now ? BB */
1150 /* need to flush data before changing file size on server */
1151 filemap_write_and_wait(direntry
->d_inode
->i_mapping
);
1153 if (attrs
->ia_valid
& ATTR_SIZE
) {
1154 /* To avoid spurious oplock breaks from server, in the case of
1155 inodes that we already have open, avoid doing path based
1156 setting of file size if we can do it by handle.
1157 This keeps our caching token (oplock) and avoids timeouts
1158 when the local oplock break takes longer to flush
1159 writebehind data than the SMB timeout for the SetPathInfo
1160 request would allow */
1162 open_file
= find_writable_file(cifsInode
);
1164 __u16 nfid
= open_file
->netfid
;
1165 __u32 npid
= open_file
->pid
;
1166 rc
= CIFSSMBSetFileSize(xid
, pTcon
, attrs
->ia_size
,
1168 atomic_dec(&open_file
->wrtPending
);
1169 cFYI(1,("SetFSize for attrs rc = %d", rc
));
1170 if((rc
== -EINVAL
) || (rc
== -EOPNOTSUPP
)) {
1172 rc
= CIFSSMBWrite(xid
, pTcon
,
1173 nfid
, 0, attrs
->ia_size
,
1174 &bytes_written
, NULL
, NULL
,
1175 1 /* 45 seconds */);
1176 cFYI(1,("Wrt seteof rc %d", rc
));
1182 /* Set file size by pathname rather than by handle
1183 either because no valid, writeable file handle for
1184 it was found or because there was an error setting
1186 rc
= CIFSSMBSetEOF(xid
, pTcon
, full_path
,
1187 attrs
->ia_size
, FALSE
,
1189 cifs_sb
->mnt_cifs_flags
&
1190 CIFS_MOUNT_MAP_SPECIAL_CHR
);
1191 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc
));
1192 if((rc
== -EINVAL
) || (rc
== -EOPNOTSUPP
)) {
1196 rc
= SMBLegacyOpen(xid
, pTcon
, full_path
,
1198 SYNCHRONIZE
| FILE_WRITE_ATTRIBUTES
,
1199 CREATE_NOT_DIR
, &netfid
, &oplock
,
1200 NULL
, cifs_sb
->local_nls
,
1201 cifs_sb
->mnt_cifs_flags
&
1202 CIFS_MOUNT_MAP_SPECIAL_CHR
);
1205 rc
= CIFSSMBWrite(xid
, pTcon
,
1208 &bytes_written
, NULL
,
1209 NULL
, 1 /* 45 sec */);
1210 cFYI(1,("wrt seteof rc %d",rc
));
1211 CIFSSMBClose(xid
, pTcon
, netfid
);
1217 /* Server is ok setting allocation size implicitly - no need
1219 CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, TRUE,
1220 cifs_sb->local_nls);
1224 rc
= vmtruncate(direntry
->d_inode
, attrs
->ia_size
);
1225 cifs_truncate_page(direntry
->d_inode
->i_mapping
,
1226 direntry
->d_inode
->i_size
);
1228 goto cifs_setattr_exit
;
1230 if (attrs
->ia_valid
& ATTR_UID
) {
1231 cFYI(1, ("UID changed to %d", attrs
->ia_uid
));
1232 uid
= attrs
->ia_uid
;
1234 if (attrs
->ia_valid
& ATTR_GID
) {
1235 cFYI(1, ("GID changed to %d", attrs
->ia_gid
));
1236 gid
= attrs
->ia_gid
;
1239 time_buf
.Attributes
= 0;
1240 if (attrs
->ia_valid
& ATTR_MODE
) {
1241 cFYI(1, ("Mode changed to 0x%x", attrs
->ia_mode
));
1242 mode
= attrs
->ia_mode
;
1245 if ((cifs_sb
->tcon
->ses
->capabilities
& CAP_UNIX
)
1246 && (attrs
->ia_valid
& (ATTR_MODE
| ATTR_GID
| ATTR_UID
)))
1247 rc
= CIFSSMBUnixSetPerms(xid
, pTcon
, full_path
, mode
, uid
, gid
,
1248 0 /* dev_t */, cifs_sb
->local_nls
,
1249 cifs_sb
->mnt_cifs_flags
&
1250 CIFS_MOUNT_MAP_SPECIAL_CHR
);
1251 else if (attrs
->ia_valid
& ATTR_MODE
) {
1253 if ((mode
& S_IWUGO
) == 0) /* not writeable */ {
1254 if ((cifsInode
->cifsAttrs
& ATTR_READONLY
) == 0)
1255 time_buf
.Attributes
=
1256 cpu_to_le32(cifsInode
->cifsAttrs
|
1258 } else if ((mode
& S_IWUGO
) == S_IWUGO
) {
1259 if (cifsInode
->cifsAttrs
& ATTR_READONLY
)
1260 time_buf
.Attributes
=
1261 cpu_to_le32(cifsInode
->cifsAttrs
&
1264 /* BB to be implemented -
1265 via Windows security descriptors or streams */
1266 /* CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, uid, gid,
1267 cifs_sb->local_nls); */
1270 if (attrs
->ia_valid
& ATTR_ATIME
) {
1272 time_buf
.LastAccessTime
=
1273 cpu_to_le64(cifs_UnixTimeToNT(attrs
->ia_atime
));
1275 time_buf
.LastAccessTime
= 0;
1277 if (attrs
->ia_valid
& ATTR_MTIME
) {
1279 time_buf
.LastWriteTime
=
1280 cpu_to_le64(cifs_UnixTimeToNT(attrs
->ia_mtime
));
1282 time_buf
.LastWriteTime
= 0;
1283 /* Do not set ctime explicitly unless other time
1284 stamps are changed explicitly (i.e. by utime()
1285 since we would then have a mix of client and
1288 if (set_time
&& (attrs
->ia_valid
& ATTR_CTIME
)) {
1290 /* Although Samba throws this field away
1291 it may be useful to Windows - but we do
1292 not want to set ctime unless some other
1293 timestamp is changing */
1294 cFYI(1, ("CIFS - CTIME changed"));
1295 time_buf
.ChangeTime
=
1296 cpu_to_le64(cifs_UnixTimeToNT(attrs
->ia_ctime
));
1298 time_buf
.ChangeTime
= 0;
1300 if (set_time
|| time_buf
.Attributes
) {
1301 time_buf
.CreationTime
= 0; /* do not change */
1302 /* In the future we should experiment - try setting timestamps
1303 via Handle (SetFileInfo) instead of by path */
1304 if (!(pTcon
->ses
->flags
& CIFS_SES_NT4
))
1305 rc
= CIFSSMBSetTimes(xid
, pTcon
, full_path
, &time_buf
,
1307 cifs_sb
->mnt_cifs_flags
&
1308 CIFS_MOUNT_MAP_SPECIAL_CHR
);
1312 if (rc
== -EOPNOTSUPP
) {
1316 cFYI(1, ("calling SetFileInfo since SetPathInfo for "
1317 "times not supported by this server"));
1318 /* BB we could scan to see if we already have it open
1319 and pass in pid of opener to function */
1320 rc
= CIFSSMBOpen(xid
, pTcon
, full_path
, FILE_OPEN
,
1321 SYNCHRONIZE
| FILE_WRITE_ATTRIBUTES
,
1322 CREATE_NOT_DIR
, &netfid
, &oplock
,
1323 NULL
, cifs_sb
->local_nls
,
1324 cifs_sb
->mnt_cifs_flags
&
1325 CIFS_MOUNT_MAP_SPECIAL_CHR
);
1327 rc
= CIFSSMBSetFileTimes(xid
, pTcon
, &time_buf
,
1329 CIFSSMBClose(xid
, pTcon
, netfid
);
1331 /* BB For even older servers we could convert time_buf
1332 into old DOS style which uses two second
1335 /* rc = CIFSSMBSetTimesLegacy(xid, pTcon, full_path,
1336 &time_buf, cifs_sb->local_nls); */
1339 /* Even if error on time set, no sense failing the call if
1340 the server would set the time to a reasonable value anyway,
1341 and this check ensures that we are not being called from
1342 sys_utimes in which case we ought to fail the call back to
1343 the user when the server rejects the call */
1344 if((rc
) && (attrs
->ia_valid
&&
1345 (ATTR_MODE
| ATTR_GID
| ATTR_UID
| ATTR_SIZE
)))
1349 /* do not need local check to inode_check_ok since the server does
1352 rc
= inode_setattr(direntry
->d_inode
, attrs
);
1359 void cifs_delete_inode(struct inode
*inode
)
1361 cFYI(1, ("In cifs_delete_inode, inode = 0x%p", inode
));
1362 /* may have to add back in if and when safe distributed caching of
1363 directories added e.g. via FindNotify */