2014-05-28 18:03:06 +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-05-28 18:03:06 +08:00
|
|
|
*/
|
|
|
|
|
2019-09-24 22:27:46 +08:00
|
|
|
#include "config.hpp"
|
2016-09-14 20:36:06 +08:00
|
|
|
#include "errno.hpp"
|
2015-09-16 06:49:18 +08:00
|
|
|
#include "fileinfo.hpp"
|
2016-10-19 21:28:06 +08:00
|
|
|
#include "fs_base_stat.hpp"
|
2016-12-12 07:27:52 +08:00
|
|
|
#include "fs_inode.hpp"
|
2015-09-16 06:49:18 +08:00
|
|
|
|
2019-01-25 20:03:46 +08:00
|
|
|
#include <fuse.h>
|
|
|
|
|
|
|
|
namespace l
|
2014-05-28 18:03:06 +08:00
|
|
|
{
|
2019-01-25 20:03:46 +08:00
|
|
|
static
|
|
|
|
int
|
2020-06-23 01:03:48 +08:00
|
|
|
fgetattr(const int fd_,
|
|
|
|
const std::string &fusepath_,
|
|
|
|
struct stat *st_)
|
2019-01-25 20:03:46 +08:00
|
|
|
{
|
|
|
|
int rv;
|
2014-05-28 18:03:06 +08:00
|
|
|
|
2019-01-25 20:03:46 +08:00
|
|
|
rv = fs::fstat(fd_,st_);
|
|
|
|
if(rv == -1)
|
|
|
|
return -errno;
|
2014-05-28 18:03:06 +08:00
|
|
|
|
2020-06-23 01:03:48 +08:00
|
|
|
fs::inode::calc(fusepath_,st_);
|
2016-12-12 07:27:52 +08:00
|
|
|
|
2019-01-25 20:03:46 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-28 18:03:06 +08:00
|
|
|
}
|
|
|
|
|
2019-01-25 20:03:46 +08:00
|
|
|
namespace FUSE
|
2014-05-28 18:03:06 +08:00
|
|
|
{
|
2019-01-25 20:03:46 +08:00
|
|
|
int
|
2020-07-09 07:25:23 +08:00
|
|
|
fgetattr(struct stat *st_,
|
2019-09-24 22:27:46 +08:00
|
|
|
fuse_file_info *ffi_,
|
|
|
|
fuse_timeouts_t *timeout_)
|
2014-05-28 18:03:06 +08:00
|
|
|
{
|
2019-09-24 22:27:46 +08:00
|
|
|
int rv;
|
|
|
|
const Config &config = Config::ro();
|
2019-01-25 20:03:46 +08:00
|
|
|
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi_->fh);
|
|
|
|
|
2020-06-23 01:03:48 +08:00
|
|
|
rv = l::fgetattr(fi->fd,fi->fusepath,st_);
|
2019-09-24 22:27:46 +08:00
|
|
|
|
|
|
|
timeout_->entry = ((rv >= 0) ?
|
|
|
|
config.cache_entry :
|
|
|
|
config.cache_negative_entry);
|
|
|
|
timeout_->attr = config.cache_attr;
|
|
|
|
|
|
|
|
return rv;
|
2014-05-28 18:03:06 +08:00
|
|
|
}
|
|
|
|
}
|