Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Mar 2019 15:07:46 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r345134 - projects/fuse2/tests/sys/fs/fuse
Message-ID:  <201903141507.x2EF7kTe026109@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Thu Mar 14 15:07:46 2019
New Revision: 345134
URL: https://svnweb.freebsd.org/changeset/base/345134

Log:
  fuse(4) tests: minor tweaks
  
  * better debugging for FUSE_SETATTR
  * Move a big variable from stack to heap
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/fuse2/tests/sys/fs/fuse/mockfs.cc

Modified: projects/fuse2/tests/sys/fs/fuse/mockfs.cc
==============================================================================
--- projects/fuse2/tests/sys/fs/fuse/mockfs.cc	Thu Mar 14 14:59:59 2019	(r345133)
+++ projects/fuse2/tests/sys/fs/fuse/mockfs.cc	Thu Mar 14 15:07:46 2019	(r345134)
@@ -170,7 +170,28 @@ void debug_fuseop(const mockfs_buf_in *in)
 				in->body.readdir.size);
 			break;
 		case FUSE_SETATTR:
-			printf(" valid=%#x", in->body.setattr.valid);
+			if (verbosity <= 1) {
+				printf(" valid=%#x", in->body.setattr.valid);
+				break;
+			}
+			if (in->body.setattr.valid & FATTR_MODE)
+				printf(" mode=%#o", in->body.setattr.mode);
+			if (in->body.setattr.valid & FATTR_UID)
+				printf(" uid=%u", in->body.setattr.uid);
+			if (in->body.setattr.valid & FATTR_GID)
+				printf(" gid=%u", in->body.setattr.gid);
+			if (in->body.setattr.valid & FATTR_SIZE)
+				printf(" size=%zu", in->body.setattr.size);
+			if (in->body.setattr.valid & FATTR_ATIME)
+				printf(" atime=%zu.%u",
+					in->body.setattr.atime,
+					in->body.setattr.atimensec);
+			if (in->body.setattr.valid & FATTR_MTIME)
+				printf(" mtime=%zu.%u",
+					in->body.setattr.mtime,
+					in->body.setattr.mtimensec);
+			if (in->body.setattr.valid & FATTR_FH)
+				printf(" fh=%zu", in->body.setattr.fh);
 			break;
 		case FUSE_WRITE:
 			printf(" offset=%lu size=%u flags=%u",
@@ -288,40 +309,42 @@ void MockFS::kill_daemon() {
 
 void MockFS::loop() {
 	mockfs_buf_in *in;
-	mockfs_buf_out out;
+	mockfs_buf_out *out;
 
 	in = (mockfs_buf_in*) malloc(sizeof(*in));
+	out = (mockfs_buf_out*) malloc(sizeof(*out));
 	ASSERT_TRUE(in != NULL);
 	while (!quit) {
 		bzero(in, sizeof(*in));
-		bzero(&out, sizeof(out));
+		bzero(out, sizeof(*out));
 		read_request(in);
 		if (quit)
 			break;
 		if (verbosity > 0)
 			debug_fuseop(in);
 		if (pid_ok((pid_t)in->header.pid)) {
-			process(in, &out);
+			process(in, out);
 		} else {
 			/* 
 			 * Reject any requests from unknown processes.  Because
 			 * we actually do mount a filesystem, plenty of
 			 * unrelated system daemons may try to access it.
 			 */
-			process_default(in, &out);
+			process_default(in, out);
 		}
 		if (in->header.opcode == FUSE_FORGET) {
 			/*Alone among the opcodes, FORGET expects no response*/
 			continue;
 		}
-		if (out.header.error == FUSE_NORESPONSE) {
+		if (out->header.error == FUSE_NORESPONSE) {
 			/* Used by tests of slow opcodes.  No response ATM */
 			continue;
 		}
-		ASSERT_TRUE(write(m_fuse_fd, &out, out.header.len) > 0 ||
+		ASSERT_TRUE(write(m_fuse_fd, out, out->header.len) > 0 ||
 			    errno == EAGAIN)
 			<< strerror(errno);
 	}
+	free(out);
 	free(in);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903141507.x2EF7kTe026109>