Module Name: src
Committed By: msaitoh
Date: Tue Jul 30 04:05:32 UTC 2013
Modified Files:
src/lib/libperfuse [netbsd-6]: ops.c
Log Message:
Pull up following revision(s) (requested by manu in ticket #923):
lib/libperfuse/ops.c: revision 1.61
lib/libperfuse/ops.c: revision 1.62
One more explicit error log, and two bug fixes
1) with recent FUSE, when lookup returns a null ino, it means ENOENT
2) odd corner case that caused a bug on dd if=test of=test conv=notrunc
This caused the file to be open first ro, then rw. A logic bug in
perfuse_node_open caused it to skip the second operation, whereas
it should open for writing, and store the write FH without touching
the read FH.
Catch open without FREAD|FWRITE (it should not happen)
To generate a diff of this commit:
cvs rdiff -u -r1.50.2.6 -r1.50.2.7 src/lib/libperfuse/ops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libperfuse/ops.c
diff -u src/lib/libperfuse/ops.c:1.50.2.6 src/lib/libperfuse/ops.c:1.50.2.7
--- src/lib/libperfuse/ops.c:1.50.2.6 Sun Aug 12 13:13:20 2012
+++ src/lib/libperfuse/ops.c Tue Jul 30 04:05:32 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: ops.c,v 1.50.2.6 2012/08/12 13:13:20 martin Exp $ */
+/* $NetBSD: ops.c,v 1.50.2.7 2013/07/30 04:05:32 msaitoh Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -1359,10 +1359,33 @@ perfuse_node_open(struct puffs_usermount
* Do not open twice, and do not reopen for reading
* if we already have write handle.
*/
- if (((mode & FREAD) && (pnd->pnd_flags & PND_RFH)) ||
- ((mode & FREAD) && (pnd->pnd_flags & PND_WFH)) ||
- ((mode & FWRITE) && (pnd->pnd_flags & PND_WFH)))
+ switch (mode & (FREAD|FWRITE)) {
+ case FREAD:
+ if (pnd->pnd_flags & (PND_RFH|PND_WFH))
+ goto out;
+ break;
+ case FWRITE:
+ if (pnd->pnd_flags & PND_WFH)
+ goto out;
+ break;
+ case FREAD|FWRITE:
+ if (pnd->pnd_flags & PND_WFH)
+ goto out;
+
+ /*
+ * Corner case: if already open for reading (PND_RFH)
+ * and re-opening FREAD|FWRITE, we need to reopen,
+ * but only for writing. Note the change on mode
+ * will only affect perfuse_new_fh()
+ */
+ if (pnd->pnd_flags & PND_RFH)
+ mode &= ~FREAD;
+ break;
+ default:
+ DWARNX("open without either FREAD nor FWRITE");
+ error = EPERM;
goto out;
+ }
/*
* Queue open on a node so that we do not open
@@ -2713,8 +2736,8 @@ perfuse_node_reclaim(struct puffs_usermo
#ifdef PERFUSE_DEBUG
if ((pnd->pnd_flags & PND_OPEN) ||
!TAILQ_EMPTY(&pnd->pnd_pcq))
- DERRX(EX_SOFTWARE, "%s: opc = %p: still open",
- __func__, opc);
+ DERRX(EX_SOFTWARE, "%s: opc = %p \"%s\": still open",
+ __func__, opc, pnd->pnd_name);
if ((pnd->pnd_flags & PND_BUSY) ||
!TAILQ_EMPTY(&pnd->pnd_pcq))