Skip to contentSkip to conversation

cluster/gfs2/libgfs2 Makefile fs_ops.c libgfs2 ...

Cluster-devel [email protected] 1 participant 1 message Jun 12, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2006-06-12 20:38:27

Modified files:
gfs2/libgfs2 : Makefile fs_ops.c libgfs2.h ondisk.c
structures.c
Added files:
gfs2/libgfs2 : gfs2_log.c super.c

Log message:
Moved functions from fsck to libgfs2, added functions to make gfs2_convert not use libgfs.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/gfs2_log.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/super.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/Makefile.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/fs_ops.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/libgfs2.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/ondisk.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/structures.c.diff?cvsroot=cluster&r1=1.3&r2=1.4

/cvs/cluster/cluster/gfs2/libgfs2/gfs2_log.c,v --> standard output revision 1.1

- renamed from gfs2/libgfs2/gfs2_log.c +152 -0
@@ -0,0 +1,152 @@
+/*****************************************************************************
+******************************************************************************
+**
+**  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
+**
+**  This copyrighted material is made available to anyone wishing to use,
+**  modify, copy, or redistribute it subject to the terms and conditions
+**  of the GNU General Public License v.2.
+**
+******************************************************************************
+*****************************************************************************/
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <libintl.h>
+
+#include <sys/select.h>
+#include <unistd.h>
+
+#include "libgfs2.h"
+
+#define _(String) gettext(String)
+
+struct log_state {
+	int print_level;
+};
+static struct log_state _state = {MSG_NOTICE};
+
+void increase_verbosity(void)
+{
+	_state.print_level++;
+}
+
+void decrease_verbosity(void)
+{
+	_state.print_level--;
+}
+
+void print_msg(int priority, char *file, int line, const char *format,
+			   va_list args) {
+
+	switch (priority) {
+
+	case MSG_DEBUG:
+		printf("(%s:%d)\t", file, line);
+		vprintf(format, args);
+		break;
+	case MSG_INFO:
+	case MSG_NOTICE:
+	case MSG_WARN:
+		vprintf(format, args);
+		break;
+	case MSG_ERROR:
+	case MSG_CRITICAL:
+	default:
+		vfprintf(stderr, format, args);
+		break;
+	}
+	return;
+}
+
+
+void print_fsck_log(int iif, int priority, char *file, int line,
+					const char *format, ...)
+{
+
+	va_list args;
+	const char *transform;
+
+        va_start(args, format);
+
+	transform = _(format);
+
+	if((_state.print_level == priority) ||
+	   (!iif && (_state.print_level >= priority)))
+		print_msg(priority, file, line, transform, args);
+
+	va_end(args);
+}
+
+
+
+int query(struct gfs2_options *opts, const char *format, ...)
+{
+
+	va_list args;
+	const char *transform;
+	char response;
+	fd_set rfds;
+	struct timeval tv;
+	int err = 0;
+	int ret = 0;
+
+	va_start(args, format);
+
+	transform = _(format);
+
+	if(opts->yes)
+		return 1;
+	if(opts->no)
+		return 0;
+
+	/* Watch stdin (fd 0) to see when it has input. */
+	FD_ZERO(&rfds);
+	FD_SET(STDIN_FILENO, &rfds);
+
+	tv.tv_sec = 0;
+	tv.tv_usec = 0;
+	/* Make sure there isn't extraneous input before asking the
+	 * user the question */
+	while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
+		if(err < 0) {
+			log_debug("Error in select() on stdin\n");
+			break;
+		}
+		read(STDIN_FILENO, &response, sizeof(char));
+
+	}
+ query:
+	vprintf(transform, args);
+
+	/* Make sure query is printed out */
+	fflush(NULL);
+
+ rescan:
+	read(STDIN_FILENO, &response, sizeof(char));
+
+	if(tolower(response) == 'y') {
+		ret = 1;
+	} else if (tolower(response) == 'n') {
+		ret = 0;
+	} else if ((response == ' ') || (response == '\t')) {
+		goto rescan;
+	} else {
+		while(response != '\n')
+			read(STDIN_FILENO, &response, sizeof(char));
+		printf("Bad response, please type 'y' or 'n'.\n");
+		goto query;
+	}
+
+	/* Clip the input */
+	while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
+		if(err < 0) {
+			log_debug("Error in select() on stdin\n");
+			break;
+		}
+		read(STDIN_FILENO, &response, sizeof(char));
+	}
+
+	return ret;
+}

/cvs/cluster/cluster/gfs2/libgfs2/super.c,v --> standard output revision 1.1

- renamed from gfs2/libgfs2/super.c +239 -0

239 lines not on this page · raw message

gfs2/libgfs2/Makefile +1 -1
@@ -27,7 +27,7 @@
        -D_GNU_SOURCE -DGFS2_RELEASE_NAME=\"2\" ${INCLUDEPATH}
 
 H=gfs2_disk_hash.h libgfs2.h linux_endian.h ondisk.h osi_list.h
-C=bitmap.c block_list.c buf.c device_geometry.c fs_bits.c fs_geometry.c fs_ops.c locking.c misc.c ondisk.c size.c structures.c rgrp.c
+C=bitmap.c block_list.c buf.c device_geometry.c fs_bits.c fs_geometry.c fs_ops.c locking.c gfs2_log.c misc.c ondisk.c size.c structures.c super.c rgrp.c
 O=$(subst .c,.o,${C})
 
 all: ${LIBGFS2}
gfs2/libgfs2/fs_ops.c +0 -3
@@ -606,9 +606,6 @@
 		return bread(sdp, dbn);
 }
 
-#define IS_LEAF     (1)
-#define IS_DINODE   (2)
-
 int gfs2_dirent_first(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
 					  struct gfs2_dirent **dent)
 {
gfs2/libgfs2/libgfs2.h +69 -0

87 lines not on this page · raw message

gfs2/libgfs2/ondisk.c +2 -2
@@ -183,7 +183,7 @@
 
 	CPIN_32(ri, str, ri_bitbytes);
 
-	CPIN_08(ri, str, ri_reserved, 32);
+	CPIN_08(ri, str, ri_reserved, 64);
 }
 
 void gfs2_rindex_out(struct gfs2_rindex *ri, char *buf)
@@ -199,7 +199,7 @@
 
 	CPOUT_32(ri, str, ri_bitbytes);
 
-	CPOUT_08(ri, str, ri_reserved, 32);
+	CPOUT_08(ri, str, ri_reserved, 64);
 }
 
 void gfs2_rindex_print(struct gfs2_rindex *ri)
gfs2/libgfs2/structures.c +6 -3
@@ -509,8 +509,10 @@
 	uint32_t blk = (first)? 0: (uint32_t)((*block+1)-rgd->ri.ri_data0);
 	int i;
 
-	if(!first && (*block < rgd->ri.ri_data0))
+	if(!first && (*block < rgd->ri.ri_data0)) {
+		log_err("next_rg_meta:  Start block is outside rgrp bounds.\n");
 		exit(1);
+	}
 	if (*block == 0x11366)
 		bits = NULL;
 	for(i=0; i < length; i++){
@@ -555,9 +557,10 @@
 	uint32_t iblk, ublk, fblk;
 	int i;
 	
-	if(!first && (*block < rgd->ri.ri_data0))
+	if(!first && (*block < rgd->ri.ri_data0)) {
+		log_err("next_rg_meta_free:  Start block is outside rgrp bounds.\n");
 		exit(1);
-
+	}
 	for(i=0; i < length; i++){
 		bits = &rgd->bits[i];
 		if(blk < bits->bi_len*GFS2_NBBY)