2019-01-25 07:03:46 -05: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.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-03-28 12:34:30 -04:00
|
|
|
#include "state.hpp"
|
2019-01-25 07:03:46 -05:00
|
|
|
#include "ugid.hpp"
|
|
|
|
|
|
2020-12-19 15:06:08 -05:00
|
|
|
#include "fuse.h"
|
2019-01-25 07:03:46 -05:00
|
|
|
|
|
|
|
|
|
2021-03-28 12:34:30 -04:00
|
|
|
namespace FUSE::LINK
|
2019-01-25 07:03:46 -05:00
|
|
|
{
|
|
|
|
|
int
|
2020-06-21 14:45:14 -04:00
|
|
|
link(const char *oldpath_,
|
|
|
|
|
const char *newpath_,
|
|
|
|
|
struct stat *st_,
|
|
|
|
|
fuse_timeouts_t *timeouts_)
|
2019-01-25 07:03:46 -05:00
|
|
|
{
|
2020-06-21 14:45:14 -04:00
|
|
|
int rv;
|
2021-03-28 12:34:30 -04:00
|
|
|
State s;
|
2022-05-15 13:11:02 -04:00
|
|
|
gfs::path oldpath;
|
|
|
|
|
gfs::path newpath;
|
2020-12-19 15:06:08 -05:00
|
|
|
const fuse_context *fc = fuse_get_context();
|
2019-09-24 10:27:46 -04:00
|
|
|
const ugid::Set ugid(fc->uid,fc->gid);
|
|
|
|
|
|
2022-05-15 13:11:02 -04:00
|
|
|
oldpath = &oldpath_[1];
|
|
|
|
|
newpath = &newpath_[1];
|
|
|
|
|
rv = s->link(oldpath,newpath);
|
2022-05-19 18:30:29 -04:00
|
|
|
if(rv < 0)
|
|
|
|
|
return rv;
|
2020-06-21 14:45:14 -04:00
|
|
|
|
2022-05-15 13:11:02 -04:00
|
|
|
return s->getattr(newpath,st_,timeouts_);
|
2019-01-25 07:03:46 -05:00
|
|
|
}
|
|
|
|
|
}
|