4 * Copyright (C) International Business Machines Corp., 2002, 2011
6 * Author(s): Pavel Shilovsky (pshilovsky@samba.org),
7 * Steve French (sfrench@us.ibm.com)
9 * This library is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/stat.h>
25 #include <linux/slab.h>
26 #include <linux/pagemap.h>
27 #include <asm/div64.h>
31 #include "cifsproto.h"
32 #include "cifs_debug.h"
33 #include "cifs_fs_sb.h"
34 #include "cifs_unicode.h"
38 #include "smb2proto.h"
41 free_set_inf_compound(struct smb_rqst
*rqst
)
44 SMB2_set_info_free(&rqst
[1]);
46 SMB2_close_free(&rqst
[2]);
51 struct cifs_open_parms oparms
;
52 struct kvec rsp_iov
[3];
53 struct smb_rqst rqst
[3];
54 struct kvec open_iov
[SMB2_CREATE_IOV_SIZE
];
55 struct kvec qi_iov
[1];
56 struct kvec si_iov
[SMB2_SET_INFO_IOV_SIZE
];
57 struct kvec close_iov
[1];
58 struct smb2_file_rename_info rename_info
;
59 struct smb2_file_link_info link_info
;
63 smb2_compound_op(const unsigned int xid
, struct cifs_tcon
*tcon
,
64 struct cifs_sb_info
*cifs_sb
, const char *full_path
,
65 __u32 desired_access
, __u32 create_disposition
,
66 __u32 create_options
, umode_t mode
, void *ptr
, int command
,
67 struct cifsFileInfo
*cfile
)
69 struct cop_vars
*vars
= NULL
;
71 struct smb_rqst
*rqst
;
73 __le16
*utf16_path
= NULL
;
74 __u8 oplock
= SMB2_OPLOCK_LEVEL_NONE
;
76 struct cifs_ses
*ses
= tcon
->ses
;
77 struct TCP_Server_Info
*server
;
80 struct smb2_query_info_rsp
*qi_rsp
= NULL
;
82 __u8 delete_pending
[8] = {1, 0, 0, 0, 0, 0, 0, 0};
87 vars
= kzalloc(sizeof(*vars
), GFP_ATOMIC
);
90 rqst
= &vars
->rqst
[0];
91 rsp_iov
= &vars
->rsp_iov
[0];
93 server
= cifs_pick_channel(ses
);
95 if (smb3_encryption_required(tcon
))
96 flags
|= CIFS_TRANSFORM_REQ
;
98 resp_buftype
[0] = resp_buftype
[1] = resp_buftype
[2] = CIFS_NO_BUFFER
;
100 /* We already have a handle so we can skip the open */
105 utf16_path
= cifs_convert_path_to_utf16(full_path
, cifs_sb
);
111 vars
->oparms
.tcon
= tcon
;
112 vars
->oparms
.desired_access
= desired_access
;
113 vars
->oparms
.disposition
= create_disposition
;
114 vars
->oparms
.create_options
= cifs_create_options(cifs_sb
, create_options
);
115 vars
->oparms
.fid
= &fid
;
116 vars
->oparms
.reconnect
= false;
117 vars
->oparms
.mode
= mode
;
119 rqst
[num_rqst
].rq_iov
= &vars
->open_iov
[0];
120 rqst
[num_rqst
].rq_nvec
= SMB2_CREATE_IOV_SIZE
;
121 rc
= SMB2_open_init(tcon
, server
,
122 &rqst
[num_rqst
], &oplock
, &vars
->oparms
,
128 smb2_set_next_command(tcon
, &rqst
[num_rqst
]);
135 case SMB2_OP_QUERY_INFO
:
136 rqst
[num_rqst
].rq_iov
= &vars
->qi_iov
[0];
137 rqst
[num_rqst
].rq_nvec
= 1;
140 rc
= SMB2_query_info_init(tcon
, server
,
142 cfile
->fid
.persistent_fid
,
143 cfile
->fid
.volatile_fid
,
144 FILE_ALL_INFORMATION
,
146 sizeof(struct smb2_file_all_info
) +
147 PATH_MAX
* 2, 0, NULL
);
149 rc
= SMB2_query_info_init(tcon
, server
,
153 FILE_ALL_INFORMATION
,
155 sizeof(struct smb2_file_all_info
) +
156 PATH_MAX
* 2, 0, NULL
);
158 smb2_set_next_command(tcon
, &rqst
[num_rqst
]);
159 smb2_set_related(&rqst
[num_rqst
]);
166 trace_smb3_query_info_compound_enter(xid
, ses
->Suid
, tcon
->tid
,
169 case SMB2_OP_POSIX_QUERY_INFO
:
170 rqst
[num_rqst
].rq_iov
= &vars
->qi_iov
[0];
171 rqst
[num_rqst
].rq_nvec
= 1;
174 rc
= SMB2_query_info_init(tcon
, server
,
176 cfile
->fid
.persistent_fid
,
177 cfile
->fid
.volatile_fid
,
178 SMB_FIND_FILE_POSIX_INFO
,
180 /* TBD: fix following to allow for longer SIDs */
181 sizeof(struct smb311_posix_qinfo
*) + (PATH_MAX
* 2) +
182 (sizeof(struct cifs_sid
) * 2), 0, NULL
);
184 rc
= SMB2_query_info_init(tcon
, server
,
188 SMB_FIND_FILE_POSIX_INFO
,
190 sizeof(struct smb311_posix_qinfo
*) + (PATH_MAX
* 2) +
191 (sizeof(struct cifs_sid
) * 2), 0, NULL
);
193 smb2_set_next_command(tcon
, &rqst
[num_rqst
]);
194 smb2_set_related(&rqst
[num_rqst
]);
201 trace_smb3_posix_query_info_compound_enter(xid
, ses
->Suid
, tcon
->tid
, full_path
);
204 trace_smb3_delete_enter(xid
, ses
->Suid
, tcon
->tid
, full_path
);
208 * Directories are created through parameters in the
211 trace_smb3_mkdir_enter(xid
, ses
->Suid
, tcon
->tid
, full_path
);
214 rqst
[num_rqst
].rq_iov
= &vars
->si_iov
[0];
215 rqst
[num_rqst
].rq_nvec
= 1;
217 size
[0] = 1; /* sizeof __u8 See MS-FSCC section 2.4.11 */
218 data
[0] = &delete_pending
[0];
220 rc
= SMB2_set_info_init(tcon
, server
,
221 &rqst
[num_rqst
], COMPOUND_FID
,
222 COMPOUND_FID
, current
->tgid
,
223 FILE_DISPOSITION_INFORMATION
,
224 SMB2_O_INFO_FILE
, 0, data
, size
);
227 smb2_set_next_command(tcon
, &rqst
[num_rqst
]);
228 smb2_set_related(&rqst
[num_rqst
++]);
229 trace_smb3_rmdir_enter(xid
, ses
->Suid
, tcon
->tid
, full_path
);
231 case SMB2_OP_SET_EOF
:
232 rqst
[num_rqst
].rq_iov
= &vars
->si_iov
[0];
233 rqst
[num_rqst
].rq_nvec
= 1;
235 size
[0] = 8; /* sizeof __le64 */
238 rc
= SMB2_set_info_init(tcon
, server
,
239 &rqst
[num_rqst
], COMPOUND_FID
,
240 COMPOUND_FID
, current
->tgid
,
241 FILE_END_OF_FILE_INFORMATION
,
242 SMB2_O_INFO_FILE
, 0, data
, size
);
245 smb2_set_next_command(tcon
, &rqst
[num_rqst
]);
246 smb2_set_related(&rqst
[num_rqst
++]);
247 trace_smb3_set_eof_enter(xid
, ses
->Suid
, tcon
->tid
, full_path
);
249 case SMB2_OP_SET_INFO
:
250 rqst
[num_rqst
].rq_iov
= &vars
->si_iov
[0];
251 rqst
[num_rqst
].rq_nvec
= 1;
254 size
[0] = sizeof(FILE_BASIC_INFO
);
258 rc
= SMB2_set_info_init(tcon
, server
,
260 cfile
->fid
.persistent_fid
,
261 cfile
->fid
.volatile_fid
, current
->tgid
,
262 FILE_BASIC_INFORMATION
,
263 SMB2_O_INFO_FILE
, 0, data
, size
);
265 rc
= SMB2_set_info_init(tcon
, server
,
268 COMPOUND_FID
, current
->tgid
,
269 FILE_BASIC_INFORMATION
,
270 SMB2_O_INFO_FILE
, 0, data
, size
);
272 smb2_set_next_command(tcon
, &rqst
[num_rqst
]);
273 smb2_set_related(&rqst
[num_rqst
]);
280 trace_smb3_set_info_compound_enter(xid
, ses
->Suid
, tcon
->tid
,
284 rqst
[num_rqst
].rq_iov
= &vars
->si_iov
[0];
285 rqst
[num_rqst
].rq_nvec
= 2;
287 len
= (2 * UniStrnlen((wchar_t *)ptr
, PATH_MAX
));
289 vars
->rename_info
.ReplaceIfExists
= 1;
290 vars
->rename_info
.RootDirectory
= 0;
291 vars
->rename_info
.FileNameLength
= cpu_to_le32(len
);
293 size
[0] = sizeof(struct smb2_file_rename_info
);
294 data
[0] = &vars
->rename_info
;
296 size
[1] = len
+ 2 /* null */;
297 data
[1] = (__le16
*)ptr
;
300 rc
= SMB2_set_info_init(tcon
, server
,
302 cfile
->fid
.persistent_fid
,
303 cfile
->fid
.volatile_fid
,
304 current
->tgid
, FILE_RENAME_INFORMATION
,
305 SMB2_O_INFO_FILE
, 0, data
, size
);
307 rc
= SMB2_set_info_init(tcon
, server
,
309 COMPOUND_FID
, COMPOUND_FID
,
310 current
->tgid
, FILE_RENAME_INFORMATION
,
311 SMB2_O_INFO_FILE
, 0, data
, size
);
313 smb2_set_next_command(tcon
, &rqst
[num_rqst
]);
314 smb2_set_related(&rqst
[num_rqst
]);
320 trace_smb3_rename_enter(xid
, ses
->Suid
, tcon
->tid
, full_path
);
322 case SMB2_OP_HARDLINK
:
323 rqst
[num_rqst
].rq_iov
= &vars
->si_iov
[0];
324 rqst
[num_rqst
].rq_nvec
= 2;
326 len
= (2 * UniStrnlen((wchar_t *)ptr
, PATH_MAX
));
328 vars
->link_info
.ReplaceIfExists
= 0;
329 vars
->link_info
.RootDirectory
= 0;
330 vars
->link_info
.FileNameLength
= cpu_to_le32(len
);
332 size
[0] = sizeof(struct smb2_file_link_info
);
333 data
[0] = &vars
->link_info
;
335 size
[1] = len
+ 2 /* null */;
336 data
[1] = (__le16
*)ptr
;
338 rc
= SMB2_set_info_init(tcon
, server
,
339 &rqst
[num_rqst
], COMPOUND_FID
,
340 COMPOUND_FID
, current
->tgid
,
341 FILE_LINK_INFORMATION
,
342 SMB2_O_INFO_FILE
, 0, data
, size
);
345 smb2_set_next_command(tcon
, &rqst
[num_rqst
]);
346 smb2_set_related(&rqst
[num_rqst
++]);
347 trace_smb3_hardlink_enter(xid
, ses
->Suid
, tcon
->tid
, full_path
);
350 cifs_dbg(VFS
, "Invalid command\n");
356 /* We already have a handle so we can skip the close */
360 rqst
[num_rqst
].rq_iov
= &vars
->close_iov
[0];
361 rqst
[num_rqst
].rq_nvec
= 1;
362 rc
= SMB2_close_init(tcon
, server
,
363 &rqst
[num_rqst
], COMPOUND_FID
,
364 COMPOUND_FID
, false);
365 smb2_set_related(&rqst
[num_rqst
]);
372 cifsFileInfo_put(cfile
);
374 rc
= compound_send_recv(xid
, ses
, server
,
376 &rqst
[1], &resp_buftype
[1],
379 rc
= compound_send_recv(xid
, ses
, server
,
386 cifsFileInfo_put(cfile
);
388 SMB2_open_free(&rqst
[0]);
389 if (rc
== -EREMCHG
) {
390 pr_warn_once("server share %s deleted\n", tcon
->treeName
);
391 tcon
->need_reconnect
= true;
395 case SMB2_OP_QUERY_INFO
:
397 qi_rsp
= (struct smb2_query_info_rsp
*)
399 rc
= smb2_validate_and_copy_iov(
400 le16_to_cpu(qi_rsp
->OutputBufferOffset
),
401 le32_to_cpu(qi_rsp
->OutputBufferLength
),
402 &rsp_iov
[1], sizeof(struct smb2_file_all_info
),
406 SMB2_query_info_free(&rqst
[1]);
408 SMB2_close_free(&rqst
[2]);
410 trace_smb3_query_info_compound_err(xid
, ses
->Suid
,
413 trace_smb3_query_info_compound_done(xid
, ses
->Suid
,
416 case SMB2_OP_POSIX_QUERY_INFO
:
418 qi_rsp
= (struct smb2_query_info_rsp
*)
420 rc
= smb2_validate_and_copy_iov(
421 le16_to_cpu(qi_rsp
->OutputBufferOffset
),
422 le32_to_cpu(qi_rsp
->OutputBufferLength
),
423 &rsp_iov
[1], sizeof(struct smb311_posix_qinfo
) /* add SIDs */, ptr
);
426 SMB2_query_info_free(&rqst
[1]);
428 SMB2_close_free(&rqst
[2]);
430 trace_smb3_posix_query_info_compound_err(xid
, ses
->Suid
, tcon
->tid
, rc
);
432 trace_smb3_posix_query_info_compound_done(xid
, ses
->Suid
, tcon
->tid
);
436 trace_smb3_delete_err(xid
, ses
->Suid
, tcon
->tid
, rc
);
438 trace_smb3_delete_done(xid
, ses
->Suid
, tcon
->tid
);
440 SMB2_close_free(&rqst
[1]);
444 trace_smb3_mkdir_err(xid
, ses
->Suid
, tcon
->tid
, rc
);
446 trace_smb3_mkdir_done(xid
, ses
->Suid
, tcon
->tid
);
448 SMB2_close_free(&rqst
[1]);
450 case SMB2_OP_HARDLINK
:
452 trace_smb3_hardlink_err(xid
, ses
->Suid
, tcon
->tid
, rc
);
454 trace_smb3_hardlink_done(xid
, ses
->Suid
, tcon
->tid
);
455 free_set_inf_compound(rqst
);
459 trace_smb3_rename_err(xid
, ses
->Suid
, tcon
->tid
, rc
);
461 trace_smb3_rename_done(xid
, ses
->Suid
, tcon
->tid
);
462 free_set_inf_compound(rqst
);
466 trace_smb3_rmdir_err(xid
, ses
->Suid
, tcon
->tid
, rc
);
468 trace_smb3_rmdir_done(xid
, ses
->Suid
, tcon
->tid
);
469 free_set_inf_compound(rqst
);
471 case SMB2_OP_SET_EOF
:
473 trace_smb3_set_eof_err(xid
, ses
->Suid
, tcon
->tid
, rc
);
475 trace_smb3_set_eof_done(xid
, ses
->Suid
, tcon
->tid
);
476 free_set_inf_compound(rqst
);
478 case SMB2_OP_SET_INFO
:
480 trace_smb3_set_info_compound_err(xid
, ses
->Suid
,
483 trace_smb3_set_info_compound_done(xid
, ses
->Suid
,
485 free_set_inf_compound(rqst
);
488 free_rsp_buf(resp_buftype
[0], rsp_iov
[0].iov_base
);
489 free_rsp_buf(resp_buftype
[1], rsp_iov
[1].iov_base
);
490 free_rsp_buf(resp_buftype
[2], rsp_iov
[2].iov_base
);
496 move_smb2_info_to_cifs(FILE_ALL_INFO
*dst
, struct smb2_file_all_info
*src
)
498 memcpy(dst
, src
, (size_t)(&src
->CurrentByteOffset
) - (size_t)src
);
499 dst
->CurrentByteOffset
= src
->CurrentByteOffset
;
500 dst
->Mode
= src
->Mode
;
501 dst
->AlignmentRequirement
= src
->AlignmentRequirement
;
502 dst
->IndexNumber1
= 0; /* we don't use it */
506 smb2_query_path_info(const unsigned int xid
, struct cifs_tcon
*tcon
,
507 struct cifs_sb_info
*cifs_sb
, const char *full_path
,
508 FILE_ALL_INFO
*data
, bool *adjust_tz
, bool *symlink
)
511 struct smb2_file_all_info
*smb2_data
;
512 __u32 create_options
= 0;
514 bool no_cached_open
= tcon
->nohandlecache
;
515 struct cifsFileInfo
*cfile
;
520 smb2_data
= kzalloc(sizeof(struct smb2_file_all_info
) + PATH_MAX
* 2,
522 if (smb2_data
== NULL
)
525 /* If it is a root and its handle is cached then use it */
526 if (!strlen(full_path
) && !no_cached_open
) {
527 rc
= open_shroot(xid
, tcon
, cifs_sb
, &fid
);
531 if (tcon
->crfid
.file_all_info_is_valid
) {
532 move_smb2_info_to_cifs(data
,
533 &tcon
->crfid
.file_all_info
);
535 rc
= SMB2_query_info(xid
, tcon
, fid
.persistent_fid
,
536 fid
.volatile_fid
, smb2_data
);
538 move_smb2_info_to_cifs(data
, smb2_data
);
540 close_shroot(&tcon
->crfid
);
544 cifs_get_readable_path(tcon
, full_path
, &cfile
);
545 rc
= smb2_compound_op(xid
, tcon
, cifs_sb
, full_path
,
546 FILE_READ_ATTRIBUTES
, FILE_OPEN
, create_options
,
547 ACL_NO_MODE
, smb2_data
, SMB2_OP_QUERY_INFO
, cfile
);
548 if (rc
== -EOPNOTSUPP
) {
550 create_options
|= OPEN_REPARSE_POINT
;
552 /* Failed on a symbolic link - query a reparse point info */
553 rc
= smb2_compound_op(xid
, tcon
, cifs_sb
, full_path
,
554 FILE_READ_ATTRIBUTES
, FILE_OPEN
,
555 create_options
, ACL_NO_MODE
,
556 smb2_data
, SMB2_OP_QUERY_INFO
, NULL
);
561 move_smb2_info_to_cifs(data
, smb2_data
);
569 smb311_posix_query_path_info(const unsigned int xid
, struct cifs_tcon
*tcon
,
570 struct cifs_sb_info
*cifs_sb
, const char *full_path
,
571 struct smb311_posix_qinfo
*data
, bool *adjust_tz
, bool *symlink
)
574 __u32 create_options
= 0;
575 struct cifsFileInfo
*cfile
;
576 struct smb311_posix_qinfo
*smb2_data
;
581 /* BB TODO: Make struct larger when add support for parsing owner SIDs */
582 smb2_data
= kzalloc(sizeof(struct smb311_posix_qinfo
),
584 if (smb2_data
== NULL
)
588 * BB TODO: Add support for using the cached root handle.
589 * Create SMB2_query_posix_info worker function to do non-compounded query
590 * when we already have an open file handle for this. For now this is fast enough
591 * (always using the compounded version).
594 cifs_get_readable_path(tcon
, full_path
, &cfile
);
595 rc
= smb2_compound_op(xid
, tcon
, cifs_sb
, full_path
,
596 FILE_READ_ATTRIBUTES
, FILE_OPEN
, create_options
,
597 ACL_NO_MODE
, smb2_data
, SMB2_OP_POSIX_QUERY_INFO
, cfile
);
598 if (rc
== -EOPNOTSUPP
) {
599 /* BB TODO: When support for special files added to Samba re-verify this path */
601 create_options
|= OPEN_REPARSE_POINT
;
603 /* Failed on a symbolic link - query a reparse point info */
604 rc
= smb2_compound_op(xid
, tcon
, cifs_sb
, full_path
,
605 FILE_READ_ATTRIBUTES
, FILE_OPEN
,
606 create_options
, ACL_NO_MODE
,
607 smb2_data
, SMB2_OP_POSIX_QUERY_INFO
, NULL
);
612 /* TODO: will need to allow for the 2 SIDs when add support for getting owner UID/GID */
613 memcpy(data
, smb2_data
, sizeof(struct smb311_posix_qinfo
));
621 smb2_mkdir(const unsigned int xid
, struct inode
*parent_inode
, umode_t mode
,
622 struct cifs_tcon
*tcon
, const char *name
,
623 struct cifs_sb_info
*cifs_sb
)
625 return smb2_compound_op(xid
, tcon
, cifs_sb
, name
,
626 FILE_WRITE_ATTRIBUTES
, FILE_CREATE
,
627 CREATE_NOT_FILE
, mode
, NULL
, SMB2_OP_MKDIR
,
632 smb2_mkdir_setinfo(struct inode
*inode
, const char *name
,
633 struct cifs_sb_info
*cifs_sb
, struct cifs_tcon
*tcon
,
634 const unsigned int xid
)
636 FILE_BASIC_INFO data
;
637 struct cifsInodeInfo
*cifs_i
;
638 struct cifsFileInfo
*cfile
;
642 memset(&data
, 0, sizeof(data
));
643 cifs_i
= CIFS_I(inode
);
644 dosattrs
= cifs_i
->cifsAttrs
| ATTR_READONLY
;
645 data
.Attributes
= cpu_to_le32(dosattrs
);
646 cifs_get_writable_path(tcon
, name
, FIND_WR_ANY
, &cfile
);
647 tmprc
= smb2_compound_op(xid
, tcon
, cifs_sb
, name
,
648 FILE_WRITE_ATTRIBUTES
, FILE_CREATE
,
649 CREATE_NOT_FILE
, ACL_NO_MODE
,
650 &data
, SMB2_OP_SET_INFO
, cfile
);
652 cifs_i
->cifsAttrs
= dosattrs
;
656 smb2_rmdir(const unsigned int xid
, struct cifs_tcon
*tcon
, const char *name
,
657 struct cifs_sb_info
*cifs_sb
)
659 return smb2_compound_op(xid
, tcon
, cifs_sb
, name
, DELETE
, FILE_OPEN
,
660 CREATE_NOT_FILE
, ACL_NO_MODE
,
661 NULL
, SMB2_OP_RMDIR
, NULL
);
665 smb2_unlink(const unsigned int xid
, struct cifs_tcon
*tcon
, const char *name
,
666 struct cifs_sb_info
*cifs_sb
)
668 return smb2_compound_op(xid
, tcon
, cifs_sb
, name
, DELETE
, FILE_OPEN
,
669 CREATE_DELETE_ON_CLOSE
| OPEN_REPARSE_POINT
,
670 ACL_NO_MODE
, NULL
, SMB2_OP_DELETE
, NULL
);
674 smb2_set_path_attr(const unsigned int xid
, struct cifs_tcon
*tcon
,
675 const char *from_name
, const char *to_name
,
676 struct cifs_sb_info
*cifs_sb
, __u32 access
, int command
,
677 struct cifsFileInfo
*cfile
)
679 __le16
*smb2_to_name
= NULL
;
682 smb2_to_name
= cifs_convert_path_to_utf16(to_name
, cifs_sb
);
683 if (smb2_to_name
== NULL
) {
685 goto smb2_rename_path
;
687 rc
= smb2_compound_op(xid
, tcon
, cifs_sb
, from_name
, access
,
688 FILE_OPEN
, 0, ACL_NO_MODE
, smb2_to_name
,
696 smb2_rename_path(const unsigned int xid
, struct cifs_tcon
*tcon
,
697 const char *from_name
, const char *to_name
,
698 struct cifs_sb_info
*cifs_sb
)
700 struct cifsFileInfo
*cfile
;
702 cifs_get_writable_path(tcon
, from_name
, FIND_WR_WITH_DELETE
, &cfile
);
704 return smb2_set_path_attr(xid
, tcon
, from_name
, to_name
,
705 cifs_sb
, DELETE
, SMB2_OP_RENAME
, cfile
);
709 smb2_create_hardlink(const unsigned int xid
, struct cifs_tcon
*tcon
,
710 const char *from_name
, const char *to_name
,
711 struct cifs_sb_info
*cifs_sb
)
713 return smb2_set_path_attr(xid
, tcon
, from_name
, to_name
, cifs_sb
,
714 FILE_READ_ATTRIBUTES
, SMB2_OP_HARDLINK
,
719 smb2_set_path_size(const unsigned int xid
, struct cifs_tcon
*tcon
,
720 const char *full_path
, __u64 size
,
721 struct cifs_sb_info
*cifs_sb
, bool set_alloc
)
723 __le64 eof
= cpu_to_le64(size
);
725 return smb2_compound_op(xid
, tcon
, cifs_sb
, full_path
,
726 FILE_WRITE_DATA
, FILE_OPEN
, 0, ACL_NO_MODE
,
727 &eof
, SMB2_OP_SET_EOF
, NULL
);
731 smb2_set_file_info(struct inode
*inode
, const char *full_path
,
732 FILE_BASIC_INFO
*buf
, const unsigned int xid
)
734 struct cifs_sb_info
*cifs_sb
= CIFS_SB(inode
->i_sb
);
735 struct tcon_link
*tlink
;
738 if ((buf
->CreationTime
== 0) && (buf
->LastAccessTime
== 0) &&
739 (buf
->LastWriteTime
== 0) && (buf
->ChangeTime
== 0) &&
740 (buf
->Attributes
== 0))
741 return 0; /* would be a no op, no sense sending this */
743 tlink
= cifs_sb_tlink(cifs_sb
);
745 return PTR_ERR(tlink
);
747 rc
= smb2_compound_op(xid
, tlink_tcon(tlink
), cifs_sb
, full_path
,
748 FILE_WRITE_ATTRIBUTES
, FILE_OPEN
,
749 0, ACL_NO_MODE
, buf
, SMB2_OP_SET_INFO
, NULL
);
750 cifs_put_tlink(tlink
);