Browse Source

Merge pull request #622 from trapexit/rename

ensure marking open files renamed over as hidden
pull/623/head
trapexit 6 years ago
committed by GitHub
parent
commit
741c559df1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 46
      libfuse/lib/fuse.c

46
libfuse/lib/fuse.c

@ -2888,19 +2888,23 @@ static void fuse_lib_mkdir(fuse_req_t req, fuse_ino_t parent, const char *name,
reply_entry(req, &e, err); reply_entry(req, &e, err);
} }
static void fuse_lib_unlink(fuse_req_t req, fuse_ino_t parent,
static
void
fuse_lib_unlink(fuse_req_t req,
fuse_ino_t parent,
const char *name) const char *name)
{ {
struct fuse *f = req_fuse_prepare(req);
struct node *wnode;
char *path;
int err; int err;
char *path;
struct fuse *f;
struct node *wnode;
struct fuse_intr_data d;
f = req_fuse_prepare(req);
err = get_path_wrlock(f,parent,name,&path,&wnode); err = get_path_wrlock(f,parent,name,&path,&wnode);
if (!err) {
struct fuse_intr_data d;
if(!err)
{
fuse_prepare_interrupt(f,req,&d); fuse_prepare_interrupt(f,req,&d);
if(node_open_and_visible(wnode)) if(node_open_and_visible(wnode))
{ {
@ -2916,6 +2920,7 @@ static void fuse_lib_unlink(fuse_req_t req, fuse_ino_t parent,
fuse_finish_interrupt(f,req,&d); fuse_finish_interrupt(f,req,&d);
free_path_wrlock(f,parent,wnode,path); free_path_wrlock(f,parent,wnode,path);
} }
reply_err(req,err); reply_err(req,err);
} }
@ -2962,37 +2967,44 @@ static void fuse_lib_symlink(fuse_req_t req, const char *linkname,
reply_entry(req, &e, err); reply_entry(req, &e, err);
} }
static void fuse_lib_rename(fuse_req_t req, fuse_ino_t olddir,
const char *oldname, fuse_ino_t newdir,
static
void
fuse_lib_rename(fuse_req_t req,
fuse_ino_t olddir,
const char *oldname,
fuse_ino_t newdir,
const char *newname) const char *newname)
{ {
struct fuse *f = req_fuse_prepare(req);
int err;
struct fuse *f;
char *oldpath; char *oldpath;
char *newpath; char *newpath;
struct node *wnode1; struct node *wnode1;
struct node *wnode2; struct node *wnode2;
int err;
struct fuse_intr_data d;
f = req_fuse_prepare(req);
err = get_path2(f,olddir,oldname,newdir,newname, err = get_path2(f,olddir,oldname,newdir,newname,
&oldpath,&newpath,&wnode1,&wnode2); &oldpath,&newpath,&wnode1,&wnode2);
if (!err) {
struct fuse_intr_data d;
err = 0;
if(!err)
{
fuse_prepare_interrupt(f,req,&d); fuse_prepare_interrupt(f,req,&d);
if(node_open_and_visible(wnode2)) if(node_open_and_visible(wnode2))
{
err = fuse_fs_prepare_hide(f->fs,newpath,&wnode2->hidden_fh,1); err = fuse_fs_prepare_hide(f->fs,newpath,&wnode2->hidden_fh,1);
if(!err) if(!err)
{
wnode2->is_hidden = 1;
}
err = fuse_fs_rename(f->fs,oldpath,newpath); err = fuse_fs_rename(f->fs,oldpath,newpath);
if(!err) if(!err)
err = rename_node(f,olddir,oldname,newdir,newname); err = rename_node(f,olddir,oldname,newdir,newname);
}
fuse_finish_interrupt(f,req,&d); fuse_finish_interrupt(f,req,&d);
free_path2(f,olddir,newdir,wnode1,wnode2,oldpath,newpath); free_path2(f,olddir,newdir,wnode1,wnode2,oldpath,newpath);
} }
reply_err(req,err); reply_err(req,err);
} }

Loading…
Cancel
Save