CVS commit: [netbsd-7] src/lib/libperfuse

2015-08-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Aug  6 21:52:13 UTC 2015

Modified Files:
src/lib/libperfuse [netbsd-7]: perfuse.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #923):
lib/libperfuse/perfuse.c: revision 1.37
Deal with limits properly.
Don't print strerror() 2ice.
XXX: pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.31.10.4 -r1.31.10.5 src/lib/libperfuse/perfuse.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/perfuse.c
diff -u src/lib/libperfuse/perfuse.c:1.31.10.4 src/lib/libperfuse/perfuse.c:1.31.10.5
--- src/lib/libperfuse/perfuse.c:1.31.10.4	Fri Feb 27 19:39:56 2015
+++ src/lib/libperfuse/perfuse.c	Thu Aug  6 21:52:13 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse.c,v 1.31.10.4 2015/02/27 19:39:56 martin Exp $ */
+/*  $NetBSD: perfuse.c,v 1.31.10.5 2015/08/06 21:52:13 snj Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -391,6 +391,27 @@ perfuse_next_unique(struct puffs_usermou
 	return ps-ps_unique++;
 } 
 
+static void
+updatelimit(const char *func, int lim, const char *name)
+{
+	struct rlimit rl;
+
+	/* Try infinity but that will fail unless we are root */
+	rl.rlim_cur = RLIM_INFINITY;
+	rl.rlim_max = RLIM_INFINITY;
+	if (setrlimit(lim, rl) != -1)
+		return;
+
+	/* Get and set to the maximum allowed */
+	if (getrlimit(lim, rl) == -1)
+		DERR(EX_OSERR, %s: getrlimit %s failed, func, name);
+
+	rl.rlim_cur = rl.rlim_max;
+	if (setrlimit(lim, rl) == -1)
+		DERR(EX_OSERR, %s: setrlimit %s to %ju failed, func,
+		name, (uintmax_t)rl.rlim_cur);
+}
+
 struct puffs_usermount *
 perfuse_init(struct perfuse_callbacks *pc, struct perfuse_mount_info *pmi)
 {
@@ -402,23 +423,12 @@ perfuse_init(struct perfuse_callbacks *p
 	unsigned int puffs_flags;
 	struct puffs_node *pn_root;
 	struct puffs_pathobj *po_root;
-	struct rlimit rl;
 
 	/*
 	 * perfused can grow quite large, let assume there's enough ram ...
 	 */
-	rl.rlim_cur = RLIM_INFINITY;
-	rl.rlim_max = RLIM_INFINITY;
-
-	if (setrlimit(RLIMIT_DATA, rl)  0) {
-		DERR(EX_OSERR, %s: setrlimit failed: %s, __func__,
-		strerror(errno));
-	}
-
-	if (setrlimit(RLIMIT_AS, rl)  0) {
-		DERR(EX_OSERR, %s: setrlimit failed: %s, __func__,
-		strerror(errno));
-	}
+	updatelimit(__func__, RLIMIT_DATA, RLIMIT_DATA);
+	updatelimit(__func__, RLIMIT_AS, RLIMIT_AS);
 
 	ps = init_state();
 	ps-ps_owner_uid = pmi-pmi_uid;



CVS commit: [netbsd-7] src/lib/libperfuse

2015-08-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Aug  6 21:52:13 UTC 2015

Modified Files:
src/lib/libperfuse [netbsd-7]: perfuse.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #923):
lib/libperfuse/perfuse.c: revision 1.37
Deal with limits properly.
Don't print strerror() 2ice.
XXX: pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.31.10.4 -r1.31.10.5 src/lib/libperfuse/perfuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2015-06-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jun  8 20:49:54 UTC 2015

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #828):
lib/libperfuse/ops.c: revision 1.84
Fix dot-lookup when readdir does not provide inodes
Some filesystems do not provide inode numbers through readdir (FUSE
mounts without -o use_ino). We therefore have to lookup each directory
entry to get the missing numbers.
dot and double-dot are exceptions, as we already know the values.
Moreover, the lookup code does not expect to get requests for dot and
will abort perfused(8) when it gets some. In order to fix that, we just
check for dot and double-dot special case and use the known values
instead of sending a lookup.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.15 -r1.66.2.16 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2015-06-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jun  8 20:49:54 UTC 2015

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #828):
lib/libperfuse/ops.c: revision 1.84
Fix dot-lookup when readdir does not provide inodes
Some filesystems do not provide inode numbers through readdir (FUSE
mounts without -o use_ino). We therefore have to lookup each directory
entry to get the missing numbers.
dot and double-dot are exceptions, as we already know the values.
Moreover, the lookup code does not expect to get requests for dot and
will abort perfused(8) when it gets some. In order to fix that, we just
check for dot and double-dot special case and use the known values
instead of sending a lookup.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.15 -r1.66.2.16 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.66.2.15 src/lib/libperfuse/ops.c:1.66.2.16
--- src/lib/libperfuse/ops.c:1.66.2.15	Fri Feb 27 19:39:56 2015
+++ src/lib/libperfuse/ops.c	Mon Jun  8 20:49:54 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.15 2015/02/27 19:39:56 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.16 2015/06/08 20:49:54 snj Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -651,13 +651,17 @@ fuse_to_dirent(struct puffs_usermount *p
 			struct puffs_node *pn;
 			struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc);
 
-			/* 
-			 * Avoid breaking out of fs 
-			 * by lookup to .. on root
-			 */
-			if ((strcmp(name, ..) == 0)  
-			(pnd-pnd_nodeid == FUSE_ROOT_ID)) {
-fd-ino = FUSE_ROOT_ID;
+			if (strcmp(name, ..) == 0) {
+/* 
+ * Avoid breaking out of fs 
+ * by lookup to .. on root
+ */
+if (pnd-pnd_nodeid == FUSE_ROOT_ID)
+	fd-ino = FUSE_ROOT_ID;
+else
+	fd-ino = pnd-pnd_parent_nodeid;
+			} else if (strcmp(name, .) == 0 ) {
+fd-ino = pnd-pnd_nodeid;
 			} else {
 int error;
 



CVS commit: [netbsd-7] src/lib/libperfuse

2015-01-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan 17 11:47:27 UTC 2015

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #422):
lib/libperfuse/ops.c: revision 1.82
Fix atime update
FUSE filesystems assume that SETATTR with atime is the result of utiimes()
being called. As a result, atime and mtime will be updated.  This happens
with MooseFS and glusterFS. atime is supposed to be updated by the
filesystem itself when it gets read operations.
We fix the problem in SETATTR operations by
1) do not create a mtime update when we have an atime update (and vice
   versa), just fill the fields to avoid the filesystem restting the
   missing field to Epoch, but do not pretend we want to update it.
2) If the change is limited to atime, iscard it, as updates should be
   done by READ operations
3) Kernel part of PUFFS has been fixed to make sure reads on empty file
   are sent to the filesystem:
   http://mail-index.netbsd.org/source-changes/2015/01/13/msg062364.html
Thanks to Tom Ivar Helbekkmo for reporting this issue.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.13 -r1.66.2.14 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2015-01-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan 17 11:47:27 UTC 2015

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #422):
lib/libperfuse/ops.c: revision 1.82
Fix atime update
FUSE filesystems assume that SETATTR with atime is the result of utiimes()
being called. As a result, atime and mtime will be updated.  This happens
with MooseFS and glusterFS. atime is supposed to be updated by the
filesystem itself when it gets read operations.
We fix the problem in SETATTR operations by
1) do not create a mtime update when we have an atime update (and vice
   versa), just fill the fields to avoid the filesystem restting the
   missing field to Epoch, but do not pretend we want to update it.
