2014-09-27 06:31:22 +08:00
|
|
|
/*
|
2016-01-15 05:50:22 +08:00
|
|
|
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2014-09-27 06:31:22 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.hpp"
|
2015-09-09 03:56:02 +08:00
|
|
|
#include "ugid.hpp"
|
2014-09-27 06:31:22 +08:00
|
|
|
|
2019-01-25 20:03:46 +08:00
|
|
|
#include <fuse.h>
|
|
|
|
|
2019-05-20 03:18:36 +08:00
|
|
|
namespace l
|
|
|
|
{
|
2019-05-22 11:23:26 +08:00
|
|
|
static
|
|
|
|
void
|
|
|
|
want(fuse_conn_info *conn_,
|
|
|
|
const int flag_)
|
|
|
|
{
|
|
|
|
conn_->want |= flag_;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
bool
|
|
|
|
capable(fuse_conn_info *conn_,
|
|
|
|
const int flag_)
|
|
|
|
{
|
2019-05-29 03:15:18 +08:00
|
|
|
return !!(conn_->capable & flag_);
|
2019-05-22 11:23:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
2019-05-20 03:18:36 +08:00
|
|
|
void
|
|
|
|
want_if_capable(fuse_conn_info *conn_,
|
|
|
|
const int flag_)
|
|
|
|
{
|
2019-05-22 11:23:26 +08:00
|
|
|
if(capable(conn_,flag_))
|
|
|
|
want(conn_,flag_);
|
2019-05-20 03:18:36 +08:00
|
|
|
}
|
2019-05-29 03:15:18 +08:00
|
|
|
|
|
|
|
static
|
|
|
|
void
|
|
|
|
want_if_capable(fuse_conn_info *conn_,
|
|
|
|
const int flag_,
|
|
|
|
bool *want_)
|
|
|
|
{
|
|
|
|
if(*want_ && l::capable(conn_,flag_))
|
|
|
|
{
|
|
|
|
l::want(conn_,flag_);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*want_ = false;
|
|
|
|
}
|
2019-05-31 06:59:18 +08:00
|
|
|
|
|
|
|
static
|
|
|
|
void
|
|
|
|
want_if_capable_max_pages(fuse_conn_info *conn_,
|
|
|
|
Config &c_)
|
|
|
|
{
|
|
|
|
if(l::capable(conn_,FUSE_CAP_MAX_PAGES))
|
|
|
|
{
|
|
|
|
l::want(conn_,FUSE_CAP_MAX_PAGES);
|
|
|
|
conn_->max_pages = c_.fuse_msg_size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
c_.fuse_msg_size = FUSE_DEFAULT_MAX_PAGES_PER_REQ;
|
|
|
|
}
|
|
|
|
}
|
2019-05-20 03:18:36 +08:00
|
|
|
}
|
|
|
|
|
2019-01-25 20:03:46 +08:00
|
|
|
namespace FUSE
|
2014-09-27 06:31:22 +08:00
|
|
|
{
|
2019-01-25 20:03:46 +08:00
|
|
|
void *
|
|
|
|
init(fuse_conn_info *conn_)
|
2014-09-27 06:31:22 +08:00
|
|
|
{
|
2019-05-22 11:23:26 +08:00
|
|
|
Config &c = Config::get_writable();
|
|
|
|
|
2019-01-25 20:03:46 +08:00
|
|
|
ugid::init();
|
2015-09-09 03:56:02 +08:00
|
|
|
|
2019-05-29 03:15:18 +08:00
|
|
|
l::want_if_capable(conn_,FUSE_CAP_ASYNC_DIO);
|
|
|
|
l::want_if_capable(conn_,FUSE_CAP_ASYNC_READ,&c.async_read);
|
2019-05-20 03:18:36 +08:00
|
|
|
l::want_if_capable(conn_,FUSE_CAP_ATOMIC_O_TRUNC);
|
|
|
|
l::want_if_capable(conn_,FUSE_CAP_BIG_WRITES);
|
2019-05-29 03:15:18 +08:00
|
|
|
l::want_if_capable(conn_,FUSE_CAP_CACHE_SYMLINKS,&c.cache_symlinks);
|
2019-05-20 03:18:36 +08:00
|
|
|
l::want_if_capable(conn_,FUSE_CAP_DONT_MASK);
|
|
|
|
l::want_if_capable(conn_,FUSE_CAP_IOCTL_DIR);
|
2019-05-20 12:36:42 +08:00
|
|
|
l::want_if_capable(conn_,FUSE_CAP_PARALLEL_DIROPS);
|
2019-06-14 20:59:04 +08:00
|
|
|
l::want_if_capable(conn_,FUSE_CAP_READDIR_PLUS,&c.readdirplus);
|
|
|
|
//l::want_if_capable(conn_,FUSE_CAP_READDIR_PLUS_AUTO);
|
2019-05-29 03:15:18 +08:00
|
|
|
l::want_if_capable(conn_,FUSE_CAP_POSIX_ACL,&c.posix_acl);
|
2020-02-08 03:05:03 +08:00
|
|
|
l::want_if_capable(conn_,FUSE_CAP_WRITEBACK_CACHE,&c.writeback_cache);
|
2019-05-31 06:59:18 +08:00
|
|
|
l::want_if_capable_max_pages(conn_,c);
|
2019-05-22 11:23:26 +08:00
|
|
|
|
|
|
|
return &c;
|
2014-09-27 06:31:22 +08:00
|
|
|
}
|
|
|
|
}
|