Re: libfs/ FUSE on L4Re

Leslie Zhai <[email protected]>
Newsgroups gmane.comp.micro-kernel.l4.devel
Message-ID <[email protected]>
diff --git a/libfs/lib/libc_backend/l4fs.cc b/libfs/lib/libc_backend/l4fs.cc
index 7a229ff..31ad120 100644
--- a/libfs/lib/libc_backend/l4fs.cc
+++ b/libfs/lib/libc_backend/l4fs.cc
@@ -219,10 +219,10 @@ int L4fs_dir::get_entry(const char *name, int 
flags, mode_t mode,
      //printf("mode=%x,flags=%x\n", mode, flags);
      if (S_ISDIR(mode)) {
          //printf("open '%s' as directory\n", name);
-        *file = new L4fs_dir(_svr, fh);
+        *file = cxx::ref_ptr(new L4fs_dir(_svr, fh));
      } else  {
          //printf("open '%s' as file\n", name);
-        *file = new L4fs_file(_svr, fh);
+        *file = cxx::ref_ptr(new L4fs_file(_svr, fh));
      }

      return (*file) ? 0 : -ENOMEM;
@@ -325,7 +325,7 @@ int L4fs_file_system::mount(char const *source, 
unsigned long mountflags,
          if (fh < 0)
              return fh;

-        *dir = new L4fs_dir(svr, fh);
+        *dir = cxx::ref_ptr(new L4fs_dir(svr, fh));
          if (!dir)
              return -ENOMEM;



在 2017年06月01日 15:36, Xiang Zhai 写道:
> Hi Florian,
>
>
> /home/zhaixiang/project/l4re/l4/pkg/libfs/lib/libc_backend/l4fs.cc: In 
> member function ‘virtual int L4fs::L4fs_dir::get_entry(const char*, 
> int, mode_t, cxx::Ref_ptr<L4Re::Vfs::File>*)’:
> /home/zhaixiang/project/l4re/l4/pkg/libfs/lib/libc_backend/l4fs.cc:222:38: 
> error: no match for ‘operator=’ (operand types are 
> ‘cxx::Ref_ptr<L4Re::Vfs::File>’ and ‘L4fs::L4fs_dir*’)
>          *file = new L4fs_dir(_svr, fh);
>                                       ^
> In file included from 
> /home/zhaixiang/project/l4re/l4/build/include/l4/l4re_vfs/vfs.h:41:0,
>                  from 
> /home/zhaixiang/project/l4re/l4/build/include/l4/l4re_vfs/backend:22,
>                  from 
> /home/zhaixiang/project/l4re/l4/pkg/libfs/lib/libc_backend/l4fs.cc:15:
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:186:8: 
> note: candidate: template<class OT> void cxx::Ref_ptr<T, 
> CNT>::operator=(const cxx::Ref_ptr<OT>&) [with OT = OT; T = 
> L4Re::Vfs::File; CNT = cxx::Default_ref_counter]
>    void operator = (Ref_ptr<OT> const &o) throw()
>         ^~~~~~~~
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:186:8: 
> note:   template argument deduction/substitution failed:
> /home/zhaixiang/project/l4re/l4/pkg/libfs/lib/libc_backend/l4fs.cc:222:38: 
> note:   mismatched types ‘const cxx::Ref_ptr<T>’ and ‘L4fs::L4fs_dir*’
>          *file = new L4fs_dir(_svr, fh);
>                                       ^
> In file included from 
> /home/zhaixiang/project/l4re/l4/build/include/l4/l4re_vfs/vfs.h:41:0,
>                  from 
> /home/zhaixiang/project/l4re/l4/build/include/l4/l4re_vfs/backend:22,
>                  from 
> /home/zhaixiang/project/l4re/l4/pkg/libfs/lib/libc_backend/l4fs.cc:15:
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:193:8: 
> note: candidate: void cxx::Ref_ptr<T, CNT>::operator=(const 
> cxx::Ref_ptr<T>&) [with T = L4Re::Vfs::File; CNT = 
> cxx::Default_ref_counter]
>    void operator = (Ref_ptr<T> const &o) throw()
>         ^~~~~~~~
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:193:8: 
> note:   no known conversion for argument 1 from ‘L4fs::L4fs_dir*’ to 
> ‘const cxx::Ref_ptr<L4Re::Vfs::File>&’
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:203:8: 
> note: candidate: void cxx::Ref_ptr<T, CNT>::operator=(cxx::Ref_ptr<T, 
> CNT>::Null_type) [with T = L4Re::Vfs::File; CNT = 
> cxx::Default_ref_counter; cxx::Ref_ptr<T, CNT>::Null_type = 
> std::nullptr_t]
>    void operator = (Null_type) throw()
>         ^~~~~~~~
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:203:8: 
> note:   no known conversion for argument 1 from ‘L4fs::L4fs_dir*’ to 
> ‘cxx::Ref_ptr<L4Re::Vfs::File>::Null_type {aka std::nullptr_t}’
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:218:8: 
> note: candidate: template<class OT> void cxx::Ref_ptr<T, 
> CNT>::operator=(cxx::Ref_ptr<OT>&&) [with OT = OT; T = 
> L4Re::Vfs::File; CNT = cxx::Default_ref_counter]
>    void operator = (Ref_ptr<OT> &&o) throw()
>         ^~~~~~~~
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:218:8: 
> note:   template argument deduction/substitution failed:
> /home/zhaixiang/project/l4re/l4/pkg/libfs/lib/libc_backend/l4fs.cc:222:38: 
> note:   mismatched types ‘cxx::Ref_ptr<T>’ and ‘L4fs::L4fs_dir*’
>          *file = new L4fs_dir(_svr, fh);
>                                       ^
> In file included from 
> /home/zhaixiang/project/l4re/l4/build/include/l4/l4re_vfs/vfs.h:41:0,
>                  from 
> /home/zhaixiang/project/l4re/l4/build/include/l4/l4re_vfs/backend:22,
>                  from 
> /home/zhaixiang/project/l4re/l4/pkg/libfs/lib/libc_backend/l4fs.cc:15:
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:224:8: 
> note: candidate: void cxx::Ref_ptr<T, 
> CNT>::operator=(cxx::Ref_ptr<T>&&) [with T = L4Re::Vfs::File; CNT = 
> cxx::Default_ref_counter]
>    void operator = (Ref_ptr<T> &&o) throw()
>         ^~~~~~~~
> /home/zhaixiang/project/l4re/l4/build/include/l4/cxx/ref_ptr:224:8: 
> note:   no known conversion for argument 1 from ‘L4fs::L4fs_dir*’ to 
> ‘cxx::Ref_ptr<L4Re::Vfs::File>&&’
>
>
> So I simply added cxx::ref_ptr() for reference counting pointer with 
> automatic cleanup:
>
>
> diff --git a/libfs/lib/libc_backend/l4fs.cc 
> b/libfs/lib/libc_backend/l4fs.cc
> index 7a229ff..31ad120 100644
> --- a/libfs/lib/libc_backend/l4fs.cc
> +++ b/libfs/lib/libc_backend/l4fs.cc
> @@ -219,10 +219,10 @@ int L4fs_dir::get_entry(const char *name, int 
> flags, mode_t mode,
>      //printf("mode=%x,flags=%x\n", mode, flags);
>      if (S_ISDIR(mode)) {
>          //printf("open '%s' as directory\n", name);
> -        *file = new L4fs_dir(_svr, fh);
> +        *file = cxx::ref_ptr(new L4fs_dir(_svr, fh));
>      } else  {
>          //printf("open '%s' as file\n", name);
> -        *file = new L4fs_file(_svr, fh);
> +        *file = cxx::ref_ptr(new L4fs_file(_svr, fh));
>      }
>
>      return (*file) ? 0 : -ENOMEM;
> @@ -325,7 +325,7 @@ int L4fs_file_system::mount(char const *source, 
> unsigned long mountflags,
>          if (fh < 0)
>              return fh;
>
> -        *dir = new L4fs_dir(svr, fh);
> +        *dir = cxx::ref_ptr(new L4fs_dir(svr, fh));
>          if (!dir)
>              return -ENOMEM;
>
>
> please review my patch, thanks a lot!
>

-- 
Regards,
Leslie Zhai - a LLVM hacker https://reviews.llvm.org/p/xiangzhai/




_______________________________________________
l4-hackers mailing list
[email protected]
http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.