@@ -478,7 +478,6 @@ namespace
478478 void Init (void *, fuse_conn_info *conn)
479479 {
480480 mtp::scoped_mutex_lock l (_mutex);
481- conn->want |= conn->capable & FUSE_CAP_BIG_WRITES;
482481 }
483482
484483 void Lookup (fuse_req_t req, FuseId parent, const char *name)
@@ -732,7 +731,7 @@ namespace
732731 void RemoveDir (fuse_req_t req, FuseId parent, const char *name)
733732 { Unlink (req, parent, name); }
734733
735- void Rename (fuse_req_t req, FuseId parent, const char *name, FuseId newparent, const char *newName)
734+ void Rename (fuse_req_t req, FuseId parent, const char *name, FuseId newparent, const char *newName, unsigned int flags )
736735 {
737736 if (parent != newparent) {
738737 // no renames across directory boundary, sorry
@@ -824,18 +823,14 @@ namespace
824823 void Init (void *userdata, struct fuse_conn_info *conn)
825824 {
826825 mtp::debug (" Init: fuse proto version: " , conn->proto_major , " ." , conn->proto_minor ,
827- " , capability: 0x" , mtp::hex (conn->capable , 8 ),
828- " , async read: " , conn->async_read ,
829- // ", congestion_threshold: ", conn->congestion_threshold,
830- // ", max bg: ", conn->max_background,
826+ " , capability: 0x" , mtp::hex (conn->capable_ext , 8 ),
831827 " , max readahead: " , conn->max_readahead , " , max write: " , conn->max_write
832828 );
833829
834830 // If synchronous reads are chosen, Fuse will wait for reads to complete before issuing any other requests.
835831 // mtp is completely synchronous. you cannot have two transaction in parallel, so you have to wait any operation to finish before starting another one
836832
837- conn->async_read = 0 ;
838- conn->want &= ~FUSE_CAP_ASYNC_READ;
833+ fuse_unset_feature_flag (conn, FUSE_CAP_ASYNC_READ);
839834 try { g_wrapper->Init (userdata, conn); } catch (const std::exception &ex) { mtp::error (" init failed:" , ex.what ()); }
840835 }
841836
@@ -866,8 +861,8 @@ namespace
866861 void Open (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
867862 { mtp::debug (" Open " , ino); WRAP_EX (g_wrapper->Open (req, FuseId (ino), fi)); }
868863
869- void Rename (fuse_req_t req, fuse_ino_t parent, const char *name, fuse_ino_t newparent, const char *newname)
870- { mtp::debug (" Rename " , parent, " " , name, " -> " , newparent, " " , newname); WRAP_EX (g_wrapper->Rename (req, FuseId (parent), name, FuseId (newparent), newname)); }
864+ void Rename (fuse_req_t req, fuse_ino_t parent, const char *name, fuse_ino_t newparent, const char *newname, unsigned int flags )
865+ { mtp::debug (" Rename " , parent, " " , name, " -> " , newparent, " " , newname); WRAP_EX (g_wrapper->Rename (req, FuseId (parent), name, FuseId (newparent), newname, flags )); }
871866
872867 void Release (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
873868 { mtp::debug (" Release " , ino); WRAP_EX (g_wrapper->Release (req, FuseId (ino), fi)); }
@@ -966,41 +961,50 @@ int main(int argc, char **argv)
966961 ops.statfs = &StatFS;
967962
968963 struct fuse_args fuse_args = FUSE_ARGS_INIT (static_cast <int >(args.size () - 1 ), args.data ());
969- struct fuse_chan *ch;
970- char *mountpoint;
964+ struct fuse_cmdline_opts opts = {};
971965 int err = -1 ;
972- int multithreaded = 0 , foreground = 0 ;
973966
974- if (fuse_parse_cmdline (&fuse_args, &mountpoint, &multithreaded, &foreground) != - 1 )
967+ if (fuse_parse_cmdline (&fuse_args, &opts) == 0 )
975968 {
976- if (!mountpoint )
969+ if (opts. show_version )
977970 {
978- auto mp = g_wrapper->GetMountpoint ();
979- mountpoint = strdup (mp.c_str ());
980- mkdir (mountpoint, 0700 );
971+ fuse_lowlevel_version ();
972+ exit (0 );
973+ }
974+ if (opts.show_help )
975+ {
976+ fuse_cmdline_help ();
977+ fuse_lowlevel_help ();
978+ exit (0 );
981979 }
982980
983- if (mountpoint != NULL && (ch = fuse_mount (mountpoint, &fuse_args)) != NULL )
981+ if (opts. mountpoint != NULL )
984982 {
985- struct fuse_session *se = fuse_lowlevel_new (&fuse_args, &ops, sizeof (ops), NULL );
983+ struct fuse_session *se = fuse_session_new (&fuse_args, &ops, sizeof (ops), NULL );
986984 if (se != NULL )
987985 {
988- if (fuse_set_signal_handlers (se) != - 1 )
986+ if (fuse_set_signal_handlers (se) == 0 )
989987 {
990- fuse_session_add_chan (se, ch);
991- if (fuse_daemonize (foreground) == -1 )
992- perror (" fuse_daemonize" );
993- err = (multithreaded? fuse_session_loop_mt: fuse_session_loop)(se);
988+ if (fuse_session_mount (se, opts.mountpoint ) == 0 )
989+ {
990+ if (fuse_daemonize (opts.foreground ) == -1 )
991+ perror (" fuse_daemonize" );
992+ if (opts.singlethread )
993+ err = fuse_session_loop (se);
994+ else
995+ err = fuse_session_loop_mt (se, nullptr );
996+
997+ fuse_session_unmount (se);
998+ }
994999 fuse_remove_signal_handlers (se);
995- fuse_session_remove_chan (ch);
9961000 }
9971001 fuse_session_destroy (se);
9981002 }
999- fuse_unmount (mountpoint, ch);
10001003 }
10011004 } else {
10021005 mtp::error (" fuse_parse_cmdline failed" );
10031006 }
1007+ free (opts.mountpoint );
10041008 fuse_opt_free_args (&fuse_args);
10051009
10061010 return err ? 1 : 0 ;
0 commit comments