[Ocfs2-tools-commits] zab commits r284 - trunk/fsck.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Sep 29 16:40:46 CDT 2004


Author: zab
Date: 2004-09-29 16:40:44 -0500 (Wed, 29 Sep 2004)
New Revision: 284

Modified:
   trunk/fsck.ocfs2/fsck.c
   trunk/fsck.ocfs2/pass2.c
   trunk/fsck.ocfs2/problem.c
Log:
o Make read_a_char() actually work as intended.  bring in termios
  behaviour similar to ext2.


Modified: trunk/fsck.ocfs2/fsck.c
===================================================================
--- trunk/fsck.ocfs2/fsck.c	2004-09-29 20:18:46 UTC (rev 283)
+++ trunk/fsck.ocfs2/fsck.c	2004-09-29 21:40:44 UTC (rev 284)
@@ -196,6 +196,7 @@
 		}
 	}
 
+
 	if (blksize % OCFS2_MIN_BLOCKSIZE) {
 		fprintf(stderr, "Invalid blocksize: %"PRId64"\n", blksize);
 		print_usage();

Modified: trunk/fsck.ocfs2/pass2.c
===================================================================
--- trunk/fsck.ocfs2/pass2.c	2004-09-29 20:18:46 UTC (rev 283)
+++ trunk/fsck.ocfs2/pass2.c	2004-09-29 21:40:44 UTC (rev 284)
@@ -184,7 +184,7 @@
 {
 	struct dirblock_data *dd = priv_data;
 	struct ocfs2_dir_entry *dirent, *prev = NULL;
-	unsigned int offset = 0, this_flags, ret_flags = 0, rc;
+	unsigned int offset = 0, this_flags, ret_flags = 0;
 	errcode_t retval;
 
 	/* XXX there is no byte swapping story here, which is wrong.  we might

Modified: trunk/fsck.ocfs2/problem.c
===================================================================
--- trunk/fsck.ocfs2/problem.c	2004-09-29 20:18:46 UTC (rev 283)
+++ trunk/fsck.ocfs2/problem.c	2004-09-29 21:40:44 UTC (rev 284)
@@ -27,33 +27,42 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
+#include <termios.h>
 
 #include "ocfs2.h"
 
 #include "problem.h"
 #include "util.h"
 
+/* 
+ * when a caller cares why read() failed we can bother to communicate
+ * the error.  
+ *
+ * XXX I wonder this termios junk is really the best way.  I bet we want
+ * to at least make a passing attempt to not be killed while we have
+ * the terminal all messed up.
+ */
 static int read_a_char(int fd)
 {
-	int c;
+	struct termios orig, new;
+	char c;
 	ssize_t ret;
 
+	/* turn off buffering and echoing and encourage single character
+	 * reads */
+	tcgetattr(0, &orig);
+	new = orig;
+	new.c_lflag &= ~(ICANON | ECHO);
+	new.c_cc[VMIN] = 1;
+	new.c_cc[VTIME] = 0;
+	tcsetattr (0, TCSANOW, &new);
+
 	ret = read(fd, &c, sizeof(c));
+
+	tcsetattr (0, TCSANOW, &orig);
+
 	if (ret != sizeof(c))
 		return EOF;
-	/*
-	 * Don't you mean:
-	 * top:
-	 * ret = read(fd, &c, 1);
-	 * if (ret == 0)
-	 * 	return EOF;
-	 * else if (ret < 0) {
-	 * 	if (errno == EINTR)
-	 * 		goto top;
-	 * 	else
-	 * 		return -errno;
-	 * }
-	 */
 
 	return c;
 }
@@ -94,6 +103,8 @@
 	/* no curses, no nothin.  overly regressive? */
 	while ((c = read_a_char(fileno(stdin))) != EOF) {
 
+		printf("read '%c'\n", c);
+
 		/* XXX control-c, we're done? */
 		if (c == 3) {
 			printf("cancelled!\n");



More information about the Ocfs2-tools-commits mailing list