@@ -112,27 +112,34 @@ pub trait ProcOperations {
112112
113113/// TBD
114114pub struct RustProcRegistration {
115- parent : * mut bindings:: proc_dir_entry ,
116- pub dir : * mut bindings:: proc_dir_entry ,
115+ dir : * mut bindings:: proc_dir_entry ,
117116 entry : * mut bindings:: proc_dir_entry ,
118117 _pin : PhantomPinned ,
119118}
120119
121120impl RustProcRegistration {
122121 /// TBD
123- pub fn new ( parent : * mut bindings:: proc_dir_entry ) -> Self {
122+ pub fn new ( dir : * mut bindings:: proc_dir_entry ) -> Self {
124123 Self {
125- parent,
126- dir : ptr:: null_mut ( ) ,
124+ dir,
127125 entry : ptr:: null_mut ( ) ,
128126 _pin : PhantomPinned ,
129127 }
130128 }
131129
132130 /// TBD
133- pub fn mkdir ( & mut self , name : & CString ) -> Result < ( ) > {
134- self . dir = unsafe { from_err_ptr ( bindings:: proc_mkdir ( name. as_char_ptr ( ) , self . parent ) ) } ?;
135- Ok ( ( ) )
131+ pub fn mkdir (
132+ name : & CString ,
133+ parent : * mut bindings:: proc_dir_entry ,
134+ ) -> Result < * mut bindings:: proc_dir_entry > {
135+ // TODO: setting parent generated panic!!!
136+ //unsafe { from_err_ptr(bindings::proc_mkdir(name.as_char_ptr(), parent)) }
137+ unsafe {
138+ from_err_ptr ( bindings:: proc_mkdir (
139+ name. as_char_ptr ( ) ,
140+ core:: ptr:: null_mut ( ) ,
141+ ) )
142+ }
136143 }
137144
138145 /// TBD
@@ -173,10 +180,6 @@ unsafe impl Sync for RustProcRegistration {}
173180impl Drop for RustProcRegistration {
174181 fn drop ( & mut self ) {
175182 unsafe {
176- //let entry_name = CString::try_from_fmt(fmt!("{}", PROC_FS_NAME)).unwrap();
177- //bindings::remove_proc_entry(entry_name.as_char_ptr(), self._parent);
178- //let parent_name = CString::try_from_fmt(fmt!("{}", SUB_DIR_NAME)).unwrap();
179- //bindings::remove_proc_entry(_SUB_DIR_NAME.as_char_ptr(), ptr::null_mut());
180183 bindings:: proc_remove ( self . entry ) ;
181184 bindings:: proc_remove ( self . dir )
182185 }
0 commit comments