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