ensure marking open files renamed over as hidden

This commit is contained in:
Antonio SJ Musumeci 2019-05-19 23:25:46 -04:00
parent af1c0d78e8
commit 3a66a68edb

View File

@ -2888,35 +2888,40 @@ 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
const char *name) void
fuse_lib_unlink(fuse_req_t req,
fuse_ino_t parent,
const char *name)
{ {
struct fuse *f = req_fuse_prepare(req); int err;
struct node *wnode; char *path;
char *path; struct fuse *f;
int err; struct node *wnode;
struct fuse_intr_data d;
err = get_path_wrlock(f, parent, name, &path, &wnode); f = req_fuse_prepare(req);
err = get_path_wrlock(f,parent,name,&path,&wnode);
if (!err) { if(!err)
struct fuse_intr_data d; {
fuse_prepare_interrupt(f,req,&d);
if(node_open_and_visible(wnode))
{
err = fuse_fs_prepare_hide(f->fs,path,&wnode->hidden_fh,0);
if(!err)
wnode->is_hidden = 1;
}
fuse_prepare_interrupt(f, req, &d); err = fuse_fs_unlink(f->fs,path);
if(node_open_and_visible(wnode)) if(!err && !wnode->is_hidden)
{ remove_node(f,parent,name);
err = fuse_fs_prepare_hide(f->fs, path, &wnode->hidden_fh, 0);
if(!err)
wnode->is_hidden = 1;
}
err = fuse_fs_unlink(f->fs, path); fuse_finish_interrupt(f,req,&d);
if(!err && !wnode->is_hidden) free_path_wrlock(f,parent,wnode,path);
remove_node(f, parent, name); }
fuse_finish_interrupt(f, req, &d); reply_err(req,err);
free_path_wrlock(f, parent, wnode, path);
}
reply_err(req, err);
} }
static void fuse_lib_rmdir(fuse_req_t req, fuse_ino_t parent, const char *name) static void fuse_lib_rmdir(fuse_req_t req, fuse_ino_t parent, const char *name)
@ -2962,38 +2967,45 @@ 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, static
const char *oldname, fuse_ino_t newdir, void
const char *newname) fuse_lib_rename(fuse_req_t req,
fuse_ino_t olddir,
const char *oldname,
fuse_ino_t newdir,
const char *newname)
{ {
struct fuse *f = req_fuse_prepare(req); int err;
char *oldpath; struct fuse *f;
char *newpath; char *oldpath;
struct node *wnode1; char *newpath;
struct node *wnode2; struct node *wnode1;
int err; struct node *wnode2;
struct fuse_intr_data d;
err = get_path2(f, olddir, oldname, newdir, newname, f = req_fuse_prepare(req);
&oldpath, &newpath, &wnode1, &wnode2); err = get_path2(f,olddir,oldname,newdir,newname,
&oldpath,&newpath,&wnode1,&wnode2);
if (!err) { if(!err)
struct fuse_intr_data d; {
err = 0; 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)
wnode2->is_hidden = 1;
}
if (!err) err = fuse_fs_rename(f->fs,oldpath,newpath);
{ if(!err)
err = fuse_fs_rename(f->fs, oldpath, newpath); err = rename_node(f,olddir,oldname,newdir,newname);
if (!err)
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);
} }
static void fuse_lib_link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent, static void fuse_lib_link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent,