@@ -4956,68 +4956,84 @@ static int smb2_next_header(struct TCP_Server_Info *server, char *buf,
4956
4956
return 0 ;
4957
4957
}
4958
4958
4959
- int cifs_sfu_make_node (unsigned int xid , struct inode * inode ,
4960
- struct dentry * dentry , struct cifs_tcon * tcon ,
4961
- const char * full_path , umode_t mode , dev_t dev )
4959
+ static int __cifs_sfu_make_node (unsigned int xid , struct inode * inode ,
4960
+ struct dentry * dentry , struct cifs_tcon * tcon ,
4961
+ const char * full_path , umode_t mode , dev_t dev )
4962
4962
{
4963
- struct cifs_open_info_data buf = {};
4964
4963
struct TCP_Server_Info * server = tcon -> ses -> server ;
4965
4964
struct cifs_open_parms oparms ;
4966
4965
struct cifs_io_parms io_parms = {};
4967
4966
struct cifs_sb_info * cifs_sb = CIFS_SB (inode -> i_sb );
4968
4967
struct cifs_fid fid ;
4969
4968
unsigned int bytes_written ;
4970
- struct win_dev * pdev ;
4969
+ struct win_dev pdev = {} ;
4971
4970
struct kvec iov [2 ];
4972
4971
__u32 oplock = server -> oplocks ? REQ_OPLOCK : 0 ;
4973
4972
int rc ;
4974
4973
4975
- if (!S_ISCHR (mode ) && !S_ISBLK (mode ) && !S_ISFIFO (mode ))
4974
+ switch (mode & S_IFMT ) {
4975
+ case S_IFCHR :
4976
+ strscpy (pdev .type , "IntxCHR" , strlen ("IntxChr" ));
4977
+ pdev .major = cpu_to_le64 (MAJOR (dev ));
4978
+ pdev .minor = cpu_to_le64 (MINOR (dev ));
4979
+ break ;
4980
+ case S_IFBLK :
4981
+ strscpy (pdev .type , "IntxBLK" , strlen ("IntxBLK" ));
4982
+ pdev .major = cpu_to_le64 (MAJOR (dev ));
4983
+ pdev .minor = cpu_to_le64 (MINOR (dev ));
4984
+ break ;
4985
+ case S_IFIFO :
4986
+ strscpy (pdev .type , "LnxFIFO" , strlen ("LnxFIFO" ));
4987
+ break ;
4988
+ default :
4976
4989
return - EPERM ;
4990
+ }
4977
4991
4978
- oparms = (struct cifs_open_parms ) {
4979
- .tcon = tcon ,
4980
- .cifs_sb = cifs_sb ,
4981
- .desired_access = GENERIC_WRITE ,
4982
- .create_options = cifs_create_options (cifs_sb , CREATE_NOT_DIR |
4983
- CREATE_OPTION_SPECIAL ),
4984
- .disposition = FILE_CREATE ,
4985
- .path = full_path ,
4986
- .fid = & fid ,
4987
- };
4992
+ oparms = CIFS_OPARMS (cifs_sb , tcon , full_path , GENERIC_WRITE ,
4993
+ FILE_CREATE , CREATE_NOT_DIR |
4994
+ CREATE_OPTION_SPECIAL , ACL_NO_MODE );
4995
+ oparms .fid = & fid ;
4988
4996
4989
- rc = server -> ops -> open (xid , & oparms , & oplock , & buf );
4997
+ rc = server -> ops -> open (xid , & oparms , & oplock , NULL );
4990
4998
if (rc )
4991
4999
return rc ;
4992
5000
4993
- /*
4994
- * BB Do not bother to decode buf since no local inode yet to put
4995
- * timestamps in, but we can reuse it safely.
4996
- */
4997
- pdev = (struct win_dev * )& buf .fi ;
4998
5001
io_parms .pid = current -> tgid ;
4999
5002
io_parms .tcon = tcon ;
5000
- io_parms .length = sizeof (* pdev );
5001
- iov [1 ].iov_base = pdev ;
5002
- iov [1 ].iov_len = sizeof (* pdev );
5003
- if (S_ISCHR (mode )) {
5004
- memcpy (pdev -> type , "IntxCHR" , 8 );
5005
- pdev -> major = cpu_to_le64 (MAJOR (dev ));
5006
- pdev -> minor = cpu_to_le64 (MINOR (dev ));
5007
- } else if (S_ISBLK (mode )) {
5008
- memcpy (pdev -> type , "IntxBLK" , 8 );
5009
- pdev -> major = cpu_to_le64 (MAJOR (dev ));
5010
- pdev -> minor = cpu_to_le64 (MINOR (dev ));
5011
- } else if (S_ISFIFO (mode )) {
5012
- memcpy (pdev -> type , "LnxFIFO" , 8 );
5013
- }
5003
+ io_parms .length = sizeof (pdev );
5004
+ iov [1 ].iov_base = & pdev ;
5005
+ iov [1 ].iov_len = sizeof (pdev );
5014
5006
5015
5007
rc = server -> ops -> sync_write (xid , & fid , & io_parms ,
5016
5008
& bytes_written , iov , 1 );
5017
5009
server -> ops -> close (xid , tcon , & fid );
5018
- d_drop (dentry );
5019
- /* FIXME: add code here to set EAs */
5020
- cifs_free_open_info (& buf );
5010
+ return rc ;
5011
+ }
5012
+
5013
+ int cifs_sfu_make_node (unsigned int xid , struct inode * inode ,
5014
+ struct dentry * dentry , struct cifs_tcon * tcon ,
5015
+ const char * full_path , umode_t mode , dev_t dev )
5016
+ {
5017
+ struct inode * new = NULL ;
5018
+ int rc ;
5019
+
5020
+ rc = __cifs_sfu_make_node (xid , inode , dentry , tcon ,
5021
+ full_path , mode , dev );
5022
+ if (rc )
5023
+ return rc ;
5024
+
5025
+ if (tcon -> posix_extensions ) {
5026
+ rc = smb311_posix_get_inode_info (& new , full_path , NULL ,
5027
+ inode -> i_sb , xid );
5028
+ } else if (tcon -> unix_ext ) {
5029
+ rc = cifs_get_inode_info_unix (& new , full_path ,
5030
+ inode -> i_sb , xid );
5031
+ } else {
5032
+ rc = cifs_get_inode_info (& new , full_path , NULL ,
5033
+ inode -> i_sb , xid , NULL );
5034
+ }
5035
+ if (!rc )
5036
+ d_instantiate (dentry , new );
5021
5037
return rc ;
5022
5038
}
5023
5039
0 commit comments