2) If the change is limited to atime, iscard it, as updates should be
   done by READ operations
3) Kernel part of PUFFS has been fixed to make sure reads on empty file
   are sent to the filesystem:
   http://mail-index.netbsd.org/source-changes/2015/01/13/msg062364.html
Thanks to Tom Ivar Helbekkmo for reporting this issue.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.13 -r1.66.2.14 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.66.2.13 src/lib/libperfuse/ops.c:1.66.2.14
--- src/lib/libperfuse/ops.c:1.66.2.13	Fri Nov 14 15:06:36 2014
+++ src/lib/libperfuse/ops.c	Sat Jan 17 11:47:27 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.13 2014/11/14 15:06:36 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.14 2015/01/17 11:47:27 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -1785,30 +1785,27 @@ perfuse_node_setattr_ttl(struct puffs_us
 	}
 
 	/*
- 	 * Setting mtime without atime or vice versa leads to
-	 * dates being reset to Epoch on glusterfs. If one
-	 * is missing, use the old value.
+ 	 * When not sending a time field, still fill with
+	 * current value, as the filesystem may just reset
+	 * the field to Epoch even if fsi-valid bit is
+	 * not set (GlusterFS does that).
  	 */
-	if ((vap-va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) || 
-	(vap-va_atime.tv_sec != (time_t)PUFFS_VNOVAL)) {
-		
-		if (vap-va_atime.tv_sec != (time_t)PUFFS_VNOVAL) {
-			fsi-atime = vap-va_atime.tv_sec;
-			fsi-atimensec = (uint32_t)vap-va_atime.tv_nsec;
-		} else {
-			fsi-atime = old_va-va_atime.tv_sec;
-			fsi-atimensec = (uint32_t)old_va-va_atime.tv_nsec;
-		}
-
-		if (vap-va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) {
-			fsi-mtime = vap-va_mtime.tv_sec;
-			fsi-mtimensec = (uint32_t)vap-va_mtime.tv_nsec;
-		} else {
-			fsi-mtime = old_va-va_mtime.tv_sec;
-			fsi-mtimensec = (uint32_t)old_va-va_mtime.tv_nsec;
-		}
+	if (vap-va_atime.tv_sec != (time_t)PUFFS_VNOVAL) {
+		fsi-atime = vap-va_atime.tv_sec;
+		fsi-atimensec = (uint32_t)vap-va_atime.tv_nsec;
+		fsi-valid |= FUSE_FATTR_ATIME;
+	} else {
+		fsi-atime = old_va-va_atime.tv_sec;
+		fsi-atimensec = (uint32_t)old_va-va_atime.tv_nsec;
+	}
 
-		fsi-valid |= (FUSE_FATTR_MTIME|FUSE_FATTR_ATIME);
+	if (vap-va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) {
+		fsi-mtime = vap-va_mtime.tv_sec;
+		fsi-mtimensec = (uint32_t)vap-va_mtime.tv_nsec;
+		fsi-valid |= FUSE_FATTR_MTIME;
+	} else {
+		fsi-mtime = old_va-va_mtime.tv_sec;
+		fsi-mtimensec = (uint32_t)old_va-va_mtime.tv_nsec;
 	}
 
 	if (vap-va_mode != (mode_t)PUFFS_VNOVAL) {
@@ -1851,6 +1848,14 @@ perfuse_node_setattr_ttl(struct puffs_us
 		fsi-mtimensec = 0;
 		fsi-valid = ~(FUSE_FATTR_ATIME|FUSE_FATTR_MTIME);
 	}
+
+	/*
+	 * If only atime is changed, discard the operation: it
+	 * happens after read, and in that case the filesystem 
+	 * already updaed atime. NB: utimes() also change mtime.
+	 */
+	if (fsi-valid == FUSE_FATTR_ATIME)
+		fsi-valid = ~FUSE_FATTR_ATIME;
 		
 	/*
 	 * If nothing remain, discard the operation.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-11-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 14 15:06:36 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #231):
lib/libperfuse/ops.c: revision 1.81
Allow setxattr to be called with a NULL value, instead of crashing.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.12 -r1.66.2.13 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.66.2.12 src/lib/libperfuse/ops.c:1.66.2.13
--- src/lib/libperfuse/ops.c:1.66.2.12	Sun Nov  9 10:06:34 2014
+++ src/lib/libperfuse/ops.c	Fri Nov 14 15:06:36 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.12 2014/11/09 10:06:34 msaitoh Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.13 2014/11/14 15:06:36 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -3460,6 +3460,7 @@ perfuse_node_setextattr(struct puffs_use
 	perfuse_msg_t *pm;
 	struct fuse_setxattr_in *fsi;
 	size_t attrnamelen;
+	size_t datalen;
 	size_t len;
 	char *np;
 	int error;
@@ -3472,23 +3473,27 @@ perfuse_node_setextattr(struct puffs_use
 	ps = puffs_getspecific(pu);
 	attrname = perfuse_native_ns(attrns, attrname, fuse_attrname);
 	attrnamelen = strlen(attrname) + 1;
-	len = sizeof(*fsi) + attrnamelen + *resid;
+
+	datalen = (resid != NULL) ? *resid : 0;
+	len = sizeof(*fsi) + attrnamelen + datalen;
 
 	pm = ps-ps_new_msg(pu, opc, FUSE_SETXATTR, len, pcr);
 	fsi = GET_INPAYLOAD(ps, pm, fuse_setxattr_in);
-	fsi-size = (unsigned int)*resid;
+	fsi-size = (unsigned int)datalen;
 	fsi-flags = 0;
 	np = (char *)(void *)(fsi + 1);
 	(void)strlcpy(np, attrname, attrnamelen);
 	np += attrnamelen;
-	(void)memcpy(np, (char *)attr, *resid);
+	if (datalen)
+		(void)memcpy(np, (char *)attr, datalen);
 
 	if ((error = xchg_msg(pu, opc, pm, 
 			  NO_PAYLOAD_REPLY_LEN, wait_reply)) != 0)
 		goto out;
 
 	ps-ps_destroy_msg(pm);
-	*resid = 0;
+	if (resid)
+		*resid = 0;
 	error = 0;
 
 out:



CVS commit: [netbsd-7] src/lib/libperfuse

2014-11-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 14 15:06:36 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #231):
lib/libperfuse/ops.c: revision 1.81
Allow setxattr to be called with a NULL value, instead of crashing.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.12 -r1.66.2.13 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-11-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Nov  9 10:06:34 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #192):
lib/libperfuse/ops.c: revision 1.80
Restore build with -DDEBUG, and avoid a spurious diagnostic error with
-DDEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.11 -r1.66.2.12 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.66.2.11 src/lib/libperfuse/ops.c:1.66.2.12
--- src/lib/libperfuse/ops.c:1.66.2.11	Wed Nov  5 18:18:27 2014
+++ src/lib/libperfuse/ops.c	Sun Nov  9 10:06:34 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.11 2014/11/05 18:18:27 snj Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.12 2014/11/09 10:06:34 msaitoh Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -813,11 +813,6 @@ requeue_request(struct puffs_usermount *
 {
 	struct perfuse_cc_queue pcq;
 	struct perfuse_node_data *pnd;
-#ifdef PERFUSE_DEBUG
-	struct perfuse_state *ps;
-
-	ps = perfuse_getspecific(pu);
-#endif
 
 	pnd = PERFUSE_NODE_DATA(opc);
 	pcq.pcq_type = type;
@@ -2821,11 +2816,11 @@ perfuse_node_inactive(struct puffs_userm
 	if (opc == 0)
 		return 0;
 
-	node_ref(opc);
 	pnd = PERFUSE_NODE_DATA(opc);
-
 	if (!(pnd-pnd_flags  (PND_OPEN|PND_REMOVED)))
-		goto out;
+		return 0;
+
+	node_ref(opc);
 
 	/*
 	 * Make sure all operation are finished



CVS commit: [netbsd-7] src/lib/libperfuse

2014-11-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Nov  9 10:06:34 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #192):
lib/libperfuse/ops.c: revision 1.80
Restore build with -DDEBUG, and avoid a spurious diagnostic error with
-DDEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.11 -r1.66.2.12 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-11-05 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Nov  5 18:18:27 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #183):
lib/libperfuse/ops.c: revision 1.79
Avoid deadlocks on write errors
On write errors, we failed to dequeue some operations, leading to
rare but unpleasant deadlocks


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.10 -r1.66.2.11 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.66.2.10 src/lib/libperfuse/ops.c:1.66.2.11
--- src/lib/libperfuse/ops.c:1.66.2.10	Wed Nov  5 18:11:30 2014
+++ src/lib/libperfuse/ops.c	Wed Nov  5 18:18:27 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.10 2014/11/05 18:11:30 snj Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.11 2014/11/05 18:18:27 snj Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -3299,6 +3299,7 @@ perfuse_node_write2(struct puffs_usermou
 	if (*resid != 0)
 		error = EFBIG;
 
+out:
 #ifdef PERFUSE_DEBUG
 	if (perfuse_diagflags  PDF_RESIZE) {
 		if (offset  (off_t)vap-va_size)
@@ -3315,16 +3316,6 @@ perfuse_node_write2(struct puffs_usermou
 	if (offset  (off_t)vap-va_size) 
 		vap-va_size = offset;
 
-	if (inresize) {
-#ifdef PERFUSE_DEBUG
-		if (!(pnd-pnd_flags  PND_INRESIZE))
-			DERRX(EX_SOFTWARE, file write grow without resize);
-#endif
-		pnd-pnd_flags = ~PND_INRESIZE;
-		(void)dequeue_requests(opc, PCQ_RESIZE, DEQUEUE_ALL);
-	}
-
-
 	/*
 	 * Statistics
 	 */
@@ -3344,7 +3335,15 @@ perfuse_node_write2(struct puffs_usermou
 			__func__, (void*)opc, perfuse_node_path(ps, opc));
 #endif
 
-out:
+	if (inresize) {
+#ifdef PERFUSE_DEBUG
+		if (!(pnd-pnd_flags  PND_INRESIZE))
+			DERRX(EX_SOFTWARE, file write grow without resize);
+#endif
+		pnd-pnd_flags = ~PND_INRESIZE;
+		(void)dequeue_requests(opc, PCQ_RESIZE, DEQUEUE_ALL);
+	}
+
 	/*
 	 * VOP_PUTPAGE causes FAF write where kernel does not 
 	 * check operation result. At least warn if it failed.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-11-05 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Nov  5 18:18:27 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #183):
lib/libperfuse/ops.c: revision 1.79
Avoid deadlocks on write errors
On write errors, we failed to dequeue some operations, leading to
rare but unpleasant deadlocks


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.10 -r1.66.2.11 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-10-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 30 12:38:15 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #170):
lib/libperfuse/ops.c: revision 1.77
Fix invalid free in deletextattr FUSE handler
Do not free FUSE message on error as it was not allocated.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.8 -r1.66.2.9 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.66.2.8 src/lib/libperfuse/ops.c:1.66.2.9
--- src/lib/libperfuse/ops.c:1.66.2.8	Mon Oct 13 19:00:16 2014
+++ src/lib/libperfuse/ops.c	Thu Oct 30 12:38:15 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.8 2014/10/13 19:00:16 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.9 2014/10/30 12:38:15 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -3633,9 +3633,11 @@ perfuse_node_deleteextattr(struct puffs_
 	(void)strlcpy(np, attrname, attrnamelen);
 	
 	error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply);
+	if (error != 0)
+		goto out;
 	
 	ps-ps_destroy_msg(pm);
-
+out:
 	node_rele(opc);
 	return error;
 }



CVS commit: [netbsd-7] src/lib/libperfuse

2014-10-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 30 12:38:15 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #170):
lib/libperfuse/ops.c: revision 1.77
Fix invalid free in deletextattr FUSE handler
Do not free FUSE message on error as it was not allocated.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.8 -r1.66.2.9 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 13 19:00:16 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #137):
lib/libperfuse/ops.c: revision 1.76
Report allocated bytes on FS correctly, instead of using file size
(which is wrong for sparse files)


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.7 -r1.66.2.8 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.66.2.7 src/lib/libperfuse/ops.c:1.66.2.8
--- src/lib/libperfuse/ops.c:1.66.2.7	Sat Oct 11 16:25:19 2014
+++ src/lib/libperfuse/ops.c	Mon Oct 13 19:00:16 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.7 2014/10/11 16:25:19 snj Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.8 2014/10/13 19:00:16 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -321,7 +321,7 @@ fuse_attr_to_vap(struct perfuse_state *p
 	vap-va_gen = 0; 
 	vap-va_flags = 0;
 	vap-va_rdev = fa-rdev;
-	vap-va_bytes = fa-size;
+	vap-va_bytes = fa-blocks * S_BLKSIZE;
 	vap-va_filerev = (u_quad_t)PUFFS_VNOVAL;
 	vap-va_vaflags = 0;
 



CVS commit: [netbsd-7] src/lib/libperfuse

2014-10-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 13 19:00:16 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #137):
lib/libperfuse/ops.c: revision 1.76
Report allocated bytes on FS correctly, instead of using file size
(which is wrong for sparse files)


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.7 -r1.66.2.8 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-10-11 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Oct 11 16:25:19 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #134):
lib/libperfuse/ops.c: revision 1.75
Do not trust the filesystem's readdir to give us nul-terminated file
names


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.6 -r1.66.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.66.2.6 src/lib/libperfuse/ops.c:1.66.2.7
--- src/lib/libperfuse/ops.c:1.66.2.6	Fri Sep 12 08:13:20 2014
+++ src/lib/libperfuse/ops.c	Sat Oct 11 16:25:19 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.6 2014/09/12 08:13:20 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.7 2014/10/11 16:25:19 snj Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -607,6 +607,7 @@ fuse_to_dirent(struct puffs_usermount *p
 	do {
 		char *ndp;
 		size_t reclen;
+		char name[MAXPATHLEN];
 
 		reclen = _DIRENT_RECLEN(dents, fd-namelen);
 
@@ -639,6 +640,9 @@ fuse_to_dirent(struct puffs_usermount *p
 			dents = (struct dirent *)(void *)ndp;
 		}
 		
+		strncpy(name, fd-name, fd-namelen);
+		name[fd-namelen] = '\0';
+
 		/*
 		 * Filesystem was mounted without -o use_ino
 		 * Perform a lookup to find it.
@@ -651,13 +655,17 @@ fuse_to_dirent(struct puffs_usermount *p
 			 * Avoid breaking out of fs 
 			 * by lookup to .. on root
 			 */
-			if ((strcmp(fd-name, ..) == 0)  
+			if ((strcmp(name, ..) == 0)  
 			(pnd-pnd_nodeid == FUSE_ROOT_ID)) {
 fd-ino = FUSE_ROOT_ID;
 			} else {
-if (node_lookup_common(pu, opc, NULL, fd-name,
-		   NULL, pn) != 0) {
-	DWARNX(node_lookup_common failed);
+int error;
+
+error = node_lookup_common(pu, opc, NULL, 
+			   name, NULL, pn);
+if (error != 0) {
+	DWARNX(node_lookup_common %s 
+	   failed: %d, name, error);
 } else {
 	fd-ino = pn-pn_va.va_fileid;
 	(void)perfuse_node_reclaim(pu, pn);
@@ -669,7 +677,7 @@ fuse_to_dirent(struct puffs_usermount *p
 		dents-d_reclen = (unsigned short)reclen;
 		dents-d_namlen = fd-namelen;
 		dents-d_type = fd-type;
-		strlcpy(dents-d_name, fd-name, fd-namelen + 1);
+		strlcpy(dents-d_name, name, fd-namelen + 1);
 
 #ifdef PERFUSE_DEBUG
 		if (perfuse_diagflags  PDF_READDIR)
@@ -720,7 +728,7 @@ fuse_to_dirent(struct puffs_usermount *p
 	 */
 	if (written != -1)
 		PERFUSE_NODE_DATA(opc)-pnd_dirent_len = written;
-	
+
 	return written;
 }
 



CVS commit: [netbsd-7] src/lib/libperfuse

2014-10-11 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Oct 11 16:25:19 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #134):
lib/libperfuse/ops.c: revision 1.75
Do not trust the filesystem's readdir to give us nul-terminated file
names


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.6 -r1.66.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.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 12 08:13:20 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c perfuse_priv.h

Log Message:
Pull up following revision(s) (requested by enami in ticket #86):
lib/libperfuse/perfuse_priv.h: revision 1.35
lib/libperfuse/ops.c: revision 1.72
Fix build failure on amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.5 -r1.66.2.6 src/lib/libperfuse/ops.c
cvs rdiff -u -r1.32.2.1 -r1.32.2.2 src/lib/libperfuse/perfuse_priv.h

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.66.2.5 src/lib/libperfuse/ops.c:1.66.2.6
--- src/lib/libperfuse/ops.c:1.66.2.5	Thu Sep 11 13:41:57 2014
+++ src/lib/libperfuse/ops.c	Fri Sep 12 08:13:20 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.5 2014/09/11 13:41:57 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.6 2014/09/12 08:13:20 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -2894,7 +2894,7 @@ perfuse_node_print(struct puffs_usermoun
 
 int
 perfuse_node_pathconf(struct puffs_usermount *pu, puffs_cookie_t opc,
-	int name, int *retval)
+	int name, register_t *retval)
 {
 	perfuse_msg_t *pm;
 	struct perfuse_state *ps;

Index: src/lib/libperfuse/perfuse_priv.h
diff -u src/lib/libperfuse/perfuse_priv.h:1.32.2.1 src/lib/libperfuse/perfuse_priv.h:1.32.2.2
--- src/lib/libperfuse/perfuse_priv.h:1.32.2.1	Sun Aug 24 08:42:06 2014
+++ src/lib/libperfuse/perfuse_priv.h	Fri Sep 12 08:13:20 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse_priv.h,v 1.32.2.1 2014/08/24 08:42:06 martin Exp $ */
+/*  $NetBSD: perfuse_priv.h,v 1.32.2.2 2014/09/12 08:13:20 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -249,7 +249,7 @@ int perfuse_node_reclaim(struct puffs_us
 int perfuse_node_inactive(struct puffs_usermount *, puffs_cookie_t);
 int perfuse_node_print(struct puffs_usermount *, puffs_cookie_t);
 int perfuse_node_pathconf(struct puffs_usermount *,
-puffs_cookie_t, int, int *);
+puffs_cookie_t, int, register_t *);
 int perfuse_node_advlock(struct puffs_usermount *,
 puffs_cookie_t, void *, int, struct flock *, int);
 int perfuse_node_read(struct puffs_usermount *, puffs_cookie_t,



CVS commit: [netbsd-7] src/lib/libperfuse

2014-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 12 08:13:20 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c perfuse_priv.h

Log Message:
Pull up following revision(s) (requested by enami in ticket #86):
lib/libperfuse/perfuse_priv.h: revision 1.35
lib/libperfuse/ops.c: revision 1.72
Fix build failure on amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.5 -r1.66.2.6 src/lib/libperfuse/ops.c
cvs rdiff -u -r1.32.2.1 -r1.32.2.2 src/lib/libperfuse/perfuse_priv.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 11 12:17:10 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c perfuse.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #86):
lib/libperfuse/perfuse.c: revision 1.34
lib/libperfuse/ops.c: revision 1.71
Improve POSIX compliance of FUSE filesystems through PERDUSE
- access denied is EPERM and not EACCES
- access to file owned by someone else in a sticy-bit directory should
  be allowed for the sticy-bit directory owner
- setting sticky-bit on a non directory should produce EFTYPE
- implement PATHCONF method as much as we can.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.3 -r1.66.2.4 src/lib/libperfuse/ops.c
cvs rdiff -u -r1.31.10.1 -r1.31.10.2 src/lib/libperfuse/perfuse.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.66.2.3 src/lib/libperfuse/ops.c:1.66.2.4
--- src/lib/libperfuse/ops.c:1.66.2.3	Mon Sep  8 19:09:07 2014
+++ src/lib/libperfuse/ops.c	Thu Sep 11 12:17:10 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.3 2014/09/08 19:09:07 msaitoh Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.4 2014/09/11 12:17:10 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -269,7 +269,7 @@ sticky_access(puffs_cookie_t opc, struct
 	  const struct puffs_cred *pcr)
 {
 	uid_t uid;
-	int sticky, owner;
+	int sticky, owner, parent_owner;
 
 	/*
 	 * This covers the case where the kernel requests a DELETE
@@ -288,9 +288,10 @@ sticky_access(puffs_cookie_t opc, struct
 
 	sticky = puffs_pn_getvap(opc)-va_mode  S_ISTXT;
 	owner = puffs_pn_getvap(targ)-va_uid == uid;
+	parent_owner = puffs_pn_getvap(opc)-va_uid == uid;
 
-	if (sticky  !owner)
-		return EACCES;
+	if (sticky  !owner  !parent_owner)
+		return EPERM;
 
 	return 0;
 }
@@ -1305,7 +1306,7 @@ perfuse_node_mknod(struct puffs_usermoun
 		break;
 	default:	/* VNON, VBLK, VCHR, VBAD */
 		if (!puffs_cred_isjuggernaut(pcn-pcn_cred)) {
-			error = EACCES;
+			error = EPERM;
 			goto out;
 		}
 		break;
@@ -1696,7 +1697,7 @@ perfuse_node_setattr_ttl(struct puffs_us
 	 (vap-va_mtime.tv_sec != (time_t)PUFFS_VNOVAL)) 
 	(puffs_access_times(old_va-va_uid, old_va-va_gid,
 old_va-va_mode, 0, pcr) != 0))
-		return EACCES;
+		return EPERM;
 
 	/*
 	 * Check for permission to change owner and group
@@ -1705,7 +1706,15 @@ perfuse_node_setattr_ttl(struct puffs_us
 	 (vap-va_gid != (gid_t)PUFFS_VNOVAL)) 
 	(puffs_access_chown(old_va-va_uid, old_va-va_gid,
 vap-va_uid, vap-va_gid, pcr)) != 0)
-		return EACCES;
+		return EPERM;
+
+	/*
+	 * Check for sticky bit on non-directory by non root user
+	 */
+	if ((vap-va_mode != (mode_t)PUFFS_VNOVAL) 
+	(vap-va_mode  S_ISTXT)  (old_va-va_type != VDIR) 
+	!puffs_cred_isjuggernaut(pcr))
+		return EFTYPE;
 
 	/*
 	 * Check for permission to change permissions
@@ -1713,7 +1722,7 @@ perfuse_node_setattr_ttl(struct puffs_us
 	if ((vap-va_mode != (mode_t)PUFFS_VNOVAL) 
 	(puffs_access_chmod(old_va-va_uid, old_va-va_gid,
 old_va-va_type, vap-va_mode, pcr)) != 0)
-		return EACCES;
+		return EPERM;
 	
 	node_ref(opc);
 	
@@ -2883,13 +2892,68 @@ perfuse_node_print(struct puffs_usermoun
 	return 0;
 }
 
-/* ARGSUSED0 */
 int
 perfuse_node_pathconf(struct puffs_usermount *pu, puffs_cookie_t opc,
 	int name, int *retval)
 {
-	DERRX(EX_SOFTWARE, %s: UNIMPLEMENTED (FATAL), __func__);
-	return 0;
+	perfuse_msg_t *pm;
+	struct perfuse_state *ps;
+	struct fuse_statfs_out *fso;
+	int error = 0;
+
+	/*
+	 * Static values copied from UFS 
+	 * in src/sys/ufs/ufs/ufs_vnops.c
+	 */
+	switch (name) {
+	case _PC_LINK_MAX:
+		*retval = LINK_MAX;
+		break;
+	case _PC_PATH_MAX:
+		*retval = PATH_MAX;
+		break;
+	case _PC_PIPE_BUF:
+		*retval = PIPE_BUF;
+		break;
+	case _PC_CHOWN_RESTRICTED:
+		*retval = 1;
+		break;
+	case _PC_NO_TRUNC:
+		*retval = 1;
+		break;
+	case _PC_SYNC_IO:
+		*retval = 1;
+		break;
+	case _PC_FILESIZEBITS:
+		*retval = 42;
+		break;
+	case _PC_SYMLINK_MAX:
+		*retval = MAXPATHLEN;
+		break;
+	case _PC_2_SYMLINKS:
+		*retval = 1;
+		break;
+	case _PC_NAME_MAX:
+		ps = puffs_getspecific(pu);
+		pm = ps-ps_new_msg(pu, opc, FUSE_STATFS, 0, NULL);
+
+		error = xchg_msg(pu, opc, pm, sizeof(*fso), wait_reply);
+		if (error != 0)
+			return error;
+
+		fso = GET_OUTPAYLOAD(ps, pm, fuse_statfs_out);
+		*retval = fso-st.namelen;
+
+		ps-ps_destroy_msg(pm);
+	
+		break;
+	default:
+		DWARN(Unimplemented pathconf for name = %d, name);
+		error = ENOSYS;
+		break;
+	}
+
+	return error;
 }
 
 int

Index: src/lib/libperfuse/perfuse.c
diff -u src/lib/libperfuse/perfuse.c:1.31.10.1 src/lib/libperfuse/perfuse.c:1.31.10.2
--- src/lib/libperfuse/perfuse.c:1.31.10.1	Sun Aug 24 08:42:06 2014
+++ src/lib/libperfuse/perfuse.c	Thu Sep 11 12:17:10 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse.c,v 1.31.10.1 

CVS commit: [netbsd-7] src/lib/libperfuse

2014-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 11 13:41:57 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #89):
lib/libperfuse/ops.c: revision 1.74
Avoid a file resize serialization deadlock when writing with
PUFFS_IO_APPEND flag. The symptom was a hang when appending to
a file with a null size.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.4 -r1.66.2.5 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.66.2.4 src/lib/libperfuse/ops.c:1.66.2.5
--- src/lib/libperfuse/ops.c:1.66.2.4	Thu Sep 11 12:17:10 2014
+++ src/lib/libperfuse/ops.c	Thu Sep 11 13:41:57 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.4 2014/09/11 12:17:10 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.5 2014/09/11 13:41:57 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -3198,16 +3198,6 @@ perfuse_node_write2(struct puffs_usermou
 		requeue_request(pu, opc, PCQ_WRITE);
 	pnd-pnd_flags |= PND_INWRITE;
 
-	/* 
-	 * Serialize size access, see comment in perfuse_node_setattr().
-	 */
-	if ((u_quad_t)offset + *resid  vap-va_size) {
-		while (pnd-pnd_flags  PND_INRESIZE)
-			requeue_request(pu, opc, PCQ_RESIZE);
-		pnd-pnd_flags |= PND_INRESIZE;
-		inresize = 1;
-	}
-
 	/*
 	 * append flag: re-read the file size so that 
 	 * we get the latest value.
@@ -3219,6 +3209,16 @@ perfuse_node_write2(struct puffs_usermou
 		offset = vap-va_size;
 	}
 
+	/* 
+	 * Serialize size access, see comment in perfuse_node_setattr().
+	 */
+	if ((u_quad_t)offset + *resid  vap-va_size) {
+		while (pnd-pnd_flags  PND_INRESIZE)
+			requeue_request(pu, opc, PCQ_RESIZE);
+		pnd-pnd_flags |= PND_INRESIZE;
+		inresize = 1;
+	}
+
 #ifdef PERFUSE_DEBUG
 	if (perfuse_diagflags  PDF_RESIZE)
 		DPRINTF( %s %p % PRIu64 \n, __func__,



CVS commit: [netbsd-7] src/lib/libperfuse

2014-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 11 12:17:10 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c perfuse.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #86):
lib/libperfuse/perfuse.c: revision 1.34
lib/libperfuse/ops.c: revision 1.71
Improve POSIX compliance of FUSE filesystems through PERDUSE
- access denied is EPERM and not EACCES
- access to file owned by someone else in a sticy-bit directory should
  be allowed for the sticy-bit directory owner
- setting sticky-bit on a non directory should produce EFTYPE
- implement PATHCONF method as much as we can.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.3 -r1.66.2.4 src/lib/libperfuse/ops.c
cvs rdiff -u -r1.31.10.1 -r1.31.10.2 src/lib/libperfuse/perfuse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 11 13:41:57 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #89):
lib/libperfuse/ops.c: revision 1.74
Avoid a file resize serialization deadlock when writing with
PUFFS_IO_APPEND flag. The symptom was a hang when appending to
a file with a null size.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.4 -r1.66.2.5 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-09-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep  8 19:09:07 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #78):
lib/libperfuse/ops.c: revision 1.73
rmdir dir/.. must return an error. Use ENOTEMPTY like FFS does.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.2 -r1.66.2.3 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.66.2.2 src/lib/libperfuse/ops.c:1.66.2.3
--- src/lib/libperfuse/ops.c:1.66.2.2	Sat Aug 30 19:30:28 2014
+++ src/lib/libperfuse/ops.c	Mon Sep  8 19:09:07 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.2 2014/08/30 19:30:28 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.3 2014/09/08 19:09:07 msaitoh Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -2343,6 +2343,12 @@ perfuse_node_rmdir(struct puffs_usermoun
 	(PERFUSE_NODE_DATA(targ)-pnd_flags  PND_REMOVED))
 		return ENOENT;
 
+	/*
+	 * Attempt to rmdir dir/.. shoud raise ENOTEMPTY
+	 */
+	if (PERFUSE_NODE_DATA(targ)-pnd_nodeid == pnd-pnd_parent_nodeid)
+		return ENOTEMPTY;
+
 	node_ref(opc);
 	node_ref(targ);
 



CVS commit: [netbsd-7] src/lib/libperfuse

2014-09-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep  8 19:09:07 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #78):
lib/libperfuse/ops.c: revision 1.73
rmdir dir/.. must return an error. Use ENOTEMPTY like FFS does.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.2 -r1.66.2.3 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-7] src/lib/libperfuse

2014-08-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug 30 19:30:29 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #71):
lib/libperfuse/ops.c: revision 1.70
We used to remove the trailing zeros in FUSE readlink replies, but
it seems it does not always happen. Just remove them if present.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.1 -r1.66.2.2 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.66.2.1 src/lib/libperfuse/ops.c:1.66.2.2
--- src/lib/libperfuse/ops.c:1.66.2.1	Sun Aug 24 08:42:06 2014
+++ src/lib/libperfuse/ops.c	Sat Aug 30 19:30:28 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66.2.1 2014/08/24 08:42:06 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.66.2.2 2014/08/30 19:30:28 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -2633,12 +2633,16 @@ perfuse_node_readlink(struct puffs_userm
 	if (len == 0)
 		DERRX(EX_PROTOCOL, path len = %zd too short, len);
 		
+	(void)memcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len);
+
 	/*
 	 * FUSE filesystems return a NUL terminated string, we 
-	 * do not want to trailing \0
+	 * do not want the trailing \0
 	 */
-	*linklen = len - 1;
-	(void)memcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len);
+	while (len  0  linkname[len - 1] == '\0')
+		len--;
+
+	*linklen = len;
 
 	ps-ps_destroy_msg(pm);
 	error = 0;



CVS commit: [netbsd-7] src/lib/libperfuse

2014-08-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug 30 19:30:29 UTC 2014

Modified Files:
src/lib/libperfuse [netbsd-7]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #71):
lib/libperfuse/ops.c: revision 1.70
We used to remove the trailing zeros in FUSE readlink replies, but
it seems it does not always happen. Just remove them if present.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.1 -r1.66.2.2 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.