1+ #include "includes.h"
12#include "commands.h"
3+ #include "vfs.h"
24
35int python_connect (vfs_handle_struct * handle ,
46 const char * service ,
@@ -11,8 +13,8 @@ int python_connect(vfs_handle_struct *handle,
1113 {
1214 PyObject * py_ret = PyObject_CallFunction (py_func , "ss" , service , user );
1315 success = PyObject_IsTrue (py_ret );
14- Py_DECREF (py_ret );
15- Py_DECREF (py_func );
16+ Py_XDECREF (py_ret );
17+ Py_XDECREF (py_func );
1618 }
1719
1820 if (success == 1 )
@@ -30,48 +32,57 @@ void python_disconnect(vfs_handle_struct *handle)
3032 SMB_VFS_NEXT_DISCONNECT (handle );
3133}
3234
33-
34- int python_mkdir ( vfs_handle_struct * handle ,
35- const char * path ,
36- mode_t mode )
35+ int python_mkdirat ( vfs_handle_struct * handle ,
36+ struct files_struct * dirfsp ,
37+ const struct smb_filename * smb_fname ,
38+ mode_t mode )
3739{
3840 int success = 1 ;
3941
4042 PyObject * py_func = get_func (handle , "mkdir" );
4143 if (py_func != NULL )
4244 {
43- PyObject * py_ret = PyObject_CallFunction (py_func , "s" , path );
45+ PyObject * py_ret = PyObject_CallFunction (py_func , "s" , smb_fname -> base_name );
4446 success = PyObject_IsTrue (py_ret );
45- Py_DECREF (py_ret );
46- Py_DECREF (py_func );
47+ Py_XDECREF (py_ret );
48+ Py_XDECREF (py_func );
4749 }
4850
4951 if (success == 1 )
5052 {
51- return SMB_VFS_NEXT_MKDIR (handle , path , mode );
53+ return SMB_VFS_NEXT_MKDIRAT (handle , dirfsp , smb_fname , mode );
5254 }
5355 else
5456 {
5557 return -1 ;
5658 }
5759}
5860
59- int python_rmdir (vfs_handle_struct * handle , const char * path )
61+ int python_unlinkat (vfs_handle_struct * handle ,
62+ struct files_struct * dirfsp ,
63+ const struct smb_filename * smb_fname ,
64+ int flags )
6065{
6166 int success = 1 ;
6267
63- PyObject * py_func = get_func (handle , "rmdir" );
68+ PyObject * py_func = NULL ;
69+ if (flags & AT_REMOVEDIR ) {
70+ py_func = get_func (handle , "rmdir" );
71+ } else {
72+ py_func = get_func (handle , "unlink" );
73+ }
74+
6475 if (py_func != NULL )
6576 {
66- PyObject * py_ret = PyObject_CallFunction (py_func , "s" , path );
77+ PyObject * py_ret = PyObject_CallFunction (py_func , "s" , smb_fname -> base_name );
6778 success = PyObject_IsTrue (py_ret );
68- Py_DECREF (py_ret );
69- Py_DECREF (py_func );
79+ Py_XDECREF (py_ret );
80+ Py_XDECREF (py_func );
7081 }
7182
7283 if (success == 1 )
7384 {
74- return SMB_VFS_NEXT_RMDIR (handle , path );
85+ return SMB_VFS_NEXT_UNLINKAT (handle , dirfsp , smb_fname , flags );
7586 }
7687 else
7788 {
@@ -81,20 +92,23 @@ int python_rmdir(vfs_handle_struct *handle, const char *path)
8192
8293NTSTATUS python_create_file (struct vfs_handle_struct * handle ,
8394 struct smb_request * req ,
84- uint16_t root_dir_fid ,
95+ struct files_struct * dirfsp ,
8596 struct smb_filename * smb_fname ,
8697 uint32_t access_mask ,
8798 uint32_t share_access ,
8899 uint32_t create_disposition ,
89100 uint32_t create_options ,
90101 uint32_t file_attributes ,
91102 uint32_t oplock_request ,
103+ const struct smb2_lease * lease ,
92104 uint64_t allocation_size ,
93105 uint32_t private_flags ,
94106 struct security_descriptor * sd ,
95107 struct ea_list * ea_list ,
96108 files_struct * * result ,
97- int * pinfo )
109+ int * pinfo ,
110+ const struct smb2_create_blobs * in_context_blobs ,
111+ struct smb2_create_blobs * out_context_blobs )
98112{
99113 int success = 1 ;
100114
@@ -103,38 +117,43 @@ NTSTATUS python_create_file(struct vfs_handle_struct *handle,
103117 {
104118 PyObject * py_ret = PyObject_CallFunction (py_func , "s" , smb_fname -> base_name );
105119 success = PyObject_IsTrue (py_ret );
106- Py_DECREF (py_ret );
107- Py_DECREF (py_func );
120+ Py_XDECREF (py_ret );
121+ Py_XDECREF (py_func );
108122 }
109123
110124 if (success == 1 )
111125 {
112126 return SMB_VFS_NEXT_CREATE_FILE (handle ,
113127 req ,
114- root_dir_fid ,
128+ dirfsp ,
115129 smb_fname ,
116130 access_mask ,
117131 share_access ,
118132 create_disposition ,
119133 create_options ,
120134 file_attributes ,
121135 oplock_request ,
136+ lease ,
122137 allocation_size ,
123138 private_flags ,
124139 sd ,
125140 ea_list ,
126141 result ,
127- pinfo );
142+ pinfo ,
143+ in_context_blobs ,
144+ out_context_blobs );
128145 }
129146 else
130147 {
131148 return NT_STATUS_UNSUCCESSFUL ;
132149 }
133150}
134151
135- int python_rename (vfs_handle_struct * handle ,
136- const struct smb_filename * smb_fname_src ,
137- const struct smb_filename * smb_fname_dst )
152+ int python_renameat (struct vfs_handle_struct * handle ,
153+ struct files_struct * oldfsp ,
154+ const struct smb_filename * smb_fname_src ,
155+ struct files_struct * newfsp ,
156+ const struct smb_filename * smb_fname_dst )
138157{
139158 int success = 1 ;
140159
@@ -146,40 +165,17 @@ int python_rename(vfs_handle_struct *handle,
146165 smb_fname_src -> base_name ,
147166 smb_fname_dst -> base_name );
148167 success = PyObject_IsTrue (py_ret );
149- Py_DECREF (py_ret );
150- Py_DECREF (py_func );
168+ Py_XDECREF (py_ret );
169+ Py_XDECREF (py_func );
151170 }
152171
153172 if (success == 1 )
154173 {
155- return SMB_VFS_NEXT_RENAME (handle , smb_fname_src , smb_fname_dst );
174+ return SMB_VFS_NEXT_RENAMEAT (handle , oldfsp , smb_fname_src , newfsp , smb_fname_dst );
156175 }
157176 else
158177 {
159178 return -1 ;
160179 }
161180}
162181
163- int python_unlink (vfs_handle_struct * handle ,
164- const struct smb_filename * smb_fname )
165- {
166- int success = 1 ;
167-
168- PyObject * py_func = get_func (handle , "unlink" );
169- if (py_func != NULL )
170- {
171- PyObject * py_ret = PyObject_CallFunction (py_func , "s" , smb_fname -> base_name );
172- success = PyObject_IsTrue (py_ret );
173- Py_DECREF (py_ret );
174- Py_DECREF (py_func );
175- }
176-
177- if (success == 1 )
178- {
179- return SMB_VFS_NEXT_UNLINK (handle , smb_fname );
180- }
181- else
182- {
183- return -1 ;
184- }
185- }
0 commit comments