aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/smb1ops.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-09-18 19:20:32 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:29 -0400
commit6bdf6dbd662176c0da5c3ac8ed10ac94e7776c85 (patch)
tree6972c90f953a9fe5efc9a8feea4613c1b15c83e1 /fs/cifs/smb1ops.c
parentc839ff244ba2d54d0933596e29a4b03e3c846a9a (diff)
CIFS: Move set_file_info to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/smb1ops.c')
-rw-r--r--fs/cifs/smb1ops.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index b73d2750296d..ed311968437a 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -758,6 +758,84 @@ cifs_sync_write(const unsigned int xid, struct cifsFileInfo *cfile,
758 return CIFSSMBWrite2(xid, parms, written, iov, nr_segs); 758 return CIFSSMBWrite2(xid, parms, written, iov, nr_segs);
759} 759}
760 760
761static int
762smb_set_file_info(struct inode *inode, const char *full_path,
763 FILE_BASIC_INFO *buf, const unsigned int xid)
764{
765 int oplock = 0;
766 int rc;
767 __u16 netfid;
768 __u32 netpid;
769 struct cifsFileInfo *open_file;
770 struct cifsInodeInfo *cinode = CIFS_I(inode);
771 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
772 struct tcon_link *tlink = NULL;
773 struct cifs_tcon *tcon;
774 FILE_BASIC_INFO info_buf;
775
776 /* if the file is already open for write, just use that fileid */
777 open_file = find_writable_file(cinode, true);
778 if (open_file) {
779 netfid = open_file->fid.netfid;
780 netpid = open_file->pid;
781 tcon = tlink_tcon(open_file->tlink);
782 goto set_via_filehandle;
783 }
784
785 tlink = cifs_sb_tlink(cifs_sb);
786 if (IS_ERR(tlink)) {
787 rc = PTR_ERR(tlink);
788 tlink = NULL;
789 goto out;
790 }
791 tcon = tlink_tcon(tlink);
792
793 /*
794 * NT4 apparently returns success on this call, but it doesn't really
795 * work.
796 */
797 if (!(tcon->ses->flags & CIFS_SES_NT4)) {
798 rc = CIFSSMBSetPathInfo(xid, tcon, full_path, buf,
799 cifs_sb->local_nls,
800 cifs_sb->mnt_cifs_flags &
801 CIFS_MOUNT_MAP_SPECIAL_CHR);
802 if (rc == 0) {
803 cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
804 goto out;
805 } else if (rc != -EOPNOTSUPP && rc != -EINVAL)
806 goto out;
807 }
808
809 cFYI(1, "calling SetFileInfo since SetPathInfo for times not supported "
810 "by this server");
811 rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
812 SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
813 &netfid, &oplock, NULL, cifs_sb->local_nls,
814 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
815
816 if (rc != 0) {
817 if (rc == -EIO)
818 rc = -EINVAL;
819 goto out;
820 }
821
822 netpid = current->tgid;
823
824set_via_filehandle:
825 rc = CIFSSMBSetFileInfo(xid, tcon, &info_buf, netfid, netpid);
826 if (!rc)
827 cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
828
829 if (open_file == NULL)
830 CIFSSMBClose(xid, tcon, netfid);
831 else
832 cifsFileInfo_put(open_file);
833out:
834 if (tlink != NULL)
835 cifs_put_tlink(tlink);
836 return rc;
837}
838
761struct smb_version_operations smb1_operations = { 839struct smb_version_operations smb1_operations = {
762 .send_cancel = send_nt_cancel, 840 .send_cancel = send_nt_cancel,
763 .compare_fids = cifs_compare_fids, 841 .compare_fids = cifs_compare_fids,
@@ -795,6 +873,7 @@ struct smb_version_operations smb1_operations = {
795 .get_srv_inum = cifs_get_srv_inum, 873 .get_srv_inum = cifs_get_srv_inum,
796 .set_path_size = CIFSSMBSetEOF, 874 .set_path_size = CIFSSMBSetEOF,
797 .set_file_size = CIFSSMBSetFileSize, 875 .set_file_size = CIFSSMBSetFileSize,
876 .set_file_info = smb_set_file_info,
798 .build_path_to_root = cifs_build_path_to_root, 877 .build_path_to_root = cifs_build_path_to_root,
799 .echo = CIFSSMBEcho, 878 .echo = CIFSSMBEcho,
800 .mkdir = CIFSSMBMkDir, 879 .mkdir = CIFSSMBMkDir,