tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Minor libpuffs and librefuse fixes
Hi all,
I did few minor fixes for libpuffs and librefuse, see below.
netbsd_libpuffs_rename.diff libpuffs fix: remove pnode of overwritten file.
When puffs_null_node_rename() overwrites existing file, its pnode
must be removed, because src pnode already represents this file.
netbsd_refuse_eofflag.diff Set eofflag in puffs_fuse_node_readdir()
from librefuse.
netbsd_libpuffs_remove2.diff libpuffs (null.c): remove files specified in pcn.
When remove files using name from pnode, another link on this file
can be unlinked. E.g. "touch 1; ln 1 2; rm 2" will remove file named
"1". Thus puffs_null_node_remove should remove directory entry which
name is provided by pcn (as said in puffs_ops.3). Caller should
provide appropriately initialized pcn.
netbsd_libpuffs_man.diff Fix a glitch in puffs.3
Manu is OK to commit it within few days if nobody complains.
--
Evgeniy Ivanov
diff --git a/lib/libpuffs/null.c b/lib/libpuffs/null.c
index d9a9621..18d7ee4 100644
--- a/lib/libpuffs/null.c
+++ b/lib/libpuffs/null.c
@@ -480,10 +480,14 @@ puffs_null_node_rename(struct puffs_usermount *pu,
puffs_cookie_t opc,
puffs_cookie_t targ_dir, puffs_cookie_t targ,
const struct puffs_cn *pcn_targ)
{
+ struct puffs_node *pn_targ = targ;
if (rename(PCNPATH(pcn_src), PCNPATH(pcn_targ)) == -1)
return errno;
+ if (pn_targ)
+ puffs_pn_remove(pn_targ);
+
return 0;
}
diff --git a/lib/librefuse/refuse.c b/lib/librefuse/refuse.c
index 6755a15..4eb155c 100644
--- a/lib/librefuse/refuse.c
+++ b/lib/librefuse/refuse.c
@@ -1139,6 +1139,9 @@ puffs_fuse_node_readdir(struct puffs_usermount *pu, void
*opc,
return -ret;
}
+ /* Both op.readdir and op.getdir read full directory */
+ *eofflag = 1;
+
/* now, stuff results into the kernel buffers */
while (*readoff < (off_t)(dirh->bufsize - dirh->reslen)) {
/*LINTED*/
diff --git a/lib/libpuffs/puffs.3 b/lib/libpuffs/puffs.3
index 5c88cff..846828b 100644
--- a/lib/libpuffs/puffs.3
+++ b/lib/libpuffs/puffs.3
@@ -215,9 +215,9 @@ asked to resolve can be found from there.
.It Dv PUFFS_FLAG_BUILDPATH
The framework will build a complete path name, which is supplied
with each operation and can be found from the
-.Va pn_po.po_full_pcn
+.Va pcn_po_full.po_path
field in a
-.Vt struct puffs_node .
+.Vt struct puffs_cn .
The option assumes that the framework can map a cookie to a
.Vt struct puffs_node .
See
commit 25b26b828cc0d7e7d594d122c99e86a587e5df8f
Author: Evgeniy Ivanov <lolkaantimat%gmail.com@localhost>
Date: Tue Sep 13 22:43:10 2011 +0400
libpuffs (null.c): remove files and dirs specified in pcn.
When remove files using name from pnode, another link on this file can
be unlinked. E.g. "touch 1; ln 1 2; rm 2" will remove file named "1".
Thus puffs_null_node_remove should remove directory entry which name
is provided by pcn (as said in puffs_ops.3). Caller should provide
appropriately initialized pcn. puffs_null_node_rmdir should behave in a
similar way.
diff --git a/lib/libpuffs/dispatcher.c b/lib/libpuffs/dispatcher.c
index b6a5d22..45b453d 100644
--- a/lib/libpuffs/dispatcher.c
+++ b/lib/libpuffs/dispatcher.c
@@ -512,8 +512,17 @@ dispatch(struct puffs_cc *pcc)
pcn.pcn_pkcnp = &auxt->pvnr_cn;
PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
+ if (buildpath) {
+ error = puffs_path_pcnbuild(pu, &pcn, opcookie);
+ if (error)
+ break;
+ }
+
error = pops->puffs_node_remove(pu,
opcookie, auxt->pvnr_cookie_targ, &pcn);
+
+ pu->pu_pathfree(pu, &pcn.pcn_po_full);
+
break;
}
@@ -661,8 +670,17 @@ dispatch(struct puffs_cc *pcc)
pcn.pcn_pkcnp = &auxt->pvnr_cn;
PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
+ if (buildpath) {
+ error = puffs_path_pcnbuild(pu, &pcn, opcookie);
+ if (error)
+ break;
+ }
+
error = pops->puffs_node_rmdir(pu,
opcookie, auxt->pvnr_cookie_targ, &pcn);
+
+ pu->pu_pathfree(pu, &pcn.pcn_po_full);
+
break;
}
diff --git a/lib/libpuffs/null.c b/lib/libpuffs/null.c
index 18d7ee4..2acbbcd 100644
--- a/lib/libpuffs/null.c
+++ b/lib/libpuffs/null.c
@@ -453,7 +453,7 @@ puffs_null_node_remove(struct puffs_usermount *pu,
puffs_cookie_t opc,
{
struct puffs_node *pn_targ = targ;
- if (unlink(PNPATH(pn_targ)) == -1)
+ if (unlink(PCNPATH(pcn)) == -1)
return errno;
puffs_pn_remove(pn_targ);
@@ -515,7 +515,7 @@ puffs_null_node_rmdir(struct puffs_usermount *pu,
puffs_cookie_t opc,
{
struct puffs_node *pn_targ = targ;
- if (rmdir(PNPATH(pn_targ)) == -1)
+ if (rmdir(PCNPATH(pcn)) == -1)
return errno;
puffs_pn_remove(pn_targ);
Home |
Main Index |
Thread Index |
Old Index