@@ -5068,41 +5068,24 @@ smb2_next_header(char *buf)
5068
5068
return le32_to_cpu (hdr -> NextCommand );
5069
5069
}
5070
5070
5071
- static int
5072
- smb2_make_node (unsigned int xid , struct inode * inode ,
5073
- struct dentry * dentry , struct cifs_tcon * tcon ,
5074
- const char * full_path , umode_t mode , dev_t dev )
5071
+ int cifs_sfu_make_node (unsigned int xid , struct inode * inode ,
5072
+ struct dentry * dentry , struct cifs_tcon * tcon ,
5073
+ const char * full_path , umode_t mode , dev_t dev )
5075
5074
{
5076
- struct cifs_sb_info * cifs_sb = CIFS_SB (inode -> i_sb );
5077
- int rc = - EPERM ;
5078
5075
struct cifs_open_info_data buf = {};
5079
- struct cifs_io_parms io_parms = {0 };
5080
- __u32 oplock = 0 ;
5081
- struct cifs_fid fid ;
5076
+ struct TCP_Server_Info * server = tcon -> ses -> server ;
5082
5077
struct cifs_open_parms oparms ;
5078
+ struct cifs_io_parms io_parms = {};
5079
+ struct cifs_sb_info * cifs_sb = CIFS_SB (inode -> i_sb );
5080
+ struct cifs_fid fid ;
5083
5081
unsigned int bytes_written ;
5084
5082
struct win_dev * pdev ;
5085
5083
struct kvec iov [2 ];
5086
-
5087
- /*
5088
- * Check if mounted with mount parm 'sfu' mount parm.
5089
- * SFU emulation should work with all servers, but only
5090
- * supports block and char device (no socket & fifo),
5091
- * and was used by default in earlier versions of Windows
5092
- */
5093
- if (!(cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL ))
5094
- return rc ;
5095
-
5096
- /*
5097
- * TODO: Add ability to create instead via reparse point. Windows (e.g.
5098
- * their current NFS server) uses this approach to expose special files
5099
- * over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions
5100
- */
5084
+ __u32 oplock = server -> oplocks ? REQ_OPLOCK : 0 ;
5085
+ int rc ;
5101
5086
5102
5087
if (!S_ISCHR (mode ) && !S_ISBLK (mode ) && !S_ISFIFO (mode ))
5103
- return rc ;
5104
-
5105
- cifs_dbg (FYI , "sfu compat create special file\n" );
5088
+ return - EPERM ;
5106
5089
5107
5090
oparms = (struct cifs_open_parms ) {
5108
5091
.tcon = tcon ,
@@ -5115,54 +5098,64 @@ smb2_make_node(unsigned int xid, struct inode *inode,
5115
5098
.fid = & fid ,
5116
5099
};
5117
5100
5118
- if (tcon -> ses -> server -> oplocks )
5119
- oplock = REQ_OPLOCK ;
5120
- else
5121
- oplock = 0 ;
5122
- rc = tcon -> ses -> server -> ops -> open (xid , & oparms , & oplock , & buf );
5101
+ rc = server -> ops -> open (xid , & oparms , & oplock , & buf );
5123
5102
if (rc )
5124
5103
return rc ;
5125
5104
5126
5105
/*
5127
5106
* BB Do not bother to decode buf since no local inode yet to put
5128
5107
* timestamps in, but we can reuse it safely.
5129
5108
*/
5130
-
5131
5109
pdev = (struct win_dev * )& buf .fi ;
5132
5110
io_parms .pid = current -> tgid ;
5133
5111
io_parms .tcon = tcon ;
5134
- io_parms .offset = 0 ;
5135
- io_parms .length = sizeof (struct win_dev );
5136
- iov [1 ].iov_base = & buf .fi ;
5137
- iov [1 ].iov_len = sizeof (struct win_dev );
5112
+ io_parms .length = sizeof (* pdev );
5113
+ iov [1 ].iov_base = pdev ;
5114
+ iov [1 ].iov_len = sizeof (* pdev );
5138
5115
if (S_ISCHR (mode )) {
5139
5116
memcpy (pdev -> type , "IntxCHR" , 8 );
5140
5117
pdev -> major = cpu_to_le64 (MAJOR (dev ));
5141
5118
pdev -> minor = cpu_to_le64 (MINOR (dev ));
5142
- rc = tcon -> ses -> server -> ops -> sync_write (xid , & fid , & io_parms ,
5143
- & bytes_written , iov , 1 );
5144
5119
} else if (S_ISBLK (mode )) {
5145
5120
memcpy (pdev -> type , "IntxBLK" , 8 );
5146
5121
pdev -> major = cpu_to_le64 (MAJOR (dev ));
5147
5122
pdev -> minor = cpu_to_le64 (MINOR (dev ));
5148
- rc = tcon -> ses -> server -> ops -> sync_write (xid , & fid , & io_parms ,
5149
- & bytes_written , iov , 1 );
5150
5123
} else if (S_ISFIFO (mode )) {
5151
5124
memcpy (pdev -> type , "LnxFIFO" , 8 );
5152
- pdev -> major = 0 ;
5153
- pdev -> minor = 0 ;
5154
- rc = tcon -> ses -> server -> ops -> sync_write (xid , & fid , & io_parms ,
5155
- & bytes_written , iov , 1 );
5156
5125
}
5157
- tcon -> ses -> server -> ops -> close (xid , tcon , & fid );
5158
- d_drop (dentry );
5159
5126
5127
+ rc = server -> ops -> sync_write (xid , & fid , & io_parms ,
5128
+ & bytes_written , iov , 1 );
5129
+ server -> ops -> close (xid , tcon , & fid );
5130
+ d_drop (dentry );
5160
5131
/* FIXME: add code here to set EAs */
5161
-
5162
5132
cifs_free_open_info (& buf );
5163
5133
return rc ;
5164
5134
}
5165
5135
5136
+ static int smb2_make_node (unsigned int xid , struct inode * inode ,
5137
+ struct dentry * dentry , struct cifs_tcon * tcon ,
5138
+ const char * full_path , umode_t mode , dev_t dev )
5139
+ {
5140
+ struct cifs_sb_info * cifs_sb = CIFS_SB (inode -> i_sb );
5141
+
5142
+ /*
5143
+ * Check if mounted with mount parm 'sfu' mount parm.
5144
+ * SFU emulation should work with all servers, but only
5145
+ * supports block and char device (no socket & fifo),
5146
+ * and was used by default in earlier versions of Windows
5147
+ */
5148
+ if (!(cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL ))
5149
+ return - EPERM ;
5150
+ /*
5151
+ * TODO: Add ability to create instead via reparse point. Windows (e.g.
5152
+ * their current NFS server) uses this approach to expose special files
5153
+ * over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions
5154
+ */
5155
+ return cifs_sfu_make_node (xid , inode , dentry , tcon ,
5156
+ full_path , mode , dev );
5157
+ }
5158
+
5166
5159
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
5167
5160
struct smb_version_operations smb20_operations = {
5168
5161
.compare_fids = smb2_compare_fids ,
0 commit comments